johnsoftek / plugin-jade

Jade loader plugin for jspm
MIT License
13 stars 5 forks source link

Broken bundle #9

Closed panicbit closed 9 years ago

panicbit commented 9 years ago

Since jspm 0.16.1 bundles including jade templates seem to be broken. Using such a bundle results in:

Error: Module undefined not declared as a dependency.
    Error loading http://localhost:8000/index.js
    at http://localhost:8000/jspm_packages/system.js:4:21254
    at http://localhost:8000/build.js:16:14
    at u (http://localhost:8000/jspm_packages/system.js:4:21145)
    at i (http://localhost:8000/jspm_packages/system.js:4:20761)
    at http://localhost:8000/jspm_packages/system.js:4:21223
    at http://localhost:8000/build.js:6:3
    at u (http://localhost:8000/jspm_packages/system.js:4:21145)
    at a (http://localhost:8000/jspm_packages/system.js:4:19710)
    at Object.Promise.all.then.execute (http://localhost:8000/jspm_packages/system.js:4:24206)
    at b (http://localhost:8000/jspm_packages/system.js:4:8159)

The generated bundle looks like this:

System.registerDynamic("index.js", ["index.jade!github:johnsoftek/plugin-jade@0.5.1"], true, function(require, exports, module) {
  ;
  var global = this,
      __define = global.define;
  global.define = undefined;
  require("index.jade!github:johnsoftek/plugin-jade@0.5.1");
  global.define = __define;
  return module.exports;
});

System.registerDynamic("index.jade!github:johnsoftek/plugin-jade@0.5.1", [], true, function(require, exports, module) {
  ;
  var global = this,
      __define = global.define;
  global.define = undefined;
  var jade = require("undefined");
  module.exports = function template(locals) {
    var buf = [];
    var jade_mixins = {};
    var jade_interp;
    ;
    return buf.join("");
  };
  global.define = __define;
  return module.exports;
});

//# sourceMappingURL=build.js.map

Note the require("undefined").

[Ref: jspm/jspm-cli#1047]

johnsoftek commented 9 years ago

@guybedford Using jspm 0.16.1, System.normalize('jade-compiler/lib/runtime', module.id ); now returns undefined.

Even System.normalize('jade-compiler', module.id ); returns undefined.

require('jade-compiler') works.

johnsoftek commented 9 years ago

Also fails under 0.16.0.

guybedford commented 9 years ago

@johnsoftek this is actually the SystemJS CJS require detection breaking down on file:/// URLs as it thinks its a comment in the require statement. I've just added a fix for this in SystemJS at https://github.com/systemjs/systemjs/commit/4717d582801fc3e9f10727c98489fa1ffeea2cc5 which makes this work again. Patch should come today or tomorrow.

johnsoftek commented 9 years ago

@guybedford Thanks. I'll test when the patch is ready.

Sent from my phone On 26 Aug 2015 1:21 am, "Guy Bedford" notifications@github.com wrote:

@johnsoftek https://github.com/johnsoftek this is actually the SystemJS CJS require detection breaking down on file:/// URLs as it thinks its a comment in the require statement. I've just added a fix for this in SystemJS at systemjs/systemjs@4717d58 https://github.com/systemjs/systemjs/commit/4717d582801fc3e9f10727c98489fa1ffeea2cc5 which makes this work again. Patch should come today or tomorrow.

— Reply to this email directly or view it on GitHub https://github.com/johnsoftek/plugin-jade/issues/9#issuecomment-134621633 .

guybedford commented 9 years ago

I've posted the SystemJS update. This should now work if you update jspm.

panicbit commented 9 years ago

@guybedford Awesome, it works!