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
Module AMD/CommonJS/Browser Global not working #610
Comments
I found the problem but not solve it.
The problem is that I have files in ES6 and others not. // Combine JavaScript into one file
// In production, the file is minified
function javascript() {
return gulp.src(PATHS.javascript)
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.concat('app.js'))
.pipe($.if(PRODUCTION, $.uglify()
.on('error', e => { console.log(e); })
))
.pipe($.if(!PRODUCTION, $.sourcemaps.write()))
.pipe(gulp.dest(PATHS.dist + '/assets/js'));
} Why wrong? Explanation...Change the file javascript.Change this to undefined Besides this:} else if (typeof exports === 'object') { }(this, function () {
"use strict";
var ScrollMagic = function () { to } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') { })(undefined, function () {
"use strict";
var ScrollMagic = function ScrollMagic() { Code fragment:Before doing so: (function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// CommonJS
module.exports = factory();
} else {
// Browser global
root.ScrollMagic = factory();
}
}(this, function () {
"use strict";
var ScrollMagic = function () { After doing so: (function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
// CommonJS
module.exports = factory();
} else {
// Browser global
root.ScrollMagic = factory();
}
})(undefined, function () {
"use strict";
var ScrollMagic = function ScrollMagic() { |
Sorry for the inconvenience, it was my problem. My solution if you want to compile SS5 SS6 and preserving sourcemaps, using Gulp-filter: |
I suspect it is for Babel but not sure.
How can we reproduce this bug?
npm install gsap --save-dev
bower install scrollmagic --save-dev
What happened instead?
In console Google Chrome:
Uncaught TypeError: Cannot set property 'ScrollMagic' of undefined
Google Chrome:
Firefox:
The text was updated successfully, but these errors were encountered: