未验证 提交 4e3eb733 编写于 作者: K Kristoffer K 提交者: GitHub

fix(next): always enable absoluteRuntime when running under webpack (#19538)

**What's the problem this PR addresses?**

In https://github.com/vercel/next.js/pull/18921 I enabled `absoluteRuntime` for everyone (it was only enabled for PnP users) but didn't consider that people used the babel preset outside of the webpack build.

Fixes https://github.com/vercel/next.js/issues/19448 - ~~Since it doesn't contain a repro I can't be certain but based on feedback from @koshea in https://github.com/vercel/next.js/pull/18921#issuecomment-733744645 I'll assume @RossMcMillan92 is doing the same thing, because when next is building it doesn't leave absolute paths as external.~~
Confirmed in https://github.com/vercel/next.js/pull/18921#issuecomment-734224014

**How did you fix it?**

Only enable `absoluteRuntime` when the preset is running under `babel-loader`
上级 b3a63130
......@@ -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)) &&
......@@ -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'],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册