Comparing version 2.0.0-beta.4 to 2.0.0-beta.5
@@ -90,3 +90,3 @@ #!/usr/bin/env node | ||
var version = "2.0.0-beta.4"; | ||
var version = "2.0.0-beta.5"; | ||
@@ -103,3 +103,3 @@ 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> js features target: swc target es versions. "es5" by default\n --runtime <runtime> build runtime: "nodejs", "browser". "browser" by default\n --sourcemap enable sourcemap generation, false by default\n --cwd <cwd> specify current working directory\n -h, --help output usage information\n'; | ||
return tslib.__awaiter(this, void 0, void 0, function() { | ||
var source, format, watch, minify, sourcemap, target, runtime, cwd, file, outputConfig, entry, bundle, err_1; | ||
var source, format, watch, minify, sourcemap, target, runtime, cwd, file, outputConfig, entry, bundle, timeStart, timeEnd, err_1, duration; | ||
return tslib.__generator(this, function(_a) { | ||
@@ -136,2 +136,3 @@ switch(_a.label){ | ||
bundle = require("./lib").bundle; | ||
timeStart = Date.now(); | ||
_a.label = 1; | ||
@@ -150,5 +151,7 @@ case 1: | ||
case 2: | ||
_a.sent(); | ||
timeEnd = Date.now(); | ||
return [ | ||
2, | ||
_a.sent() | ||
3, | ||
4 | ||
]; | ||
@@ -166,2 +169,6 @@ case 3: | ||
case 4: | ||
duration = timeEnd - timeStart; | ||
if (!watch) { | ||
logger.log("✅ Finished in ".concat(duration, " ms")); | ||
} | ||
return [ | ||
@@ -168,0 +175,0 @@ 2 |
@@ -341,3 +341,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
function createRollupConfig(entry, pkg, cliArgs) { | ||
var _a; | ||
var _a, _b; | ||
var file = cliArgs.file; | ||
@@ -370,3 +370,4 @@ var ext = path.extname(entry); | ||
input: inputOptions, | ||
output: outputConfigs | ||
output: outputConfigs, | ||
exportName: ((_b = options.exportCondition) === null || _b === void 0 ? void 0 : _b.name) || pkg.name | ||
}; | ||
@@ -414,6 +415,12 @@ } | ||
} | ||
var npmPackage = getPackageMeta(); | ||
var packageExports = npmPackage.exports; | ||
var pkg = getPackageMeta(); | ||
var packageExports = pkg.exports; | ||
var isSingleEntry = typeof packageExports === "string"; | ||
var hasMultiEntries = packageExports && !isSingleEntry && Object.keys(packageExports).length > 0; | ||
var bundleOrWatch = function bundleOrWatch(rollupConfig) { | ||
if (options.watch) { | ||
return Promise.resolve(runWatch(pkg, rollupConfig)); | ||
} | ||
return runBundle(pkg, rollupConfig); | ||
}; | ||
if (isSingleEntry) { | ||
@@ -438,18 +445,22 @@ entryPath = getSourcePathFromExportPath(config.rootDir, "."); | ||
}; | ||
var rollupConfig = createRollupConfig(path.resolve(cwd, source), npmPackage, options); | ||
var rollupConfig = createRollupConfig(path.resolve(cwd, source), pkg, options); | ||
return rollupConfig; | ||
}).filter(function(v) { | ||
return !!v; | ||
}); | ||
return Promise.all(rollupConfigs.filter(Boolean).map(function(rollupConfig) { | ||
return runBundle(rollupConfig); | ||
return Promise.all(rollupConfigs.map(function(rollupConfig) { | ||
return bundleOrWatch(rollupConfig); | ||
})); | ||
} | ||
} | ||
var rollupConfig = createRollupConfig(entryPath, npmPackage, options); | ||
if (options.watch) { | ||
return Promise.resolve(runWatch(rollupConfig)); | ||
} | ||
return runBundle(rollupConfig); | ||
var rollupConfig = createRollupConfig(entryPath, pkg, options); | ||
return bundleOrWatch(rollupConfig); | ||
} | ||
function runWatch(_a) { | ||
var input = _a.input, output = _a.output; | ||
function getExportPath(pkg, exportName) { | ||
var name = pkg.name || "<package>"; | ||
if (exportName === "." || !exportName) return name; | ||
return path.join(name, exportName); | ||
} | ||
function runWatch(pkg, _a) { | ||
var exportName = _a.exportName, input = _a.input, output = _a.output; | ||
var watchOptions = [ | ||
@@ -466,5 +477,24 @@ tslib.__assign(tslib.__assign({}, input), { | ||
var watcher = rollup.watch(watchOptions); | ||
var exportPath = getExportPath(pkg, exportName); | ||
var startTime = Date.now(); | ||
watcher.on("event", function(event) { | ||
if (event.code === "ERROR") { | ||
onError(event.error); | ||
switch(event.code){ | ||
case "ERROR": | ||
{ | ||
return onError(event.error); | ||
} | ||
case "START": | ||
{ | ||
startTime = Date.now(); | ||
logger.log("Start building ".concat(exportPath, " ...")); | ||
} | ||
case "END": | ||
{ | ||
var duration = Date.now() - startTime; | ||
if (duration > 0) { | ||
logger.log("✨ Built ".concat(exportPath)); | ||
} | ||
} | ||
default: | ||
return; | ||
} | ||
@@ -474,4 +504,5 @@ }); | ||
} | ||
function runBundle(_a) { | ||
var input = _a.input, output = _a.output; | ||
function runBundle(pkg, _a) { | ||
var exportName = _a.exportName, input = _a.input, output = _a.output; | ||
var startTime = Date.now(); | ||
return rollup.rollup(input).then(function(bundle) { | ||
@@ -482,3 +513,8 @@ var writeJobs = output.map(function(options) { | ||
return Promise.all(writeJobs); | ||
}, onError); | ||
}, onError).then(function() { | ||
var duration = Date.now() - startTime; | ||
if (duration > 0) { | ||
logger.log("✨ Built ".concat(getExportPath(pkg, exportName))); | ||
} | ||
}); | ||
} | ||
@@ -485,0 +521,0 @@ function onError(error) { |
@@ -30,2 +30,3 @@ import type { JscTarget } from '@swc/core'; | ||
declare type BuncheeRollupConfig = Partial<Omit<RollupOptions, 'input' | 'output'>> & { | ||
exportName?: string; | ||
input: InputOptions; | ||
@@ -32,0 +33,0 @@ output: OutputOptions[]; |
{ | ||
"name": "bunchee", | ||
"version": "2.0.0-beta.4", | ||
"version": "2.0.0-beta.5", | ||
"description": "zero config bundler for js/ts/jsx libraries", | ||
@@ -5,0 +5,0 @@ "bin": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32579
798
0