Conversation
1. Entrypoints with custom names that don't match the file name 2. CSS-only entrypoints
|
Some corrections need to be made after vitejs/vite#20585. Setting to draft for now. |
|
I've talked to the Vite/Rolldown team and turns out both |
| asset_entries[name] = { | ||
| "isEntry" => true, | ||
| "file" => file, | ||
| } |
There was a problem hiding this comment.
Any reason not to point to the same entry object instead of creating a new one?
| entry[key] = entry[key].map { |path| prefix_vite_asset(path) } if entry[key] | ||
| end | ||
| entry["imports"]&.map! { |name| manifest.fetch(name) } | ||
| asset_entries[entry["name"] + ".js"] = entry if entry["name"] && entry["isEntry"] |
There was a problem hiding this comment.
Adding .js feels like a hack to make using vite_javascript_tag more convenient.
|
Something that seems fragile is assuming that Is the Vite dev server able to resolve custom entrypoint names in this fashion? In particular, custom name |
Description 📖
This change adds support for more advanced entrypoints:
Example config for custom names:
Example config for CSS only entrypoint:
Background 📜
At GitLab we have entrypoints that don't necessarily match the filenames. This is due to how we change the entrypoints based on the target release: community edition (CE) or enterprise (EE). EE entrypoints are resolved outside of the
sourceCodeDirand thus don't match exactly the filename. Also, we use special names for those:pages/foo/bar/index.jswill get a namepages.foo.bar. As you can see it can not be directly matched to the filename. That's why we need to respect thenameproperty stored in the manifest and use it instead or the actual filename to resolve an asset.The same thing applies to the stylesheets, we could have different name for these. So we have to resolve CSS entrypoints using
namesproperty, which as added in vitejs/vite#19912 and released in https://github.com/vitejs/vite/releases/tag/v7.0.0-beta.0.The Fix 🔨
We fix the issue by using
nameandnamesproperty for entries withisEntryfield. For such entries we create new records in the manifest withname(or each key innames) used as a primary key.