Merge pull request #107 from developit/externals-cleanup

Reworked external option slightly (default to all), removed undocumen…
This commit is contained in:
Mateusz Burzyński 2018-03-29 00:18:07 +02:00 committed by GitHub
commit 7282f2cae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View File

@ -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

View File

@ -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",

View File

@ -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) => {

View File

@ -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')