Skip to content
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

Allow transforms to be ignored #945

Merged
2 commits merged into from
Oct 13, 2014
Merged

Conversation

mattdesl
Copy link
Contributor

This lets you ignore transforms by name, and it trickles down to the module dependency level so they get ignored through the entire bundle. The general idea here is to apply a global top-level transform after the fact, that gets applied to the entire bundle, i.e. to override a transform completely for application-specific purposes.

@ghost
Copy link

ghost commented Oct 13, 2014

Looks good and I'm down with merging this patch, but can you describe your specific use-case a little bit, just so I have a better picture of what kind of scenario this feature is for?

@mattdesl
Copy link
Contributor Author

Yep, basically I'm exploring some ways of optimizing bundle size at the application level. Transforms could inline content into the bundle, like urify for base64 images. Or another example might be a transform to inline CSS and inject it with insert-css:

require('static-css')(__dirname+'/style.less', { transform: 'less-stream' })

In both cases the browserified bundle would work because the transforms are listed, but it wouldn't be ideal for frontend. For images, it would be better to load from a URL with the <img> tag so that the browser can take advantage of caching. For CSS, it would be better to load them as a single (compressed) style sheet so that you don't end up with hundreds of <head> tags injected to the site.

So the plugin would only be for optimizing the bundle at the application level; overriding all transforms throughout the bundle with some app-specific emitter.

An example with images here:
https://github.com/mattdesl/urify-example

If you have other ideas on how to tackle this, I'm all ears. Or maybe static analysis is not the right tool here, and using package.json a la Atomify would be more suitable?

@ghost
Copy link

ghost commented Oct 13, 2014

This seems like a reasonable way to achieve the goal, and it's just turning off a feature, not actually adding anything as such.

@ghost ghost merged commit a1772aa into browserify:master Oct 13, 2014
@ghost
Copy link

ghost commented Oct 13, 2014

Merged in 6.1.0. Thanks for the patch!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant