Unverified Commit c69d7817 authored by Sukka's avatar Sukka Committed by GitHub

chore: enable swc externalHelpers when pre-compile (#38182)

parent b8460266
...@@ -25,6 +25,7 @@ module.exports = function (task) { ...@@ -25,6 +25,7 @@ module.exports = function (task) {
const isClient = serverOrClient === 'client' const isClient = serverOrClient === 'client'
/** @type {import('@swc/core').Options} */
const swcClientOptions = { const swcClientOptions = {
module: { module: {
type: 'commonjs', type: 'commonjs',
...@@ -32,7 +33,7 @@ module.exports = function (task) { ...@@ -32,7 +33,7 @@ module.exports = function (task) {
}, },
jsc: { jsc: {
loose: true, loose: true,
externalHelpers: true,
target: 'es2016', target: 'es2016',
parser: { parser: {
syntax: 'typescript', syntax: 'typescript',
...@@ -55,6 +56,7 @@ module.exports = function (task) { ...@@ -55,6 +56,7 @@ module.exports = function (task) {
}, },
} }
/** @type {import('@swc/core').Options} */
const swcServerOptions = { const swcServerOptions = {
module: { module: {
type: 'commonjs', type: 'commonjs',
...@@ -67,7 +69,9 @@ module.exports = function (task) { ...@@ -67,7 +69,9 @@ module.exports = function (task) {
}, },
jsc: { jsc: {
loose: true, loose: true,
// Do not enable external helpers on server-side files build
// _is_native_funtion helper is not compatible with edge runtime (need investigate)
externalHelpers: false,
parser: { parser: {
syntax: 'typescript', syntax: 'typescript',
dynamicImport: true, dynamicImport: true,
......
...@@ -97,6 +97,8 @@ const externals = { ...@@ -97,6 +97,8 @@ const externals = {
'terser-webpack-plugin': 'terser-webpack-plugin':
'next/dist/build/webpack/plugins/terser-webpack-plugin', 'next/dist/build/webpack/plugins/terser-webpack-plugin',
// TODO: Add @swc/helpers to externals once @vercel/ncc switch to swc-loader
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['node-html-parser'] = 'next/dist/compiled/node-html-parser' externals['node-html-parser'] = 'next/dist/compiled/node-html-parser'
......
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