-
Notifications
You must be signed in to change notification settings - Fork 71
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
Advice required for working with npm packages that break Hem conventions #73
Comments
Hi Louis, Thanks for the questions and input, definitely appreciated. I'll try my best to answer the questions you posted.
I am currently working on a refactor of hem and one of the main areas I wanted to focus on was improving the module/dependency handling. I'd like to keep the ability of using npm modules, but at the some time was hoping to open the door to using bower/component as well. Its my gut feeling that the web related javascript modules are a better fit in those vs trying to make them npm modules. |
Hi Chris, Thanks so much for taking the time to reply, and providing such a detailed and helpful response! As our app is increasingly dependent on front-end Javascript modules rather than Node modules, we might be better served by switching to Bower or Component as you suggested. This past week, I've been investigating Yeoman (Bower + Grunt + RequireJS), and this combination has solved all of the issues I list above. However, I must say that putting all of these components together has taken a lot of effort (I'd say around 8 hours so far), and has made me appreciate even more how much utility we were getting from Hem with very little effort! I think it might be time for us to switch to Yeoman for the flexibility, but I will certainly miss the simplicity that Hem provides. Keep up the good work, and I shall be looking out for Bower / Component support in Hem, so that we can switch back to a simpler world! Cheers, |
Hi Louis, Again I appreciate the feedback. I really do like the idea of something that should take minutes to setup (vs hours) and hopefully I can get hem to that point. I think it should be doable, especially if simple conventions are followed. Really it should be a matter of simply putting the files in the correct location and they are automagically used/compiled. I understand that doesn't work for everyone or for every application, in those cases something like yeoman is a great tool, but for simple web applications I think hem can have a home. But it would be great to get some more feedback once the refactored hem is ready for serious use, I'll update this issue once its further along. thanks! |
Hi,
Firstly, thank-you for Hem: a fantastic tool that significantly simplifies my workflow!
I'm having a little bit of trouble understanding how I can use Hem with npm packages that don't have an
index.js
file. For example, I'm trying to use Hem to allow my application to require files from thecodemirror
npm package. I see thatcodemirror
has the followingpackage.json
:I have a number of questions related to this:
require('codemirror')
, Hem can't find the module and I receivemodule 'codemirror' not found
. This makes sense as there is no index.js file (and I see that Hem'sstitch.eco
looks for the path of an index file). Instead, I see that arequire('codemirror/lib/codemirror')
does work. Is there any workaround for this so that I can userequire('codemirror')
?lib/codemirror.js
exports a global variable ontowindow
, rather than ontomodule.exports
, like this:window.CodeMirror = (function() { ...
I see that Hem expects the CommonJS style, and so won't pick up this variable. I can changelib/codemirror.js
to store the variable onmodule.exports
, but I'd prefer not to change code that I don't own. Is there any workaround for this?codemirror
npm package includes a number of additional JS files that I'd like to include, but they rely on the presence of the CodeMirror variable. I can issue a separate require statement for each:require('codemirror/lib/codemirror')
then arequire('codemirror/modes/javascript/javascript')
. However, this fails becausecodemirror/modes/javascript/javascript
assumes that it will be able to access the CodeMirror global variable, and I believe that Hem might be requiring files into a "sandboxed" environment where there is no access to other variables. The following doesn't work either:CodeMirror = require('codemirror/lib/codemirror')
followed by arequire('codemirror/modes/javascript/javascript')
. Any ideas?codemirror
npm package includes a number of CSS files that I'd like to include in my application. Is there any support for this in Hem?I'm using Spine as my application framework, and would prefer to use the npm dependencies rather than plain-old javascript files (i.e. Hem
libs
) if possible.If needed and of interest to the Hem developers, I would be happy to work on a patch to support any of the features above (though I would require a little help in designing solutions).
Thank-you in advance for answers or hints towards solving any of these questions.
Best,
Louis.
The text was updated successfully, but these errors were encountered: