Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 17 17:05
    Jack-Works commented #2265
  • Oct 17 16:36
    guybedford closed #2265
  • Oct 17 16:36
    guybedford commented #2265
  • Oct 17 16:19
    Jack-Works commented #2265
  • Oct 17 14:50
    guybedford commented #2265
  • Oct 17 14:26
    Jack-Works commented #2265
  • Oct 12 17:42
    joeldenning commented #2250
  • Oct 12 10:34
    guybedford edited #2013
  • Oct 12 10:32

    guybedford on 6.7.1

    (compare)

  • Oct 12 10:32

    guybedford on master

    6.7.1 (compare)

  • Oct 12 10:30

    guybedford on autoimport-race

    (compare)

  • Oct 12 10:30

    guybedford on master

    autoimport race (#2266) (compare)

  • Oct 12 10:30
    guybedford closed #2266
  • Oct 11 20:17
    github-actions[bot] commented #2266
  • Oct 11 20:16
    guybedford synchronize #2266
  • Oct 11 20:16

    guybedford on autoimport-race

    autoimport race (compare)

  • Oct 11 20:16
    github-actions[bot] commented #2266
  • Oct 11 20:15
    guybedford commented #2266
  • Oct 11 20:15
    guybedford synchronize #2266
  • Oct 11 20:15

    guybedford on autoimport-race

    auto import race (compare)

Frank Lemanschik
@frank-dspeed
when i read the code i think that has something to do with translating the specifier into a url
but i have no idea what exactly that would look like
Frank Lemanschik
@frank-dspeed
Frank Lemanschik
@frank-dspeed
Hahahaha lol you puted the function into a extra awsome found it after 4 hours :)
Edd Neal
@eddneal

Hi, I am experiencing an issue related to using a script tag with type=system-js-module. The system js module script has a dependency on another script that is loaded with a script tag using defer, and from reading MDN docs it is my understanding that...

"Scripts with the defer attribute will prevent the DOMContentLoaded event from firing until the script has loaded and finished evaluating."

However I am seeing errors thrown from the system js module telling me that the deferred script has not executed.

I thought that the type=system-js-module style of modules were not fired until DOMContentLoaded but when looking at the src it appears that straight after the event listener is attached the modules are loaded anyway.

if (hasDocument) {
  window.addEventListener('error', function (evt) {
    lastWindowErrorUrl = evt.filename;
    lastWindowError = evt.error;
  });

  window.addEventListener('DOMContentLoaded', loadScriptModules);
  loadScriptModules();
}


function loadScriptModules() {
  [].forEach.call(
    document.querySelectorAll('script[type=systemjs-module]'), function (script) {
      if (script.src) {
        System.import(script.src.slice(0, 7) === 'import:' ? script.src.slice(7) : resolveUrl(script.src, baseUrl));
      }
    });
}
Steven Vachon
@stevenvachon
can System.set() be called after the initial import map has been loaded? System.prepareImport() will only ever check the DOM once ... i'm writing unit tests
@guybedford ^^ ?
Frank Lemanschik
@frank-dspeed
System.set() can be called as often as you like
but the set will as you found out may or may not get uesed
depends on your code
Guy Bedford
@guybedford
@eddneal we do both because we want to ensure scripts are loaded as soon as possible. This does bring up an interesting feature idea though, if we should support eg defer on type=systemjs-module for your use case. I would in general think that this would be unadvisable though since any delay = direct performance issues for the user (especially since these scripts aren't preloaded by the browser preloader as it does not understnad them).
1 reply
Perhaps you could explain a little more about your use case why this is necessary
@stevenvachon System.set should be set with full URLs usually if you can. prepareImport is just for loading the import map initially. Updating the import map after that prepareImport is a use case we have yet to support, but are currently matching what browser import maps provide.
4 replies
Guy Bedford
@guybedford
Exactly - import maps spec is now frozen and doesn’t support updates
It does support dynamic injection before the first module load, but so does systemjs
After the first module load they are frozen
I’ve created http://github.com/guybedford/import-maps-extensions to get movement on new spec work for these sorts of cases
Will post to WICG when import maps unflag
Steven Vachon
@stevenvachon
oh
so, then you wouldn't be interested in a PR
@guybedford if you're aware of any hacks i can use (i'm using jest), please post them to the github issue i created
Akanksha Singh
@Flamingo09
Hello everyone. I need help. I'm using systemJS with import map inside my react application to load certain external modules (micro front end modules) . I have configured cors in my webpack-dev-server. Still it's throwing cors access not allowed error. Any idea, on how to fix it?
@hiaparna I'm using same single-spa for microfrint end, but getting cors error when importing modules using systemJS. Can you please help me, on how you did it.
Jari Germeraad
@jari_germeraad_gitlab

Hey everyone!

We're currently using SystemJS' Import Maps with single-spa and we were wondering whether we can add a header to the requests done by SystemJS (if I'm not mistaken?)!
It would be a custom header.

Any thoughts? Thanks!

Frank Lemanschik
@frank-dspeed
it is possible you can add a modifyed loader
or you use serviceworkers
both are good methods
ehm sorry
serviceworkers :)
thats the right term
Guy Bedford
@guybedford
@jari_germeraad_gitlab custom headers aren't supported for script tags in browsers, but you could do this by using a fetch loader and then cutomizing the fetch request. You can use the module types extra and then set the shouldFetch hook to always return true in https://github.com/systemjs/systemjs/blob/master/docs/hooks.md#shouldfetchurl---boolean. Then hook the fetch call as well itself to add the extra headers you need.
Michiel Vermandel
@resolvethis
Hi, I want to use SystemJS 6 to build a plugin system in Angular. Almost any example uses SystemJS 0.2x. Is it possible to achieve the same as describes in this SO question with SystemJS6? https://stackoverflow.com/questions/60284943/updating-systemjs-from-0-21-to-6-x-with-webpack => The thing I do not know to migrate is the SystemJS.newModule, as it does not exist in SystemJS 6 anymore. Any advice would be greatly appriciated!
Guy Bedford
@guybedford
@resolvethis you can use System.set instead of System.registry.set, then you likely want to use a resolved URL for those dependencies configured via an import map.
If you look for System.set examples in the issue queue I'm sure you should find a similar answer
For example see systemjs/systemjs#2152
Michiel Vermandel
@resolvethis
Thanks a lot, I managed to get it working! See https://stackoverflow.com/a/63917606/2528609 for details
charliematters
@charliematters
Hello! I'm sorry this is a super-old question, but we're using 0.21.0 as part of a dynamically fetched system and I'm trying to work out how to externalise react and react-dom. The outer application is built using webpack, and I've got that happily putting the UMD builds of react/dom as script imports in the html file, but I'm not sure how I can tell systemjs that import React from 'react' is already provided and doesn't need fetching. Any ideas?