From b87511c739f0a1a8ac00272732cfa65ebf999f5a Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 2 Apr 2024 09:56:21 +0200 Subject: [PATCH] fix: Create word-based fidelity source mapping for code transformations (#513) --- packages/bundler-plugin-core/package.json | 2 +- packages/bundler-plugin-core/src/index.ts | 6 +++--- packages/bundler-plugin-core/src/utils.ts | 2 +- yarn.lock | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/bundler-plugin-core/package.json b/packages/bundler-plugin-core/package.json index b6a0d64e..9d08c326 100644 --- a/packages/bundler-plugin-core/package.json +++ b/packages/bundler-plugin-core/package.json @@ -58,7 +58,7 @@ "dotenv": "^16.3.1", "find-up": "^5.0.0", "glob": "^9.3.2", - "magic-string": "0.27.0", + "magic-string": "0.30.8", "unplugin": "1.0.1" }, "devDependencies": { diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index f601bca2..c4f12ee8 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -419,7 +419,7 @@ export function createRollupReleaseInjectionHooks(injectionCode: string) { return { code: ms.toString(), - map: ms.generateMap({ hires: true }), + map: ms.generateMap({ hires: "boundary" }), }; }, }; @@ -464,7 +464,7 @@ export function createRollupDebugIdInjectionHooks() { return { code: ms.toString(), - map: ms.generateMap({ file: chunk.fileName, hires: true }), + map: ms.generateMap({ file: chunk.fileName, hires: "boundary" }), }; } else { return null; // returning null means not modifying the chunk at all @@ -495,7 +495,7 @@ export function createRollupModuleMetadataInjectionHooks(injectionCode: string) return { code: ms.toString(), - map: ms.generateMap({ file: chunk.fileName, hires: true }), + map: ms.generateMap({ file: chunk.fileName, hires: "boundary" }), }; } else { return null; // returning null means not modifying the chunk at all diff --git a/packages/bundler-plugin-core/src/utils.ts b/packages/bundler-plugin-core/src/utils.ts index 870dcb76..2389ecae 100644 --- a/packages/bundler-plugin-core/src/utils.ts +++ b/packages/bundler-plugin-core/src/utils.ts @@ -326,7 +326,7 @@ export function replaceBooleanFlagsInCode( if (ms.hasChanged()) { return { code: ms.toString(), - map: ms.generateMap({ hires: true }), + map: ms.generateMap({ hires: "boundary" }), }; } diff --git a/yarn.lock b/yarn.lock index fb9d3976..79095fe6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2001,7 +2001,7 @@ resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.13", "@jridgewell/sourcemap-codec@^1.4.15": +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.15": version "1.4.15" resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== @@ -9314,12 +9314,12 @@ lru_map@^0.3.3: resolved "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd" integrity sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ== -magic-string@0.27.0: - version "0.27.0" - resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.27.0.tgz#e4a3413b4bab6d98d2becffd48b4a257effdbbf3" - integrity sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA== +magic-string@0.30.8: + version "0.30.8" + resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.30.8.tgz#14e8624246d2bedba70d5462aa99ac9681844613" + integrity sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ== dependencies: - "@jridgewell/sourcemap-codec" "^1.4.13" + "@jridgewell/sourcemap-codec" "^1.4.15" magic-string@^0.25.7: version "0.25.9"