Skip to content

Invalid index.html file transformation using global scripts in angular.json file #890

@fernandezn

Description

@fernandezn

With what library do you have an issue?

native-federation

Reproduction of the bug/regression with instructions

When we include a global library through the project's angular.json file

Image

Angular compiler adds the following tag:

<script src="scripts.js" defer></script>

before importing the main project file (main.js). This causes an incorrect transformation of the following tag:

<script src="main.js" type="module"></script>

Specifically, the type="module-shim" attribute is mistakenly applied to the scripts.js file tag instead of the main.js file tag. As a result, main.js file tag is left without the type="module" attribute

Image

leading to the following error:

Image

Expected behavior

  • Tag <script src="scripts.js" defer></script> should remain untouched and should not undergo any changes
  • Tag <script src="main.js" type="module"></script> should be modified to change the attribute from type="module" to type="module-shim".

Versions of Native/Module Federation, Angular, Node, Browser, and operating system

Native Federation: v20.0.7
Angular: v20.0.6
Node: v22.13.0
Browser: Chrome v138.0.7204.97
Operating System: Windows 10

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions