Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vitejs/vite
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.0.0-beta.4
Choose a base ref
...
head repository: vitejs/vite
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.0.0-beta.5
Choose a head ref
  • 15 commits
  • 37 files changed
  • 9 contributors

Commits on Oct 23, 2024

  1. feat(json)!: add json.stringify: 'auto' and make that the default (#…

    sapphi-red authored Oct 23, 2024

    Verified

    This commit was created on github.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b80daa7 View commit details

Commits on Oct 24, 2024

  1. docs: add some migration guide for v6 (#18444)

    sapphi-red authored Oct 24, 2024

    Verified

    This commit was created on github.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fd55c60 View commit details
  2. chore(deps): update dependency picomatch to v4 (#15876)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
    renovate[bot] and sapphi-red authored Oct 24, 2024
    Copy the full SHA
    3774881 View commit details
  3. fix(ssr): preserve source maps for hoisted imports (fix #16355) (#16356)

    Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
    smcenlly and sapphi-red authored Oct 24, 2024
    Copy the full SHA
    8e382a6 View commit details
  4. fix(preview): set resolvedUrls null after close (#18445)

    bluwy authored Oct 24, 2024
    Copy the full SHA
    65014a3 View commit details
  5. test: fix test conflict (#18446)

    sapphi-red authored Oct 24, 2024
    Copy the full SHA
    94cd1e6 View commit details
  6. fix: add typing to CSSOptions.preprocessorOptions (#18001)

    Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
    Co-authored-by: bluwy <bjornlu.dev@gmail.com>
    3 people authored Oct 24, 2024
    Copy the full SHA
    7eeb6f2 View commit details
  7. fix(dev): prevent double URL encoding in server.open on macOS (#18443)

    Sun79 authored Oct 24, 2024
    Copy the full SHA
    56b7176 View commit details
  8. fix(create-vite): add tsBuildInfoFile option (#18435)

    hairihou authored Oct 24, 2024
    Copy the full SHA
    0a4427f View commit details
  9. fix!: default build.cssMinify to 'esbuild' for SSR (#15637)

    sapphi-red authored Oct 24, 2024
    Copy the full SHA
    f1d3bf7 View commit details
  10. chore: replace deprecated File type with RunnerTestFile (#18448)

    dario-piotrowicz authored Oct 24, 2024
    Copy the full SHA
    8cc8e51 View commit details
  11. refactor: use originalFileNames/names (#18240)

    sapphi-red authored Oct 24, 2024
    Copy the full SHA
    f2957c8 View commit details
  12. feat(css)!: load postcss config within workspace root only (#18440)

    bluwy authored Oct 24, 2024
    Copy the full SHA
    d23a493 View commit details
  13. fix(ssr): inject identity function at the top (#18449)

    sapphi-red authored Oct 24, 2024
    Copy the full SHA
    0ab20a3 View commit details
  14. release: v6.0.0-beta.5

    bluwy committed Oct 24, 2024
    Copy the full SHA
    91a1acb View commit details
Showing with 729 additions and 349 deletions.
  1. +1 −1 docs/config/build-options.md
  2. +4 −4 docs/config/shared-options.md
  3. +4 −4 docs/guide/api-javascript.md
  4. +21 −0 docs/guide/migration.md
  5. +1 −1 package.json
  6. +1 −0 packages/create-vite/template-preact-ts/tsconfig.app.json
  7. +1 −0 packages/create-vite/template-preact-ts/tsconfig.node.json
  8. +1 −0 packages/create-vite/template-qwik-ts/tsconfig.app.json
  9. +1 −0 packages/create-vite/template-qwik-ts/tsconfig.node.json
  10. +1 −0 packages/create-vite/template-react-ts/tsconfig.app.json
  11. +1 −0 packages/create-vite/template-react-ts/tsconfig.node.json
  12. +1 −0 packages/create-vite/template-solid-ts/tsconfig.app.json
  13. +1 −0 packages/create-vite/template-solid-ts/tsconfig.node.json
  14. +1 −0 packages/create-vite/template-vue-ts/tsconfig.app.json
  15. +1 −0 packages/create-vite/template-vue-ts/tsconfig.node.json
  16. +16 −0 packages/vite/CHANGELOG.md
  17. +3 −3 packages/vite/package.json
  18. +112 −2 packages/vite/src/node/__tests__/plugins/json.spec.ts
  19. +2 −2 packages/vite/src/node/build.ts
  20. +3 −14 packages/vite/src/node/plugins/asset.ts
  21. +109 −89 packages/vite/src/node/plugins/css.ts
  22. +2 −1 packages/vite/src/node/plugins/html.ts
  23. +1 −0 packages/vite/src/node/plugins/index.ts
  24. +59 −15 packages/vite/src/node/plugins/json.ts
  25. +20 −27 packages/vite/src/node/plugins/manifest.ts
  26. +7 −1 packages/vite/src/node/plugins/worker.ts
  27. +3 −2 packages/vite/src/node/preview.ts
  28. +9 −3 packages/vite/src/node/server/index.ts
  29. +1 −3 packages/vite/src/node/server/openBrowser.ts
  30. +8 −7 packages/vite/src/node/server/transformRequest.ts
  31. +54 −0 packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
  32. +39 −23 packages/vite/src/node/ssr/ssrTransform.ts
  33. +0 −5 packages/vite/src/types/shims.d.ts
  34. +43 −0 packages/vite/types/cssPreprocessorOptions.d.ts
  35. +4 −1 playground/json/__tests__/ssr/json-ssr.spec.ts
  36. +2 −2 playground/vitestSetup.ts
  37. +191 −139 pnpm-lock.yaml
2 changes: 1 addition & 1 deletion docs/config/build-options.md
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ In this case, you need to set `build.cssTarget` to `chrome61` to prevent vite fr
## build.cssMinify

- **Type:** `boolean | 'esbuild' | 'lightningcss'`
- **Default:** the same as [`build.minify`](#build-minify)
- **Default:** the same as [`build.minify`](#build-minify) for client, `'esbuild'` for SSR

This option allows users to override CSS minification specifically instead of defaulting to `build.minify`, so you can configure minification for JS and CSS separately. Vite uses `esbuild` by default to minify CSS. Set the option to `'lightningcss'` to use [Lightning CSS](https://lightningcss.dev/minification.html) instead. If selected, it can be configured using [`css.lightningcss`](./shared-options.md#css-lightningcss).

8 changes: 4 additions & 4 deletions docs/config/shared-options.md
Original file line number Diff line number Diff line change
@@ -217,7 +217,7 @@ Inline PostCSS config or a custom directory to search PostCSS config from (defau

For inline PostCSS config, it expects the same format as `postcss.config.js`. But for `plugins` property, only [array format](https://github.com/postcss/postcss-load-config/blob/main/README.md#array) can be used.

The search is done using [postcss-load-config](https://github.com/postcss/postcss-load-config) and only the supported config file names are loaded.
The search is done using [postcss-load-config](https://github.com/postcss/postcss-load-config) and only the supported config file names are loaded. Config files outside the workspace root (or the [project root](/guide/#index-html-and-project-root) if no workspace is found) are not searched by default. You can specify a custom path outside of the root to load the specific config file instead if needed.

Note if an inline config is provided, Vite will not search for other PostCSS config sources.

@@ -345,12 +345,12 @@ Whether to support named imports from `.json` files.

## json.stringify

- **Type:** `boolean`
- **Default:** `false`
- **Type:** `boolean | 'auto'`
- **Default:** `'auto'`

If set to `true`, imported JSON will be transformed into `export default JSON.parse("...")` which is significantly more performant than Object literals, especially when the JSON file is large.

Enabling this disables named imports.
If set to `'auto'`, the data will be stringified only if [the data is bigger than 10kB](https://v8.dev/blog/cost-of-javascript-2019#json:~:text=A%20good%20rule%20of%20thumb%20is%20to%20apply%20this%20technique%20for%20objects%20of%2010%20kB%20or%20larger).

## esbuild

8 changes: 4 additions & 4 deletions docs/guide/api-javascript.md
Original file line number Diff line number Diff line change
@@ -128,8 +128,8 @@ interface ViteDevServer {
*/
moduleGraph: ModuleGraph
/**
* The resolved urls Vite prints on the CLI. null in middleware mode or
* before `server.listen` is called.
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
* in middleware mode or if the server is not listening on any port.
*/
resolvedUrls: ResolvedServerUrls | null
/**
@@ -274,8 +274,8 @@ interface PreviewServer {
*/
httpServer: http.Server
/**
* The resolved urls Vite prints on the CLI.
* null before server is listening.
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
* if the server is not listening on any port.
*/
resolvedUrls: ResolvedServerUrls | null
/**
21 changes: 21 additions & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,27 @@ Some internal APIs have been removed due to changes in Vite's implementation. If

The experimental Vite Runtime API evolved into the Module Runner API, released in Vite 6 as part of the new experimental [Environment API](/guide/api-environment). Given that the feature was experimental the removal of the previous API introduced in Vite 5.1 isn't a breaking change, but users will need to update their use to the Module Runner equivalent as part of migrating to Vite 6.

## General Changes

### JSON stringify

In Vite 5, when [`json.stringify: true`](/config/shared-options#json-stringify) is set, [`json.namedExports`](/config/shared-options#json-namedexports) was disabled.

From Vite 6, even when `json.stringify: true` is set, `json.namedExports` is not disabled and the value is respected. If you wish to achieve the previous behavior, you can set `json.namedExports: false`.

Vite 6 also introduces a new default value for `json.stringify` which is `'auto'`, which will only stringify large JSON files. To disable this behavior, set `json.stringify: false`.

## Advanced

There are other breaking changes which only affect few users.

- [[#15637] fix!: default `build.cssMinify` to `'esbuild'` for SSR](https://github.com/vitejs/vite/pull/15637)
- [`build.cssMinify`](/config/build-options#build-cssminify) is now enabled by default even for SSR builds.
- [[#18209] refactor!: bump minimal terser version to 5.16.0](https://github.com/vitejs/vite/pull/18209)
- Minimal supported terser version for [`build.minify: 'terser'`](/config/build-options#build-minify) was bumped to 5.16.0 from 5.4.0.
- [[#18243] chore(deps)!: migrate `fast-glob` to `tinyglobby`](https://github.com/vitejs/vite/pull/18243)
- Range braces (`{01..03}``['01', '02', '03']`) and incremental braces (`{2..8..2}``['2', '4', '6', '8']`) are no longer supported in globs.

## Migration from v4

Check the [Migration from v4 Guide](https://v5.vite.dev/guide/migration.html) in the Vite v5 docs first to see the needed changes to port your app to Vite 5, and then proceed with the changes on this page.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@
"playwright-chromium": "^1.48.1",
"prettier": "3.3.3",
"rimraf": "^5.0.10",
"rollup": "^4.22.5",
"rollup": "^4.23.0",
"rollup-plugin-esbuild": "^6.1.1",
"simple-git-hooks": "^2.11.1",
"tslib": "^2.8.0",
1 change: 1 addition & 0 deletions packages/create-vite/template-preact-ts/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-preact-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-qwik-ts/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-qwik-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-react-ts/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
1 change: 1 addition & 0 deletions packages/create-vite/template-react-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-solid-ts/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-solid-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-vue-ts/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
1 change: 1 addition & 0 deletions packages/create-vite/template-vue-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
16 changes: 16 additions & 0 deletions packages/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 6.0.0-beta.5 (2024-10-24)

* fix: add typing to `CSSOptions.preprocessorOptions` (#18001) ([7eeb6f2](https://github.com/vitejs/vite/commit/7eeb6f2f97abf5dfc71c225b9cff9779baf2ed2f)), closes [#18001](https://github.com/vitejs/vite/issues/18001)
* fix(dev): prevent double URL encoding in server.open on macOS (#18443) ([56b7176](https://github.com/vitejs/vite/commit/56b71768f3ee498962fba898804086299382bb59)), closes [#18443](https://github.com/vitejs/vite/issues/18443)
* fix(preview): set resolvedUrls null after close (#18445) ([65014a3](https://github.com/vitejs/vite/commit/65014a32ef618619c5a34b729d67340d9253bdd5)), closes [#18445](https://github.com/vitejs/vite/issues/18445)
* fix(ssr): inject identity function at the top (#18449) ([0ab20a3](https://github.com/vitejs/vite/commit/0ab20a3ee26eacf302415b3087732497d0a2f358)), closes [#18449](https://github.com/vitejs/vite/issues/18449)
* fix(ssr): preserve source maps for hoisted imports (fix #16355) (#16356) ([8e382a6](https://github.com/vitejs/vite/commit/8e382a6a1fed2cd41051b81f9cd9c94b484352a5)), closes [#16355](https://github.com/vitejs/vite/issues/16355) [#16356](https://github.com/vitejs/vite/issues/16356)
* feat(css)!: load postcss config within workspace root only (#18440) ([d23a493](https://github.com/vitejs/vite/commit/d23a493cc4b54a2e2b2c1337b3b1f0c9b1be311e)), closes [#18440](https://github.com/vitejs/vite/issues/18440)
* feat(json)!: add `json.stringify: 'auto'` and make that the default (#18303) ([b80daa7](https://github.com/vitejs/vite/commit/b80daa7c0970645dca569d572892648f66c6799c)), closes [#18303](https://github.com/vitejs/vite/issues/18303)
* fix!: default `build.cssMinify` to `'esbuild'` for SSR (#15637) ([f1d3bf7](https://github.com/vitejs/vite/commit/f1d3bf74cc7f12e759442fd7111d07e2c0262a67)), closes [#15637](https://github.com/vitejs/vite/issues/15637)
* refactor: use `originalFileNames`/`names` (#18240) ([f2957c8](https://github.com/vitejs/vite/commit/f2957c84f69c14c882809889fbd0fc66b97ca3e9)), closes [#18240](https://github.com/vitejs/vite/issues/18240)
* test: fix test conflict (#18446) ([94cd1e6](https://github.com/vitejs/vite/commit/94cd1e6f95e2434d2b52b5c16d50fe0472214634)), closes [#18446](https://github.com/vitejs/vite/issues/18446)
* chore(deps): update dependency picomatch to v4 (#15876) ([3774881](https://github.com/vitejs/vite/commit/377488178a7ef372d9b76526bb01fd60b97f51df)), closes [#15876](https://github.com/vitejs/vite/issues/15876)



## 6.0.0-beta.4 (2024-10-23)

* refactor: use builder in `build` (#18432) ([cc61d16](https://github.com/vitejs/vite/commit/cc61d169a4826996f7b2289618c383f8c5c6d470)), closes [#18432](https://github.com/vitejs/vite/issues/18432)
6 changes: 3 additions & 3 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "6.0.0-beta.4",
"version": "6.0.0-beta.5",
"type": "module",
"license": "MIT",
"author": "Evan You",
@@ -87,7 +87,7 @@
"dependencies": {
"esbuild": "^0.24.0",
"postcss": "^8.4.47",
"rollup": "^4.22.5"
"rollup": "^4.23.0"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
@@ -133,7 +133,7 @@
"pathe": "^1.1.2",
"periscopic": "^4.0.2",
"picocolors": "^1.1.1",
"picomatch": "^2.3.1",
"picomatch": "^4.0.2",
"postcss-import": "^16.1.0",
"postcss-load-config": "^4.0.2",
"postcss-modules": "^6.0.0",
114 changes: 112 additions & 2 deletions packages/vite/src/node/__tests__/plugins/json.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { expect, test } from 'vitest'
import { extractJsonErrorPosition } from '../../plugins/json'
import { describe, expect, test } from 'vitest'
import {
type JsonOptions,
extractJsonErrorPosition,
jsonPlugin,
} from '../../plugins/json'

const getErrorMessage = (input: string) => {
try {
@@ -24,3 +28,109 @@ test('can extract json error position', () => {
)
}
})

describe('transform', () => {
const transform = (input: string, opts: JsonOptions, isBuild: boolean) => {
const plugin = jsonPlugin(opts, isBuild)
return (plugin.transform! as Function)(input, 'test.json').code
}

test('namedExports: true, stringify: false', () => {
const actual = transform(
'{"a":1,\n"🫠": "",\n"const": false}',
{ namedExports: true, stringify: false },
false,
)
expect(actual).toMatchInlineSnapshot(`
"export const a = 1;
export default {
a: a,
"🫠": "",
"const": false
};
"
`)
})

test('namedExports: false, stringify: false', () => {
const actual = transform(
'{"a":1,\n"🫠": "",\n"const": false}',
{ namedExports: false, stringify: false },
false,
)
expect(actual).toMatchInlineSnapshot(`
"export default {
a: 1,
"🫠": "",
"const": false
};"
`)
})

test('namedExports: true, stringify: true', () => {
const actual = transform(
'{"a":1,\n"🫠": "",\n"const": false}',
{ namedExports: true, stringify: true },
false,
)
expect(actual).toMatchInlineSnapshot(`
"export const a = 1;
export default {
a,
"🫠": "",
"const": false,
};
"
`)
})

test('namedExports: false, stringify: true', () => {
const actualDev = transform(
'{"a":1,\n"🫠": "",\n"const": false}',
{ namedExports: false, stringify: true },
false,
)
expect(actualDev).toMatchInlineSnapshot(
`"export default JSON.parse("{\\"a\\":1,\\n\\"🫠\\": \\"\\",\\n\\"const\\": false}")"`,
)

const actualBuild = transform(
'{"a":1,\n"🫠": "",\n"const": false}',
{ namedExports: false, stringify: true },
true,
)
expect(actualBuild).toMatchInlineSnapshot(
`"export default JSON.parse("{\\"a\\":1,\\"🫠\\":\\"\\",\\"const\\":false}")"`,
)
})

test("namedExports: true, stringify: 'auto'", () => {
const actualSmall = transform(
'{"a":1,\n"🫠": "",\n"const": false}',
{ namedExports: true, stringify: 'auto' },
false,
)
expect(actualSmall).toMatchInlineSnapshot(`
"export const a = 1;
export default {
a,
"🫠": "",
"const": false,
};
"
`)
const actualLargeNonObject = transform(
`{"a":1,\n"🫠": "${'vite'.repeat(3000)}",\n"const": false}`,
{ namedExports: true, stringify: 'auto' },
false,
)
expect(actualLargeNonObject).not.toContain('JSON.parse(')

const actualLarge = transform(
`{"a":1,\n"🫠": {\n"foo": "${'vite'.repeat(3000)}"\n},\n"const": false}`,
{ namedExports: true, stringify: 'auto' },
false,
)
expect(actualLarge).toContain('JSON.parse(')
})
})
4 changes: 2 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
@@ -369,7 +369,7 @@ export function resolveBuildEnvironmentOptions(
cssCodeSplit: !raw.lib,
sourcemap: false,
rollupOptions: {},
minify: raw.ssr ? false : 'esbuild',
minify: consumer === 'server' ? false : 'esbuild',
terserOptions: {},
write: true,
emptyOutDir: null,
@@ -434,7 +434,7 @@ export function resolveBuildEnvironmentOptions(
}

if (resolved.cssMinify == null) {
resolved.cssMinify = !!resolved.minify
resolved.cssMinify = consumer === 'server' ? 'esbuild' : !!resolved.minify
}

return resolved
17 changes: 3 additions & 14 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
@@ -38,17 +38,8 @@ const jsSourceMapRE = /\.[cm]?js\.map$/

const assetCache = new WeakMap<Environment, Map<string, string>>()

// chunk.name is the basename for the asset ignoring the directory structure
// For the manifest, we need to preserve the original file path and isEntry
// for CSS assets. We keep a map from referenceId to this information.
export interface GeneratedAssetMeta {
originalFileName: string
isEntry?: boolean
}
export const generatedAssetsMap = new WeakMap<
Environment,
Map<string, GeneratedAssetMeta>
>()
/** a set of referenceId for entry CSS assets for each environment */
export const cssEntriesMap = new WeakMap<Environment, Set<string>>()

// add own dictionary entry by directly assigning mrmime
export function registerCustomMime(): void {
@@ -146,7 +137,7 @@ export function assetPlugin(config: ResolvedConfig): Plugin {

buildStart() {
assetCache.set(this.environment, new Map())
generatedAssetsMap.set(this.environment, new Map())
cssEntriesMap.set(this.environment, new Set())
},

resolveId(id) {
@@ -384,8 +375,6 @@ async function fileToBuiltUrl(
originalFileName,
source: content,
})
generatedAssetsMap.get(environment)!.set(referenceId, { originalFileName })

url = `__VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}`
}

Loading