-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(@ngtools/webpack): allow .svg files as templates #13284
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
Conversation
This might be a breaking change, if for a reason at the moment you have a file named |
packages/angular_devkit/build_angular/test/browser/svg_spec_large.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/test/browser/svg_spec_large.ts
Outdated
Show resolved
Hide resolved
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.
See above comments.
I still think that this might be a breaking change in some cases.
Should I just add a breaking change note to the commit message? I can't think of a way to implement this that's not a potentially breaking change. |
I think we should try to use the |
This could also be a breaking change if you already import .svg from .js files. |
I'm not too keen on the |
I've just spent several hours debugging webpack. For some reason I don't understand yet, webpack does not always provide an issuer. When you look at webpack\lib\RuleSet.js, there is a method _run that evaluates rules. The first parameter to run is an object "data", which has the object against which the rule should be evaluated. Here, data.issuer is not always set, in many cases (especially in my experiments with using a .svg as template), issuer is set to "". I currently don't see a way to use issuer here without hours of reverse engineering webpack. I'll ask for help in the webpack gitter. However, I already spent about 8 hours today for a simple change that is not even 5 lines of configuration (maybe 15 minutes for the actual change, a few hours to figure out how to unit test it, then again several hours to work on feedback). If I don't find a solution soon, the problem is just not worth investing more time. |
@alan-agius4 as requested, I've added a test that uses a component and aot. Is this what you had in mind, or am I still missing something? I'm still switching loaders based on the .component.svg suffix, as the idea to use the issuer does not seem to work. |
Thanks @oocx, as @filipesilva mentioned we’ll discuss this with the rest of the team in our next meeting. |
packages/angular_devkit/build_angular/test/browser/svg_spec_large.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts
Outdated
Show resolved
Hide resolved
Can you kindly fix the commit message as the feature is bound to |
Hi @oocx, are you willing to continue on this and address the above comments? Thanks. |
@alan-agius4 yes, I can probably continue working on it next weekend |
I hope I understood and implemented all the requested changes correctly this time. |
@oocx, ci is red. |
@alan-agius4 Thanks. I'm sorry, I don't know how I could miss that. I'll fix that next weekend. |
"ci/angular: size — cli/new-production/test-project/main.js increased by 24.00KB." How can I troubleshoot that? Is there a way to get details for that check? (for exmple, get a diff of the increased output vs. thee baseline)? I don't see a size increase with my local build (for "ng build --prod", but I don't even know which build settings this check tests). |
For the size check, try rebasing against the latest upstream master. |
With directTemplateLoading enabled, components can now use .svg files as templates. For AOT builds, the Angular compiler host now reads .svg files directly when reading component templates. For JIT builds, replaceResources creates a require call that directly uses raw-loader instead of using the loader provided by the current webpack configuration. Closes angular#10567
@clydin thanks, rebasing helped. |
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.
LGTM, great work!
I left a question but it's non blocking really.
@oocx this is now merged and should be part of 8.0. Thanks for all the work you've done on it! |
Thanks everyone for your feedback! You have been very helpful and provided valuable feedback, so this was a great experience for me as new contributor. |
@oocx, thanks for sharing your experience. Looking forward to have more PRs from you in the near future :) Thanks again for your contribution. |
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. |
With directTemplateLoading enabled, components
can now use .svg files as templates. For AOT builds,
the Angular compiler host now reads .svg files
directly when reading component templates.
For JIT builds, replaceResources creates a require call
that directly uses raw-loader instead of using the
loader provided by the current webpack configuration.
Closes #10567