Add ability to expose require() with standalone.#51
Open
jmm wants to merge 2 commits intobrowserify:masterfrom
Open
Add ability to expose require() with standalone.#51jmm wants to merge 2 commits intobrowserify:masterfrom
jmm wants to merge 2 commits intobrowserify:masterfrom
Conversation
I suppose yes. What's the current behaviour for require()? |
Contributor
Author
I think that is the current behavior, but I'm not sure it should be. I want to look into it sometime. |
Contributor
Author
|
There need to be some tests here for browser-unpack don't there? |
Contributor
Author
|
Here is an alternative implementation that changes the source and output less. In either case I think browser-unpack will need a little adjustment. |
This was referenced Mar 17, 2015
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
exposevalue passed torequire()should probably be coerced in similar fashion to the coercion UMD does on thestandalonevalue. 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 generatedexposekey be exposed?require()being exposed?.require()ifrow.expose === opts.standalone?