Comparing version 2.0.4 to 2.1.0
254
dist/cli.js
#!/usr/bin/env node | ||
var tslib = require('tslib'); | ||
var path = require('path'); | ||
var arg = require('arg'); | ||
require('fs'); | ||
var arg = require('arg'); | ||
@@ -12,4 +11,148 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
process.cwd(); | ||
function exit(err) { | ||
logger.error(err); | ||
process.exit(1); | ||
} | ||
var logger = { | ||
log: function log(arg) { | ||
console.log(arg); | ||
}, | ||
warn: function warn(arg) { | ||
console.log("\x1b[33m" + arg + "\x1b[0m"); | ||
}, | ||
error: function error(arg) { | ||
console.error("\x1b[31m" + arg + "\x1b[0m"); | ||
} | ||
}; | ||
var version = "2.1.0"; | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
var __generator = undefined && undefined.__generator || function(thisArg, body) { | ||
var f, y, t, g, _ = { | ||
label: 0, | ||
sent: function() { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function(v) { | ||
return step([ | ||
n, | ||
v | ||
]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while(_)try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [ | ||
op[0] & 2, | ||
t.value | ||
]; | ||
switch(op[0]){ | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [ | ||
0 | ||
]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [ | ||
6, | ||
e | ||
]; | ||
y = 0; | ||
} finally{ | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
}; | ||
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. default: false\n -o, --output <file> specify output filename\n -f, --format <format> type of output (esm, amd, cjs, iife, umd, system), default: esm\n -e, --external <mod> specify an external dependency\n -h, --help output usage information\n --target <target> js features target: swc target es versions. default: es5\n --runtime <runtime> build runtime (nodejs, browser). default: browser\n --cwd <cwd> specify current working directory\n --sourcemap enable sourcemap generation, default: false\n --dts determine if need to generate types, default: false\n"; | ||
function help() { | ||
logger.log(helpMessage); | ||
} | ||
function parseCliArgs(argv) { | ||
@@ -19,2 +162,3 @@ var args; | ||
"--cwd": String, | ||
"--dts": Boolean, | ||
"--output": String, | ||
@@ -52,2 +196,3 @@ "--format": String, | ||
cwd: args["--cwd"], | ||
dts: !!args["--dts"], | ||
help: args["--help"], | ||
@@ -61,68 +206,20 @@ version: args["--version"], | ||
} | ||
var logger = { | ||
log: function log() { | ||
var args = []; | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, args); | ||
}, | ||
warn: function warn() { | ||
var args = []; | ||
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)); | ||
}, | ||
error: function error() { | ||
var args = []; | ||
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)); | ||
} | ||
}; | ||
var version = "2.0.4"; | ||
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'; | ||
function help() { | ||
console.log(helpMessage); | ||
function run(args) { | ||
return _run.apply(this, arguments); | ||
} | ||
function exit(err) { | ||
logger.error(err); | ||
process.exit(1); | ||
} | ||
function run(args) { | ||
return tslib.__awaiter(this, void 0, void 0, function() { | ||
var source, format, watch, minify, sourcemap, target, runtime, cwd, file, outputConfig, entry, bundle, timeStart, timeEnd, err_1, duration; | ||
return tslib.__generator(this, function(_a) { | ||
switch(_a.label){ | ||
function _run() { | ||
_run = _asyncToGenerator(function(args) { | ||
var source, format, watch, minify, sourcemap, target, runtime, dts, cwd, file, cliArgs, _tmp, entry, bundle, timeStart, timeEnd, err, duration; | ||
return __generator(this, function(_state) { | ||
switch(_state.label){ | ||
case 0: | ||
source = args.source, format = args.format, watch = args.watch, minify = args.minify, sourcemap = args.sourcemap, target = args.target, runtime = args.runtime; | ||
source = args.source, format = args.format, watch = args.watch, minify = args.minify, sourcemap = args.sourcemap, target = args.target, runtime = args.runtime, dts = args.dts; | ||
cwd = args.cwd || process.cwd(); | ||
file = args.file ? path__default["default"].resolve(cwd, args.file) : args.file; | ||
outputConfig = { | ||
file: file, | ||
format: format, | ||
cwd: cwd, | ||
target: target, | ||
runtime: runtime, | ||
external: args.external || [], | ||
watch: !!watch, | ||
minify: !!minify, | ||
sourcemap: sourcemap === false ? false : true | ||
}; | ||
file = args.file ? path__default["default"].resolve(cwd, args.file) : undefined; | ||
_tmp = {}; | ||
cliArgs = (_tmp.dts = dts, _tmp.file = file, _tmp.format = format, _tmp.cwd = cwd, _tmp.target = target, _tmp.runtime = runtime, _tmp.external = args.external || [], _tmp.watch = !!watch, _tmp.minify = !!minify, _tmp.sourcemap = sourcemap === false ? false : true, _tmp); | ||
if (args.version) { | ||
return [ | ||
2, | ||
console.log(version) | ||
logger.log(version) | ||
]; | ||
@@ -139,5 +236,5 @@ } | ||
timeStart = Date.now(); | ||
_a.label = 1; | ||
_state.label = 1; | ||
case 1: | ||
_a.trys.push([ | ||
_state.trys.push([ | ||
1, | ||
@@ -150,6 +247,6 @@ 3, | ||
4, | ||
bundle(entry, outputConfig) | ||
bundle(entry, cliArgs) | ||
]; | ||
case 2: | ||
_a.sent(); | ||
_state.sent(); | ||
timeEnd = Date.now(); | ||
@@ -161,15 +258,15 @@ return [ | ||
case 3: | ||
err_1 = _a.sent(); | ||
if (err_1.name === "NOT_EXISTED") { | ||
err = _state.sent(); | ||
if (err.name === "NOT_EXISTED") { | ||
help(); | ||
return [ | ||
2, | ||
exit(err_1) | ||
exit(err) | ||
]; | ||
} | ||
throw err_1; | ||
throw err; | ||
case 4: | ||
duration = timeEnd - timeStart; | ||
if (!watch) { | ||
logger.log("✅ Finished in ".concat(duration, " ms")); | ||
logger.log("✨ Finished in " + duration + " ms"); | ||
} | ||
@@ -182,8 +279,12 @@ return [ | ||
}); | ||
return _run.apply(this, arguments); | ||
} | ||
function main() { | ||
return tslib.__awaiter(this, void 0, void 0, function() { | ||
return _main.apply(this, arguments); | ||
} | ||
function _main() { | ||
_main = _asyncToGenerator(function() { | ||
var params, error; | ||
return tslib.__generator(this, function(_a) { | ||
switch(_a.label){ | ||
return __generator(this, function(_state) { | ||
switch(_state.label){ | ||
case 0: | ||
@@ -207,3 +308,3 @@ try { | ||
case 1: | ||
_a.sent(); | ||
_state.sent(); | ||
return [ | ||
@@ -215,3 +316,4 @@ 2 | ||
}); | ||
return _main.apply(this, arguments); | ||
} | ||
main().catch(exit); |
832
dist/lib.js
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib = require('tslib'); | ||
var fs = require('fs'); | ||
@@ -12,3 +11,4 @@ var path = require('path'); | ||
var nodeResolve = require('@rollup/plugin-node-resolve'); | ||
require('arg'); | ||
var dts = require('rollup-plugin-dts'); | ||
var module$1 = require('module'); | ||
@@ -23,2 +23,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var nodeResolve__default = /*#__PURE__*/_interopDefaultLegacy(nodeResolve); | ||
var dts__default = /*#__PURE__*/_interopDefaultLegacy(dts); | ||
@@ -30,200 +31,8 @@ var rootDir = process.cwd(); | ||
function getPackageMeta() { | ||
var pkgFilePath = path__default["default"].resolve(config.rootDir, "package.json"); | ||
var targetPackageJson = {}; | ||
try { | ||
targetPackageJson = JSON.parse(fs__default["default"].readFileSync(pkgFilePath, { | ||
encoding: "utf-8" | ||
})); | ||
} catch (_) {} | ||
return targetPackageJson; | ||
function getTypings(pkg) { | ||
return pkg.types || pkg.typings; | ||
} | ||
var logger = { | ||
log: function log() { | ||
var args = []; | ||
for(var _i = 0; _i < arguments.length; _i++){ | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, args); | ||
}, | ||
warn: function warn() { | ||
var args = []; | ||
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)); | ||
}, | ||
error: function error() { | ||
var args = []; | ||
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)); | ||
} | ||
}; | ||
var Module = require("module").Module; | ||
var minifyOptions = { | ||
compress: true, | ||
format: { | ||
comments: "some", | ||
wrapFuncArgs: false, | ||
preserveAnnotations: true | ||
}, | ||
mangle: true | ||
}; | ||
var hasLoggedTsWarning = false; | ||
function resolveTypescript() { | ||
var ts; | ||
var m = new Module("", null); | ||
m.paths = Module._nodeModulePaths(config.rootDir); | ||
try { | ||
ts = m.require("typescript"); | ||
} catch (_) { | ||
if (!hasLoggedTsWarning) { | ||
hasLoggedTsWarning = true; | ||
logger.error("Could not load TypeScript compiler. Try `yarn add --dev typescript`"); | ||
process.exit(1); | ||
} | ||
} | ||
return ts; | ||
} | ||
function getDistPath(distPath) { | ||
return path.resolve(config.rootDir, distPath); | ||
} | ||
function createInputConfig(entry, pkg, options, _a) { | ||
var _b; | ||
var _c; | ||
var tsconfigPath = _a.tsconfigPath, tsCompilerOptions = _a.tsCompilerOptions; | ||
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(((_c = options.external) !== null && _c !== void 0 ? _c : []).concat(pkg.name ? [ | ||
pkg.name | ||
] : [])); | ||
var useTypescript = options.useTypescript, runtime = options.runtime, jscTarget = options.target, minify = options.minify, exportCondition = options.exportCondition; | ||
var typings = pkg.types || pkg.typings; | ||
var cwd = config.rootDir; | ||
var tsPath; | ||
var declarationDir; | ||
if (useTypescript) { | ||
var tsconfig = path.resolve(cwd, "tsconfig.json"); | ||
tsPath = fs__default["default"].existsSync(tsconfig) ? tsconfig : undefined; | ||
if (typings) { | ||
declarationDir = path.dirname(path.resolve(cwd, typings)); | ||
} | ||
if (exportCondition) { | ||
var exportConditionDistFolder = path.dirname(typeof exportCondition.export === "string" ? exportCondition.export : Object.values(exportCondition.export)[0]); | ||
declarationDir = path.resolve(config.rootDir, exportConditionDistFolder); | ||
} | ||
} | ||
var isMainExport = !exportCondition || exportCondition.name === "."; | ||
var plugins = [ | ||
nodeResolve__default["default"]({ | ||
preferBuiltins: runtime === "node", | ||
extensions: [ | ||
".mjs", | ||
".js", | ||
".json", | ||
".node", | ||
".jsx" | ||
] | ||
}), | ||
commonjs__default["default"]({ | ||
include: /node_modules\// | ||
}), | ||
json__default["default"](), | ||
shebang__default["default"](), | ||
useTypescript && isMainExport && require("@rollup/plugin-typescript")(tslib.__assign({ | ||
tsconfig: tsPath, | ||
typescript: resolveTypescript(), | ||
jsx: (tsCompilerOptions === null || tsCompilerOptions === void 0 ? void 0 : tsCompilerOptions.jsx) || "react", | ||
module: "ES6", | ||
target: jscTarget, | ||
noEmitOnError: !options.watch, | ||
sourceMap: options.sourcemap, | ||
declaration: !!typings, | ||
emitDeclarationOnly: true | ||
}, !!typings && { | ||
declarationDir: declarationDir | ||
})), | ||
rollupPluginSwc3.swc({ | ||
include: /\.(m|c)?[jt]sx?$/, | ||
exclude: "node_modules", | ||
tsconfig: tsconfigPath, | ||
jsc: tslib.__assign({ | ||
target: jscTarget, | ||
loose: true, | ||
externalHelpers: false, | ||
parser: (_b = { | ||
syntax: useTypescript ? "typescript" : "ecmascript" | ||
}, _b[useTypescript ? "tsx" : "jsx"] = true, _b.privateMethod = true, _b.classPrivateProperty = true, _b.exportDefaultFrom = true, _b) | ||
}, minify && { | ||
minify: tslib.__assign(tslib.__assign({}, minifyOptions), { | ||
sourceMap: options.sourcemap | ||
}) | ||
}), | ||
sourceMaps: options.sourcemap, | ||
inlineSourcesContent: false | ||
}), | ||
].filter(function(n) { | ||
return Boolean(n); | ||
}); | ||
return { | ||
input: entry, | ||
external: function external(id) { | ||
return externals.some(function(name) { | ||
return id === name || id.startsWith(name + "/"); | ||
}); | ||
}, | ||
plugins: plugins, | ||
treeshake: { | ||
propertyReadSideEffects: false | ||
}, | ||
onwarn: function onwarn(warning, warn) { | ||
var code = warning.code || ""; | ||
if ([ | ||
"MIXED_EXPORTS", | ||
"PREFER_NAMED_EXPORTS", | ||
"THIS_IS_UNDEFINED" | ||
].includes(code)) return; | ||
if (code === "CIRCULAR_DEPENDENCY" && /Circular dependency: node_modules/.test(warning.message)) { | ||
return; | ||
} | ||
warn(warning); | ||
} | ||
}; | ||
} | ||
function createOutputOptions(options, pkg, _a) { | ||
var tsCompilerOptions = _a.tsCompilerOptions; | ||
var format = options.format; | ||
var exportPaths = getExportPaths(pkg); | ||
var useEsModuleMark = Boolean(tsCompilerOptions.esModuleInterop || exportPaths.main && exportPaths.module); | ||
var file = path.resolve(options.file); | ||
return { | ||
name: pkg.name, | ||
file: file, | ||
format: format, | ||
exports: "named", | ||
esModule: useEsModuleMark && format !== "umd", | ||
freeze: false, | ||
strict: false, | ||
sourcemap: options.sourcemap | ||
}; | ||
} | ||
function findExport(field) { | ||
@@ -297,2 +106,3 @@ if (!field) return; | ||
} | ||
// default fallback to output `dist/index.js` in default esm format | ||
if (dist.length === 0) { | ||
@@ -306,4 +116,6 @@ dist.push({ | ||
} | ||
function getSubExportDist(pkg, exportCondition) { | ||
function getExportConditionDist(pkg, exportCondition) { | ||
// const pkgExports = pkg.exports || {} | ||
var dist = []; | ||
// "exports": "..." | ||
if (typeof exportCondition === "string") { | ||
@@ -315,3 +127,7 @@ dist.push({ | ||
} else { | ||
var subExports = exportCondition; | ||
// "./<subexport>": { } | ||
var subExports = exportCondition // pkgExports[subExport] | ||
; | ||
// Ignore json exports, like "./package.json" | ||
// if (subExport.endsWith('.json')) return dist | ||
if (typeof subExports === "string") { | ||
@@ -339,42 +155,266 @@ dist.push({ | ||
} | ||
function createRollupConfig(entry, pkg, cliArgs) { | ||
var _a, _b; | ||
function exit(err) { | ||
logger.error(err); | ||
process.exit(1); | ||
} | ||
function getPackageMeta(cwd) { | ||
var pkgFilePath = path__default["default"].resolve(cwd, "package.json"); | ||
var targetPackageJson = {}; | ||
try { | ||
targetPackageJson = JSON.parse(fs__default["default"].readFileSync(pkgFilePath, { | ||
encoding: "utf-8" | ||
})); | ||
} catch (_) {} | ||
return targetPackageJson; | ||
} | ||
var logger = { | ||
log: function log(arg) { | ||
console.log(arg); | ||
}, | ||
warn: function warn(arg) { | ||
console.log("\x1b[33m" + arg + "\x1b[0m"); | ||
}, | ||
error: function error(arg) { | ||
console.error("\x1b[31m" + arg + "\x1b[0m"); | ||
} | ||
}; | ||
function isTypescript(filename) { | ||
var ext = path__default["default"].extname(filename); | ||
return ext === ".ts" || ext === ".tsx"; | ||
} | ||
var isNotNull = function(n) { | ||
return Boolean(n); | ||
}; | ||
function _extends$1() { | ||
_extends$1 = Object.assign || function(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i]; | ||
for(var key in source){ | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends$1.apply(this, arguments); | ||
} | ||
var minifyOptions = { | ||
compress: true, | ||
format: { | ||
comments: "some", | ||
wrapFuncArgs: false, | ||
preserveAnnotations: true | ||
}, | ||
mangle: true | ||
}; | ||
var hasLoggedTsWarning = false; | ||
function resolveTypescript(cwd) { | ||
var ts; | ||
var m = new module$1.Module("", undefined); | ||
m.paths = module$1.Module._nodeModulePaths(cwd); | ||
try { | ||
ts = m.require("typescript"); | ||
} catch (_) { | ||
console.error(_); | ||
if (!hasLoggedTsWarning) { | ||
hasLoggedTsWarning = true; | ||
exit("Could not load TypeScript compiler. Try to install `typescript` as dev dependency"); | ||
} | ||
} | ||
return ts; | ||
} | ||
function buildInputConfig(entry, pkg, options, param) { | ||
var tsConfigPath = param.tsConfigPath, tsCompilerOptions = param.tsCompilerOptions, dtsOnly = param.dtsOnly; | ||
var _external; | ||
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(((_external = options.external) != null ? _external : []).concat(pkg.name ? [ | ||
pkg.name | ||
] : [])); | ||
var useTypescript = options.useTypescript, runtime = options.runtime, jscTarget = options.target, minify = options.minify; | ||
var _obj; | ||
var plugins = (dtsOnly ? [ | ||
shebang__default["default"](), | ||
useTypescript && dts__default["default"]({ | ||
compilerOptions: _extends$1({}, tsCompilerOptions, { | ||
declaration: true, | ||
noEmit: false, | ||
noEmitOnError: true, | ||
emitDeclarationOnly: true, | ||
checkJs: false, | ||
declarationMap: false, | ||
skipLibCheck: true, | ||
preserveSymlinks: false, | ||
target: "esnext", | ||
module: "esnext", | ||
jsx: (tsCompilerOptions == null ? void 0 : tsCompilerOptions.jsx) || "react" | ||
}) | ||
}), | ||
] : [ | ||
nodeResolve__default["default"]({ | ||
preferBuiltins: runtime === "node", | ||
extensions: [ | ||
".mjs", | ||
".js", | ||
".json", | ||
".node", | ||
".jsx" | ||
] | ||
}), | ||
commonjs__default["default"]({ | ||
include: /node_modules\// | ||
}), | ||
json__default["default"](), | ||
shebang__default["default"](), | ||
rollupPluginSwc3.swc({ | ||
include: /\.(m|c)?[jt]sx?$/, | ||
exclude: "node_modules", | ||
tsconfig: tsConfigPath, | ||
jsc: _extends$1({ | ||
target: jscTarget, | ||
loose: true, | ||
externalHelpers: false, | ||
parser: (_obj = { | ||
syntax: useTypescript ? "typescript" : "ecmascript" | ||
}, _obj[useTypescript ? "tsx" : "jsx"] = true, _obj.privateMethod = true, _obj.classPrivateProperty = true, _obj.exportDefaultFrom = true, _obj) | ||
}, minify && { | ||
minify: _extends$1({}, minifyOptions, { | ||
sourceMap: options.sourcemap | ||
}) | ||
}), | ||
sourceMaps: options.sourcemap, | ||
inlineSourcesContent: false | ||
}), | ||
]).filter(isNotNull); | ||
return { | ||
input: entry, | ||
external: function external(id) { | ||
return externals.some(function(name) { | ||
return id === name || id.startsWith(name + "/"); | ||
}); | ||
}, | ||
plugins: plugins, | ||
treeshake: { | ||
propertyReadSideEffects: false | ||
}, | ||
onwarn: function onwarn(warning, warn) { | ||
var code = warning.code || ""; | ||
// Some may not have types, like CLI binary | ||
if (dtsOnly && code === "EMPTY_BUNDLE") return; | ||
if ([ | ||
"MIXED_EXPORTS", | ||
"PREFER_NAMED_EXPORTS", | ||
"UNRESOLVED_IMPORT", | ||
"THIS_IS_UNDEFINED" | ||
].includes(code)) return; | ||
// If the circular dependency warning is from node_modules, ignore it | ||
if (code === "CIRCULAR_DEPENDENCY" && /Circular dependency: node_modules/.test(warning.message)) { | ||
return; | ||
} | ||
warn(warning); | ||
} | ||
}; | ||
} | ||
function buildOutputConfigs(options, pkg, param) { | ||
var tsCompilerOptions = param.tsCompilerOptions, dtsOnly = param.dtsOnly; | ||
var format = options.format, exportCondition = options.exportCondition; | ||
var exportPaths = getExportPaths(pkg); | ||
// respect if tsconfig.json has `esModuleInterop` config; | ||
// add ESModule mark if cjs and ESModule are both generated; | ||
// TODO: support `import` in exportCondition | ||
var useEsModuleMark = Boolean(tsCompilerOptions.esModuleInterop || exportPaths.main && exportPaths.module); | ||
var typings = getTypings(pkg); | ||
var file = options.file && path.resolve(config.rootDir, options.file); | ||
var dtsDir = typings ? path.dirname(path.resolve(config.rootDir, typings)) : path.resolve(config.rootDir, "dist"); | ||
// file base name without extension | ||
var name = file ? file.replace(new RegExp("" + path.extname(file) + "$"), "") : undefined; | ||
var dtsFile = (exportCondition == null ? void 0 : exportCondition.name) ? path.resolve(dtsDir, (exportCondition.name === "." ? "index" : exportCondition.name) + ".d.ts") : file ? name + ".d.ts" : typings; | ||
// If there's dts file, use `output.file` | ||
var dtsPathConfig = dtsFile ? { | ||
file: dtsFile | ||
} : { | ||
dir: dtsDir | ||
}; | ||
return _extends$1({ | ||
name: pkg.name || name | ||
}, dtsOnly ? dtsPathConfig : { | ||
file: file | ||
}, { | ||
format: format, | ||
exports: "named", | ||
esModule: useEsModuleMark, | ||
freeze: false, | ||
strict: false, | ||
sourcemap: options.sourcemap | ||
}); | ||
} | ||
function buildConfig(entry, pkg, cliArgs, dtsOnly) { | ||
var ref; | ||
var file = cliArgs.file; | ||
var ext = path.extname(entry); | ||
var useTypescript = ext === ".ts" || ext === ".tsx"; | ||
var options = tslib.__assign(tslib.__assign({}, cliArgs), { | ||
var useTypescript = isTypescript(entry); | ||
var options = _extends$1({}, cliArgs, { | ||
useTypescript: useTypescript | ||
}); | ||
var tsCompilerOptions = {}; | ||
var tsconfigPath; | ||
var tsConfigPath; | ||
if (useTypescript) { | ||
var ts = resolveTypescript(); | ||
tsconfigPath = path.resolve(config.rootDir, "tsconfig.json"); | ||
if (fs__default["default"].existsSync(tsconfigPath)) { | ||
var tsconfigJSON = ts.readConfigFile(tsconfigPath, ts.sys.readFile).config; | ||
var ts = resolveTypescript(config.rootDir); | ||
tsConfigPath = path.resolve(config.rootDir, "tsconfig.json"); | ||
if (fs__default["default"].existsSync(tsConfigPath)) { | ||
var tsconfigJSON = ts.readConfigFile(tsConfigPath, ts.sys.readFile).config; | ||
tsCompilerOptions = ts.parseJsonConfigFileContent(tsconfigJSON, ts.sys, "./").options; | ||
} else { | ||
tsConfigPath = undefined; | ||
exit("tsconfig.json is missing in your project directory"); | ||
} | ||
} | ||
var typescriptOptions = { | ||
tsconfigPath: tsconfigPath, | ||
dtsOnly: dtsOnly, | ||
tsConfigPath: tsConfigPath, | ||
tsCompilerOptions: tsCompilerOptions | ||
}; | ||
var inputOptions = createInputConfig(entry, pkg, options, typescriptOptions); | ||
var outputExports = options.exportCondition ? getSubExportDist(pkg, options.exportCondition.export) : getExportDist(pkg); | ||
var outputConfigs = outputExports.map(function(exportDist) { | ||
return createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { | ||
file: exportDist.file, | ||
format: exportDist.format, | ||
useTypescript: useTypescript | ||
}), pkg, typescriptOptions); | ||
}); | ||
if (file) { | ||
var format = (_a = outputExports[0]) === null || _a === void 0 ? void 0 : _a.format; | ||
var inputOptions = buildInputConfig(entry, pkg, options, typescriptOptions); | ||
var outputExports = options.exportCondition ? getExportConditionDist(pkg, options.exportCondition.export) : getExportDist(pkg); | ||
var outputConfigs = []; | ||
// Generate dts job - single config | ||
if (dtsOnly) { | ||
outputConfigs = [ | ||
createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { | ||
file: file, | ||
format: cliArgs.format || format, | ||
buildOutputConfigs(_extends$1({}, cliArgs, { | ||
file: undefined, | ||
format: "es", | ||
useTypescript: useTypescript | ||
}), pkg, typescriptOptions), | ||
]; | ||
} else { | ||
// multi outputs with specified format | ||
outputConfigs = outputExports.map(function(exportDist) { | ||
return buildOutputConfigs(_extends$1({}, cliArgs, { | ||
file: exportDist.file, | ||
format: exportDist.format, | ||
useTypescript: useTypescript | ||
}), pkg, typescriptOptions); | ||
}); | ||
// CLI output option is always prioritized | ||
if (file) { | ||
var ref1; | ||
var format = (ref1 = outputExports[0]) == null ? void 0 : ref1.format; | ||
outputConfigs = [ | ||
buildOutputConfigs(_extends$1({}, cliArgs, { | ||
file: file, | ||
format: cliArgs.format || format, | ||
useTypescript: useTypescript | ||
}), pkg, typescriptOptions), | ||
]; | ||
} | ||
} | ||
@@ -384,6 +424,160 @@ return { | ||
output: outputConfigs, | ||
exportName: ((_b = options.exportCondition) === null || _b === void 0 ? void 0 : _b.name) || "." | ||
exportName: ((ref = options.exportCondition) == null ? void 0 : ref.name) || ".", | ||
dtsOnly: dtsOnly | ||
}; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _extends() { | ||
_extends = Object.assign || function(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i]; | ||
for(var key in source){ | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for(i = 0; i < sourceKeys.length; i++){ | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
var __generator = undefined && undefined.__generator || function(thisArg, body) { | ||
var f, y, t, g, _ = { | ||
label: 0, | ||
sent: function() { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function(v) { | ||
return step([ | ||
n, | ||
v | ||
]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while(_)try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [ | ||
op[0] & 2, | ||
t.value | ||
]; | ||
switch(op[0]){ | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [ | ||
0 | ||
]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [ | ||
6, | ||
e | ||
]; | ||
y = 0; | ||
} finally{ | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
}; | ||
function logBuild(exportPath, dtsOnly, _duration) { | ||
logger.log(" ✓ " + (dtsOnly ? "Generated types" : "Built") + " " + exportPath); | ||
} | ||
function assignDefault(options, name, defaultValue) { | ||
@@ -394,2 +588,4 @@ if (!(name in options) || options[name] == null) { | ||
} | ||
// Map '.' -> './index.[ext]' | ||
// Map './lite' -> './lite.[ext]' | ||
function getSourcePathFromExportPath(cwd, exportPath) { | ||
@@ -404,7 +600,8 @@ var exts = [ | ||
]; | ||
for(var _i = 0, exts_1 = exts; _i < exts_1.length; _i++){ | ||
var ext = exts_1[_i]; | ||
for(var _i = 0; _i < exts.length; _i++){ | ||
var ext = exts[_i]; | ||
// ignore package.json | ||
if (exportPath.endsWith("package.json")) return; | ||
if (exportPath === ".") exportPath = "./index"; | ||
var filename = path.resolve(cwd, "".concat(exportPath, ".").concat(ext)); | ||
var filename = path.resolve(cwd, exportPath + "." + ext); | ||
if (fs__default["default"].existsSync(filename)) { | ||
@@ -416,40 +613,13 @@ return filename; | ||
} | ||
function bundle(entryPath, _a) { | ||
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, "minify", false); | ||
assignDefault(options, "target", "es5"); | ||
if (options.format === "esm") { | ||
options.format = "es"; | ||
} | ||
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) { | ||
entryPath = getSourcePathFromExportPath(config.rootDir, "."); | ||
} | ||
if (!fs__default["default"].existsSync(entryPath)) { | ||
var hasEntryFile = entryPath === "" ? "" : fs__default["default"].statSync(entryPath).isFile(); | ||
if (!hasEntryFile && !hasMultiEntries) { | ||
var err = new Error("Entry file is not existed"); | ||
err.name = "NOT_EXISTED"; | ||
return Promise.reject(err); | ||
} | ||
if (hasMultiEntries) { | ||
var rollupConfigs = Object.keys(packageExports).map(function(entryExport) { | ||
function bundle(entryPath) { | ||
return _bundle.apply(this, arguments); | ||
} | ||
function _bundle() { | ||
_bundle = _asyncToGenerator(function(entryPath, _param) { | ||
var cwd, options, pkg, packageExports, _tmp, isSingleEntry, hasMultiEntries, bundleOrWatch, hasSpecifiedEntryFile, err, hasTypings, _tmp1, assetsJobs, typesJobs, rollupConfig; | ||
function buildEntryConfig(packageExports, dtsOnly) { | ||
var configs = Object.keys(packageExports).map(function(entryExport) { | ||
var source = getSourcePathFromExportPath(config.rootDir, entryExport); | ||
if (!source) return; | ||
if (!source) return undefined; | ||
if (dtsOnly && !isTypescript(source)) return; | ||
options.exportCondition = { | ||
@@ -460,3 +630,4 @@ source: source, | ||
}; | ||
var rollupConfig = createRollupConfig(path.resolve(cwd, source), pkg, options); | ||
var entry = path.resolve(cwd, source); | ||
var rollupConfig = buildConfig(entry, pkg, options, dtsOnly); | ||
return rollupConfig; | ||
@@ -466,10 +637,101 @@ }).filter(function(v) { | ||
}); | ||
return Promise.all(rollupConfigs.map(function(rollupConfig) { | ||
return bundleOrWatch(rollupConfig); | ||
})); | ||
return configs; | ||
} | ||
} | ||
var rollupConfig = createRollupConfig(entryPath, pkg, options); | ||
return bundleOrWatch(rollupConfig); | ||
return __generator(this, function(_state) { | ||
switch(_state.label){ | ||
case 0: | ||
if (_param === void 0) _param = {}; | ||
cwd = _param.cwd, options = _objectWithoutPropertiesLoose(_param, [ | ||
"cwd" | ||
]); | ||
config.rootDir = path.resolve(process.cwd(), cwd || ""); | ||
assignDefault(options, "format", "es"); | ||
assignDefault(options, "minify", false); | ||
assignDefault(options, "target", "es5"); | ||
pkg = getPackageMeta(config.rootDir); | ||
_tmp = {}; | ||
packageExports = pkg.exports || _tmp; | ||
isSingleEntry = typeof packageExports === "string"; | ||
hasMultiEntries = packageExports && !isSingleEntry && Object.keys(packageExports).length > 0; | ||
if (isSingleEntry) { | ||
entryPath = getSourcePathFromExportPath(config.rootDir, "."); | ||
} | ||
bundleOrWatch = function(rollupConfig) { | ||
var input = rollupConfig.input, exportName = rollupConfig.exportName; | ||
var exportPath = getExportPath(pkg, exportName); | ||
// Log original entry file relative path | ||
var source = typeof input.input === "string" ? path.relative(config.rootDir, input.input) : exportPath; | ||
var buildMetadata = { | ||
source: source | ||
}; | ||
if (options.watch) { | ||
return Promise.resolve(runWatch(rollupConfig, buildMetadata)); | ||
} | ||
return runBundle(rollupConfig, buildMetadata); | ||
}; | ||
if (!!fs__default["default"].existsSync(entryPath)) return [ | ||
3, | ||
2 | ||
]; | ||
hasSpecifiedEntryFile = entryPath === "" ? false : fs__default["default"].statSync(entryPath).isFile(); | ||
if (!hasSpecifiedEntryFile && !hasMultiEntries) { | ||
err = new Error("Entry file `" + entryPath + "` is not existed"); | ||
err.name = "NOT_EXISTED"; | ||
return [ | ||
2, | ||
Promise.reject(err) | ||
]; | ||
} | ||
_tmp1 = {}; | ||
hasTypings = !!getTypings(pkg) || typeof packageExports === "object" && Array.from(Object.values(packageExports || _tmp1)).some(function(condition) { | ||
return condition.hasOwnProperty("types"); | ||
}); | ||
// If there's no entry file specified, should enable dts bundling based on package.json exports info | ||
if (!hasSpecifiedEntryFile && hasTypings) { | ||
options.dts = hasTypings; | ||
} | ||
if (!hasMultiEntries) return [ | ||
3, | ||
2 | ||
]; | ||
assetsJobs = buildEntryConfig(packageExports, false).map(function(rollupConfig) { | ||
return bundleOrWatch(rollupConfig); | ||
}); | ||
typesJobs = options.dts ? buildEntryConfig(packageExports, true).map(function(rollupConfig) { | ||
return bundleOrWatch(rollupConfig); | ||
}) : []; | ||
return [ | ||
4, | ||
Promise.all(assetsJobs.concat(typesJobs)) | ||
]; | ||
case 1: | ||
return [ | ||
2, | ||
_state.sent() | ||
]; | ||
case 2: | ||
if (!(isTypescript(entryPath) && options.dts)) return [ | ||
3, | ||
4 | ||
]; | ||
return [ | ||
4, | ||
bundleOrWatch(buildConfig(entryPath, pkg, options, true)) | ||
]; | ||
case 3: | ||
_state.sent(); | ||
_state.label = 4; | ||
case 4: | ||
rollupConfig = buildConfig(entryPath, pkg, options, false); | ||
return [ | ||
2, | ||
bundleOrWatch(rollupConfig) | ||
]; | ||
} | ||
}); | ||
}); | ||
return _bundle.apply(this, arguments); | ||
} | ||
// . -> pkg name | ||
// ./lite -> <pkg name>/lite | ||
function getExportPath(pkg, exportName) { | ||
@@ -480,6 +742,6 @@ var name = pkg.name || path.basename(config.rootDir); | ||
} | ||
function runWatch(pkg, _a) { | ||
var exportName = _a.exportName, input = _a.input, output = _a.output; | ||
function runWatch(param, metadata) { | ||
var input = param.input, output = param.output, dtsOnly = param.dtsOnly; | ||
var watchOptions = [ | ||
tslib.__assign(tslib.__assign({}, input), { | ||
_extends({}, input, { | ||
output: output, | ||
@@ -494,4 +756,2 @@ watch: { | ||
var watcher = rollup.watch(watchOptions); | ||
var exportPath = getExportPath(pkg, exportName); | ||
var startTime = Date.now(); | ||
watcher.on("event", function(event) { | ||
@@ -505,11 +765,7 @@ switch(event.code){ | ||
{ | ||
startTime = Date.now(); | ||
logger.log("Start building ".concat(exportPath, " ...")); | ||
logger.log("Start building " + metadata.source + " ..."); | ||
} | ||
case "END": | ||
{ | ||
var duration = Date.now() - startTime; | ||
if (duration > 0) { | ||
logger.log("✨ Built ".concat(exportPath)); | ||
} | ||
logBuild(metadata.source, dtsOnly); | ||
} | ||
@@ -522,5 +778,4 @@ default: | ||
} | ||
function runBundle(pkg, _a) { | ||
var exportName = _a.exportName, input = _a.input, output = _a.output; | ||
var startTime = Date.now(); | ||
function runBundle(param, jobOptions) { | ||
var input = param.input, output = param.output, dtsOnly = param.dtsOnly; | ||
return rollup.rollup(input).then(function(bundle) { | ||
@@ -532,6 +787,3 @@ var writeJobs = output.map(function(options) { | ||
}, onError).then(function() { | ||
var duration = Date.now() - startTime; | ||
if (duration > 0) { | ||
logger.log("✨ Built ".concat(getExportPath(pkg, exportName))); | ||
} | ||
logBuild(jobOptions.source, dtsOnly); | ||
}); | ||
@@ -541,5 +793,7 @@ } | ||
if (!error) return; | ||
// logging source code in format | ||
if (error.frame) { | ||
process.stderr.write(error.frame + "\n"); | ||
} | ||
// filter out the rollup plugin error information such as loc/frame/code... | ||
var err = new Error(error.message); | ||
@@ -546,0 +800,0 @@ err.stack = error.stack; |
{ | ||
"name": "bunchee", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"description": "zero config bundler for js/ts/jsx libraries", | ||
@@ -44,6 +44,6 @@ "bin": { | ||
"@rollup/plugin-node-resolve": "13.3.0", | ||
"@rollup/plugin-typescript": "8.4.0", | ||
"@swc/core": "^1.2.244", | ||
"@swc/core": "^1.2.249", | ||
"arg": "5.0.0", | ||
"rollup": "2.74.1", | ||
"rollup-plugin-dts": "4.2.2", | ||
"rollup-plugin-preserve-shebang": "1.0.1", | ||
@@ -62,5 +62,7 @@ "rollup-plugin-swc3": "0.5.0", | ||
"devDependencies": { | ||
"@swc/jest": "0.2.22", | ||
"@types/jest": "29.0.0", | ||
"jest": "29.0.1", | ||
"react": "18.2.0", | ||
"tsx": "3.4.3", | ||
"tsx": "3.9.0", | ||
"typescript": "4.8.2" | ||
@@ -73,5 +75,10 @@ }, | ||
"moduleNameMapper": { | ||
"bunchee": "<rootDir>/dist/lib.js" | ||
"bunchee": "<rootDir>/lib.ts" | ||
}, | ||
"transform": { | ||
"^.+\\.(t|j)sx?$": [ | ||
"@swc/jest" | ||
] | ||
} | ||
} | ||
} |
@@ -73,11 +73,12 @@ # bunchee | ||
-w, --watch watch src files changes | ||
-m, --minify compress output. false by default | ||
-m, --minify compress output. default: false | ||
-o, --output <file> specify output filename | ||
-f, --format <format> specify bundle type: "esm", "cjs", "umd". "esm" by default | ||
-f, --format <format> type of output (esm, amd, cjs, iife, umd, system), default: esm | ||
-e, --external <mod> specify an external dependency | ||
-h, --help output usage information | ||
--target <target> js features target: swc target es versions. "es5" by default | ||
--runtime <runtime> build runtime: "nodejs", "browser". "browser" by default | ||
--sourcemap enable sourcemap generation, false by default | ||
--target <target> js features target: swc target es versions. default: es5 | ||
--runtime <runtime> build runtime (nodejs, browser). default: browser | ||
--cwd <cwd> specify current working directory | ||
--sourcemap enable sourcemap generation, default: false | ||
--dts determine if need to generate types, default: false | ||
@@ -84,0 +85,0 @@ Usage: |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
44903
1082
168
6
4
1
+ Addedrollup-plugin-dts@4.2.2
+ Added@babel/code-frame@7.24.7(transitive)
+ Added@babel/helper-validator-identifier@7.24.7(transitive)
+ Added@babel/highlight@7.24.7(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedmagic-string@0.26.7(transitive)
+ Addedpicocolors@1.1.0(transitive)
+ Addedrollup-plugin-dts@4.2.2(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtypescript@4.9.5(transitive)
- Removed@rollup/plugin-typescript@8.4.0
- Removed@rollup/plugin-typescript@8.4.0(transitive)
Updated@swc/core@^1.2.249