angular/angular-cli

Add script config for adding scripts as type="module"

tmcconechy opened this issue · 5 comments

Command

build, config

Description

Looking at the script config https://angular.io/guide/workspace-config#style-script-config there does not seem to be any way to add the scripts as type="module" for esm.

If the third party script is delivered as an Es Module it cant be imported in the angular.json.

Screenshot 2023-01-23 at 11 30 28 AM

Seems like there is some thought about this

This comment may be the one of why it won't add type="module"

// Also, non entrypoints need to be loaded as no module as they can contain problematic code.
-> but still think it should be possible.

Describe the solution you'd like

Add a new setting to the script config, something like.

"scripts": [
  {
    "input": "node_modules/third-party/esm-script.js", 
    "inject": true,
    "scriptType": "module"
   }
],

Describe alternatives you've considered

  • can not use angular.json and
  • manually add a script tag or
  • just import the module in the Angular module code

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.