jspm / generator.jspm.io

8 stars 6 forks source link

Configure a library's `import * as lib` name in importmap generator? #31

Open trusktr opened 9 months ago

trusktr commented 9 months ago

For example, I might like to have a convention where users use import * as Lib or import * as LIB in all my code examples, and it would be nice if JSPM can perhaps read metadata (I'm guessing from package.json) so it know what name to use by default in the importmap generator's output sample.

trusktr commented 9 months ago

As an example, people in Three.js community tend to use THREE as the namespace when they import (convention from the global script days). So if the import statement for Three.js could be configured at the library level, the script in the output could be:

  <script type="module">
    import * as THREE from "three";

    // Write main module code here, or as a separate file with a "src" attribute on the module script.
    console.log(THREE);
  </script>
guybedford commented 8 months ago

I've transferred this issue into the main generator repo. I'd be open to options here. This may also be related to https://github.com/jspm/generator.jspm.io/issues/32.