Skip to content

Commit

Permalink
fix(next): only enable absolute runtime when running under webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Jan 4, 2021
1 parent 246c265 commit 7080799
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next/build/babel/preset.ts
Expand Up @@ -77,6 +77,10 @@ module.exports = (
// Default to production mode if not `test` nor `development`:
const isProduction = !(isTest || isDevelopment)

const isBabelLoader = api.caller(
(caller: any) => !!caller && caller.name === 'babel-loader'
)

const useJsxRuntime =
options['preset-react']?.runtime === 'automatic' ||
(Boolean(api.caller((caller: any) => !!caller && caller.hasJsxRuntime)) &&
Expand Down Expand Up @@ -180,7 +184,7 @@ module.exports = (
helpers: true,
regenerator: true,
useESModules: supportsESM && presetEnvConfig.modules !== 'commonjs',
absoluteRuntime: process.versions.pnp
absoluteRuntime: isBabelLoader
? dirname(require.resolve('@babel/runtime/package.json'))
: undefined,
...options['transform-runtime'],
Expand Down

0 comments on commit 7080799

Please sign in to comment.