Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
preview.generateTypescriptConfiguration(null);
}
const { tsCompilerOptions } = preview.typescriptConfiguration;
code = tsTranspileModule(code, {
compilerOptions: tsCompilerOptions,
fileName: fsPath,
}).outputText;
}
// Transform:
// - exclude node_modules
// - include file in node_modules only if it's es module
const isInNodeModules = fsPath.split(path.sep).includes('node_modules');
if (
!isInNodeModules ||
isModule(code)
) {
console.log(`Transpiling: ${fsPath}`);
// use sucrase to transpile node_module files as it's faster
if (isInNodeModules || useSucrase) {
try {
code = (sucraseTransform(code)).code;
} catch (error) {
code = (await babelTransformAsync(code)).code;
}
} else {
code = (await babelTransformAsync(code)).code;
}
}
return code;
}
return readFileAsync(resolved, 'utf-8').then((code) =>
isModule(code)
? { id: resolved, moduleSideEffects: hasModuleSideEffects(resolved) }
: null
);
.then(code => isModule( code ) ? {id: resolved, moduleSideEffects: hasModuleSideEffects(resolved)} : null);
} else {