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

support compilation.mainTemplate.hooks.localVars hook #2982

Closed
underfin opened this issue Apr 28, 2023 · 8 comments
Closed

support compilation.mainTemplate.hooks.localVars hook #2982

underfin opened this issue Apr 28, 2023 · 8 comments
Assignees
Labels
feat New feature or request team The issue/pr is created by the member of Rspack.

Comments

@underfin
Copy link
Contributor

underfin commented Apr 28, 2023

What problem does this feature solve?

What does the proposed API of configuration look like?

  • support the user add runtime code to runtime module.
@underfin underfin added feat New feature or request pending triage The issue/PR is currently untouched. labels Apr 28, 2023
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Apr 28, 2023
@underfin underfin added p3-nice-to-have and removed pending triage The issue/PR is currently untouched. labels Apr 28, 2023
@underfin underfin added this to the Planned milestone Apr 28, 2023
@jerrykingxyz jerrykingxyz modified the milestones: Planned, 0.1.14 - Patch May 23, 2023
@hardfist
Copy link
Contributor

hi @alexander-akait, I see the comment in https://github.com/webpack/webpack/blob/main/lib/MainTemplate.js#L40, and want to know whether MainTemplate will be removed in webpack6 and are all the hooks in mainTemplate will be gone, if MainTemplate will be removed what's alternative to put all these hooks, because if it will be removed in webpack@6 then we don't think it's necessary to implement it in rspack.

@alexander-akait
Copy link

It will be removed without replacement, we have good messages about deprecations - https://github.com/webpack/webpack/blob/main/lib/MainTemplate.js#L301, therefore, we should not implement it

@hardfist
Copy link
Contributor

hardfist commented May 24, 2023

It will be removed without replacement, we have good messages about deprecations - webpack/webpack@main/lib/MainTemplate.js#L301, therefore, we should not implement it

so there's no alternative for compilation.mainTemplate.hooks.localVars?, it seems some frameworks and plugins relys on this hook, nuxtjs

@alexander-akait
Copy link

Based on logic you can rewrite it using compilation.hooks.additionalTreeRuntimeRequirements hook - https://github.com/webpack/webpack/blob/main/lib/RuntimePlugin.js#L442, we already do it 😄

@alexander-akait
Copy link

https://github.com/nuxt/nuxt/blob/a672cd7a4291eb812d76b9841ec516cd8609c680/packages/webpack/src/plugins/chunk.ts#L22 can be rewritten on using compilation.hooks.additionalTreeRuntimeRequirements without any problems

@hardfist
Copy link
Contributor

it seems all the hooks(which is useful) in the Template will be replaced with some hook in compilation?

@alexander-akait
Copy link

@hardfist Yeah, we done a lot of refactor around runtime and now runtime contains modules, like other modules, so now it is possible to write custom plugins with runtime without hacking like replace/regexp/etc

@hyf0 hyf0 removed this from the 0.1.14 - Patch milestone Jun 7, 2023
@hardfist
Copy link
Contributor

low priority now we can reopen if we do need it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

No branches or pull requests

5 participants