-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 general lodash require? #249
Comments
Probably it‘s a good idea. But probably current way to optionally enable it is a bit too complicated. You need to add a JS file to entries like this: globals._ = require('lodash'); |
But probably we can use globals: {
_: require('lodash'),
} I’d use that too! Not sure that |
But don’t compare ungzipped sizes, they are not that important ;-) |
I've never used ungzipped sizes are important for runtime afaik. The more code that's there, gzipped or not, the more it needs to execute which will slow startup. |
I think it should be |
I'm not sure that will work for the case we want. It doesn't actually set them globally, it makes them available as free variables w/in modules, which our examples are not. |
Looks like it works fine. I’ve added a todo list to the issue. Do you want to work on that? |
An alternative would be to use babel-plugin-lodash to automate the module extraction: possibly less onerous. |
We can’t use Babel for user’s code and especially for examples. Styleguidist itself already use crerry-picking everywhere. |
got it: good catch :) |
Very strange. Why does it work for me then? ;-} |
I'm guessing because of the new build step. If you didn't compile after making the change it'd still look like it works. I think that what we actually want to do is add Furthermore, the config option to add "globals" should maybe be called context: {
_: 'lodash',
foo: 'foo',
} |
You're genius! I forgot to start the compiler 🐙 And I agree on both points: about context and about the name. |
#249 BREAKING CHANGE: Lodash will not be available in examples as `_`.
Before:
After:
Almost 100 KB difference gzipped! |
And with fixed UglifyJS (and with proper name mangling options):
|
Very nice! |
As mentioned in #136, lodash is required and included globally for use within examples. I personally don't use this and don't care to pay the 100kb+ price in size and load time. Would it be possible to make this optional or just not include it and let people require what they want in examples?
Is there currently a hook to add globals like this? If so, I'd probably like to use it for a few other things.
The text was updated successfully, but these errors were encountered: