Description
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 commentedon Jul 30, 2019
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 commentedon Jul 30, 2019
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 commentedon Jul 31, 2019
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:
If so, the problem is that there is a
.a
access being done, so it isundefined
becauseSystem.get('rxjs').a
is undefined...Let me know if I'm missing something though.
TheMcMurder commentedon Aug 7, 2019
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 commentedon Aug 7, 2019
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 bothrxjs__WEBPACK_IMPORTED_MODULE_1___default
andrxjs__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 commentedon Sep 24, 2019
@TheMcMurder I'm also running into this issue. There is an issue I believe with the
System.register
declarationsetters
not running, thus causing undefined vars. I'm going to set up a sandbox to try and repo this.gabemeola commentedon Sep 24, 2019
@guybedford Using
v6.1.2
. Registersetters
is never called if there is a matchingSystem.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 commentedon Sep 26, 2019
@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.