Unverified Commit 9dd5ff2b authored by Guy Bedford's avatar Guy Bedford Committed by GitHub

fix: Revert #18921 and inline absolute babel runtime only for YarnPnp (#19542)

This reverts #18921 and ensures that the Babel runtime is only inlined as an absolute path when using PnP as before, but then including the correction this resolution as implemented by @merceyz only in the PnP cases, while keeping the diff to a minimum.
parent 899a29ca
import { PluginItem } from 'next/dist/compiled/babel/core'
import { dirname } from 'path'
const env = process.env.NODE_ENV
const isProduction = env === 'production'
const isDevelopment = env === 'development'
......@@ -170,9 +169,9 @@ module.exports = (
helpers: true,
regenerator: true,
useESModules: supportsESM && presetEnvConfig.modules !== 'commonjs',
absoluteRuntime: dirname(
require.resolve('@babel/runtime/package.json')
),
absoluteRuntime: process.versions.pnp
? dirname(require.resolve('@babel/runtime/package.json'))
: undefined,
...options['transform-runtime'],
},
],
......
......@@ -64,8 +64,8 @@ describe('next/babel', () => {
expect(output).toMatch(`__jsx(${react}.Fragment`)
expect(output).toMatch(`__jsx("a",{href:"/"`)
expect(babel(`const a = ()=><a href="/">home</a>`)).toMatch(
`var _react=_interopRequireDefault(require("react"));var __jsx=_react["default"].createElement;var a=function a(){return __jsx("a",{href:"/"},"home");};`
expect(babel(`const a = ()=><a href="/">home</a>`)).toMatchInlineSnapshot(
`"\\"use strict\\";var _interopRequireDefault=require(\\"@babel/runtime/helpers/interopRequireDefault\\");var _react=_interopRequireDefault(require(\\"react\\"));var __jsx=_react[\\"default\\"].createElement;var a=function a(){return __jsx(\\"a\\",{href:\\"/\\"},\\"home\\");};"`
)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment