davis / plugin-hbs

Handlebars template loader plugin for SystemJS
MIT License
21 stars 9 forks source link

problem bundling hbs template with commonjs #12

Closed tjaartvdwalt closed 8 years ago

tjaartvdwalt commented 8 years ago

Hi, this might be a noob question, but does this plugin work with CommonJS modules? I try to do the follow (It might be worth noting that I am running jspm 0.17.0-beta.22):

var Template = require('./template.hbs!')

when I run the bundler:

jspm bundle main.js

I get the following exception:

 err  (SystemJS) TypeError: /home/tjaart/solmates/client/solmates-client/jspm_packages/github/davis/plugin-hbs@master/hbs.js: (0 , _getIterator3.default) is not a function
      at Parser.loadPlugins (/home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:31925:58)
      at new Parser (/home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:31894:29)
      at parse (/home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:32462:12)
      at File.parse (/home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9404:36)
      at File.parseCode (/home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9476:22)
      at /home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9620:14
      at File.wrap (/home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9445:18)
      at Pipeline.transform (/home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9618:19)
      at /home/tjaart/solmates/client/solmates-client/jspm_packages/npm/systemjs-plugin-babel@0.0.12/plugin-babel.js:169:24
  Error loading /home/tjaart/solmates/client/solmates-client/jspm_packages/github/davis/plugin-hbs@master/hbs.js
davis commented 8 years ago

Hey @tjaartvdwalt, I tried to recreate your issue over at this repo (with the same version of jspm): https://github.com/davis/hbs-test

Try running the following:

git clone git@github.com:davis/hbs-test.git
cd hbs-test
npm install
npm run build # runs jspm bundle jspm bundle j-test

And see if you still get that exception. I'm running node v6.3.1.

tjaartvdwalt commented 8 years ago

@davis, thank you so much for going through all the trouble of creating a test app!

I still get get a similar (if slightly different) error when running the test app. This time the stacktrace does not even mention the plugin, it seems to come from babel. I will keep on digging, and let you know if I find out anything.

err  Error on translate for j-test/j-test.js at file:///home/tjaart/hbs-test/src/j-test.js
  TypeError: file:///home/tjaart/hbs-test/src/j-test.js: (0 , _getIterator3.default) is not a function
    at Parser.loadPlugins (file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:31925:58)
    at new Parser (file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:31894:29)
    at parse (file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:32462:12)
    at File.parse (file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9404:36)
    at File.parseCode (file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9476:22)
    at file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9620:14
    at File.wrap (file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9445:18)
    at Pipeline.transform (file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/systemjs-babel-node.js:9618:19)
    at file:///home/tjaart/hbs-test/jspm_packages/npm/systemjs-plugin-babel@0.0.12/plugin-babel.js:169:24
tjaartvdwalt commented 8 years ago

Oh and by the way, if anyone is interested, I am running the following system Arch Linux 4.6.3 x86_64 node: v6.3.0 npm: 3.10.5 jspm 0.17.0-beta.22

tjaartvdwalt commented 8 years ago

@davis thank you so much for your help. It seems there is already a bug logged for this issue: https://github.com/nodejs/node/issues/7163

I can confirm the behavior described in the bug... if I downgrade to node v6.1.0 it works fine.

davis commented 8 years ago

Ah just saw this! Glad you found the issue!