systemjs / plugin-babel

SystemJS Babel Plugin
MIT License
82 stars 33 forks source link

plugin-babel trying to load systemjs-babel-browser without preserving version in path #86

Open ericnewton76 opened 6 years ago

ericnewton76 commented 6 years ago

I'm new to Babel, React, and SystemJS. Basically inherited a project that uses all this and trying to get things running in the browser. They used bundles for production, but are not being helpful due to contract/work dispute.

My attempts to get things working have been good up until a problem with running in the browser, and plugin-babel passing control(?) or importing 'systemjs-babel-browser' which makes sense, but problem is that the actual network request has the version string dropped, and so generates a 404 error when trying to load that dependency.

Given the following express static debug log: (ie set DEBUG=express:* & gulp serve )

1:   express:router dispatching GET / +6s
2:   express:router query  : / +6ms
3:   express:router expressInit  : / +3ms
4:   express:router dispatching GET /jspm_packages/system.js +41ms
5:   express:router query  : /jspm_packages/system.js +17ms
6:   express:router expressInit  : /jspm_packages/system.js +1ms
7:   express:router trim prefix (/jspm_packages) from url /jspm_packages/system.js +0ms
8:   express:router serveStatic /jspm_packages : /jspm_packages/system.js +1ms
9:   express:router dispatching GET /config.js +3ms
10:   express:router query  : /config.js +1ms
11:   express:router expressInit  : /config.js +0ms
12:   express:router dispatching GET /app/location.js +163ms
13:   express:router query  : /app/location.js +3ms
14:   express:router expressInit  : /app/location.js +0ms
15:   express:router trim prefix (/app) from url /app/location.js +3ms
16:   express:router serveStatic /app : /app/location.js +1ms
17:   express:router dispatching GET /jspm_packages/npm/systemjs-plugin-babel@0.0.25/plugin-babel.js +29ms
18:   express:router query  : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/plugin-babel.js +13ms
19:   express:router expressInit  : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/plugin-babel.js +1ms
20:   express:router trim prefix (/jspm_packages) from url /jspm_packages/npm/systemjs-plugin-babel@0.0.25/plugin-babel.js +0ms
21:   express:router serveStatic /jspm_packages : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/plugin-babel.js +0ms
22:   express:router dispatching GET /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +91ms
23:   express:router query  : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +3ms
24:   express:router expressInit  : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +1ms
25:   express:router trim prefix (/jspm_packages) from url /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +0ms
26:   express:router serveStatic /jspm_packages : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +3ms
27:   express:router <anonymous>  : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +4ms
28:   express:router dispatching GET /jspm_packages/npm/systemjs-plugin-babel@0.0.25/ +5m
29:   express:router query  : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/ +2ms
30:   express:router expressInit  : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/ +0ms
31:   express:router trim prefix (/jspm_packages) from url /jspm_packages/npm/systemjs-plugin-babel@0.0.25/ +0ms
32:   express:router serveStatic /jspm_packages : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/ +1ms
33:   express:router <anonymous>  : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/ +2ms
34:   express:router dispatching GET /jspm_packages/npm/systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js +26s
35:   express:router query  : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js +2ms
36:   express:router expressInit  : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js +1ms
37:   express:router trim prefix (/jspm_packages) from url /jspm_packages/npm/systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js +1ms
38:   express:router serveStatic /jspm_packages : /jspm_packages/npm/systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js +0ms
39:   express:router dispatching GET /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +14s
40:   express:router query  : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +12ms
41:   express:router expressInit  : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +0ms
42:   express:router trim prefix (/jspm_packages) from url /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +1ms
43:   express:router serveStatic /jspm_packages : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +0ms
44:   express:router <anonymous>  : /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js +1ms

notice how the initial request by systemjs is to /jspm_packages/npm/systemjs-plugin-babel@0.0.25/plugin-babel.js and succeeds (shown via lines 17-19)

However, plugin-babel does an import for systemjs-babel-browser, but the request drops the version string @0.0.25 and tries to have the browser download /jspm_packages/npm/systemjs-plugin-babel/systemjs-babel-browser.js which fails.

Here's chrome network tab: image image

Whats going on here?

ericnewton76 commented 6 years ago

I'm wondering if this is a SystemJS problem or plugin-babel incorrectly specifying its requires/imports?

ericnewton76 commented 6 years ago

I updated the title because I just noticed this is also happening during a gulp bundle building task, so I'm seeing the same behavior in nodejs using the same config.js.

ericnewton76 commented 6 years ago

nm, I found the offending line in config.js which was quoted as to be used, which of prevents success because the mapping of systemjs-babel-build has the version removed and therefore won't be found.

System.config({
/*snip*/
map: {
    "plugin-babel": "npm:systemjs-plugin-babel@0.0.25/plugin-babel.js",
    "plugin-babel-runtime": "npm:babel-runtime@5.8.38",
    "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js",
/*snip*/

is jspm supposed to be loading the version numbers into the tree, and thereby forcing a huge map section?