fix(deps)!: update magic-string to v1

This commit is contained in:
alex8088 2026-09-25 01:26:57 +08:00
parent 2937574aa4
commit a7f76d8d44
5 changed files with 18 additions and 9 deletions

View File

@ -95,7 +95,7 @@
"@babel/core": "^7.29.0",
"@babel/plugin-transform-arrow-functions": "^7.27.1",
"cac": "^7.0.0",
"magic-string": "^0.30.21",
"magic-string": "^1.4.2",
"picocolors": "^1.1.1",
"rolldown": "~1.2.10"
},

16
pnpm-lock.yaml generated
View File

@ -18,8 +18,8 @@ importers:
specifier: ^7.0.0
version: 7.0.0
magic-string:
specifier: ^0.30.21
version: 0.30.21
specifier: ^1.4.2
version: 1.4.2
picocolors:
specifier: ^1.1.1
version: 1.1.1
@ -271,6 +271,9 @@ packages:
'@jridgewell/sourcemap-codec@1.5.5':
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
'@jridgewell/sourcemap-codec@1.6.0':
resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==}
'@jridgewell/trace-mapping@0.3.31':
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
@ -1086,6 +1089,9 @@ packages:
magic-string@0.30.21:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
magic-string@1.4.2:
resolution: {integrity: sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g==}
minimatch@10.2.6:
resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==}
engines: {node: 18 || 20 || >=22}
@ -1545,6 +1551,8 @@ snapshots:
'@jridgewell/sourcemap-codec@1.5.5': {}
'@jridgewell/sourcemap-codec@1.6.0': {}
'@jridgewell/trace-mapping@0.3.31':
dependencies:
'@jridgewell/resolve-uri': 3.1.2
@ -2215,6 +2223,10 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
magic-string@1.4.2:
dependencies:
'@jridgewell/sourcemap-codec': 1.6.0
minimatch@10.2.6:
dependencies:
brace-expansion: 5.0.12

View File

@ -1,6 +1,5 @@
import path from 'node:path'
import fs from 'node:fs/promises'
import type { SourceMapInput } from 'rollup'
import { type Plugin, type Environment, normalizePath } from 'vite'
import MagicString from 'magic-string'
import { cleanUrl, getHash, toRelativePath } from '../utils'
@ -106,7 +105,7 @@ export default function assetPlugin(): Plugin {
export default importObject => loadWasm(${referenceId}, importObject)`
}
},
renderChunk(code, chunk, { sourcemap, dir }): { code: string; map: SourceMapInput } | null {
renderChunk(code, chunk, { sourcemap, dir }) {
let match: RegExpExecArray | null
let s: MagicString | undefined

View File

@ -5,7 +5,6 @@
*/
import MagicString from 'magic-string'
import type { SourceMapInput } from 'rollup'
import type { Plugin } from 'vite'
import { supportImportMetaPaths } from '../electron'
@ -52,7 +51,7 @@ export default function esmShimPlugin(): Plugin {
name: 'vite:esm-shim',
apply: 'build',
enforce: 'post',
renderChunk(code, _chunk, { format, sourcemap }): { code: string; map?: SourceMapInput } | null {
renderChunk(code, _chunk, { format, sourcemap }) {
if (format === 'es') {
if (code.includes(CJSShim) || !CJSyntaxRe.test(code)) {
return null

View File

@ -1,5 +1,4 @@
import type { Plugin } from 'vite'
import type { SourceMapInput } from 'rollup'
import MagicString from 'magic-string'
import { cleanUrl, toRelativePath } from '../utils'
@ -36,7 +35,7 @@ export default function workerPlugin(): Plugin {
}
}
},
renderChunk(code, chunk, { sourcemap }): { code: string; map: SourceMapInput } | null {
renderChunk(code, chunk, { sourcemap }) {
let match: RegExpExecArray | null
let s: MagicString | undefined