Skip to content
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

Dependency not loading, seems to be a naming issue? #76

Open
4imble opened this issue Nov 30, 2015 · 0 comments
Open

Dependency not loading, seems to be a naming issue? #76

4imble opened this issue Nov 30, 2015 · 0 comments

Comments

@4imble
Copy link

4imble commented Nov 30, 2015

Hello all,

I am attempting to transpile a file (it comes with it's own transpiled version but i wanted to be able to work with the es6 version and transpile it myself):
https://github.com/cbcrc/knockout-dragula/blob/master/knockout-dragula.js

I have set up gulp like so:

gulp.task('transpile', function() {
    return gulp.src('Dependencies/lib/knockout-dragula/knockout-dragula.js')
        .pipe(plumber())
        .pipe(babel({
            presets: ['es2015'],
            plugins: ["transform-es2015-modules-umd"]
        }))
        .pipe(gulp.dest('Scripts/generated'));
});

The file that it is generating looks starts like this:

(function (global, factory) {
    if (typeof define === "function" && define.amd) {
        define(['exports', 'knockout', 'dragula'], factory);
    } else if (typeof exports !== "undefined") {
        factory(exports, require('knockout'), require('dragula'));
    } else {
        var mod = {
            exports: {}
        };
        factory(mod.exports, global.knockout, global.dragula);
        global.knockoutDragula = mod.exports;
    }
})(this, function (exports, _knockout, _dragula) {

The problem i am encountering and i am not sure if it is ignorance on my part but _knockout is coming through undefined.
I looked at the transpiled file that they supply and this looks like this at the start:
https://github.com/cbcrc/knockout-dragula/blob/master/dist/knockout-dragula.js

(function (global, factory) {
  if (typeof define === 'function' && define.amd) {
    define(['exports', 'module', 'knockout', 'dragula'], factory);
  } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
    factory(exports, module, require('knockout'), require('dragula'));
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports, mod, global.ko, global.dragula);
    global.knockoutDragula = mod.exports;
  }
})(this, function (exports, module, _knockout, _dragula) {

After some debugging the breaking difference seems to be this:
factory(mod.exports, global.knockout , global.dragula);//broken
vs.
factory(mod.exports, mod, global.ko, global.dragula); //works

If i change my version to global.ko it works.

Am i doing something wrong, do i need to do something extra so that it knows to look for knockout inside global.ko and not global.knockout?

Many thanks.
4imble

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant