GithubHelp home page GithubHelp logo

Comments (12)

MajorBreakfast avatar MajorBreakfast commented on July 3, 2024 15

I use this in my app:

Promise.all([
    System.import('module1'),
    System.import('module2')
  ])
  .then(function(modules) { ... })

Alternatively:

function multiImport(modules) {
  return Promise.all(modules.map(function(m) { return System.import(m) }))
}

from systemjs.

 avatar commented on July 3, 2024 3

+1 @guybedford @robdodson Array support for System.import would be convenient when combining SystemJS and Web Components.

from systemjs.

probins avatar probins commented on July 3, 2024

https://groups.google.com/forum/#!topic/jspm-io/rQd_XT_ZetU

from systemjs.

guybedford avatar guybedford commented on July 3, 2024

Yes, this is supported, but it is undocumented as I'm still not sure if the Loader specification will allow this or not.

Even if not in the spec though, I would still add it to jspm. But it then just depends how possible that is.

from systemjs.

AlessandroEmm avatar AlessandroEmm commented on July 3, 2024

Thank you guys, worked like a charm!

May I ask how much work it would be to remove the functionality for npm, github and cdnJS? As for an internal web application I can't anyway rely on them so I'd rather save the few KB's if possible.

from systemjs.

guybedford avatar guybedford commented on July 3, 2024

The endpoints are simply this line here - https://github.com/jspm/jspm-loader/blob/master/loader.js#L811

It's just a default. There is really nothing to remove.

You may want to set a custom registryURL as well.

Any further questions just ask.

from systemjs.

robdodson avatar robdodson commented on July 3, 2024

@guybedford is this still supported? I was looking to do the same thing this weekend but wasn't sure how to make the jspm object available on my page

from systemjs.

robdodson avatar robdodson commented on July 3, 2024

@MajorBreakfast yeah I wrote something similar, was just curious if there is some way to not have to do all the boilerplate myself. I think (but I may be mistaken) that System usually wants there to just be 1 call to import (like for a main.js file) and so maybe this is outside normal usage. @guybedford is that accurate?

from systemjs.

guybedford avatar guybedford commented on July 3, 2024

@robdodson I don't know of any plans for an array require, but it could be worth bringing up as a spec issue. I do like the perspective of having a single entry point though, as you then need all dynamic calls to be full modules themselves, which works well with bundling. We will have <script type="module"> to make the inline case easier anyway in future.

from systemjs.

robdodson avatar robdodson commented on July 3, 2024

@guybedford yeah I'm specifically looking at it from the case of Web Components where it's harder to have one entry point if you're using HTML Imports. I'm not a fan of the current approach in ModuleLoader/es-module-loader#95 with htmlimport-esmodule, I'd love to just System.import whatever I need in my script tags vs having to include an HTML Import and then an import statement which references the url for the import. That approach just feels cumbersome to me.

from systemjs.

guybedford avatar guybedford commented on July 3, 2024

@robdodson Erik's proposal is out of date, I've updated ModuleLoader/es-module-loader#95 to reflect the latest information. It's worth thinking in terms of module tags first, then working backwards to System.import.

from systemjs.

bennycode avatar bennycode commented on July 3, 2024

I tried to use it this way:

System.import(['dexie', 'proteus'])
.then(function(dexie, proteus) {
  console.log('dexie', dexie);
  console.log('proteus', proteus);
});

But all I'm getting is:

system.src.js:1226 Uncaught (in promise) TypeError: e.match is not a function(…)

from systemjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.