bunchee 2.0.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/lib.js +31 -24
- package/package.json +7 -2
package/dist/cli.js
CHANGED
|
@@ -87,7 +87,7 @@ var logger = {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
var version = "2.0.
|
|
90
|
+
var version = "2.0.4";
|
|
91
91
|
|
|
92
92
|
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';
|
|
93
93
|
function help() {
|
package/dist/lib.js
CHANGED
|
@@ -96,9 +96,10 @@ function resolveTypescript() {
|
|
|
96
96
|
function getDistPath(distPath) {
|
|
97
97
|
return path.resolve(config.rootDir, distPath);
|
|
98
98
|
}
|
|
99
|
-
function createInputConfig(entry, pkg, options) {
|
|
100
|
-
var _a;
|
|
99
|
+
function createInputConfig(entry, pkg, options, _a) {
|
|
101
100
|
var _b;
|
|
101
|
+
var _c;
|
|
102
|
+
var tsconfigPath = _a.tsconfigPath, tsCompilerOptions = _a.tsCompilerOptions;
|
|
102
103
|
var externals = [
|
|
103
104
|
pkg.peerDependencies,
|
|
104
105
|
pkg.dependencies,
|
|
@@ -109,7 +110,7 @@ function createInputConfig(entry, pkg, options) {
|
|
|
109
110
|
return Object.keys(o);
|
|
110
111
|
}).reduce(function(a, b) {
|
|
111
112
|
return a.concat(b);
|
|
112
|
-
}, []).concat(((
|
|
113
|
+
}, []).concat(((_c = options.external) !== null && _c !== void 0 ? _c : []).concat(pkg.name ? [
|
|
113
114
|
pkg.name
|
|
114
115
|
] : []));
|
|
115
116
|
var useTypescript = options.useTypescript, runtime = options.runtime, jscTarget = options.target, minify = options.minify, exportCondition = options.exportCondition;
|
|
@@ -148,7 +149,7 @@ function createInputConfig(entry, pkg, options) {
|
|
|
148
149
|
useTypescript && isMainExport && require("@rollup/plugin-typescript")(tslib.__assign({
|
|
149
150
|
tsconfig: tsPath,
|
|
150
151
|
typescript: resolveTypescript(),
|
|
151
|
-
jsx: "react",
|
|
152
|
+
jsx: (tsCompilerOptions === null || tsCompilerOptions === void 0 ? void 0 : tsCompilerOptions.jsx) || "react",
|
|
152
153
|
module: "ES6",
|
|
153
154
|
target: jscTarget,
|
|
154
155
|
noEmitOnError: !options.watch,
|
|
@@ -161,14 +162,14 @@ function createInputConfig(entry, pkg, options) {
|
|
|
161
162
|
rollupPluginSwc3.swc({
|
|
162
163
|
include: /\.(m|c)?[jt]sx?$/,
|
|
163
164
|
exclude: "node_modules",
|
|
164
|
-
tsconfig:
|
|
165
|
+
tsconfig: tsconfigPath,
|
|
165
166
|
jsc: tslib.__assign({
|
|
166
167
|
target: jscTarget,
|
|
167
168
|
loose: true,
|
|
168
169
|
externalHelpers: false,
|
|
169
|
-
parser: (
|
|
170
|
+
parser: (_b = {
|
|
170
171
|
syntax: useTypescript ? "typescript" : "ecmascript"
|
|
171
|
-
},
|
|
172
|
+
}, _b[useTypescript ? "tsx" : "jsx"] = true, _b.privateMethod = true, _b.classPrivateProperty = true, _b.exportDefaultFrom = true, _b)
|
|
172
173
|
}, minify && {
|
|
173
174
|
minify: tslib.__assign(tslib.__assign({}, minifyOptions), {
|
|
174
175
|
sourceMap: options.sourcemap
|
|
@@ -205,17 +206,9 @@ function createInputConfig(entry, pkg, options) {
|
|
|
205
206
|
}
|
|
206
207
|
};
|
|
207
208
|
}
|
|
208
|
-
function createOutputOptions(options, pkg) {
|
|
209
|
-
var
|
|
210
|
-
var
|
|
211
|
-
if (useTypescript) {
|
|
212
|
-
var ts = resolveTypescript();
|
|
213
|
-
var tsconfigPath = path.resolve(config.rootDir, "tsconfig.json");
|
|
214
|
-
if (fs__default["default"].existsSync(tsconfigPath)) {
|
|
215
|
-
var tsconfigJSON = ts.readConfigFile(tsconfigPath, ts.sys.readFile).config;
|
|
216
|
-
tsCompilerOptions = ts.parseJsonConfigFileContent(tsconfigJSON, ts.sys, "./").options;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
209
|
+
function createOutputOptions(options, pkg, _a) {
|
|
210
|
+
var tsCompilerOptions = _a.tsCompilerOptions;
|
|
211
|
+
var format = options.format;
|
|
219
212
|
var exportPaths = getExportPaths(pkg);
|
|
220
213
|
var useEsModuleMark = Boolean(tsCompilerOptions.esModuleInterop || exportPaths.main && exportPaths.module);
|
|
221
214
|
var file = path.resolve(options.file);
|
|
@@ -345,29 +338,43 @@ function createRollupConfig(entry, pkg, cliArgs) {
|
|
|
345
338
|
var options = tslib.__assign(tslib.__assign({}, cliArgs), {
|
|
346
339
|
useTypescript: useTypescript
|
|
347
340
|
});
|
|
348
|
-
var
|
|
341
|
+
var tsCompilerOptions = {};
|
|
342
|
+
var tsconfigPath;
|
|
343
|
+
if (useTypescript) {
|
|
344
|
+
var ts = resolveTypescript();
|
|
345
|
+
tsconfigPath = path.resolve(config.rootDir, "tsconfig.json");
|
|
346
|
+
if (fs__default["default"].existsSync(tsconfigPath)) {
|
|
347
|
+
var tsconfigJSON = ts.readConfigFile(tsconfigPath, ts.sys.readFile).config;
|
|
348
|
+
tsCompilerOptions = ts.parseJsonConfigFileContent(tsconfigJSON, ts.sys, "./").options;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
var typescriptOptions = {
|
|
352
|
+
tsconfigPath: tsconfigPath,
|
|
353
|
+
tsCompilerOptions: tsCompilerOptions
|
|
354
|
+
};
|
|
355
|
+
var inputOptions = createInputConfig(entry, pkg, options, typescriptOptions);
|
|
349
356
|
var outputExports = options.exportCondition ? getSubExportDist(pkg, options.exportCondition.export) : getExportDist(pkg);
|
|
350
357
|
var outputConfigs = outputExports.map(function(exportDist) {
|
|
351
358
|
return createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), {
|
|
352
359
|
file: exportDist.file,
|
|
353
360
|
format: exportDist.format,
|
|
354
361
|
useTypescript: useTypescript
|
|
355
|
-
}), pkg);
|
|
362
|
+
}), pkg, typescriptOptions);
|
|
356
363
|
});
|
|
357
364
|
if (file) {
|
|
358
365
|
var format = (_a = outputExports[0]) === null || _a === void 0 ? void 0 : _a.format;
|
|
359
366
|
outputConfigs = [
|
|
360
367
|
createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), {
|
|
361
368
|
file: file,
|
|
362
|
-
format: format ||
|
|
369
|
+
format: cliArgs.format || format,
|
|
363
370
|
useTypescript: useTypescript
|
|
364
|
-
}), pkg),
|
|
371
|
+
}), pkg, typescriptOptions),
|
|
365
372
|
];
|
|
366
373
|
}
|
|
367
374
|
return {
|
|
368
375
|
input: inputOptions,
|
|
369
376
|
output: outputConfigs,
|
|
370
|
-
exportName: ((_b = options.exportCondition) === null || _b === void 0 ? void 0 : _b.name) ||
|
|
377
|
+
exportName: ((_b = options.exportCondition) === null || _b === void 0 ? void 0 : _b.name) || "."
|
|
371
378
|
};
|
|
372
379
|
}
|
|
373
380
|
|
|
@@ -453,7 +460,7 @@ function bundle(entryPath, _a) {
|
|
|
453
460
|
return bundleOrWatch(rollupConfig);
|
|
454
461
|
}
|
|
455
462
|
function getExportPath(pkg, exportName) {
|
|
456
|
-
var name = pkg.name ||
|
|
463
|
+
var name = pkg.name || path.basename(config.rootDir);
|
|
457
464
|
if (exportName === "." || !exportName) return name;
|
|
458
465
|
return path.join(name, exportName);
|
|
459
466
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bunchee": "./dist/cli.js"
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"*.md"
|
|
33
33
|
],
|
|
34
34
|
"author": "huozhi (github.com/huozhi)",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/huozhi/bunchee.git"
|
|
38
|
+
},
|
|
35
39
|
"license": "MIT",
|
|
36
40
|
"dependencies": {
|
|
37
41
|
"@rollup/plugin-commonjs": "22.0.2",
|
|
@@ -42,7 +46,7 @@
|
|
|
42
46
|
"arg": "5.0.0",
|
|
43
47
|
"rollup": "2.74.1",
|
|
44
48
|
"rollup-plugin-preserve-shebang": "1.0.1",
|
|
45
|
-
"rollup-plugin-swc3": "0.
|
|
49
|
+
"rollup-plugin-swc3": "0.5.0",
|
|
46
50
|
"tslib": "2.4.0"
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
@@ -55,6 +59,7 @@
|
|
|
55
59
|
},
|
|
56
60
|
"devDependencies": {
|
|
57
61
|
"jest": "29.0.1",
|
|
62
|
+
"react": "18.2.0",
|
|
58
63
|
"tsx": "3.4.3",
|
|
59
64
|
"typescript": "4.8.2"
|
|
60
65
|
},
|