fix(compiler): move dynamic import path into a variable #6452
+10
−51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
A dynamic import path in
src/client/client-load-module.tscan cause a warning to appear for users in Angular projects.The warning is printed because no files are found for this path.
GitHub Issue Number: 5427
What is the new behavior?
Esbuild and Rollup docs indicate an import path containing a string literal will be evaluated at build time. An import path containing only a variable will not be evaluated. It looks like a dynamic import was the intended behavior, so this PR moves the path to a variable and removes code to work around problems in the previous approach.
Documentation
Does this introduce a breaking change?
There are many ways to build javascript and I wouldn't be surprised if this breaks some build system out there. Also, though the current behavior seems incorrect, someone may be relying on it.
Testing
Tried these changes with the reproduction steps in the issue. No warning is printed and project builds.
Other information
Looking for community feedback: does this change follow intended behavior? Could it be incompatible with your build system?