-
Notifications
You must be signed in to change notification settings - Fork 1k
Add support for CommonJS, and publish to NPM #1329
Add support for CommonJS, and publish to NPM #1329
Conversation
I feel this should be done all at once. If you do this, you can just publish it, that's it. It won't really work, since nothing has been done to enable it for CJS. I spent a few hours going over what needs to be done to get it working.
Was going to try and work on this sooner than later, but above is the general gist to getting it working |
Thanks Alex for delimiting these. I agree it might piss some people off to publish but not support commonJS. I'll modify this PR with the above suggestions. |
@vernak2539 It appears that even though Bootstrap "supports" CommonJS packaging, it still is asking for jQuery on the window object. In Fuel UX, AMD users can get around this with requirejs shim in their config object. Do we need to to wrap BS somehow ourselves like we suggest with AMD or is it OK to depend on the global for jQuery? I am kind of new to CommonJS on the front-end space, so I wanted to see if you had any common usage suggestions. |
@vernak2539 I have a WIP branch here for you to test. I didn't want to force push it here, because it's got a lotta cruft in it that's not going in the library in order to just use it (and I didn't want to scare anyone into thinking it was all going in). It has Fuel UX controls running as commonJS modules in I don't think it would be good idea to duplicate all the tests just in a commonJS format. In this example, Bootstrap is using jQuery on the window, but Fuel UX should not be. |
@interactivellama yeah ill take a look today. Definitely should be no need to duplicate the tests. |
One thought I had is that I didn't add the CommonJS wrapper to |
I think that looks fine. You'll probably have to have a gist or something demonstrating how it needs to be setup with jquery, bootstrap, etc. not sure what you should do about including bootstrap. usually in these kind of things, it would be stated as a dependency, and thus installed on the npm install. But, this is a repo for all the various types. May want to look into that, and making sure only real dependencies are listed in the package.json Edit: bootstrap and jquery would have to be added as deps probably |
Since you've set the "main" script in the package.json, all that's required is Edit: and you should never have to bundle it for them. just leave that npm.js file there, and then when they include via browserify, it should do all the work for them in their implementation |
Looks like I forget to push the latest updates to package.json that add jquery and bootstrap as dependencies. |
yep that looks good |
0a09672
to
48564bd
Compare
48564bd
to
9db7837
Compare
9db7837
to
5e3e952
Compare
Updated with actual code to support commonJS + basic unit tests ran within the Welcome to 2012 Fuel UX! 😺 |
2e8023b
to
547fbd1
Compare
This creates a test like the Browser globals test that detects if the CommonJS bundle created with browserify has initialized the plugins. It gitignores the bundled file that is created within the validate-dist task.
547fbd1
to
f02ddbd
Compare
…ivate-package2 Conflicts: .gitignore
@swilliamset Updated with master branch. Also tests finally passed by getting |
Add support for CommonJS, and publish to NPM
We may promote use of the more feature rich npm module workflow in the future instead of bower. This at least opens the door to that possible effort. This does not however make the library compatible with CommonJS, yet though.