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

fix: re-use ident of vue rule for template compiler, fixes #2029 #2030

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

xanf
Copy link
Contributor

@xanf xanf commented Mar 12, 2023

Webpack 4 uses ident query param underneath to store options objects passed to loaders, and relies on this ident param to retrieve options for correct loaders https://github.com/webpack/webpack/blob/v4.46.0/lib/RuleSet.js#L560-L566

Logic of "identing" is pretty straightforward - if ident is provided in options - that one is respected, but if there is no ident - it is generated based on index of rule in RuleSet

vue-loader heavily modifies rules after normalizeRules kicked in and put ident's for existing rules here & there.

That means that templateLoader rule, will receive ident based on it's position in rules array, but at this point this ident might be occupied by some other loader (and that loader will not be "re-indented" because logic there is to maintain existing idents

Since we're putting old rules lower than templateLoader - when resoving ident --> options we will receive wrong object

To fix this we will be reusing vueLoaderUse ident. This is 100% safe, since our rule after identing will be thrown away so no clash here possible. I was even able to test that 😄

This should fix #2029

Ensure that correct ident id is used for storing options object
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.

vue-loader options might get lost for template compiler in webpack 4
2 participants