Comparing version 2.0.0-alpha.2 to 2.0.0-beta.2
119
dist/cli.js
@@ -25,4 +25,6 @@ #!/usr/bin/env node | ||
"--target": String, | ||
"--no-sourcemap": Boolean, | ||
"--external": [String], | ||
"--sourcemap": Boolean, | ||
"--external": [ | ||
String | ||
], | ||
"-h": "--help", | ||
@@ -34,3 +36,3 @@ "-v": "--version", | ||
"-m": "--minify", | ||
"-e": "--external", | ||
"-e": "--external" | ||
}, { | ||
@@ -47,3 +49,3 @@ permissive: true, | ||
minify: args["--minify"], | ||
sourcemap: args["--no-sourcemap"] !== true, | ||
sourcemap: !!args["--sourcemap"], | ||
cwd: args["--cwd"], | ||
@@ -53,3 +55,3 @@ help: args["--help"], | ||
target: args["--target"], | ||
external: args["--external"], | ||
external: args["--external"] | ||
}; | ||
@@ -59,5 +61,5 @@ return parsedArgs; | ||
var logger = { | ||
log: function () { | ||
log: function log() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
@@ -67,21 +69,29 @@ } | ||
}, | ||
warn: function () { | ||
warn: function warn() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[33m"], args, false), ["\x1b[0m"], false)); | ||
console.log.apply(console, tslib.__spreadArray(tslib.__spreadArray([ | ||
"\x1b[33m" | ||
], args, false), [ | ||
"\x1b[0m" | ||
], false)); | ||
}, | ||
error: function () { | ||
error: function error() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
} | ||
console.error.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[31m"], args, false), ["\x1b[0m"], false)); | ||
}, | ||
console.error.apply(console, tslib.__spreadArray(tslib.__spreadArray([ | ||
"\x1b[31m" | ||
], args, false), [ | ||
"\x1b[0m" | ||
], false)); | ||
} | ||
}; | ||
var version = "2.0.0-alpha.2"; | ||
var version = "2.0.0-beta.2"; | ||
var helpMessage = "\nUsage: bunchee [options]\n\nOptions:\n -v, --version output the version number\n -w, --watch watch src files changes\n -m, --minify compress output. false by default\n -o, --output <file> specify output filename\n -f, --format <format> specify bundle type: \"esm\", \"cjs\", \"umd\". \"esm\" by default\n -e, --external <mod> specify an external dependency\n --target <target> build environment, use \"node\" for nodejs runtime\n --no-sourcemap disable sourcemap generation, sourcemap generation is enabled by default\n --cwd <cwd> specify current working directory\n -h, --help output usage information\n"; | ||
var helpMessage = '\nUsage: bunchee [options]\n\nOptions:\n -v, --version output the version number\n -w, --watch watch src files changes\n -m, --minify compress output. false by default\n -o, --output <file> specify output filename\n -f, --format <format> specify bundle type: "esm", "cjs", "umd". "esm" by default\n -e, --external <mod> specify an external dependency\n --target <target> build environment, use "node" for nodejs runtime\n --sourcemap enable sourcemap generation, sourcemap generation is disabled by default\n --cwd <cwd> specify current working directory\n -h, --help output usage information\n'; | ||
function help() { | ||
@@ -95,6 +105,6 @@ console.log(helpMessage); | ||
function run(args) { | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
return tslib.__awaiter(this, void 0, void 0, function() { | ||
var source, format, watch, minify, sourcemap, target, cwd, file, outputConfig, entry, bundle, err_1; | ||
return tslib.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
return tslib.__generator(this, function(_a) { | ||
switch(_a.label){ | ||
case 0: | ||
@@ -112,25 +122,49 @@ source = args.source, format = args.format, watch = args.watch, minify = args.minify, sourcemap = args.sourcemap, target = args.target; | ||
minify: !!minify, | ||
sourcemap: sourcemap === false ? false : true, | ||
sourcemap: sourcemap === false ? false : true | ||
}; | ||
if (args.version) { | ||
return [2, console.log(version)]; | ||
return [ | ||
2, | ||
console.log(version) | ||
]; | ||
} | ||
if (args.help) { | ||
return [2, help()]; | ||
return [ | ||
2, | ||
help() | ||
]; | ||
} | ||
entry = source ? path__default["default"].resolve(cwd, source) : ''; | ||
entry = source ? path__default["default"].resolve(cwd, source) : ""; | ||
bundle = require(".").bundle; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4, bundle(entry, outputConfig)]; | ||
case 2: return [2, _a.sent()]; | ||
_a.trys.push([ | ||
1, | ||
3, | ||
, | ||
4 | ||
]); | ||
return [ | ||
4, | ||
bundle(entry, outputConfig) | ||
]; | ||
case 2: | ||
return [ | ||
2, | ||
_a.sent() | ||
]; | ||
case 3: | ||
err_1 = _a.sent(); | ||
if (err_1.name === 'NOT_EXISTED') { | ||
if (err_1.name === "NOT_EXISTED") { | ||
help(); | ||
return [2, exit(err_1)]; | ||
return [ | ||
2, | ||
exit(err_1) | ||
]; | ||
} | ||
throw err_1; | ||
case 4: return [2]; | ||
case 4: | ||
return [ | ||
2 | ||
]; | ||
} | ||
@@ -141,22 +175,28 @@ }); | ||
function main() { | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
return tslib.__awaiter(this, void 0, void 0, function() { | ||
var params, error; | ||
return tslib.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
return tslib.__generator(this, function(_a) { | ||
switch(_a.label){ | ||
case 0: | ||
try { | ||
params = parseCliArgs(process.argv.slice(2)); | ||
} | ||
catch (err) { | ||
} catch (err) { | ||
error = err; | ||
} | ||
if (error || !params) { | ||
if (!error) | ||
help(); | ||
return [2, exit(error)]; | ||
if (!error) help(); | ||
return [ | ||
2, | ||
exit(error) | ||
]; | ||
} | ||
return [4, run(params)]; | ||
return [ | ||
4, | ||
run(params) | ||
]; | ||
case 1: | ||
_a.sent(); | ||
return [2]; | ||
return [ | ||
2 | ||
]; | ||
} | ||
@@ -167,2 +207,1 @@ }); | ||
main().catch(exit); | ||
//# sourceMappingURL=cli.js.map |
@@ -12,3 +12,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
var nodeResolve = require('@rollup/plugin-node-resolve'); | ||
var rollupPluginTerser = require('rollup-plugin-terser'); | ||
require('arg'); | ||
@@ -27,3 +26,3 @@ | ||
var config = { | ||
rootDir: rootDir, | ||
rootDir: rootDir | ||
}; | ||
@@ -35,11 +34,12 @@ | ||
try { | ||
targetPackageJson = JSON.parse(fs__default["default"].readFileSync(pkgFilePath, { encoding: "utf-8" })); | ||
} | ||
catch (_) { } | ||
targetPackageJson = JSON.parse(fs__default["default"].readFileSync(pkgFilePath, { | ||
encoding: "utf-8" | ||
})); | ||
} catch (_) {} | ||
return targetPackageJson; | ||
} | ||
var logger = { | ||
log: function () { | ||
log: function log() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
@@ -49,16 +49,24 @@ } | ||
}, | ||
warn: function () { | ||
warn: function warn() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[33m"], args, false), ["\x1b[0m"], false)); | ||
console.log.apply(console, tslib.__spreadArray(tslib.__spreadArray([ | ||
"\x1b[33m" | ||
], args, false), [ | ||
"\x1b[0m" | ||
], false)); | ||
}, | ||
error: function () { | ||
error: function error() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
} | ||
console.error.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[31m"], args, false), ["\x1b[0m"], false)); | ||
}, | ||
console.error.apply(console, tslib.__spreadArray(tslib.__spreadArray([ | ||
"\x1b[31m" | ||
], args, false), [ | ||
"\x1b[0m" | ||
], false)); | ||
} | ||
}; | ||
@@ -70,5 +78,5 @@ | ||
format: { | ||
comments: 'some', | ||
comments: "some", | ||
wrapFuncArgs: false, | ||
preserveAnnotations: true, | ||
preserveAnnotations: true | ||
}, | ||
@@ -84,4 +92,3 @@ mangle: true | ||
ts = m.require("typescript"); | ||
} | ||
catch (_) { | ||
} catch (_) { | ||
if (!hasLoggedTsWarning) { | ||
@@ -100,7 +107,15 @@ hasLoggedTsWarning = true; | ||
var _b; | ||
var externals = [pkg.peerDependencies, pkg.dependencies, pkg.peerDependenciesMeta] | ||
.filter(function (n) { return Boolean(n); }) | ||
.map(function (o) { return Object.keys(o); }) | ||
.reduce(function (a, b) { return a.concat(b); }, []) | ||
.concat(((_b = options.external) !== null && _b !== void 0 ? _b : []).concat(pkg.name ? [pkg.name] : [])); | ||
var externals = [ | ||
pkg.peerDependencies, | ||
pkg.dependencies, | ||
pkg.peerDependenciesMeta | ||
].filter(function(n) { | ||
return Boolean(n); | ||
}).map(function(o) { | ||
return Object.keys(o); | ||
}).reduce(function(a, b) { | ||
return a.concat(b); | ||
}, []).concat(((_b = options.external) !== null && _b !== void 0 ? _b : []).concat(pkg.name ? [ | ||
pkg.name | ||
] : [])); | ||
var useTypescript = options.useTypescript, target = options.target, _c = options.minify, minify = _c === void 0 ? false : _c; | ||
@@ -112,56 +127,69 @@ var typings = pkg.types || pkg.typings; | ||
preferBuiltins: target === "node", | ||
extensions: [".mjs", ".js", ".json", ".node", ".jsx"], | ||
extensions: [ | ||
".mjs", | ||
".js", | ||
".json", | ||
".node", | ||
".jsx" | ||
] | ||
}), | ||
commonjs__default["default"]({ | ||
include: /node_modules\//, | ||
include: /node_modules\// | ||
}), | ||
json__default["default"](), | ||
shebang__default["default"](), | ||
useTypescript && require("@rollup/plugin-typescript")(tslib.__assign({ tsconfig: (function () { | ||
useTypescript && require("@rollup/plugin-typescript")(tslib.__assign({ | ||
tsconfig: function() { | ||
var tsconfig = path.resolve(cwd, "tsconfig.json"); | ||
return fs__default["default"].existsSync(tsconfig) ? tsconfig : undefined; | ||
})(), typescript: resolveTypescript(), jsx: "react", module: "ES6", target: "ES5", noEmitOnError: !options.watch, sourceMap: options.sourcemap, declaration: !!typings }, (!!typings && { | ||
declarationDir: path.dirname(path.resolve(cwd, typings)), | ||
}))), | ||
useTypescript && minify && rollupPluginTerser.terser({ | ||
compress: { | ||
"keep_infinity": true, | ||
}, | ||
format: { | ||
"comments": /^\s*([@#]__[A-Z]__\s*$|@[a-zA-Z]\s*$)/, | ||
"wrap_func_args": false, | ||
"preserve_annotations": true, | ||
} | ||
}), | ||
!useTypescript && rollupPluginSwc3.swc({ | ||
}(), | ||
typescript: resolveTypescript(), | ||
jsx: "react", | ||
module: "ES6", | ||
target: "ES5", | ||
noEmitOnError: !options.watch, | ||
sourceMap: options.sourcemap, | ||
declaration: !!typings, | ||
emitDeclarationOnly: true | ||
}, !!typings && { | ||
declarationDir: path.dirname(path.resolve(cwd, typings)) | ||
})), | ||
rollupPluginSwc3.swc({ | ||
include: /\.(m|c)?[jt]sx?$/, | ||
exclude: 'node_modules', | ||
tsconfig: 'tsconfig.json', | ||
jsc: tslib.__assign({ target: 'es5', loose: true, externalHelpers: false, parser: (_a = { | ||
syntax: useTypescript ? 'typescript' : 'ecmascript' | ||
}, | ||
_a[useTypescript ? 'tsx' : 'jsx'] = true, | ||
_a.privateMethod = true, | ||
_a.classPrivateProperty = true, | ||
_a.exportDefaultFrom = true, | ||
_a) }, (minify && { minify: minifyOptions })), | ||
exclude: "node_modules", | ||
tsconfig: "tsconfig.json", | ||
jsc: tslib.__assign({ | ||
target: "es5", | ||
loose: true, | ||
externalHelpers: false, | ||
parser: (_a = { | ||
syntax: useTypescript ? "typescript" : "ecmascript" | ||
}, _a[useTypescript ? "tsx" : "jsx"] = true, _a.privateMethod = true, _a.classPrivateProperty = true, _a.exportDefaultFrom = true, _a) | ||
}, minify && { | ||
minify: minifyOptions | ||
}), | ||
sourceMaps: options.sourcemap, | ||
inlineSourcesContent: false, | ||
}), | ||
].filter(function (n) { return Boolean(n); }); | ||
inlineSourcesContent: false | ||
}), | ||
].filter(function(n) { | ||
return Boolean(n); | ||
}); | ||
return { | ||
input: entry, | ||
external: function (id) { | ||
return externals.some(function (name) { return id === name || id.startsWith(name + "/"); }); | ||
external: function external(id) { | ||
return externals.some(function(name) { | ||
return id === name || id.startsWith(name + "/"); | ||
}); | ||
}, | ||
plugins: plugins, | ||
treeshake: { | ||
propertyReadSideEffects: false, | ||
propertyReadSideEffects: false | ||
}, | ||
onwarn: function (warning, warn) { | ||
if (warning.code && | ||
['MIXED_EXPORTS', 'PREFER_NAMED_EXPORTS'].includes(warning.code)) | ||
return; | ||
onwarn: function onwarn(warning, warn) { | ||
if (warning.code && [ | ||
"MIXED_EXPORTS", | ||
"PREFER_NAMED_EXPORTS" | ||
].includes(warning.code)) return; | ||
warn(warning); | ||
}, | ||
} | ||
}; | ||
@@ -181,5 +209,3 @@ } | ||
var exportPaths = getExportPaths(pkg); | ||
var useEsModuleMark = Boolean(tsCompilerOptions.esModuleInterop || | ||
(exportPaths.main && | ||
exportPaths.module)); | ||
var useEsModuleMark = Boolean(tsCompilerOptions.esModuleInterop || exportPaths.main && exportPaths.module); | ||
var file = path.resolve(options.file); | ||
@@ -195,10 +221,8 @@ return { | ||
strict: false, | ||
sourcemap: options.sourcemap, | ||
sourcemap: options.sourcemap | ||
}; | ||
} | ||
function findExport(field) { | ||
if (!field) | ||
return; | ||
if (typeof field === "string") | ||
return field; | ||
if (!field) return; | ||
if (typeof field === "string") return field; | ||
var value = field["."] || field["import"] || field["module"] || field["default"]; | ||
@@ -211,4 +235,3 @@ return findExport(value); | ||
paths.export = exportsCondition; | ||
} | ||
else { | ||
} else { | ||
paths.main = paths.main || exportsCondition["require"] || exportsCondition["node"] || exportsCondition["default"]; | ||
@@ -229,16 +252,16 @@ paths.module = paths.module || exportsCondition["module"]; | ||
} | ||
pathsMap['.'] = mainExport; | ||
pathsMap["."] = mainExport; | ||
var exportsConditions = pkg.exports; | ||
if (exportsConditions) { | ||
if (typeof exportsConditions === 'string') { | ||
if (typeof exportsConditions === "string") { | ||
mainExport.export = exportsConditions; | ||
} | ||
else { | ||
} else { | ||
var exportKeys = Object.keys(exportsConditions); | ||
if (exportKeys.some(function (key) { return key.startsWith('.'); })) { | ||
exportKeys.forEach(function (subExport) { | ||
if (exportKeys.some(function(key) { | ||
return key.startsWith("."); | ||
})) { | ||
exportKeys.forEach(function(subExport) { | ||
pathsMap[subExport] = parseExport(exportsConditions[subExport]); | ||
}); | ||
} | ||
else { | ||
} else { | ||
Object.assign(mainExport, parseExport(exportsConditions)); | ||
@@ -248,19 +271,31 @@ } | ||
} | ||
pathsMap['.'] = mainExport; | ||
pathsMap["."] = mainExport; | ||
return pathsMap; | ||
} | ||
function getExportDist(pkg) { | ||
var paths = getExportPaths(pkg)['.']; | ||
var paths = getExportPaths(pkg)["."]; | ||
var dist = []; | ||
if (paths.main) { | ||
dist.push({ format: "cjs", file: getDistPath(paths.main) }); | ||
dist.push({ | ||
format: "cjs", | ||
file: getDistPath(paths.main) | ||
}); | ||
} | ||
if (paths.module) { | ||
dist.push({ format: "esm", file: getDistPath(paths.module) }); | ||
dist.push({ | ||
format: "esm", | ||
file: getDistPath(paths.module) | ||
}); | ||
} | ||
if (paths.export) { | ||
dist.push({ format: "esm", file: getDistPath(paths.export) }); | ||
dist.push({ | ||
format: "esm", | ||
file: getDistPath(paths.export) | ||
}); | ||
} | ||
if (dist.length === 0) { | ||
dist.push({ format: "cjs", file: getDistPath("dist/index.js") }); | ||
dist.push({ | ||
format: "cjs", | ||
file: getDistPath("dist/index.js") | ||
}); | ||
} | ||
@@ -272,18 +307,27 @@ return dist; | ||
var dist = []; | ||
if (typeof pkgExports === 'string') { | ||
dist.push({ format: pkg.type === "module" ? "esm" : "cjs", file: getDistPath(pkgExports) }); | ||
} | ||
else { | ||
if (typeof pkgExports === "string") { | ||
dist.push({ | ||
format: pkg.type === "module" ? "esm" : "cjs", | ||
file: getDistPath(pkgExports) | ||
}); | ||
} else { | ||
var exports_1 = pkgExports[subExport]; | ||
if (subExport.endsWith(".json")) | ||
return dist; | ||
if (typeof exports_1 === 'string') { | ||
dist.push({ format: "esm", file: getDistPath(exports_1) }); | ||
} | ||
else { | ||
if (subExport.endsWith(".json")) return dist; | ||
if (typeof exports_1 === "string") { | ||
dist.push({ | ||
format: "esm", | ||
file: getDistPath(exports_1) | ||
}); | ||
} else { | ||
if (exports_1.require) { | ||
dist.push({ format: "cjs", file: getDistPath(exports_1.require) }); | ||
dist.push({ | ||
format: "cjs", | ||
file: getDistPath(exports_1.require) | ||
}); | ||
} | ||
if (exports_1.import) { | ||
dist.push({ format: "esm", file: getDistPath(exports_1.import) }); | ||
dist.push({ | ||
format: "esm", | ||
file: getDistPath(exports_1.import) | ||
}); | ||
} | ||
@@ -298,14 +342,21 @@ } | ||
var useTypescript = ext === ".ts" || ext === ".tsx"; | ||
var options = tslib.__assign(tslib.__assign({}, cliArgs), { useTypescript: useTypescript }); | ||
var options = tslib.__assign(tslib.__assign({}, cliArgs), { | ||
useTypescript: useTypescript | ||
}); | ||
var inputOptions = createInputConfig(entry, pkg, options); | ||
var outputExports = entryExport | ||
? getSubExportDist(pkg, entryExport) | ||
: getExportDist(pkg); | ||
var outputConfigs = outputExports | ||
.map(function (exportDist) { | ||
return createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { file: exportDist.file, format: exportDist.format, useTypescript: useTypescript }), pkg); | ||
var outputExports = entryExport ? getSubExportDist(pkg, entryExport) : getExportDist(pkg); | ||
var outputConfigs = outputExports.map(function(exportDist) { | ||
return createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { | ||
file: exportDist.file, | ||
format: exportDist.format, | ||
useTypescript: useTypescript | ||
}), pkg); | ||
}); | ||
if (file) { | ||
outputConfigs = [ | ||
createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { file: file, format: format, useTypescript: useTypescript }), pkg) | ||
createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { | ||
file: file, | ||
format: format, | ||
useTypescript: useTypescript | ||
}), pkg) | ||
]; | ||
@@ -315,3 +366,3 @@ } | ||
input: inputOptions, | ||
output: outputConfigs, | ||
output: outputConfigs | ||
}; | ||
@@ -326,7 +377,10 @@ } | ||
function bundle(entryPath, _a) { | ||
if (_a === void 0) { _a = {}; } | ||
var cwd = _a.cwd, options = tslib.__rest(_a, ["cwd"]); | ||
if (_a === void 0) { | ||
_a = {}; | ||
} | ||
var cwd = _a.cwd, options = tslib.__rest(_a, [ | ||
"cwd" | ||
]); | ||
config.rootDir = path.resolve(process.cwd(), cwd || ""); | ||
assignDefault(options, "format", "es"); | ||
assignDefault(options, "sourcemap", true); | ||
if (options.format === "esm") { | ||
@@ -336,7 +390,7 @@ options.format = "es"; | ||
var npmPackage = getPackageMeta(); | ||
var _b = npmPackage.bunchee || {}, entries = _b.entry, customConfig = tslib.__rest(_b, ["entry"]); | ||
var isSingleEntry = typeof entries === 'string'; | ||
var hasMultiEntries = entries | ||
&& !isSingleEntry | ||
&& Object.keys(entries).length > 0; | ||
var _b = npmPackage.bunchee || {}, entries = _b.entry, customConfig = tslib.__rest(_b, [ | ||
"entry" | ||
]); | ||
var isSingleEntry = typeof entries === "string"; | ||
var hasMultiEntries = entries && !isSingleEntry && Object.keys(entries).length > 0; | ||
if (isSingleEntry) { | ||
@@ -346,3 +400,3 @@ entryPath = path.resolve(config.rootDir, entries); | ||
if (!fs__default["default"].existsSync(entryPath)) { | ||
var hasEntryFile = entryPath === '' ? '' : fs__default["default"].statSync(entryPath).isFile(); | ||
var hasEntryFile = entryPath === "" ? "" : fs__default["default"].statSync(entryPath).isFile(); | ||
if (!hasEntryFile && !hasMultiEntries) { | ||
@@ -355,3 +409,3 @@ var err = new Error("Entry file is not existed"); | ||
Object.assign(options, customConfig); | ||
var rollupConfigs = Object.keys(entries).map(function (entryExport) { | ||
var rollupConfigs = Object.keys(entries).map(function(entryExport) { | ||
var source = entries[entryExport]; | ||
@@ -361,3 +415,3 @@ var rollupConfig = createRollupConfig(path.resolve(cwd, source), npmPackage, options, entryExport); | ||
}); | ||
return Promise.all(rollupConfigs.map(function (rollupConfig) { | ||
return Promise.all(rollupConfigs.map(function(rollupConfig) { | ||
return runBundle(rollupConfig); | ||
@@ -376,8 +430,15 @@ })); | ||
var input = _a.input, output = _a.output; | ||
var watchOptions = [tslib.__assign(tslib.__assign({}, input), { output: output, watch: { | ||
exclude: ["node_modules/**"], | ||
} })]; | ||
var watchOptions = [ | ||
tslib.__assign(tslib.__assign({}, input), { | ||
output: output, | ||
watch: { | ||
exclude: [ | ||
"node_modules/**" | ||
] | ||
} | ||
}) | ||
]; | ||
var watcher = rollup.watch(watchOptions); | ||
watcher.on('event', function (event) { | ||
if (event.code === 'ERROR') { | ||
watcher.on("event", function(event) { | ||
if (event.code === "ERROR") { | ||
onError(event.error); | ||
@@ -390,4 +451,4 @@ } | ||
var input = _a.input, output = _a.output; | ||
return rollup.rollup(input).then(function (bundle) { | ||
var writeJobs = output.map(function (options) { | ||
return rollup.rollup(input).then(function(bundle) { | ||
var writeJobs = output.map(function(options) { | ||
return bundle.write(options); | ||
@@ -399,4 +460,3 @@ }); | ||
function onError(error) { | ||
if (!error) | ||
return; | ||
if (!error) return; | ||
if (error.frame) { | ||
@@ -412,2 +472,1 @@ process.stdout.write(error.frame + "\n"); | ||
exports.bundle = bundle; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "bunchee", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0-beta.2", | ||
"description": "zero config bundler for js/ts/jsx libraries", | ||
@@ -9,3 +9,3 @@ "bin": { | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"types": "./dist/src/index.d.ts", | ||
"scripts": { | ||
@@ -15,2 +15,3 @@ "test": "jest --env node", | ||
"clean": "rm -rf ./dist", | ||
"types": "tsc --declaration --declarationDir dist --emitDeclarationOnly", | ||
"typecheck": "tsc --noEmit", | ||
@@ -20,3 +21,3 @@ "prepublishOnly": "yarn clean && yarn build && chmod +x dist/cli.js && yarn test", | ||
"build:main": "tsx src/cli.ts src/index.ts --target node -f cjs", | ||
"build": "yarn build:main && yarn build:cli" | ||
"build": "yarn build:main && yarn build:cli && yarn types" | ||
}, | ||
@@ -44,4 +45,3 @@ "type": "commonjs", | ||
"@rollup/plugin-typescript": "8.3.4", | ||
"@swc/core": "~1.2.229", | ||
"regenerator-runtime": "0.13.9", | ||
"@swc/core": "^1.2.244", | ||
"arg": "5.0.0", | ||
@@ -51,3 +51,2 @@ "rollup": "2.74.1", | ||
"rollup-plugin-swc3": "0.3.0", | ||
"rollup-plugin-terser": "7.0.2", | ||
"tslib": "2.3.0" | ||
@@ -54,0 +53,0 @@ }, |
@@ -16,3 +16,3 @@ # bunchee | ||
Bunchee can help you to bundle your library into one file with zero configuration. It's built on top of rollup. | ||
Bunchee can help you to bundle your library into one file with zero configuration. It's built on top of rollup and SWC ⚡️. | ||
@@ -80,3 +80,3 @@ Let you focus on writing code and can generate multiple types of module (CommonJS, ESModules) at the same time. | ||
--target <target> build environment, use "node" for nodejs runtime | ||
--no-sourcemap disable sourcemap generation, sourcemap generation is enabled by default | ||
--sourcemap enable sourcemap generation, sourcemap generation is disabled by default | ||
--cwd <cwd> specify current working directory | ||
@@ -83,0 +83,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
18
780
31283
+ Added@swc/core@1.7.28(transitive)
+ Added@swc/core-darwin-arm64@1.7.28(transitive)
+ Added@swc/core-darwin-x64@1.7.28(transitive)
+ Added@swc/core-linux-arm-gnueabihf@1.7.28(transitive)
+ Added@swc/core-linux-arm64-gnu@1.7.28(transitive)
+ Added@swc/core-linux-arm64-musl@1.7.28(transitive)
+ Added@swc/core-linux-x64-gnu@1.7.28(transitive)
+ Added@swc/core-linux-x64-musl@1.7.28(transitive)
+ Added@swc/core-win32-arm64-msvc@1.7.28(transitive)
+ Added@swc/core-win32-ia32-msvc@1.7.28(transitive)
+ Added@swc/core-win32-x64-msvc@1.7.28(transitive)
+ Added@swc/counter@0.1.3(transitive)
+ Added@swc/types@0.1.13(transitive)
- Removedregenerator-runtime@0.13.9
- Removedrollup-plugin-terser@7.0.2
- Removed@babel/code-frame@7.25.7(transitive)
- Removed@babel/helper-validator-identifier@7.25.7(transitive)
- Removed@babel/highlight@7.25.7(transitive)
- Removed@jridgewell/gen-mapping@0.3.5(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/source-map@0.3.6(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removed@swc/core@1.2.249(transitive)
- Removed@swc/core-android-arm-eabi@1.2.249(transitive)
- Removed@swc/core-android-arm64@1.2.249(transitive)
- Removed@swc/core-darwin-arm64@1.2.249(transitive)
- Removed@swc/core-darwin-x64@1.2.249(transitive)
- Removed@swc/core-freebsd-x64@1.2.249(transitive)
- Removed@swc/core-linux-arm-gnueabihf@1.2.249(transitive)
- Removed@swc/core-linux-arm64-gnu@1.2.249(transitive)
- Removed@swc/core-linux-arm64-musl@1.2.249(transitive)
- Removed@swc/core-linux-x64-gnu@1.2.249(transitive)
- Removed@swc/core-linux-x64-musl@1.2.249(transitive)
- Removed@swc/core-win32-arm64-msvc@1.2.249(transitive)
- Removed@swc/core-win32-ia32-msvc@1.2.249(transitive)
- Removed@swc/core-win32-x64-msvc@1.2.249(transitive)
- Removed@swc/wasm@1.2.1221.2.130(transitive)
- Removedacorn@8.12.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcommander@2.20.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.04.0.0(transitive)
- Removedjest-worker@26.6.2(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedmerge-stream@2.0.0(transitive)
- Removedpicocolors@1.1.0(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedregenerator-runtime@0.13.9(transitive)
- Removedrollup-plugin-terser@7.0.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedserialize-javascript@4.0.0(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedsource-map-support@0.5.21(transitive)
- Removedsupports-color@5.5.07.2.0(transitive)
- Removedterser@5.34.1(transitive)
Updated@swc/core@^1.2.244