Skip to content

Commit 72fe399

Browse files
fix: use our versions of the presets for transpiling
If you simply pass package names into babel's list of presets then it'll try to load them from the working directory. That doesn't work for us, so we need to resolve–but not load!–the presets relative to babel-codemod itself. Fixes #102
1 parent f49f599 commit 72fe399

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/transpile-requires.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export function hook(code: string, filename: string): string {
3030

3131
if (!useBabelrc) {
3232
if (ext === '.ts') {
33-
options.presets.push('@babel/preset-typescript');
33+
options.presets.push(require.resolve('@babel/preset-typescript'));
3434
}
3535

36-
options.presets.push('@babel/preset-env');
36+
options.presets.push(require.resolve('@babel/preset-env'));
3737
}
3838

3939
return transform(code, options).code as string;

0 commit comments

Comments
 (0)