Skip to content

Conversation

@austinw-fineart
Copy link

Refactors the webpack plugin to use the proper hook, only extracting keys from processed files. Also avoids triggering compilation twice in watch mode.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@shaharkazaz
Copy link
Collaborator

@austinw-fineart Tnx for the PR, I'll take a look soon!

@austinw-fineart
Copy link
Author

Made an error with the webpack types so I ended up reusing the stringified contents for RawSource, which means I ended up not using the file utils.

Refactors the webpack plugin to use the proper hook, only extracting
keys from processed files. Also avoids triggering compilation twice in
watch mode.
@austinw-fineart
Copy link
Author

Ideally being able to reference the webpack types would be preferrable but that'd take a dev or peer dependency so it's understandable.

@shaharkazaz
Copy link
Collaborator

@austinw-fineart I'm unfamiliar with testing such plugins, but I want to ensure that regressions are introduced. How did you test it?

@austinw-fineart
Copy link
Author

austinw-fineart commented Sep 26, 2025

I used my own project to test with. I could add a stripped down version here but it wouldn't exactly match your existing tests. It'll require a dependency on @angular-builders/custom-webpack to run however.

@austinw-fineart
Copy link
Author

There is a breaking change if you consider that before the plugin would run extract on the entire project initially, but doing so triggers a second compilation in watch mode. Now the plugin only extracts keys from modified files which makes it more suited as a watch companion rather than a build step which the CLI can fulfill. It's still possible to scan the entire project manually on the first pass but I'm not sure if that's worth the tradeoff.

@shaharkazaz
Copy link
Collaborator

@austinw-fineart What's the tradeoff here? Did you feel any big impact when using the plugin as is? The extraction should be pretty quick. Can you share the considerations and metrics (if some were collected)?

@austinw-fineart
Copy link
Author

I wouldn't know how to do any synthetic benchmarks but here are my numbers from a large size project:
ℹ 1110 keys were found in 1142 files.
Initial total: 12.56 MB

Version Run1 Run1² Run2 Run2² Run3 Run3² Mean Error StdDev
old 247876 ms 99288 ms 237235 ms 91887 ms 222362 ms 93602 ms 235824.333 ms 7398.9534 ms 12815.3632 ms
new 233102 ms - 224513 ms - 218590 ms - 225401.667 ms 4212.7518 ms 7296.7001 ms

² second compilation triggered immediately after by the file watcher

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.

2 participants