Giter VIP home page Giter VIP logo

derequire's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

derequire's Issues

Exclude external dependencies

Some require function calling which calls external libraries are desired to keep that function name because we cannot rebundle derequired libraries using browserify. Could you add the exclude option for rebundling?

derequire(code, [
  {
    exclude: ['another'], // `require('another')` -> `require('another')`
    from: 'require',  // `require('./index.js')` -> `_dereq_('./index.js')`
    to: '_dereq_'
  }
]);

command-line versions

For browserify v5 I'm dropping derequire for standalone for performance reasons but would like to present a concise alternative for command-line usage. A dequire command would be very good for this, especially if it could just read from stdin and write to stdout. If you agree I can send a pull request with an implementation.

Why is derequire useful?

Hi Calvin, The use case I'm currently facing is 3 browserify applications sharing a single resource with some overlap in require's between the resource and the applications. Is this a typical scenario where you'd use derequire, maybe with stubs?

Thanks,
Thad

Cannot install from npm because of esprima-fb version

From Log:

158 error Error: No compatible version found: esprima-fb@'^3001.1.0-dev-harmony-fb'
158 error Valid install targets:
158 error ["1001.1001.1000-dev-harmony-fb","1001.1001.1001-dev-harmony-fb","1001.1001.2000-dev-harmony-fb","2001.1001.2000-dev-harmony-fb","2001.1001.0-dev-harmony-fb","3001.1.0-dev-harmony-fb"]
158 error at installTargetsError (C:\Program Files\nodejs\node_modules\npm\lib\cache.js:719:10)
158 error at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:638:10
158 error at saved (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:142:7)
158 error at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:133:7
158 error at Object.oncomplete (fs.js:107:15)
159 error If you need help, you may report this log at:
159 error http://github.com/isaacs/npm/issues
159 error or email it to:
159 error [email protected]
160 error System Windows_NT 6.1.7601
161 error command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "derequire"
162 error cwd D:\Projects
163 error node -v v0.10.15
164 error npm -v 1.3.5
165 verbose exit [ 1, true ]

Exclude modules from derequire?

Hello, @calvinmetcalf

So, upon trying to bundle a React library recently using browserify & derequire, I ran into a problem.

If I bundle React with the module then when it's installed you end up with 2 versions of React running in your application, which causes a host of problems. Alternatively you can exclude modules from your bundle, but then after derequiring, the libraries will not get required when building your application.

My suggestion is that another option is added (with the same syntax as browserify's CLI) so that certain requires can be excluded from derequiring e.g.

browserify --exclude react input.js | derequire --exclude react > output.js

Note: browserify's exclude is also aliased to -u. https://github.com/substack/node-browserify#usage

This the above command would not bundle React with the library, but would also not rename the requires. So the following:

var React = require('react');
var otherLib = require('other-lib');

Would compile to:

var React = require('react');
var otherLib = _dereq_('other-lib');

I started having a play around with this here: JakeSidSmith#1

I'm not certain that this approach will even solve my problem, but haven't got it to a suitable point to test it yet.

I'm using a custom walker for the AST, and having not worked with escope before was a little confused by all the scope stuff. Currently all tests are passing (plus my new addition) except for a couple of the larger ones, in which certain requires are not supposed to be replaced. I believe this is because they are "tainted"? Though I'm not sure of the meaning.

Let me know what your thoughts are, and if you could explain what "tainted" is, or why those couple of tests have some requires that are not modified, that'd be really helpful. :)

Browserify transform

If this were available as a transform, it could be used with watchify. Any interest?

Create LICENSE file

Could you please create a LICENSE file with your copyright information and the text of the MIT license? The MIT license requires that the text of the license accompany the source code.

escope dependency is out of date

Hey there,

I'm currently using gulp-derequire@latest on node 6.9.1, npm 3.10.9. The latest version of derequire is using a very old version of escope, which means you get this error:

node_modules/estraverse/estraverse.js:517
                        throw new Error('Unknown node type ' + nodeType + '.');
                        ^

Error: Unknown node type AssignmentPattern.

When you use derequire. This appears to be a solved issue in the underlying libraries, with estraverse >4.2.0 being the minimum version for the fix.

Is there any chance of this being updated to resolve this bug down the bottom of the dependency chain?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.