We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4f3770e commit 0036f23Copy full SHA for 0036f23
packages/vite/src/node/plugins/json.ts
@@ -29,6 +29,8 @@ export interface JsonOptions {
29
// Custom json filter for vite
30
const jsonExtRE = /\.json(?:$|\?)(?!commonjs-(?:proxy|external))/
31
32
+const jsonObjRE = /^\s*\{/
33
+
34
const jsonLangs = `\\.(?:json|json5)(?:$|\\?)`
35
const jsonLangRE = new RegExp(jsonLangs)
36
export const isJSONRequest = (request: string): boolean =>
@@ -49,7 +51,7 @@ export function jsonPlugin(
49
51
50
52
try {
53
if (options.stringify !== false) {
- if (options.namedExports && /^\s*\{/.test(json)) {
54
+ if (options.namedExports && jsonObjRE.test(json)) {
55
const parsed = JSON.parse(json)
56
const keys = Object.keys(parsed)
57
0 commit comments