-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem using SystemJS/JSPM? #17
Comments
@eduardolundgren This seems to annoy RequireJS as well. Sort of defies the UMD thoughts. |
@nicklasb Hopefully you have identified a pattern that works for you. The pattern you have in the original issue is that somewhere in "......my code......" you should define an export variable. Usually this is an object or constructor. Say you have a class you named "Engine". You write a file like this named "engine.js". function Engine(valves) {
this.valves = valves;
}
Engine.prototype.start = function() {
// make the starter motor turn and send fuel into the injection system.
}; In your dev environment ;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['starter', 'fuel-injection'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('starter'), require('fuel-injection'));
} else {
root.Engine = factory(root.starter, root.fuelInjection);
}
}(this, function(starter, fuelInjection) {
function Engine(valves) {
this.valves = valves;
}
Engine.prototype.start = function() {
// make the starter motor turn and send fuel into the injection system.
};
return Engine;
})); You can also change what value is returned by the "factory" function by providing the name via Say instead of var options = {
exports: function(file) {
if (file.basename === 'engine.js') {
return 'CombustionEngine';
}
// file is a vinyl instance: https://github.com/gulpjs/vinyl#filestem
return file.stem;
}
};
gulp.src('*.js')
.pipe(umd(options))
.pipe(gulp.dest('dist')); By the way, I am a new maintainer here, so at some point I will go about improving the documentation. |
Hi,
I am using SystemJS to load my modules, this means that the wrapper sets module.exports, and then exits the conditions. That leaves the
root.angularSchemaFormDynamicSelect
undefined, which causes an "Uncaught (in promise) Uncaught ReferenceError: angularSchemaFormDynamicSelect is not defined" when the wrapper tries to return it in the end, code:That said, I am not sure I understand the UMD model completely..
The text was updated successfully, but these errors were encountered: