Unverified Commit 8a6307fc authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Remove isCommonJS check as it has been moved to next-swc (#30677)

Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 622a1a55
...@@ -40,7 +40,6 @@ function getSWCOptions({ ...@@ -40,7 +40,6 @@ function getSWCOptions({
pagesDir, pagesDir,
isNextDist, isNextDist,
hasReactRefresh, hasReactRefresh,
isCommonJS,
}) { }) {
const isTSFile = filename.endsWith('.ts') const isTSFile = filename.endsWith('.ts')
const isTypeScript = isTSFile || filename.endsWith('.tsx') const isTypeScript = isTSFile || filename.endsWith('.tsx')
...@@ -77,14 +76,6 @@ function getSWCOptions({ ...@@ -77,14 +76,6 @@ function getSWCOptions({
if (isServer) { if (isServer) {
return { return {
jsc, 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 // Disables getStaticProps/getServerSideProps tree shaking on the server compilation for pages
disableNextSsg: true, disableNextSsg: true,
disablePageConfig: true, disablePageConfig: true,
...@@ -103,7 +94,7 @@ function getSWCOptions({ ...@@ -103,7 +94,7 @@ function getSWCOptions({
jsc.target = 'es5' jsc.target = 'es5'
return { return {
// Ensure Next.js internals are output as commonjs modules // Ensure Next.js internals are output as commonjs modules
...(isNextDist || isCommonJS ...(isNextDist
? { ? {
module: { module: {
type: 'commonjs', type: 'commonjs',
...@@ -129,7 +120,6 @@ async function loaderTransform(parentTrace, source, inputSourceMap) { ...@@ -129,7 +120,6 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
const isPageFile = filename.startsWith(pagesDir) const isPageFile = filename.startsWith(pagesDir)
const isNextDist = nextDistPath.test(filename) const isNextDist = nextDistPath.test(filename)
const isCommonJS = source.indexOf('module.exports') !== -1
const swcOptions = getSWCOptions({ const swcOptions = getSWCOptions({
pagesDir, pagesDir,
...@@ -138,7 +128,6 @@ async function loaderTransform(parentTrace, source, inputSourceMap) { ...@@ -138,7 +128,6 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
isPageFile, isPageFile,
development: this.mode === 'development', development: this.mode === 'development',
isNextDist, isNextDist,
isCommonJS,
hasReactRefresh, hasReactRefresh,
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment