I need to use --exclude, -u
within package.json rather then as a command line option, but how?
From: browserify test.js -u request > test.browserify.js
To: browserify test.js > test.browserify.js
Potential solutions:
"browser": { "request": false }
"browserify": {"transform": ...}
Found a solution:
Add the following to package.json: "browser": { "request": "./request.js" }
Create ./request.js
and put the following in it:
var req = "request";
module.exports = require(req);
And you have to put the "request" string in a separate variable, if you don't the require
will just return an empty object stub {}
.
The downside of this is that I have to define such a file for every module I want to require, ideally I'd have a single file that can detect what to require.
Edit
Haven't tested this yet but I could probably dynamically require these modules without an external file var req = "request"; var request = require(req);
var req = "request"; var request = require(req);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.