Skip to content

Commit

Permalink
fix: use our versions of the presets for transpiling
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eventualbuddha committed Mar 19, 2018
1 parent f49f599 commit 72fe399
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transpile-requires.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export function hook(code: string, filename: string): string {

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

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

return transform(code, options).code as string;
Expand Down

0 comments on commit 72fe399

Please sign in to comment.