Skip to content

Commit c69d781

Browse files
authored
chore: enable swc externalHelpers when pre-compile (vercel#38182)
1 parent b846026 commit c69d781

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/next/taskfile-swc.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ module.exports = function (task) {
2525

2626
const isClient = serverOrClient === 'client'
2727

28+
/** @type {import('@swc/core').Options} */
2829
const swcClientOptions = {
2930
module: {
3031
type: 'commonjs',
3132
ignoreDynamic: true,
3233
},
3334
jsc: {
3435
loose: true,
35-
36+
externalHelpers: true,
3637
target: 'es2016',
3738
parser: {
3839
syntax: 'typescript',
@@ -55,6 +56,7 @@ module.exports = function (task) {
5556
},
5657
}
5758

59+
/** @type {import('@swc/core').Options} */
5860
const swcServerOptions = {
5961
module: {
6062
type: 'commonjs',
@@ -67,7 +69,9 @@ module.exports = function (task) {
6769
},
6870
jsc: {
6971
loose: true,
70-
72+
// Do not enable external helpers on server-side files build
73+
// _is_native_funtion helper is not compatible with edge runtime (need investigate)
74+
externalHelpers: false,
7175
parser: {
7276
syntax: 'typescript',
7377
dynamicImport: true,

packages/next/taskfile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ const externals = {
9797

9898
'terser-webpack-plugin':
9999
'next/dist/build/webpack/plugins/terser-webpack-plugin',
100+
101+
// TODO: Add @swc/helpers to externals once @vercel/ncc switch to swc-loader
100102
}
101103
// eslint-disable-next-line camelcase
102104
externals['node-html-parser'] = 'next/dist/compiled/node-html-parser'

0 commit comments

Comments
 (0)