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

Aliasify code in modules #26

Open
glassresistor opened this issue May 7, 2015 · 4 comments
Open

Aliasify code in modules #26

glassresistor opened this issue May 7, 2015 · 4 comments

Comments

@glassresistor
Copy link

I have an project that requires a library which uses the request library. For it to work in the browser i have to swap that for the browser-request.
Is there a way for aliasify to update requires in dependencies?

@kadamwhite
Copy link

+1 to this—I just spent an hour trying to figure out what was wrong in my configuration (where I was trying to aliasify underscore to lodash for use in a required Backbone), but it seems that aliasify, as with the browser field, doesn't affect anything within your node_modules directory. If this is the case, that should be added to the documentation.

To clarify, I'd have expected this to work:

demo.js:

module.exports = require( 'backbone' );

package.json:

{
  "scripts": {
    "test": "browserify demo.js | grep lodash"
  },
  "browserify": {
    "transform": [ "aliasify" ]
  },
  "aliasify": {
    "aliases": {
      "underscore": "lodash"
    }
  },
  "dependencies": {
    "backbone": "^1.2.1",
    "jquery": "^2.1.4",
    "lodash": "^3.10.0"
  },
  "devDependencies": {
    "aliasify": "^1.7.2",
    "browserify": "^10.2.6"
  }
}

npm test will not output anything, meaning that lodash isn't being subbed in.

@jwalton
Copy link
Contributor

jwalton commented Jul 17, 2015

This is a restriction imposed on us by browserify. Browserify will never run transforms on modules.

You might try the new --global-transform option in Browserify, though, and see if that does what you want.

@kadamwhite
Copy link

@jwalton I just discovered the --global-transform option—it does indeed work! Looks like there is no way to configure that to automatically happen with the "browserify":{} config within package.json, but it does work from the command line, and (I would assume) through the programmatic invocation interface as well.

I'd vote to have that caveat mentioned in the documentation, but thanks for the response and for making a very useful tool!

@rockuw
Copy link
Contributor

rockuw commented Apr 12, 2016

@jwalton Good to know the --global-transform option. Thanks!

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

No branches or pull requests

4 participants