Skip to content

Commit

Permalink
Add back default exports interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Apr 12, 2022
1 parent e7bdab1 commit 7f35e4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion packages/next/taskfile-swc.js
Expand Up @@ -14,7 +14,11 @@ module.exports = function (task) {
function* (
file,
serverOrClient,
{ stripExtension, keepImportAssertions = false } = {}
{
stripExtension,
keepImportAssertions = false,
interopClientDefaultExport = false,
} = {}
) {
// Don't compile .d.ts
if (file.base.endsWith('.d.ts')) return
Expand Down Expand Up @@ -111,6 +115,15 @@ module.exports = function (task) {
}

if (output.map) {
if (interopClientDefaultExport) {
output.code += `
if (typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) {
Object.assign(exports.default, exports);
module.exports = exports.default;
}
`
}

const map = `${file.base}.map`

output.code += Buffer.from(`\n//# sourceMappingURL=${map}`)
Expand Down
2 changes: 1 addition & 1 deletion packages/next/taskfile.js
Expand Up @@ -1826,7 +1826,7 @@ export async function nextbuild(task, opts) {
export async function client(task, opts) {
await task
.source(opts.src || 'client/**/*.+(js|ts|tsx)')
.swc('client', { dev: opts.dev })
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/client')
notify('Compiled client files')
}
Expand Down

0 comments on commit 7f35e4d

Please sign in to comment.