2

Is it possible to set Angular to load external scripts defined in the angular.json under architect/build/options/scripts as type="module"?

When running Angular I can see the automatically injected script tags like this:

<script src="runtime.js" type="module"></script>
<script src="polyfills.js" type="module"></script>
<script src="styles.js" type="module"></script>
<script src="scripts.js" defer></script>
<script src="vendor.js" type="module"></script>
<script src="main.js" type="module"></script>

The scripts.js has a defer attribute, but not type="module". I'm trying to load a Stencil JS Web Component installed via npm into my app. The Stencil Component Script needs to be loaded as module, otherwise the other imports won't work.

1

1 Answer 1

2

I can also confirm it's not currently possible to add a type attribute to the scripts field. Possible values are: object with inject|lazy|bundleName|input attributes or directly a string.

To use a WebComponent in Angular, I ended up adding an import statement into the polyfills.ts file

import 'node_modules/my-web-components/dist/example.js';

I was able to see the content imported correctly and my web component was active in my angular component html file. content added here

Sign up to request clarification or add additional context in comments.

1 Comment

Can you vote up my enhancement request here github.com/angular/angular-cli/issues/… ? Looking for the same thing..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.