Skip to content

Commit

Permalink
fix(next/turbopack): Always preserve import attributes with esm modules
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Oct 9, 2024
1 parent 81147ee commit 92d9dde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
11 changes: 3 additions & 8 deletions packages/next/taskfile-swc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ module.exports = function (task) {
function* (
file,
serverOrClient,
{
stripExtension,
keepImportAttributes = false,
interopClientDefaultExport = false,
esm = false,
} = {}
{ stripExtension, interopClientDefaultExport = false, esm = false } = {}
) {
// Don't compile .d.ts
if (file.base.endsWith('.d.ts') || file.base.endsWith('.json')) return
Expand Down Expand Up @@ -51,7 +46,7 @@ module.exports = function (task) {
tsx: file.base.endsWith('.tsx'),
},
experimental: {
keepImportAttributes,
keepImportAttributes: esm,
},
transform: {
react: {
Expand Down Expand Up @@ -96,7 +91,7 @@ module.exports = function (task) {
tsx: file.base.endsWith('.tsx'),
},
experimental: {
keepImportAttributes,
keepImportAttributes: esm,
},
transform: {
react: {
Expand Down
10 changes: 2 additions & 8 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@ export async function nextbuild_esm(task, opts) {
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev, esm: true, keepImportAttributes: true })
.swc('server', { dev: opts.dev, esm: true })
.target('dist/esm/build')
}

Expand Down Expand Up @@ -2587,7 +2587,7 @@ export async function client(task, opts) {
export async function client_esm(task, opts) {
await task
.source('src/client/**/!(*.test).+(js|ts|tsx)')
.swc('client', { dev: opts.dev, esm: true, keepImportAttributes: true })
.swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/client')
}

Expand All @@ -2612,7 +2612,6 @@ export async function pages_app(task, opts) {
.source('src/pages/_app.tsx')
.swc('client', {
dev: opts.dev,
keepImportAttributes: true,
interopClientDefaultExport: true,
})
.target('dist/pages')
Expand All @@ -2623,7 +2622,6 @@ export async function pages_error(task, opts) {
.source('src/pages/_error.tsx')
.swc('client', {
dev: opts.dev,
keepImportAttributes: true,
interopClientDefaultExport: true,
})
.target('dist/pages')
Expand All @@ -2634,7 +2632,6 @@ export async function pages_document(task, opts) {
.source('src/pages/_document.tsx')
.swc('server', {
dev: opts.dev,
keepImportAttributes: true,
})
.target('dist/pages')
}
Expand All @@ -2644,7 +2641,6 @@ export async function pages_app_esm(task, opts) {
.source('src/pages/_app.tsx')
.swc('client', {
dev: opts.dev,
keepImportAttributes: true,
esm: true,
})
.target('dist/esm/pages')
Expand All @@ -2655,7 +2651,6 @@ export async function pages_error_esm(task, opts) {
.source('src/pages/_error.tsx')
.swc('client', {
dev: opts.dev,
keepImportAttributes: true,
esm: true,
})
.target('dist/esm/pages')
Expand All @@ -2666,7 +2661,6 @@ export async function pages_document_esm(task, opts) {
.source('src/pages/_document.tsx')
.swc('server', {
dev: opts.dev,
keepImportAttributes: true,
esm: true,
})
.target('dist/esm/pages')
Expand Down

0 comments on commit 92d9dde

Please sign in to comment.