Skip to content

Commit

Permalink
Remove isCommonJS check as it has been moved to next-swc (#30677)
Browse files Browse the repository at this point in the history
Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
timneutkens and ijjk committed Oct 30, 2021
1 parent 622a1a5 commit 8a6307f
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions packages/next/build/webpack/loaders/next-swc-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function getSWCOptions({
pagesDir,
isNextDist,
hasReactRefresh,
isCommonJS,
}) {
const isTSFile = filename.endsWith('.ts')
const isTypeScript = isTSFile || filename.endsWith('.tsx')
Expand Down Expand Up @@ -77,14 +76,6 @@ function getSWCOptions({
if (isServer) {
return {
jsc,
// Next.js dist intentionally does not have type: commonjs on server compilation
...(isCommonJS
? {
module: {
type: 'commonjs',
},
}
: {}),
// Disables getStaticProps/getServerSideProps tree shaking on the server compilation for pages
disableNextSsg: true,
disablePageConfig: true,
Expand All @@ -103,7 +94,7 @@ function getSWCOptions({
jsc.target = 'es5'
return {
// Ensure Next.js internals are output as commonjs modules
...(isNextDist || isCommonJS
...(isNextDist
? {
module: {
type: 'commonjs',
Expand All @@ -129,7 +120,6 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
const isPageFile = filename.startsWith(pagesDir)

const isNextDist = nextDistPath.test(filename)
const isCommonJS = source.indexOf('module.exports') !== -1

const swcOptions = getSWCOptions({
pagesDir,
Expand All @@ -138,7 +128,6 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
isPageFile,
development: this.mode === 'development',
isNextDist,
isCommonJS,
hasReactRefresh,
})

Expand Down

0 comments on commit 8a6307f

Please sign in to comment.