Skip to content

Issue loading dependencies from System.set #1976

Closed
@TheMcMurder

Description

@TheMcMurder

This is a bit complicated of a story but I've reproduced the issue (links below).

Fundamentally I'm trying to manage my dependencies via npm for what amount to workaround reasons. There are a few node modules that have poor or non-existent UMD builds and I figured I could avoid that entirely by using System.set for those modules*.

Problem, use the custom resolver solution suggested here I was able to successfully set and import the correct value but the set value isn't being provided to my AMD modules, despite being specified as a dependency.

Example:

const systemResolve = System.resolve;
System.resolve = function (name, parent) {
  if (name === 'myModule') return name;
  return systemResolve.call(this, name, parent);
};
System.set('myModule', {test: 'test'}

// works
System.import('myModule').then(...)
// import works but myModule is undefined
System.import('otherModule')
// otherModule
define('otherModule', ['myModule'], function(__WEBPACK_EXTERNAL_MODULE...
// myModule is always undefined

I think this is a bug but there is a lot going on here so it's probable that it's a misconfiguration on my end.

I have two projects that must be running to reproduce this issue use RXJS
https://gitlab.com/TheMcMurder/common npm i -> npm start
https://gitlab.com/TheMcMurder/systemjs-3 (poorly named) npm i -> npm start -> open to http://localhost:8080 -> open console

*RXJS UMD build had different import paths than the npm build, meaning migrating from the magical system.registerDynamic to import maps requires a bunch of code changes (import statements). I'm hoping to avoid those changes by setting the npm modules directly into the registry.

Activity

guybedford

guybedford commented on Jul 30, 2019

@guybedford
Member

Are you definitely running the latest version of SystemJS here? Can you confirm the version? This is something I believe we should have fixed recently, but otherwise yes it sounds like a bug to me.

TheMcMurder

TheMcMurder commented on Jul 30, 2019

@TheMcMurder
Author

I'm running 4.1.0, here is my package.json https://gitlab.com/TheMcMurder/common/blob/master/package.json#L14

Sorry for the confusion, I really shouldn't have used my old repo called SystemJS 3.

guybedford

guybedford commented on Jul 31, 2019

@guybedford
Member

I had a quick look at this and am I right in thinking the line that has the issue is this one in the build:

console.log('rxjs synchronous import', rxjs__WEBPACK_IMPORTED_MODULE_1___default.a);

If so, the problem is that there is a .a access being done, so it is undefined because System.get('rxjs').a is undefined...

Let me know if I'm missing something though.

TheMcMurder

TheMcMurder commented on Aug 7, 2019

@TheMcMurder
Author

Sorry for the delay! I think you're correct which means the problem is probably a web pack configuration issue. I'm not sure how to solve it at this point, but I'll keep digging into different potential solutions.

TheMcMurder

TheMcMurder commented on Aug 7, 2019

@TheMcMurder
Author

This is an area I'm just not sure how to proceed.

I put a debugger near that line and found webpack was getting undefined for both rxjs__WEBPACK_IMPORTED_MODULE_1___default and rxjs__WEBPACK_IMPORTED_MODULE_1___default.a

I fully recognize that this may be a webpack issue, but I can't determine for sure if it's webpack, SystemJS, or configuration on my side that's causing the issue.

gabemeola

gabemeola commented on Sep 24, 2019

@gabemeola

@TheMcMurder I'm also running into this issue. There is an issue I believe with the System.register declaration setters not running, thus causing undefined vars. I'm going to set up a sandbox to try and repo this.

gabemeola

gabemeola commented on Sep 24, 2019

@gabemeola

@guybedford Using v6.1.2. Register setters is never called if there is a matching System.set for the resource. This seems like a bug, but I'm not too familiar with SystemJS internals. Is there something I'm missing here?

Code: https://glitch.com/edit/#!/systemjs-set-bug
Live App: https://systemjs-set-bug.glitch.me

guybedford

guybedford commented on Sep 26, 2019

@guybedford
Member

@gabemeola ah I see the issue, thanks. Ok I've pushed the fix to the existing registry change PR at #2020. Should be able to land this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Issue loading dependencies from System.set · Issue #1976 · systemjs/systemjs