Skip to content

Commit

Permalink
chore: reduce diff
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Nov 18, 2024
1 parent 9afe273 commit 0330bb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,9 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
const file = checkPublicFile(id, config) || cleanUrl(id)
this.addWatchFile(file)
// raw query, read file and return as string
return {
code: `export default ${JSON.stringify(
await fsp.readFile(file, 'utf-8'),
)}`,
moduleType: 'js', // TODO: remove later when not needed
}
return `export default ${JSON.stringify(
await fsp.readFile(file, 'utf-8'),
)}`
}

if (!urlRE.test(id) && !config.assetsInclude(cleanUrl(id))) {
Expand Down Expand Up @@ -216,7 +213,6 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
? 'no-treeshake'
: false,
meta: config.command === 'build' ? { 'vite:asset': true } : undefined,
moduleType: 'js', // TODO: remove later when not needed
}
},

Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function jsonPlugin(
return {
code,
map: { mappings: '' },
moduleType: 'js', // TODO: remove later when not needed
moduleType: 'js',
}
}

Expand All @@ -90,7 +90,7 @@ export function jsonPlugin(
return {
code: `export default JSON.parse(${JSON.stringify(json)})`,
map: { mappings: '' },
moduleType: 'js', // TODO: remove later when not needed
moduleType: 'js',
}
}
}
Expand All @@ -101,7 +101,7 @@ export function jsonPlugin(
namedExports: options.namedExports,
}),
map: { mappings: '' },
moduleType: 'js', // TODO: remove later when not needed
moduleType: 'js',
}
} catch (e) {
const position = extractJsonErrorPosition(e.message, json.length)
Expand Down

0 comments on commit 0330bb1

Please sign in to comment.