-
Notifications
You must be signed in to change notification settings - Fork 24
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
Remove Browserify-Shim transform from package.json in all Chiasm subprojects #49
Comments
Done for Chiasm itself in 154c130 Needs to be done in:
|
Done for chiasm-component in chiasm-project/chiasm-component@775401f Done for chiasm-layout in chiasm-project/chiasm-layout@75262fc |
Done for chiasm-links in chiasm-project/chiasm-links@fc25ae7 |
Done for chiasm-dsv-dataset in chiasm-project/chiasm-dataset-loader@7c33b2f |
Done for chiasm-data-reduction in chiasm-project/chiasm-data-reduction@639c879 |
chiasm-component is still being shimmed out for some reason. I think this is because the components are depending on an older version and need to be updated. I'm going to make one more pass through all the modules and update their dependencies to the latest using npm-check-updates. |
Here's the sequence of commands used to upgrade dependencies for a package and push out a new version. Step 1. Upgrade dependencies and ensure tests pass:
Some tests may fail - watch out for the jsdom package, which needs to be pegged at version 3.1.2 because it is has some funky Node.js version compatibility issues. Step 2. If everything looks good, publish a new version:
After doing this for all modules, I see the following beautiful upgrade set for the Magic Bar Chart (Browserified) example.
|
The shim situation is horrible using browserify-shim. The top-level package being bundled cannot specify the set of modules to be shimmed. This is because browserify-shim looks in the package.json of all dependency packages to find out which modules to be shimmed. Example scenario - I want to have a UMD bundle that has a bunch of Chiasm modules AND model.js included, but has D3 and Lodash shimmed out. If the top-level package only specifies D3 and Lodash to be shimmed, model.js is also shimmed, because it is configured to be shimmed out within one of the chiasm modules. This is so frustrating - I want to be able to include model.js in the bundle, but it seems there is no way to get browserify-shim to include it if any dependencies want to shim it out in their own browser builds. Rollup seems to have a better story in terms of specifying shims. I think all of this will go away after adopting Rollup #54 |
Can you quickly explain the reason the shim transform is needed? I was going to bump lodash v4 and thought it might be a good idea also replace each require with the specific lodash module. For example Also, related, what is your target for chiasm. |
Perhaps I have that backwords? The browserify-shim ensures that lodash is not included in the bundle? |
Ahh yes. The reason why these were included in the first place is to exclude D3 and Lodash from the bundles. The target here was a Rails app, which included D3 and Lodash separately through the Rails asset pipeline. We wanted to be able to just include one copy of D3 and Lodash for the entire app, rather than have two copies, one in the Chiasm bundle (not exposed globally) and one via the Rails asset pipeline. We can definitely make use of |
There is a problem now with bundling Chiasm applications using Browserify. When a project requires Chiasm as a dependency, and uses Browserify to bundle the application, the fact that
browserify-shim
is listed in the transforms in the package.json of Chiasm and each component causes Browserify to try running those transforms in the outer project that requires Chiasm as a dependency. I didn't realize this would happen, I added thebrowserify-shim
transform with the idea that it would only apply locally, and not when the package is a dependency. For example, model.js should not be shimmed in the parent project (which may want model.js included in the bundle), but should be shimmed in the Browser build of Chiasm (which is for use in bl.ocks.org examples and should not have model.js in the bundle).To remedy this situation, the package.json of all Chiasm subprojects needs to be changed such that there are no browserify transforms listed. For example, consider the following package.json:
This needs to be changed around such that the transforms are specified in the Browserify command rather than the "browserify" field in package.json. After the change, it looks like this:
After this change is made, new NPM releases must be made so the changes come through when adding Chiasm as a dependency.
The text was updated successfully, but these errors were encountered: