Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(migration): add assets names array hint to avoid breaking the build when manifest enabled #18846

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

userquin
Copy link
Contributor

Description

Changes included in #18240 can break the build when the manifest is enabled and missing names if some plugin emit any asset without the entry (with type='asset').

Vite <6 using name entry to check whether the asset should be included in the manifest (name is deprecated, not sure when was deprecated in Rollup).

For example, vite-plugin-pwa emits 2 assets (not registered in the manifest): vite-pwa/vite-plugin-pwa@58553f8

image

@@ -81,6 +81,8 @@ If you prefer to stick with `style.css` like in Vite 5, you can set `build.lib.c

There are other breaking changes which only affect few users.

- [[#18240] refactor: use `originalFileNames/names`](https://github.com/vitejs/vite/pull/18240):
- any plugin that emits assets with type `asset` must include the `names` array in the asset to avoid breaking the build when the manifest is enabled. Older versions of Vite use the `name` field to check whether the asset should be included in the manifest.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just older versions. Vite 6 does too

name: path.basename(file),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe only when using generateBundle hook adding the asset to the bundle?

@sapphi-red
Copy link
Member

I think #18240 is not a breaking change. Rollup 4.23.0 added the properties as non-optional so it's valid to rely on the fact. You can argue that that change was a breaking change though. But I guess won't break anything, unless you assign to the bundle object, which is discouraged by the document.
https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants