-
Notifications
You must be signed in to change notification settings - Fork 122
Automate build gulp workflow with systemjs-builder #23
Comments
I have actually fixed the |
Glad to hear you've fixed the second issue. For the first issue, I've created an issue at #24. Once this is landed you'll be able to do: var builder = require('systemjs-builder');
global.System = builder.loader;
require('./jspm.conf');
builder.build('app', null, 'out.js'); |
I've added this feature in https://github.com/systemjs/builder#loading-a-separate-config-file. Release coming shortly, let me know if that helps. |
@guybedford Yeah that's working fine now.. :) But I have found another issue :( I am using Issue 1 [11:00:07] 'scripts' errored after 87 ms
[11:00:07] Error: Error: ENOENT, open '/Users/martinmicunda/projects/employee-scheduling/ui/angular.js' gulp scripts taks gulp.task('scripts', 'Compile JS files into the app.js', ['build-init'], function (cb) {
var builder = require('systemjs-builder');
builder.reset(); --> this cause error after each re-run
builder.loadConfig('./src/jspm.conf.js');
builder.build('src/app/app',
paths.tmp.scripts + 'app.js')
.then(function() {
console.log('es6 build');
return cb();
})
.catch(function(ex) {
cb(new Error(ex));
});
}); Issue 2 gulp.task('build-init', function (cb) {
// systemjs-builder crashes, when build directory does not exist yet
// so we will create it if needed
fs.mkdir(paths.tmp.scripts, function (error) {
if (error && error.code !== 'EEXIST') {return cb(error);}
cb();
});
}); |
It sounds like the configuration is not being properly sent in the build loader after running reset? It may be worth debugging if the path is not being normalized properly, and looking into if the correct map / paths config is present in the builder loader (inspecting I've added directory creation in 0f065cf. |
@guybedford I had a quick look at this issue and I tried debug systemjs-builder code exports.loadConfig = function(configFile) {
var curSystem = global.System;
global.System = loader;
require(path.resolve(process.cwd(), configFile)); --> this is resolved only once
global.System = curSystem;
} |
@martinmicunda that clarifies great - I've released a 0.3.1 with an updated loadConfig that works repeatedly now. |
See https://github.com/systemjs/builder#loading-a-separate-config-file for the updated documentation. |
@guybedford great I have test that and it works now.. thanks a lot! :) I have find one more thing but I am not sure if this is issue.. supposed follow project structure:
When I run gulp.task('scripts', 'Compile JS files into the app.js', function (cb) {
var builder = require('systemjs-builder');
builder.reset();
builder.loadConfig('./src/jspm.conf.js')
.then(function() {
builder.build('src/app/app', paths.tmp.scripts + 'app.js');
});
}); |
Yes you need to set the baseURL for builder to reflect the baseURL: builder.loadConfig('./src/jspm.conf.js')
.then(function() {
builder.loader.baseURL = path.resolve('./src/');
return builder.build('app/app')
}) etc. This is done automatically when running bundling through jspm (https://github.com/jspm/jspm-cli/blob/master/lib/bundle.js#L84). |
thanks |
Hi,
I am trying to automated my workflow to build bundle with gulp but I am getting 2 errors and I wasn't sure where to post this question so I have opened new issue.
Issue 1:
As I mentioned early I try automated my workflow with gulp that use
systemjs-builder
for bundle task. I don't want to manually addmaps
,version
etc. tobuilder.build()
(seegulpfile.js
below) as I think this configuration doesn't belong to gulpfile.js so I put them intojspm.conf.js
(systemjs doing the same thing). The problem is that I was not able to figure out how to load this file withSystem.config
injspm.conf.js
(seewhat I would like to use
) because when Irequire('./jspm.conf.js')
in gulpfile I am gettingReferenceError: System is not defined
which make sense asSystem
is part ofsystemjs
so I export config stuff (see what I am using now) and this works fine where I run my gulp task however if I runjspm install
it always overwritejspm.conf.js
and addSystem.config
which I can't load intoBuilder.build()
. Also if I make any manual changes injspm.conf.js
and then I runjspm install
my changes are overwrite and this can possible cause an issue in future when somebody else try clone my repo and runjspm install
then my manual changes will be gone and overwrite.Basically what I am trying to do is get running gulp bundle task with
systemjs-builder
and keep to config systemjs data out of thegulpfile.js
injspm.conf.js
. I am not sure if that make sense for you :)gulpfile.js
jspm.conf.js
what I am using now
what I would like to use
My project structure:
index.html
package.json
issue 2:
I am getting below error when I am importing
angular-animate
. If I comment outimport 'angular-animate'
then angular is loading without any problem (I tried debug the issue but I couldn't figure out that)Error in browser console:
src/app/bootstrap.js
The text was updated successfully, but these errors were encountered: