mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
Merge pull request #107 from developit/externals-cleanup
Reworked external option slightly (default to all), removed undocumen…
This commit is contained in:
commit
7282f2cae4
@ -67,7 +67,7 @@ Just like `microbundle build`, but watches your source files and rebuilds on any
|
||||
-o, --output Directory to place build files into
|
||||
-f, --format Only build specified formats (default es,cjs,umd)
|
||||
--target Specify your target environment (default node)
|
||||
--external Specify external dependencies, or 'all'
|
||||
--external Specify external dependencies, or 'none'
|
||||
--compress Compress output using UglifyJS (default true)
|
||||
--strict Enforce undefined global context and add "use strict"
|
||||
--name Specify name exposed in UMD builds
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
"bin": "dist/cli.js",
|
||||
"scripts": {
|
||||
"build": "npm run -s build:babel && npm run -s build:self",
|
||||
"build:babel": "babel-node src/cli.js --external all --format cjs src/*.js --presets env",
|
||||
"build:self": "node dist/cli.js --external all --format cjs src/*.js",
|
||||
"build:babel": "babel-node src/cli.js --format cjs src/*.js --presets env",
|
||||
"build:self": "node dist/cli.js --format cjs src/*.js",
|
||||
"prepare": "npm run -s build",
|
||||
"prepare:babel": "babel --presets env src/*.js -d dist && npm t",
|
||||
"lint": "eslint src",
|
||||
|
||||
14
src/index.js
14
src/index.js
@ -138,7 +138,6 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
let { pkg } = options;
|
||||
|
||||
let external = ['dns', 'fs', 'path', 'url'].concat(
|
||||
Object.keys(pkg.peerDependencies || {}),
|
||||
options.entries.filter( e => e!==entry )
|
||||
);
|
||||
|
||||
@ -149,13 +148,18 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
external.push('.');
|
||||
}
|
||||
|
||||
let useNodeResolve = true;
|
||||
if (options.inline === 'all') {
|
||||
let useNodeResolve;
|
||||
const peerDeps = Object.keys(pkg.peerDependencies || {});
|
||||
if (options.external==='none') {
|
||||
useNodeResolve = true;
|
||||
}
|
||||
else if (options.external==='all' || options.inline==='none') {
|
||||
else if (options.external) {
|
||||
useNodeResolve = true;
|
||||
external = external.concat(peerDeps).concat(options.external.split(','));
|
||||
}
|
||||
else {
|
||||
useNodeResolve = false;
|
||||
external = external.concat(Object.keys(pkg.dependencies || {}));
|
||||
external = external.concat(peerDeps).concat(Object.keys(pkg.dependencies || {}));
|
||||
}
|
||||
|
||||
let globals = external.reduce( (globals, name) => {
|
||||
|
||||
@ -18,7 +18,7 @@ export default handler => {
|
||||
.option('--output, -o', 'Directory to place build files into')
|
||||
.option('--format, -f', 'Only build specified formats', 'es,cjs,umd')
|
||||
.option('--target', 'Specify your target environment', 'node')
|
||||
.option('--external', `Specify external dependencies, or 'all'`)
|
||||
.option('--external', `Specify external dependencies, or 'none'`)
|
||||
.option('--compress', 'Compress output using UglifyJS', true)
|
||||
.option('--strict', 'Enforce undefined global context and add "use strict"')
|
||||
.option('--name', 'Specify name exposed in UMD builds')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user