From a7925f28be863854fafaeea75d9d8ceab9cf5687 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Thu, 21 May 2020 23:36:46 -0400 Subject: [PATCH] fix(v2): use `require.resolve` for all webpack presets and plugins (#2788) --- packages/docusaurus/src/webpack/utils.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/docusaurus/src/webpack/utils.ts b/packages/docusaurus/src/webpack/utils.ts index 06169abd699a..2fda739cf192 100644 --- a/packages/docusaurus/src/webpack/utils.ts +++ b/packages/docusaurus/src/webpack/utils.ts @@ -100,7 +100,7 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader { presets: [ isServer ? [ - '@babel/env', + require.resolve('@babel/preset-env'), { targets: { node: 'current', @@ -108,7 +108,7 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader { }, ] : [ - '@babel/env', + require.resolve('@babel/preset-env'), { useBuiltIns: 'usage', loose: true, @@ -119,14 +119,14 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader { exclude: ['transform-typeof-symbol'], }, ], - '@babel/react', - '@babel/preset-typescript', + require.resolve('@babel/preset-react'), + require.resolve('@babel/preset-typescript'), ], plugins: [ // Polyfills the runtime needed for async/await, generators, and friends // https://babeljs.io/docs/en/babel-plugin-transform-runtime [ - '@babel/plugin-transform-runtime', + require.resolve('@babel/plugin-transform-runtime'), { corejs: false, helpers: true, @@ -143,7 +143,9 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader { }, ], // Adds syntax support for import() - isServer ? 'dynamic-import-node' : '@babel/syntax-dynamic-import', + isServer + ? require.resolve('babel-plugin-dynamic-import-node') + : require.resolve('@babel/plugin-syntax-dynamic-import'), ], }, babelOptions,