-
Notifications
You must be signed in to change notification settings - Fork 12k
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(@angular-devkit/build-angular): Set chunk names explicitly #25511
Conversation
This seems like a good idea, but can you please provide some context? |
Mostly, the issue comes down to ESBuild generating chunk names as When running tests with Jest, the builder is using pattern First idea was to simply change the pattern to For build code it doesn't make any difference. For tests it makes sure that all chunks have the same name pattern and are excluded from the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gultyayev for looking into this, I haven't had a chance to dig in yet. I think this is probably a reasonable solution, though it looks like one of the tests is failing, as it is expecting the app to print the lazy loaded file's name which is no longer true. Maybe we could search for a more generic "rebuild done" string like "Application bundle generation complete"?
Also making this change in builder-context.ts
means that it will apply to all ESBuild executions, not just Jest. I think that's probably ok, but I wonder if there might be some unintended consequences from it. @clydin, do you have any concerns with that?
570ce59
to
4c14f0c
Compare
TBH I can't think of any possible shortcomings from this. The names are always generated and hence cannot be relied on. Furthermore, current behavior is to create chunks with It's also possible to pass this change for Jest builder only. I didn't locate the place though. Not sure if it would make much sense to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of setting the option in the builder context which only contains infrastructure related options. It would be better to follow the existing pattern for similar options and set it in
angular-cli/packages/angular_devkit/build_angular/src/tools/esbuild/application-code-bundle.ts
Line 183 in 4a8edff
function getEsBuildCommonOptions(options: NormalizedApplicationBuildOptions): BuildOptions { |
angular-cli/packages/angular_devkit/build_angular/src/builders/application/options.ts
Line 92 in 4a8edff
const outputNames = { |
Did the first suggested change. The 2nd one doesn't work. |
One concern that may be is that chunk names become obscure. Current |
@gultyayev, thanks for your patience. Using Just the one comment from @clydin about making sure a chunk is created on the rebuild and this should be good to go. |
Explicitly set chunk name pattern to exclude them from Jest run
Thanks! This looks good to merge. |
Thank you for guidance. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently, chunk names are determined by ESBuild. Some libraries may resolve to a name that is not in a format of
chunk.hash.mjs
. This causes Jest to run over the lib files and fail as it contains no test suite.Fixes: #25189
What is the new behavior?
The change sets chunk name pattern explicitly so that all
chunk
s are exluded by pattern from running tests over.Does this PR introduce a breaking change?
Other information
I didn't figure out how this could be covered by tests. I did run a local build & installation and verified on a sample project that
@azure/msal-angular
no longer creates a "StandardController" file. Instead, it's named aschunk...
and hence is excluded from tests.