Skip to content

Commit

Permalink
chore: enable swc externalHelpers when pre-compile (#38182)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 26, 2022
1 parent b846026 commit c69d781
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/next/taskfile-swc.js
Expand Up @@ -25,14 +25,15 @@ module.exports = function (task) {

const isClient = serverOrClient === 'client'

/** @type {import('@swc/core').Options} */
const swcClientOptions = {
module: {
type: 'commonjs',
ignoreDynamic: true,
},
jsc: {
loose: true,

externalHelpers: true,
target: 'es2016',
parser: {
syntax: 'typescript',
Expand All @@ -55,6 +56,7 @@ module.exports = function (task) {
},
}

/** @type {import('@swc/core').Options} */
const swcServerOptions = {
module: {
type: 'commonjs',
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/next/taskfile.js
Expand Up @@ -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'
Expand Down

0 comments on commit c69d781

Please sign in to comment.