Skip to content

Commit

Permalink
Fixed error message, xo, updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypercubed committed Apr 19, 2016
1 parent 83c3c85 commit e9d397c
Show file tree
Hide file tree
Showing 23 changed files with 256 additions and 224 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
jspm_packages
node_modules
temp
153 changes: 96 additions & 57 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,96 @@
System.config({
"baseURL": "/",
"transpiler": "traceur",
"paths": {
"*": "*.js",
"github:*": "jspm_packages/github/*.js",
"npm:*": "jspm_packages/npm/*.js"
},
"buildCSS": false,
"defaultJSExtensions": true,
"vulvanizeHTML": {
"excludes": [
"jspm_packages/github/Polymer/[email protected]/polymer.html"
]
}
});

System.config({
"map": {
"chai": "npm:[email protected]",
"marked": "github:chjj/[email protected]",
"mocha": "npm:[email protected]",
"polymer": "github:Polymer/[email protected]",
"polymerjs": "test/polymer/polymer",
"traceur": "github:jmcriffey/[email protected]",
"traceur-runtime": "github:jmcriffey/[email protected]",
"vulcanize": "github:Polymer/[email protected]",
"webcomponentsjs": "github:webcomponents/[email protected]",
"github:jspm/[email protected]": {
"buffer": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"process": "npm:[email protected]"
},
"npm:[email protected]": {
"base64-js": "npm:[email protected]",
"ieee754": "npm:[email protected]",
"is-array": "npm:[email protected]"
},
"npm:[email protected]": {
"assertion-error": "npm:[email protected]",
"buffer": "github:jspm/[email protected]",
"deep-eql": "npm:[email protected]",
"process": "github:jspm/[email protected]",
"systemjs-json": "github:systemjs/[email protected]",
"type-detect": "npm:[email protected]"
},
"npm:[email protected]": {
"buffer": "github:jspm/[email protected]",
"type-detect": "npm:[email protected]"
},
"npm:[email protected]": {
"css": "github:systemjs/[email protected]"
}
}
});

System.config({
baseURL: "/",
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
optional: [
"runtime",
"optimisation.modules.system"
]
},
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
buildCSS: false,
vulvanizeHTML: {
excludes: [
"jspm_packages/github/Polymer/[email protected]/polymer.html"
]
},

map: {
"babel": "npm:[email protected]",
"babel-runtime": "npm:[email protected]",
"chai": "npm:[email protected]",
"core-js": "npm:[email protected]",
"marked": "github:chjj/[email protected]",
"mocha": "npm:[email protected]",
"polymer": "github:Polymer/[email protected]",
"polymerjs": "test/polymer/polymer",
"webcomponentsjs": "github:webcomponents/[email protected]",
"github:jspm/[email protected]": {
"assert": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"buffer": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"path-browserify": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"process": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"util": "npm:[email protected]"
},
"npm:[email protected]": {
"util": "npm:[email protected]"
},
"npm:[email protected]": {
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"base64-js": "npm:[email protected]",
"child_process": "github:jspm/[email protected]",
"fs": "github:jspm/[email protected]",
"ieee754": "npm:[email protected]",
"isarray": "npm:[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"assertion-error": "npm:[email protected]",
"buffer": "github:jspm/[email protected]",
"deep-eql": "npm:[email protected]",
"process": "github:jspm/[email protected]",
"systemjs-json": "github:systemjs/[email protected]",
"type-detect": "npm:[email protected]"
},
"npm:[email protected]": {
"fs": "github:jspm/[email protected]",
"path": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]",
"systemjs-json": "github:systemjs/[email protected]"
},
"npm:[email protected]": {
"buffer": "github:jspm/[email protected]",
"type-detect": "npm:[email protected]"
},
"npm:[email protected]": {
"util": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"css": "github:systemjs/[email protected]"
},
"npm:[email protected]": {
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"assert": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"inherits": "npm:[email protected]",
"process": "github:jspm/[email protected]"
}
}
});
47 changes: 25 additions & 22 deletions html-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Guy Bedford https://github.com/guybedford

var Vulcan = System._nodeRequire('vulcanize');
//var Minimize = System._nodeRequire('minimize');
var Promise = global.Promise || System._nodeRequire('es6-promise').Promise;

