diff --git a/packages/next/taskfile-swc.js b/packages/next/taskfile-swc.js index 52e2ce34ccaa7..94a6bc5652217 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 externalHelpers for server-side code + // "_is_native_function.mjs" helper is not compatible with edge runtime + externalHelpers: false, parser: { syntax: 'typescript', dynamicImport: true, diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index b90e92f8b8ec6..f19b4651ea341 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1956,7 +1956,7 @@ export async function shared(task, opts) { .source( opts.src || 'shared/**/!(amp|config|constants|dynamic|head).+(js|ts|tsx)' ) - .swc('server', { dev: opts.dev }) + .swc('client', { dev: opts.dev }) .target('dist/shared') notify('Compiled shared files') } @@ -1966,7 +1966,7 @@ export async function shared_re_exported(task, opts) { .source( opts.src || 'shared/**/{amp,config,constants,dynamic,head}.+(js|ts|tsx)' ) - .swc('server', { dev: opts.dev, interopClientDefaultExport: true }) + .swc('client', { dev: opts.dev, interopClientDefaultExport: true }) .target('dist/shared') notify('Compiled shared re-exported files') }