From 81b292e9090a71f3f1d16050474170f37cd32d11 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 18 Nov 2024 16:12:09 +0100 Subject: [PATCH] Fix sourcemaps for internal client boundaries 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. --- packages/next/taskfile-swc.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/next/taskfile-swc.js b/packages/next/taskfile-swc.js index 6aed4617d1c8e..95327966af231 100644 --- a/packages/next/taskfile-swc.js +++ b/packages/next/taskfile-swc.js @@ -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')