Add ability to expose require() with standalone. #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Designed to fix #45. This sets up the ability to opt-in to exposing a
require()
when bundling in standalone mode, like this:EDIT: also see below for an alternative implementation.
Standalone without
.require(..., {expose: ...})
and vice versa work pretty much like currently.Constructive criticism appreciated.
TODO:
Some fine tuning may be in order depending on the answer to Is exposed name from
b.require()
supposed to be available inside bundle? browserify#1137.The
expose
value passed torequire()
should probably be coerced in similar fashion to the coercion UMD does on thestandalone
value. Breaking out and exposing some additional functions in ForbesLindesay/umd may make sense for that. Probably better yet would be to give the user the option to use either the coerced value or the verbatim value they pass.I have a new test on browserify for this. Are there new tests here that would make sense? (EDIT: tests for browser-unpack for one, I think.)
If the user does:
require()
with automatically generatedexpose
key be exposed?require()
being exposed?.require()
ifrow.expose === opts.standalone
?