Skip to content

Commit

Permalink
Finally fixes babel.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Vilk committed Feb 20, 2018
1 parent e7aa793 commit caf161e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/closure_state_transform.ts
Expand Up @@ -4,6 +4,7 @@ import {generate as generateJavaScript} from 'astring';
import {SourceMapGenerator, SourceMapConsumer, RawSourceMap} from 'source-map';
import {transform as buble} from 'buble';
import {transform as babel} from 'babel-core';
import {dirname} from 'path';

/**
* Fake AST node that contains multiple statements that must be
Expand Down Expand Up @@ -2165,14 +2166,17 @@ function tryJSTransform(filename: string, source: string, transform: (filename:
} catch (e) {
try {
// Might be even crazier ES2015! Use Babel (SLOWEST PATH)
// Babel wants to know the exact location of this preset plugin.
// I really don't like Babel's (un)usability.
const envPath = dirname(require.resolve('babel-preset-env/package.json'));
const transformed = babel(source, {
sourceMapTarget: filename,
sourceFileName: filename,
compact: true,
sourceMaps: true,
// Disable modules to disable global "use strict"; declaration
// https://stackoverflow.com/a/39225403
presets: [["env", { "modules": false }]]
presets: [[envPath, { "modules": false }]]
});
const conversionSourceMap = new SourceMapGenerator({
file: filename
Expand Down

0 comments on commit caf161e

Please sign in to comment.