Issue #2289Opened September 25, 2019by JCKodel3 reactions

[FeatureRequest] Allow to import javascript modules

Question

When using Ionic StencilJS, the components are imported using the new module support:

<script type="module" src="http://localhost:3333/build/grapejspoc.esm.js"></script>
<script nomodule="" src="http://localhost:3333/build/grapejspoc.js"></script>

On {canvas: scripts: []} I can only load external scripts by their url. To cover such case, we could import modules as this:

canvas: {
  scripts: [
    { src: "https://pagecdn.io/lib/jquery/3.4.1/jquery.min.js", integrity: "sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=", crossorigin="anonymous" },
    { type: "module", src: "https://bla/bla.esm.js"},
    { nomodule: "", src: "https://bla/bla.js" }
  ]
}

The final result inside canvas would be:

<script src="https://pagecdn.io/lib/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script type="module" src="http://bla/bla.esm.js"></script>
<script nomodule="" src="http://bla/bla.js"></script>

Notice that this would cover also the case when we want to use integrity or crossorigin in <script> tags and, of course, inserting a url string would still work as it is today.

Answers (3)

devtechkMarch 10, 20210 reactions

Hi can I start from yours code to init grapesjs not in the html file but in a separated js file? Thank you

rywilson28August 4, 20210 reactions

@artf it looks like this feature has been implemented. There is a minor issue where type will default to 'text/javascript'. For HTML 5 it should be omitted but should not cause any issues if there.

Should this issue be closed?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.