Skip to content

Commit ba7ed2d

Browse files
committed
chore(vite): drop comments
1 parent ea39c8f commit ba7ed2d

4 files changed

Lines changed: 0 additions & 11 deletions

File tree

‎packages/vite/hmr/server/constants.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
// Generic query suffix
55
export const QUERY_PATTERN = /\?.*$/;
66

7-
// Vite's `?raw` import query (its own `rawRE`), which loads a file's text as
8-
// `export default "..."`. Doesn't match the `raw=1` diagnostics flag.
97
export const RAW_QUERY_PATTERN = /[?&]raw(?:&|$)/;
108

119
// Detect whether Vite's variable dynamic import helper is already inlined

‎packages/vite/hmr/server/rewrite-imports.spec.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ describe('rewriteImports — ?raw imports', () => {
5656
const rewrite = (code: string) => rewriteImports(code, '/src/icons.ts', new Map(), new Map(), root, false, undefined, ORIGIN, true);
5757

5858
it('keeps ?raw on an app file import', () => {
59-
// Vite adds `import` to the query of non-JS imports.
6059
const out = rewrite(`import svg from "/src/icon.svg?import&raw";\n`);
6160
expect(out).toContain(`from "/ns/m/src/icon.svg?raw"`);
6261
});

‎packages/vite/hmr/server/rewrite-imports.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export function rewriteImports(code: string, importerPath: string, sfcFileMap: M
143143
// Inline JSON imports (package.json, config.json, etc.)
144144
// This must happen BEFORE other rewrites because JSON imports get a ?import query added by Vite
145145
result = result.replace(/import\s+(\w+)\s+from\s+["']([^"']+\.json(?:\?[^"']*)?)["'];?/g, (match, varName, jsonPath) => {
146-
// `?raw` wants the file's text, not the parsed object; it's served below.
147146
if (PAT.RAW_QUERY_PATTERN.test(jsonPath)) {
148147
return match;
149148
}
@@ -538,10 +537,6 @@ export function rewriteImports(code: string, importerPath: string, sfcFileMap: M
538537
return `${prefix}${spec}${suffix}`;
539538
};
540539

541-
// A `?raw` import (`import svg from './icon.svg?raw'`, which Vite emits as
542-
// `?import&raw`) is routed like the plain file, then keeps `?raw` on its
543-
// /ns/m URL so the route serves the file's text (see websocket-ns-m.ts).
544-
// The routing above drops queries, which served the asset module instead.
545540
const replaceImport = (match: string, prefix: string, spec: string, suffix: string): string => {
546541
if (typeof spec !== 'string' || !PAT.RAW_QUERY_PATTERN.test(spec)) {
547542
return replaceVueImport(match, prefix, spec, suffix);

‎packages/vite/hmr/server/websocket-ns-m.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ export function registerNsModuleServerRoute(server: ViteDevServer, options: Regi
169169
} catch {}
170170
}
171171

172-
// `?raw` imports keep the query on their /ns/m URL (rewriteImports).
173-
// Vite's raw load is the file's text as `export default "..."`,
174-
// which needs none of the device passes below.
175172
if (RAW_QUERY_PATTERN.test(urlObj.search)) {
176173
const rawSpec = resolveFsAnchoredSpec(spec, serverRoot, monorepoWorkspaceRoot) || spec;
177174
const rawRes = await sharedTransformRequest(`${rawSpec}?raw`);

0 commit comments

Comments
 (0)