These are chat archives for systemjs/systemjs

13th
Apr 2015
carlosagsmendes
@carlosagsmendes
Apr 13 2015 16:46
I'm trying to use the builder
but I get the following message
uild error
{ [Error: Error loading "main" at file:/Users/carlosmendes/Repos/bundling/src/main.js
Error loading "npm:babel-core@5.1.2" at file:/src/lib/npm/babel-core@5.1.2.js
any ideas?
Guy Bedford
@guybedford
Apr 13 2015 17:02
Have you installed Babel?
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:02
yes
when I type babel in the command line it is there
Guy Bedford
@guybedford
Apr 13 2015 17:02
but locally into the application?
npm install babel or jspm install babel if using jspm
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:03
no... I missed that
I'm still getting the same error { [Error: Error loading "main" at file:/Users/carlosmendes/Repos/bundling/src/main.js Error loading "babel" at file:/Users/carlosmendes/Repos/bundling/src/babel.js ENOENT, open '/Users/carlosmendes/Repos/bundling/src/babel.js'] errno: -2, code: 'ENOENT', path: '/Users/carlosmendes/Repos/bundling/src/babel.js' }
The only "special thing" I'm doing is loading the config file

```var path = require("path");
var Builder = require('systemjs-builder');

var builder = new Builder({
baseURL: './src',
// any map config
// map: {
// jquery: 'jquery-1.2.3/jquery'
// },

// opt in to Babel for transpiling over Traceur
transpiler: 'babel'

// etc. any SystemJS config
});
builder.loadConfig('config.js');

builder.build('main', 'main-outfile.js')
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});```

Guy Bedford
@guybedford
Apr 13 2015 17:05
if its not being picked up automatically you can just set the path to Babel
paths: { babel: '../node_modules/babel/browser.js' }
or whatever
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:06
I also tried that:
paths: {
'': '.js',
'babel': 'src/lib/npm/babel-core@5.1.2/browser.js',
'babel-helpers': 'src/lib/npm/babel-core@5.1.2/external-helpers.js'
},
Guy Bedford
@guybedford
Apr 13 2015 17:06
and?
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:08
Then I have an error about the other dependencies
Guy Bedford
@guybedford
Apr 13 2015 17:08
well that's a step forward
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:09
I think the problem is that my map section of the config is not imported
map: {},
Guy Bedford
@guybedford
Apr 13 2015 17:10
what error are you getting?
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:12
Now, "Only file URLs of the form file: allowed running in Node."
Guy Bedford
@guybedford
Apr 13 2015 17:13
Try setting your baseURL to 'file:' + path.resolve('./src')
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:15
it works but the dependencies are still not there: [Error: Error loading "knockout" at file:/Users/carlosmendes/Repos/bundling/src/knockout.js
Error loading "knockout" from "main" at file:/Users/carlosmendes/Repos/bundling/src/main.js
ENOENT, open '/Users/carlosmendes/Repos/bundling/src/knockout.js']
errno: -2,
code: 'ENOENT',
path: '/Users/carlosmendes/Repos/bundling/src/knockout.js' }
when I log my builder object to the console, the map property doesn't have the maps defined in my config.js
do I need to use the file format for loading the config.hs?
Guy Bedford
@guybedford
Apr 13 2015 17:16
where is your config file located? Perhaps the path in loadConfig is incorrect
loadConfig('./config.js') perhaps or loadConfig('./src/config.js')
Actually
it looks like you want to be using loadConfigSync
loadConfig returns a promise
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:18
Ah! Nice catch.
now my maps are there
map:
{ babel: 'npm:babel-core@5.1.2',
'babel-runtime': 'npm:babel-runtime@5.1.2',
'core-js': 'npm:core-js@0.8.2',
knockout: 'github:knockout/knockout@3.3.0',
'github:jspm/nodelibs-process@0.1.1': [Object],
'npm:core-js@0.8.2': [Object] },
But I'm still getting an error:
Build error
{ [Error: Error loading "main" at file:/src/main.js
ENOENT, open '/src/main.js'] errno: -2, code: 'ENOENT', path: '/src/main.js' }

this is how I'm building it:

builder.build('main', 'main-outfile.js')
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});

Guy Bedford
@guybedford
Apr 13 2015 17:34
sounds like you're setting the incorrect baseURL
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:35
how can I debug that? now it is picking up the config file. and it is loading babel. but then it fails in getting the file
Guy Bedford
@guybedford
Apr 13 2015 17:36
you're setting the baseURL yourself int he above config, so make sure you're setting it to the right value
I think you want it to be file:/Users/carlosmendes/Repos/bundling/src/, which was what my suggestion previously should have set it to, but didn't for some reason :point_up: April 13 2015 7:13 PM
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:39

Here's how my config.js file looks:

System.config({
"baseURL": "/src",
"transpiler": "babel",
"babelOptions": {
"optional": [
"runtime"
]
},

carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:45
Guy, you are right. The problem is that loading the config file overrides the "baseURL to 'file:' + path.resolve('./src')" that you suggested.
What's the recommend approach? setting it again after loading the config?
Apparently changing it afterwards doesn't work.
Should I load the config from the filestream, change the baseURL and then create the builder?
In the documentation it is mentioned that I can change the baseURL after loading the config:

// builder.loadConfig will load config from a file
builder.loadConfig('./cfg.js')
.then(function() {
// additional config can also be set through builder.config
builder.config({ baseURL: 'file:' + process.cwd() });

return builder.build('myModule', 'outfile.js');
});

carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:52
I got it and it is working. Sorry for the mess. I should have been using the async version to load the config from the beginning... but I missed that it was returning a promise!
carlosagsmendes
@carlosagsmendes
Apr 13 2015 17:58
One more question Guy. I want to ignore all my external dependencies when building. Is there a way to ignore a directory using the bundle arithmetic? Or can I trace the external dependencies folder? I considering this approach since all my external dependencies are inside a 'lib' folder
Guy Bedford
@guybedford
Apr 13 2015 18:43
You can exclude a folder with builder.build('myModule - lib/**/*') but be careful with globbing as it is expensive, can be preferable to use explicit modules
carlosagsmendes
@carlosagsmendes
Apr 13 2015 20:06
Thank you. I will give it a try with that in mind