// it's bad to do this in general, as code is now heavily environment specific
Expand All @@ -13,10 +12,11 @@ var isWin = process.platform.match(/^win/);
function fromFileURL(address) {
address = address.replace(/^file:(\/+)?/i, '');

if (!isWin)
address = '/' + address;
else
if (isWin) {
address = address.replace(/\//g, '\\');
} else {
address = '/' + address;
}

return address;
}
Expand All @@ -30,9 +30,11 @@ function extend(a, b) {
return a;
}

function errCallback(err) {
setTimeout(function() { throw err; });
}
/* function errCallback(err) {
setTimeout(function () {
throw err;
});
} */

module.exports = function bundle(loads, opts) {
var loader = this;
Expand Down Expand Up @@ -62,29 +64,30 @@ module.exports = function bundle(loads, opts) {
loose: false // KEEP one whitespace
}); */

var rootURL = loader.rootURL || fromFileURL(loader.baseURL);
// var rootURL = loader.rootURL || fromFileURL(loader.baseURL);
var outFile = opts.outFile.replace(/\.js$/, '.html');

var output = loads.map(function(load) {
return '<link rel="import" href="'+fromFileURL(load.address)+'">';
var output = loads.map(function (load) {
return '<link rel="import" href="' + fromFileURL(load.address) + '">';
}).join('\n');

var stubDefines =loads.map(function(load) {
var stubDefines = loads.map(function (load) {
return "System\.register('" + load.name + "', [], false, function() {});";
}).join('\n');

return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
fs.writeFileSync(outFile, output);
console.log(' Vulcanizing ',outFile);

vulcan.process(outFile, function(error, output) {
if (error) { return reject(error); }
//minimize.parse(output, function(error, output) {
//if (error) { return reject(error); }
fs.writeFileSync(outFile, output);
resolve(stubDefines);
//});
console.log(' Vulcanizing ', outFile);

vulcan.process(outFile, function (error, output) {
if (error) {
return reject(error);
}
// minimize.parse(output, function(error, output) {
// if (error) { return reject(error); }
fs.writeFileSync(outFile, output);
resolve(stubDefines);
// });
});
});

};
77 changes: 39 additions & 38 deletions html.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,45 @@
https://github.com/systemjs/plugin-css
*/

if (typeof window !== 'undefined') {

exports.build = false;

exports.fetch = function(load) {
return importHref(load);
};

exports.instantiate = function(load) {
return load.metadata.link.import;
};
} else {

exports.fetch = function(load) {
if (typeof window === 'undefined') {
exports.fetch = function (load) {
load.metadata.build = true;
load.metadata.format = 'defined';
return '';
};
exports.instantiate = function() {};
exports.bundle = function(loads, opts) {
exports.instantiate = function () {};
exports.bundle = function (loads, opts) {
var loader = this;
if (loader.buildHTML === false) { return ''; }
return loader['import']('./html-builder', { name: module.id }).then(function(builder) {
if (loader.buildHTML === false) {
return '';
}
return loader['import']('./html-builder', {name: module.id}).then(function (builder) {
return builder.call(loader, loads, opts);
}, function(err) {
throw new Error('Install Polymer/vulcanize via `jspm install npm:vulcanize` for HTML build support. Set System.buildHTML = false to skip HTML builds.');
}, function (err) {
if (err.toString().indexOf('Cannot find module \'vulcanize\'') !== -1) {
throw new Error('Install Polymer/vulcanize via `npm install vulcanize --save-dev` for HTML build support. Set System.buildHTML = false to skip CSS builds.');
}
throw err;
});
};
} else {
exports.build = false;
exports.fetch = function (load) {
return importHref(load);
};

exports.instantiate = function (load) {
return load.metadata.link.import;
};
}

var waitSeconds = 100;
var head = (typeof document !== 'undefined') ? document.getElementsByTagName('head')[0] : null;
var head = (typeof document === 'undefined') ? null : document.getElementsByTagName('head')[0];

function errCallback(err) {
setTimeout(function() { throw err; });
setTimeout(function () {
throw err;
});
}

// from https://github.com/ModuleLoader/es6-module-loader/issues/95#issuecomment-98705035
Expand All @@ -49,7 +52,6 @@ function processScript(script) {
}

function processDocument(e) {

var Q = [];

// process modules in this document
Expand All @@ -68,34 +70,33 @@ function processDocument(e) {
}

function importHref(load) {
return new Promise(function (resolve, reject) {
var link = load.metadata.link = document.createElement('link');
link.rel = 'import';
link.href = load.address;

return new Promise(function(resolve, reject) {

var timeout = setTimeout(function() {
var timeout = setTimeout(function () {
reject('Unable to load HTML');
}, waitSeconds * 1000);
var _callback = function(error) {
var _callback = function (error) {
clearTimeout(timeout);
link.onload = link.onerror = function() {};
setTimeout(function() {
if (error)
link.onload = link.onerror = function () {};
setTimeout(function () {
if (error) {
reject(error);
else
} else {
resolve('');
}
}, 7);
};

var link = load.metadata.link = document.createElement('link');
link.rel = 'import';
link.href = load.address;

link.onload = function() {
processDocument(link.import).then(function() {
link.onload = function () {
processDocument(link.import).then(function () {
_callback();
});
};

link.onerror = function(event) {
link.onerror = function (event) {
_callback(event.error);
};

Expand Down
Loading

0 comments on commit e9d397c

Please sign in to comment.