Skip to content

Commit

Permalink
Fix sourcemaps for internal client boundaries
Browse files Browse the repository at this point in the history
We used to manually insert `use client` where SWC strips it.
This caused sourcemaps to be off by one line.

The underlying issue in SWC is fixed so we can remove the workaround
and fix sourcemaps for internal files with a `use client` directive.
  • Loading branch information
eps1lon committed Nov 18, 2024
1 parent 2a23d2f commit 5ab7f7d
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions packages/next/taskfile-swc.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,6 @@ module.exports = function (task) {
const output = yield transform(source, options)
const ext = path.extname(file.base)

// Make sure the output content keeps the `"use client"` directive.
// TODO: Remove this once SWC fixes the issue.
if (/^['"]use client['"]/.test(source)) {
output.code =
'"use client";\n' +
output.code
.split('\n')
.map((l) => (/^['"]use client['"]/.test(l) ? '' : l))
.join('\n')
}

// Replace `.ts|.tsx` with `.js` in files with an extension
if (ext) {
const extRegex = new RegExp(ext.replace('.', '\\.') + '$', 'i')
Expand Down

0 comments on commit 5ab7f7d

Please sign in to comment.