@@ -55,7 +55,7 @@ type AutoPreprocessOptions = {
5555 [ languageName : string ] : TransformerOptions ;
5656} ;
5757
58- export const runTransformer = async (
58+ export const transform = async (
5959 name : string ,
6060 options : TransformerOptions ,
6161 { content, map, filename, attributes } : TransformerArgs < any > ,
@@ -68,6 +68,7 @@ export const runTransformer = async (
6868 return options ( { content, map, filename, attributes } ) ;
6969 }
7070
71+ // todo: maybe add a try-catch here looking for module-not-found errors
7172 const { transformer } = await import ( `./transformers/${ name } ` ) ;
7273
7374 return transformer ( {
@@ -166,7 +167,7 @@ export function sveltePreprocess(
166167 return { code : content , dependencies } ;
167168 }
168169
169- const transformed = await runTransformer ( lang , transformerOptions , {
170+ const transformed = await transform ( lang , transformerOptions , {
170171 content,
171172 filename,
172173 attributes,
@@ -184,11 +185,10 @@ export function sveltePreprocess(
184185
185186 const markup : PreprocessorGroup [ 'markup' ] = async ( { content, filename } ) => {
186187 if ( transformers . replace ) {
187- const transformed = await runTransformer (
188- 'replace' ,
189- transformers . replace ,
190- { content, filename } ,
191- ) ;
188+ const transformed = await transform ( 'replace' , transformers . replace , {
189+ content,
190+ filename,
191+ } ) ;
192192
193193 content = transformed . code ;
194194 }
@@ -214,7 +214,7 @@ export function sveltePreprocess(
214214 let { code, map, dependencies, diagnostics } = transformResult ;
215215
216216 if ( transformers . babel ) {
217- const transformed = await runTransformer (
217+ const transformed = await transform (
218218 'babel' ,
219219 getTransformerOptions ( 'babel' ) ,
220220 {
@@ -250,7 +250,7 @@ export function sveltePreprocess(
250250 // istanbul ignore else
251251 if ( await hasDepInstalled ( 'postcss' ) ) {
252252 if ( transformers . postcss ) {
253- const transformed = await runTransformer (
253+ const transformed = await transform (
254254 'postcss' ,
255255 getTransformerOptions ( 'postcss' ) ,
256256 { content : code , map, filename, attributes } ,
@@ -261,7 +261,7 @@ export function sveltePreprocess(
261261 dependencies = concat ( dependencies , transformed . dependencies ) ;
262262 }
263263
264- const transformed = await runTransformer (
264+ const transformed = await transform (
265265 'globalStyle' ,
266266 getTransformerOptions ( 'globalStyle' ) ,
267267 { content : code , map, filename, attributes } ,
0 commit comments