Skip to content

Commit

Permalink
fix(v2): use require.resolve for all webpack presets and plugins (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SamChou19815 authored May 22, 2020
1 parent 783e7e7 commit a7925f2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/docusaurus/src/webpack/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ export function getBabelLoader(isServer: boolean, babelOptions?: {}): Loader {
presets: [
isServer
? [
'@babel/env',
require.resolve('@babel/preset-env'),
{
targets: {
node: 'current',
},
},
]
: [
'@babel/env',
require.resolve('@babel/preset-env'),
{
useBuiltIns: 'usage',
loose: true,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit a7925f2

Please sign in to comment.