vazco / universe-modules

Use ES6 / ES2015 modules in Meteor with SystemJS
https://atmospherejs.com/universe/modules
MIT License
52 stars 7 forks source link

Recent update changes module mapping behaviour #18

Closed optilude closed 9 years ago

optilude commented 9 years ago

Hi,

In meteor-react-example (https://github.com/optilude/meteor-react-example), I have this in packages/app-deps/system-config.js:

System.config({
    map: {
        'app-deps': 'app-deps/main'
    }
});

That used to allow me to do imports like:

import { _, Router } from 'app-deps';

However, upon upgrading to the latest Meteor and universe:modules this no longer works. I get the following error:

W20150809-10:15:35.038(1)? (STDERR) [Universe Modules]: Module app-deps/main does not exist! You will probably see other errors in the console because of that.
W20150809-10:15:35.039(1)? (STDERR) Potentially unhandled rejection [4] TypeError: Cannot call method 'match' of undefined
W20150809-10:15:35.040(1)? (STDERR)     at SystemJSLoader.translate (packages/universe:modules/vendor/system.js:3482:1)
W20150809-10:15:35.040(1)? (STDERR)     at p.then.load.status (packages/universe:modules/vendor/system.js:335:1)
W20150809-10:15:35.040(1)? (STDERR)     at tryCatchReject (packages/universe:modules/vendor/system-polyfills.js:1255:1)
W20150809-10:15:35.040(1)? (STDERR)     at runContinuation1 (packages/universe:modules/vendor/system-polyfills.js:1214:1)
W20150809-10:15:35.040(1)? (STDERR)     at Fulfilled.when (packages/universe:modules/vendor/system-polyfills.js:1002:1)
W20150809-10:15:35.040(1)? (STDERR)     at Pending.run (packages/universe:modules/vendor/system-polyfills.js:893:1)
W20150809-10:15:35.040(1)? (STDERR)     at Scheduler._drain (packages/universe:modules/vendor/system-polyfills.js:169:1)
W20150809-10:15:35.041(1)? (STDERR)     at Scheduler.drain (packages/universe:modules/vendor/system-polyfills.js:134:1)
W20150809-10:15:35.041(1)? (STDERR)     at process._tickCallback (node.js:442:13)
W20150809-10:15:35.041(1)? (STDERR)     Error loading file:///Users/maraspeli/Development/JavaScript/meteor-react-example/.meteor/local/build/programs/server/app-deps/main from file:///Users/maraspeli/Development/JavaScript/meteor-react-example/.meteor/local/build/programs/server/server/startup
W20150809-10:15:35.041(1)? (STDERR)     Error loading file:///Users/maraspeli/Development/JavaScript/meteor-react-example/.meteor/local/build/programs/server/app-deps/main

I also tried:

/* global System */

System.config({
    packages: {
        'app-deps': {
            main: 'main',
            format: 'register',
            map: {
                '.': System.normalizeSync('{app-deps}')
            }
        }
    }
});

This seems to remove the error from startup of the server, but I'm getting errors client-side because SystemJS seems to be trying to fetch app-deps as a file and this returns a skeleton HTML page.

What am I doing wrong? Right now, the meteor-react-example is not working for people who try to use the latest versions. :(

optilude commented 9 years ago

I think this may be a red herring. The packages syntax probably works, but there is an error in the loaded code that breaks the package client-side, and so I think it never properly registers as a module.

See https://github.com/meteor/react-packages/issues/83

MacRusher commented 9 years ago

Ok I will monitor issue on the react-packages repo. We have some problems with "different Reacts" because of browserify before, but it never makes modules to crash/not load/not register like in your case, I will take a look at this.

MacRusher commented 9 years ago

Aside double-react issue, with new version there is no more need to define System.config({packages: {...}}) Index module is loaded out of the box, and the old syntax could actually produce Maximum call stack size exceeded error. See docs for more info. Please reopen if problems still occur.