tildeio / htmlbars

A variant of Handlebars that emits DOM and allows you to write helpers that manipulate live DOM nodes
MIT License
1.61k stars 193 forks source link

Fix htmlbars-runtime import paths #432

Closed timkendrick closed 8 years ago

timkendrick commented 8 years ago

I was trying to require the htmlbars-runtime package as a CommonJS module, but I kept receiving dependency errors.

On closer inspection, it looks like the import paths in packages/htmlbars-runtime/lib/main.js were inconsistent.

This PR should fix the module for use in CommonJS projects – I've tested the build and all seems fine, but let me know if there are any problems.

timkendrick commented 8 years ago

Is there any chance somebody could take a look at this? It'd be great to get HTMLBars working as a CommonJS module!

timkendrick commented 8 years ago

Just to clarify, I'm using webpack to load the htmlbars-runtime on the client side, as follows:

var htmlbars = require('htmlbars/dist/cjs/htmlbars-runtime')

...which gives the following error:

Error: Cannot find module '../htmlbars-util/morph-utils'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/tim/test/node_modules/htmlbars/dist/cjs/htmlbars-runtime.js:13:31)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

This PR fixes that error, without affecting the ES6 module version (as far as I'm aware).

Let me know if I'm importing it wrong!

mixonic commented 8 years ago

This seems good to me. @timkendrick please note that we really don't think HTMLBars is ready to be used as a stand-alone API yet. The codebase is being actively refactored elsewhere, and really we are very focused on getting Ember's own use-case down correctly before attempting to make the library generic.

timkendrick commented 8 years ago

Thanks for the heads-up @mixonic, that's good to know – sorry for hassling you in that case! Really impressed with all the work you guys have put in so far, can't wait till it comes out.