diff --git a/packages/next/taskfile-swc.js b/packages/next/taskfile-swc.js index 52e2ce34ccaa..f7e8478798cb 100644 --- a/packages/next/taskfile-swc.js +++ b/packages/next/taskfile-swc.js @@ -25,6 +25,7 @@ module.exports = function (task) { const isClient = serverOrClient === 'client' + /** @type {import('@swc/core').Options} */ const swcClientOptions = { module: { type: 'commonjs', @@ -32,7 +33,7 @@ module.exports = function (task) { }, jsc: { loose: true, - + externalHelpers: true, target: 'es2016', parser: { syntax: 'typescript', @@ -55,6 +56,7 @@ module.exports = function (task) { }, } + /** @type {import('@swc/core').Options} */ const swcServerOptions = { module: { type: 'commonjs', @@ -67,7 +69,9 @@ module.exports = function (task) { }, jsc: { 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: { syntax: 'typescript', dynamicImport: true, diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index b6ed0f018c12..1dd80baefe66 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -97,6 +97,8 @@ const externals = { '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 externals['node-html-parser'] = 'next/dist/compiled/node-html-parser'