Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure user plugin's resolvedId() 'meta' reply isn't lost
This commit improves the parity of behaviour between 'vite build' and 'vite dev' when Rollup plugins retuning non-null 'meta' properties from resolveId() hooks are used. If one takes the Rollup behaviour to be any kind of reference in these cases, this is fixing a small bug in Vite, which was in a very large part already fixed by PR vitejs#5465. Here's an explanation of the faulty behaviour: The normalizeUrl() helper calls user plugins's resolveId() twice. - Once with the URL string containing a query suffix. Here it _ignores_ the meta reply. - Again, with the URL no longer containing said suffix. Here it doesn't ignore the meta reply. It is stored in the moduleGraph node. As can be seen, if the user's plugin meta reply depends on the query suffix being passed in the imported URL, that meta reply won't be registered correctly in the module graph and is not retrievable via getModuleInfo() later on. This change makes it so that the first call doesn't ignore the meta reply. This makes Vite's dev server match Rollup's plugin-calling behaviour and fixes vitejs#6766. Fix: vitejs#6766 * packages/vite/src/node/importGlob.ts (ResolvedUrl): Import it. (transformImportGlob): Use it. * packages/vite/src/node/plugins/importAnalysis.ts (ResolvedUrl): Import it. (normalizeUrl): Use it. Always return meta. (transform): Ensure moduleGraph is correctly built.
- Loading branch information