Skip to content

Conversation

@JoostK
Copy link
Member

@JoostK JoostK commented Jun 13, 2024

…f imports

The linker inserts the constant statements that are needed to support compiled templates after the import statements of an ESM file, but it failed to account for import statements that are not at the top of the file. This is typically seen in FESM files where multiple individual ESMs have been concatenated into a single ESM file, with imports in various places. The linker would then find the very last import statement to insert the constant statements after, but this may result in TDZ errors for component templates that have been emitted earlier in the file.

This commit updates the Babel linker plugin to insert constant statements after the last import of the first import group, therefore avoiding the TDZ error.

Fixes #56403

@JoostK JoostK added target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler compiler: linker labels Jun 13, 2024
@ngbot ngbot bot added this to the Backlog milestone Jun 13, 2024
…f imports

The linker inserts the constant statements that are needed to support compiled templates
after the import statements of an ESM file, but it failed to account for import statements
that are not at the top of the file. This is typically seen in FESM files where multiple
individual ESMs have been concatenated into a single ESM file, with imports in various places.
The linker would then find the very last import statement to insert the constant statements
after, but this may result in TDZ errors for component templates that have been emitted
earlier in the file.

This commit updates the Babel linker plugin to insert constant statements after the last
import of the first import group, therefore avoiding the TDZ error.

Fixes angular#56403
@JoostK JoostK force-pushed the linker/inbetween-imports branch from 6b8400e to 5188604 Compare June 13, 2024 13:15
@JoostK JoostK marked this pull request as ready for review June 13, 2024 13:49
@JoostK JoostK added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jun 13, 2024
@JoostK JoostK requested a review from crisbeto June 13, 2024 13:49
@JoostK JoostK added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 13, 2024
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 0b867e8.

The changes were merged into the following branches: main, 18.0.x

AndrewKushnir pushed a commit that referenced this pull request Jun 13, 2024
…f imports (#56431)

The linker inserts the constant statements that are needed to support compiled templates
after the import statements of an ESM file, but it failed to account for import statements
that are not at the top of the file. This is typically seen in FESM files where multiple
individual ESMs have been concatenated into a single ESM file, with imports in various places.
The linker would then find the very last import statement to insert the constant statements
after, but this may result in TDZ errors for component templates that have been emitted
earlier in the file.

This commit updates the Babel linker plugin to insert constant statements after the last
import of the first import group, therefore avoiding the TDZ error.

Fixes #56403

PR Close #56431
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler compiler: linker target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Libraries built with esbuild yield "ReferenceError: Cannot access '_c1' before initialization"

3 participants