Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

weird error loading config.js #124

Closed
lookfirst opened this issue Apr 4, 2015 · 16 comments
Closed

weird error loading config.js #124

lookfirst opened this issue Apr 4, 2015 · 16 comments

Comments

@lookfirst
Copy link
Contributor

v0.10.3

system.config.js:

System.config({
    "baseURL": ".",
    "transpiler": "babel",
    "babelOptions": {
        "optional": [
            "runtime"
        ]
    },
    "paths": {
        "*": "*.js"
    },
    "buildCSS": true,
    "separateCSS": false
});

test.js:

var Builder = require('systemjs-builder');
var builder = new Builder();

var config = {
  config.config = 'system.config.js';
  config.baseURL = 'test/fixtures';
  config.main = 'app/app';
};

var build = function(config) {
  builder.loadConfig(config.config).then(function() {
    console.log("loaded config");

    builder.config({baseURL: config.baseURL});

    return builder.trace(config.main).then(function(trees) {
      console.log(trees);
    }, function(error) {
      console.log(error);
    });
  });
};

build(config);

test/fixutres/app/app.js:

class App {

}
export default App;

The error message is:

{ [Error: Error loading "app/app" at file:/my-test/test/fixtures/app/app.js
Error loading "babel" at file:/my-test/test/fixtures/babel.js
ENOENT, open '/my-test/test/fixtures/babel.js']
  errno: -2,
  code: 'ENOENT',
  path: '/my-test/test/fixtures/babel.js' }

If I remove transpiler: 'babel' from the system.config.js, it works fine and I get this output instead:

{ 'app/app':
   { name: 'app/app',
     deps: [],
     depMap: {},
     address: 'file:/my-test/test/fixtures/app/app.js',
     metadata: { deps: [], format: 'es6' },
     source: 'class App {\n\n}\nexport default App;',
     kind: 'declarative' } }
@guybedford
Copy link
Member

You need to manually install Babel-core (npm install babel-core) as it is no longer a bundled dependency.

@lookfirst
Copy link
Contributor Author

a) the docs just say that babel needs to be installed, which i did have installed. https://github.com/systemjs/builder#basic-use
b) if i remove babel, but have babel-core, i get an error saying babel/register is missing.
c) if i install babel and babel-core, after exactly 3 tries running the code (no idea why), i get an error saying that /test/fixtures/babel-runtime/helpers/class-call-check.js (note the path) is missing.
d) if i install babel-runtime, i still get the same error.

@lookfirst
Copy link
Contributor Author

The error is printed out of this:

var build = function(config) {
  builder.loadConfig(config.config).then(function() {
    console.log("loaded config");

    builder.config({baseURL: config.baseURL});

    console.log('here')
    return builder.trace('app/app').then(function(trees) {
      console.log('trees')
      console.log(trees);
    }, function(error) {
      console.log('error')
      console.log(error);
    });
  });
};

@guybedford
Copy link
Member

Ok yes this is a bug, and is the same bug posted on the SystemJS gitter room earlier.

I'm posting out a patch for ES6 Module Loader now.

@guybedford
Copy link
Member

Ok I've published es6-module-loader 0.16.2 with a patch. If you npm install es6-module-loader I think that should make it update?

@lookfirst
Copy link
Contributor Author

I did the npm install suggested above, v0.16.3, and get the same error about class-call-check mentioned above.

@lookfirst
Copy link
Contributor Author

Please try the test case above. If you'd like, I can package it up for you somewhere, but it is just creating a few files.

@lookfirst
Copy link
Contributor Author

I should add... how are things working now? This is a pretty simple test case. Is there something out of the ordinary that I'm doing here?

@guybedford
Copy link
Member

@lookfirst the path file:/my-test/test/fixtures/babel.js looks like the baseURL isn't being set properly. If you can share an example I can point out how this is happening.

@lookfirst
Copy link
Contributor Author

Actually, I see the problem above...

var config = {
  config.config = 'system.config.js';
  config.baseURL = 'test/fixtures';
  config.main = 'app/app';
};

Nested config. =(

@lookfirst
Copy link
Contributor Author

Wait though... still getting same error... that was just a typo in the example. I'll produce something and put it up on github.

@lookfirst
Copy link
Contributor Author

  1. git clone https://github.com/lookfirst/broken-builder
  2. cd broken-builder
  3. npm install
  4. npm test (Assuming you have node_modules/.bin in your PATH.)

What I'm realizing is that it seems like the builder doesn't like to have the baseURL redefined.

@guybedford
Copy link
Member

The only error I got here was:

> broken-builder@1.0.0 test /Users/guybedford/Projects/jspm-cli/sandbox/broken-builder
> mocha  --compilers js:babel/register test/**/*.spec.js



  builder
loaded config, baseURL: test/fixtures
error 2
{ [Error: Error loading "node_modules/babel-runtime/helpers/class-call-check" at file:/Users/guybedford/Projects/jspm-cli/sandbox/broken-builder/test/fixtures/node_modules/babel-runtime/helpers/class-call-check.js
Error loading "node_modules/babel-runtime/helpers/class-call-check" from "app/app" at file:/Users/guybedford/Projects/jspm-cli/sandbox/broken-builder/test/fixtures/app/app.js
ENOENT, open '/Users/guybedford/Projects/jspm-cli/sandbox/broken-builder/test/fixtures/node_modules/babel-runtime/helpers/class-call-check.js']
  errno: -2,
  code: 'ENOENT',
  path: '/Users/guybedford/Projects/jspm-cli/sandbox/broken-builder/test/fixtures/node_modules/babel-runtime/helpers/class-call-check.js' }
output
undefined

I then fixed that by adding map config for babel-runtime. I created an issue to track that at systemjs/systemjs#392, but it wasn't actually failing the build.

See screenshots below:

screen shot 2015-04-07 at 09 48 00
screen shot 2015-04-07 at 09 50 30

@lookfirst
Copy link
Contributor Author

Yes, that is the same error that I'm seeing.

I didn't make it fail the build. There isn't an assertion for that. I was just using mocha to be able to run the builder.

So this seems like a bug in systemjs then?

@guybedford
Copy link
Member

Ok right, yes, as per the issue, and a different one to the cannot find babel.

@lookfirst
Copy link
Contributor Author

By the way, you can use my code as a basis for writing some unit tests. =) I'd really like to see you get into the habit of doing that more. TDD for the win. If I can help, let me know...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants