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

Add ability to expose require() with standalone. #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jmm
Copy link
Contributor

@jmm jmm commented Mar 2, 2015

Designed to fix #45. This sets up the ability to opt-in to exposing a require() when bundling in standalone mode, like this:

browserify({standalone: 'whatever'})
  .require('entry', {expose: 'whatever'});

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 to require() should probably be coerced in similar fashion to the coercion UMD does on the standalone 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:

    browserify({standalone: 'whatever'})
      .require('entry');
    • Just let the require() with automatically generated expose key be exposed?
    • Document that that usage will result in a require() being exposed?.
    • Should browserify even be exposing in that case?
    • Only expose require() if row.expose === opts.standalone?

@piranna
Copy link

piranna commented Mar 9, 2015

Just let the require() with automatically generated expose key be exposed?

I suppose yes. What's the current behaviour for require()?

@jmm
Copy link
Contributor Author

jmm commented Mar 9, 2015

I suppose yes. What's the current behaviour for require()?

I think that is the current behavior, but I'm not sure it should be. I want to look into it sometime.

@jmm
Copy link
Contributor Author

jmm commented Mar 16, 2015

There need to be some tests here for browser-unpack don't there?

@jmm
Copy link
Contributor Author

jmm commented Mar 16, 2015

Here is an alternative implementation that changes the source and output less. In either case I think browser-unpack will need a little adjustment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not able to use standalone & require flags at the same time
2 participants