fix(web): use require.resolve for babel presets/plugins so we don't rely on module hoisting (#1813)

This commit is contained in:
Jack Hsu 2019-09-09 21:37:35 -04:00 committed by GitHub
parent 835f3b091d
commit 6f48e0175d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,7 @@ export function getBaseWebpackPartial(
compact: isScriptOptimizeOn, compact: isScriptOptimizeOn,
presets: [ presets: [
[ [
'@babel/preset-env', require.resolve('@babel/preset-env'),
{ {
// Allows browserlist file from project to be used. // Allows browserlist file from project to be used.
configPath: dirname(options.main), configPath: dirname(options.main),
@ -67,16 +67,16 @@ export function getBaseWebpackPartial(
targets: esm ? { esmodules: true } : undefined targets: esm ? { esmodules: true } : undefined
} }
], ],
['@babel/preset-typescript'] [require.resolve('@babel/preset-typescript')]
], ],
plugins: [ plugins: [
'babel-plugin-macros', require.resolve('babel-plugin-macros'),
[ [
// Allows decorators to be before export since it is consistent with TypeScript syntax. // Allows decorators to be before export since it is consistent with TypeScript syntax.
'@babel/plugin-proposal-decorators', require.resolve('@babel/plugin-proposal-decorators'),
{ decoratorsBeforeExport: true } { decoratorsBeforeExport: true }
], ],
['@babel/plugin-proposal-class-properties'] [require.resolve('@babel/plugin-proposal-class-properties')]
] ]
} }
} }