Skip to content

Commit fb0e51b

Browse files
committed
fix: use parseAst for rolldown for workerImportMetaUrl as well
1 parent 536d540 commit fb0e51b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/vite/src/node/parseAst.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const parseAstGeneric = (
1818
const result = rolldownParseAst(filename ?? 'file.js', code, {
1919
sourceType: 'module',
2020
lang: 'js',
21+
preserveParens: false,
2122
...opts,
2223
})
2324
if (result.errors.length > 0) {
@@ -35,6 +36,7 @@ export const parseAstGenericAsync = async (
3536
const result = await rolldownParseAstAsync(filename ?? 'file.js', code, {
3637
sourceType: 'module',
3738
lang: 'js',
39+
preserveParens: false,
3840
...opts,
3941
})
4042
if (result.errors.length > 0) {

packages/vite/src/node/plugins/workerImportMetaUrl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import path from 'node:path'
22
import MagicString from 'magic-string'
33
import type { RolldownPlugin, RollupError } from 'rolldown'
44
import type { RollupAstNode } from 'rollup'
5-
import { parseAstAsync } from 'rollup/parseAst'
65
import { stripLiteral } from 'strip-literal'
76
import type { Expression, ExpressionStatement } from 'estree'
87
import type { ResolvedConfig } from '../config'
98
import { evalValue, injectQuery, transformStableResult } from '../utils'
109
import { createBackCompatIdResolver } from '../idResolver'
1110
import type { ResolveIdFn } from '../idResolver'
1211
import { cleanUrl, slash } from '../../shared/utils'
12+
import { parseAstAsync } from '../parseAst'
1313
import type { WorkerType } from './worker'
1414
import { WORKER_FILE_ID, workerFileToUrl } from './worker'
1515
import { fileToUrl } from './asset'

0 commit comments

Comments
 (0)