bunchee 3.4.1 → 3.5.1
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 +6 -6
- package/dist/index.js +168 -52
- package/package.json +17 -17
package/dist/cli.js
CHANGED
|
@@ -97,7 +97,7 @@ function _fileExists() {
|
|
|
97
97
|
return _fileExists.apply(this, arguments);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
var version = "3.
|
|
100
|
+
var version = "3.5.1";
|
|
101
101
|
|
|
102
102
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
103
103
|
try {
|
|
@@ -159,8 +159,8 @@ function _lintPackage() {
|
|
|
159
159
|
if (!(yield hasPackageJson(cwd))) {
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
|
-
const { publint
|
|
163
|
-
const { printMessage
|
|
162
|
+
const { publint } = yield import('publint');
|
|
163
|
+
const { printMessage } = yield import('publint/utils');
|
|
164
164
|
const messages = yield publint({
|
|
165
165
|
pkgDir: cwd,
|
|
166
166
|
level: 'error'
|
|
@@ -223,8 +223,8 @@ function run(args) {
|
|
|
223
223
|
}
|
|
224
224
|
function _run() {
|
|
225
225
|
_run = _async_to_generator(function*(args) {
|
|
226
|
-
var _args_external;
|
|
227
|
-
const { source
|
|
226
|
+
var _args_external, _env;
|
|
227
|
+
const { source, format, watch, minify, sourcemap, target, runtime, dts, env } = args;
|
|
228
228
|
const cwd = args.cwd || process.cwd();
|
|
229
229
|
const file = args.file ? path__default.default.resolve(cwd, args.file) : undefined;
|
|
230
230
|
const bundleConfig = {
|
|
@@ -238,7 +238,7 @@ function _run() {
|
|
|
238
238
|
watch: !!watch,
|
|
239
239
|
minify: !!minify,
|
|
240
240
|
sourcemap: sourcemap === false ? false : true,
|
|
241
|
-
env: (env == null ? void 0 :
|
|
241
|
+
env: ((_env = env) == null ? void 0 : _env.split(',')) || []
|
|
242
242
|
};
|
|
243
243
|
if (args.version) {
|
|
244
244
|
return logger.log(version);
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,12 @@ var rollup = require('rollup');
|
|
|
6
6
|
var pluginWasm = require('@rollup/plugin-wasm');
|
|
7
7
|
var rollupPluginSwc3 = require('rollup-plugin-swc3');
|
|
8
8
|
var commonjs = require('@rollup/plugin-commonjs');
|
|
9
|
-
var shebang = require('rollup-plugin-preserve-shebang');
|
|
10
9
|
var json = require('@rollup/plugin-json');
|
|
11
10
|
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
|
12
11
|
var replace = require('@rollup/plugin-replace');
|
|
13
12
|
var prettyBytes = require('pretty-bytes');
|
|
13
|
+
var core = require('@swc/core');
|
|
14
|
+
var MagicString = require('magic-string');
|
|
14
15
|
var module$1 = require('module');
|
|
15
16
|
|
|
16
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -18,10 +19,10 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
18
19
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
19
20
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
20
21
|
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
|
21
|
-
var shebang__default = /*#__PURE__*/_interopDefault(shebang);
|
|
22
22
|
var json__default = /*#__PURE__*/_interopDefault(json);
|
|
23
23
|
var replace__default = /*#__PURE__*/_interopDefault(replace);
|
|
24
24
|
var prettyBytes__default = /*#__PURE__*/_interopDefault(prettyBytes);
|
|
25
|
+
var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
|
|
25
26
|
|
|
26
27
|
function chunkSizeCollector() {
|
|
27
28
|
const sizes = new Map();
|
|
@@ -61,7 +62,7 @@ function chunkSizeCollector() {
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
function asyncGeneratorStep$
|
|
65
|
+
function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
|
|
65
66
|
try {
|
|
66
67
|
var info = gen[key](arg);
|
|
67
68
|
var value = info.value;
|
|
@@ -75,16 +76,16 @@ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
75
76
|
Promise.resolve(value).then(_next, _throw);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
function _async_to_generator$
|
|
79
|
+
function _async_to_generator$4(fn) {
|
|
79
80
|
return function() {
|
|
80
81
|
var self = this, args = arguments;
|
|
81
82
|
return new Promise(function(resolve, reject) {
|
|
82
83
|
var gen = fn.apply(self, args);
|
|
83
84
|
function _next(value) {
|
|
84
|
-
asyncGeneratorStep$
|
|
85
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
|
|
85
86
|
}
|
|
86
87
|
function _throw(err) {
|
|
87
|
-
asyncGeneratorStep$
|
|
88
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
|
|
88
89
|
}
|
|
89
90
|
_next(undefined);
|
|
90
91
|
});
|
|
@@ -98,7 +99,7 @@ function getPackageMeta(cwd) {
|
|
|
98
99
|
return _getPackageMeta.apply(this, arguments);
|
|
99
100
|
}
|
|
100
101
|
function _getPackageMeta() {
|
|
101
|
-
_getPackageMeta = _async_to_generator$
|
|
102
|
+
_getPackageMeta = _async_to_generator$4(function*(cwd) {
|
|
102
103
|
const pkgFilePath = path__default.default.resolve(cwd, 'package.json');
|
|
103
104
|
let targetPackageJson = {};
|
|
104
105
|
try {
|
|
@@ -125,7 +126,7 @@ function fileExists(filePath) {
|
|
|
125
126
|
return _fileExists.apply(this, arguments);
|
|
126
127
|
}
|
|
127
128
|
function _fileExists() {
|
|
128
|
-
_fileExists = _async_to_generator$
|
|
129
|
+
_fileExists = _async_to_generator$4(function*(filePath) {
|
|
129
130
|
try {
|
|
130
131
|
yield fs__default.default.access(filePath);
|
|
131
132
|
return true;
|
|
@@ -155,7 +156,7 @@ function findSourceEntryFile(cwd, exportPath, exportTypeSuffix, ext) {
|
|
|
155
156
|
return _findSourceEntryFile.apply(this, arguments);
|
|
156
157
|
}
|
|
157
158
|
function _findSourceEntryFile() {
|
|
158
|
-
_findSourceEntryFile = _async_to_generator$
|
|
159
|
+
_findSourceEntryFile = _async_to_generator$4(function*(cwd, exportPath, exportTypeSuffix, ext) {
|
|
159
160
|
const filename = resolveSourceFile(cwd, `${exportPath}${exportTypeSuffix ? `.${exportTypeSuffix}` : ''}.${ext}`);
|
|
160
161
|
if (yield fileExists(filename)) {
|
|
161
162
|
return filename;
|
|
@@ -171,6 +172,7 @@ function _findSourceEntryFile() {
|
|
|
171
172
|
// Map '.' -> './index.[ext]'
|
|
172
173
|
// Map './lite' -> './lite.[ext]'
|
|
173
174
|
// Return undefined if no match or if it's package.json exports
|
|
175
|
+
// TODO: add mts and cts once the types generation for dual package is supported
|
|
174
176
|
const availableExtensions = [
|
|
175
177
|
'js',
|
|
176
178
|
'cjs',
|
|
@@ -184,11 +186,12 @@ const availableExportConventions = [
|
|
|
184
186
|
'react-native',
|
|
185
187
|
'edge-light'
|
|
186
188
|
];
|
|
189
|
+
const availableESExtensionsRegex = /\.(m|c)?[jt]sx?$/;
|
|
187
190
|
function getSourcePathFromExportPath(cwd, exportPath, exportType) {
|
|
188
191
|
return _getSourcePathFromExportPath.apply(this, arguments);
|
|
189
192
|
}
|
|
190
193
|
function _getSourcePathFromExportPath() {
|
|
191
|
-
_getSourcePathFromExportPath = _async_to_generator$
|
|
194
|
+
_getSourcePathFromExportPath = _async_to_generator$4(function*(cwd, exportPath, exportType) {
|
|
192
195
|
for (const ext of availableExtensions){
|
|
193
196
|
// ignore package.json
|
|
194
197
|
if (exportPath.endsWith('package.json')) return;
|
|
@@ -211,6 +214,109 @@ function filenameWithoutExtension(file) {
|
|
|
211
214
|
}
|
|
212
215
|
const nonNullable = (n)=>Boolean(n);
|
|
213
216
|
|
|
217
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
218
|
+
try {
|
|
219
|
+
var info = gen[key](arg);
|
|
220
|
+
var value = info.value;
|
|
221
|
+
} catch (error) {
|
|
222
|
+
reject(error);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (info.done) {
|
|
226
|
+
resolve(value);
|
|
227
|
+
} else {
|
|
228
|
+
Promise.resolve(value).then(_next, _throw);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function _async_to_generator$3(fn) {
|
|
232
|
+
return function() {
|
|
233
|
+
var self = this, args = arguments;
|
|
234
|
+
return new Promise(function(resolve, reject) {
|
|
235
|
+
var gen = fn.apply(self, args);
|
|
236
|
+
function _next(value) {
|
|
237
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
238
|
+
}
|
|
239
|
+
function _throw(err) {
|
|
240
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
241
|
+
}
|
|
242
|
+
_next(undefined);
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function _extends$2() {
|
|
247
|
+
_extends$2 = Object.assign || function(target) {
|
|
248
|
+
for(var i = 1; i < arguments.length; i++){
|
|
249
|
+
var source = arguments[i];
|
|
250
|
+
for(var key in source){
|
|
251
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
252
|
+
target[key] = source[key];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return target;
|
|
257
|
+
};
|
|
258
|
+
return _extends$2.apply(this, arguments);
|
|
259
|
+
}
|
|
260
|
+
const directiveRegex = /^use (\w+)$/;
|
|
261
|
+
function swcRenderDirectivePlugin({ swcParserConfig }) {
|
|
262
|
+
const meta = {
|
|
263
|
+
shebang: null,
|
|
264
|
+
directives: new Set()
|
|
265
|
+
};
|
|
266
|
+
const parseOptions = _extends$2({}, swcParserConfig, {
|
|
267
|
+
script: false,
|
|
268
|
+
target: 'es2018'
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
name: 'swc-render-directive',
|
|
272
|
+
transform (code, id) {
|
|
273
|
+
return _async_to_generator$3(function*() {
|
|
274
|
+
const ext = path.extname(id);
|
|
275
|
+
if (!availableESExtensionsRegex.test(ext)) return code;
|
|
276
|
+
const { body, interpreter } = yield core.parse(code, parseOptions);
|
|
277
|
+
if (interpreter) {
|
|
278
|
+
meta.shebang = `#!${interpreter}`;
|
|
279
|
+
code = code.replace(new RegExp('^[\\s\\n]*' + meta.shebang.replace(/\//g, '\/') + '\\n*'), '') // Remove shebang from code
|
|
280
|
+
;
|
|
281
|
+
}
|
|
282
|
+
for (const node of body){
|
|
283
|
+
if (node.type === 'ExpressionStatement') {
|
|
284
|
+
if (node.expression.type === 'StringLiteral' && directiveRegex.test(node.expression.value)) {
|
|
285
|
+
meta.directives.add(node.expression.value);
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
code,
|
|
293
|
+
map: null,
|
|
294
|
+
meta
|
|
295
|
+
};
|
|
296
|
+
})();
|
|
297
|
+
},
|
|
298
|
+
renderChunk (code, _chunk, { sourcemap }) {
|
|
299
|
+
const { shebang, directives } = meta;
|
|
300
|
+
if (!directives.size && !shebang) return null;
|
|
301
|
+
const s = new MagicString__default.default(code);
|
|
302
|
+
if (directives.size) {
|
|
303
|
+
s.prepend(`${[
|
|
304
|
+
...directives
|
|
305
|
+
].map((directive)=>`'${directive}';`).join('\n')}\n`);
|
|
306
|
+
}
|
|
307
|
+
if (shebang) {
|
|
308
|
+
s.prepend(`${shebang}\n`);
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
code: s.toString(),
|
|
312
|
+
map: sourcemap ? s.generateMap({
|
|
313
|
+
hires: true
|
|
314
|
+
}) : null
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
214
320
|
function getTypings(pkg) {
|
|
215
321
|
return pkg.types || pkg.typings;
|
|
216
322
|
}
|
|
@@ -347,7 +453,7 @@ function findExport(name, value, paths, packageType) {
|
|
|
347
453
|
*/ function getExportPaths(pkg) {
|
|
348
454
|
const pathsMap = {};
|
|
349
455
|
const packageType = getPackageType(pkg);
|
|
350
|
-
const { exports: exportsConditions
|
|
456
|
+
const { exports: exportsConditions } = pkg;
|
|
351
457
|
if (exportsConditions) {
|
|
352
458
|
const paths = parseExport(exportsConditions, packageType);
|
|
353
459
|
Object.assign(pathsMap, paths);
|
|
@@ -430,9 +536,10 @@ function getExportConditionDist(pkg, parsedExportCondition, cwd) {
|
|
|
430
536
|
return dist;
|
|
431
537
|
}
|
|
432
538
|
function getTypeFilePath(entryFilePath, exportCondition, cwd) {
|
|
539
|
+
var _exportCondition;
|
|
433
540
|
const name = filenameWithoutExtension(entryFilePath);
|
|
434
541
|
const firstDistPath = exportCondition ? Object.values(exportCondition.export)[0] : undefined;
|
|
435
|
-
const exportName = (exportCondition == null ? void 0 :
|
|
542
|
+
const exportName = ((_exportCondition = exportCondition) == null ? void 0 : _exportCondition.name) || 'index';
|
|
436
543
|
return entryFilePath ? name + '.d.ts' : path.resolve(firstDistPath ? path.dirname(firstDistPath) : path.join(cwd, 'dist'), (exportName === '.' ? 'index' : exportName) + '.d.ts');
|
|
437
544
|
}
|
|
438
545
|
|
|
@@ -479,7 +586,7 @@ function _extends$1() {
|
|
|
479
586
|
};
|
|
480
587
|
return _extends$1.apply(this, arguments);
|
|
481
588
|
}
|
|
482
|
-
const
|
|
589
|
+
const swcMinifyOptions = {
|
|
483
590
|
compress: true,
|
|
484
591
|
format: {
|
|
485
592
|
comments: 'some',
|
|
@@ -505,7 +612,8 @@ function getBuildEnv(envs) {
|
|
|
505
612
|
}, {});
|
|
506
613
|
return envVars;
|
|
507
614
|
}
|
|
508
|
-
function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath
|
|
615
|
+
function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath, tsCompilerOptions }, dts) {
|
|
616
|
+
var _tsCompilerOptions;
|
|
509
617
|
var _options_external;
|
|
510
618
|
const externals = options.noExternal ? [] : [
|
|
511
619
|
pkg.peerDependencies,
|
|
@@ -514,11 +622,35 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
514
622
|
].filter((n)=>Boolean(n)).map((o)=>Object.keys(o)).reduce((a, b)=>a.concat(b), []).concat(((_options_external = options.external) != null ? _options_external : []).concat(pkg.name ? [
|
|
515
623
|
pkg.name
|
|
516
624
|
] : []));
|
|
517
|
-
const { useTypescript
|
|
518
|
-
const hasSpecifiedTsTarget = Boolean((tsCompilerOptions == null ? void 0 :
|
|
625
|
+
const { useTypescript, runtime, target: jscTarget, minify: shouldMinify } = options;
|
|
626
|
+
const hasSpecifiedTsTarget = Boolean(((_tsCompilerOptions = tsCompilerOptions) == null ? void 0 : _tsCompilerOptions.target) && tsConfigPath);
|
|
627
|
+
const swcParserConfig = {
|
|
628
|
+
syntax: useTypescript ? 'typescript' : 'ecmascript',
|
|
629
|
+
[useTypescript ? 'tsx' : 'jsx']: true,
|
|
630
|
+
privateMethod: true,
|
|
631
|
+
classPrivateProperty: true,
|
|
632
|
+
exportDefaultFrom: true
|
|
633
|
+
};
|
|
634
|
+
const swcOptions = {
|
|
635
|
+
jsc: _extends$1({}, !hasSpecifiedTsTarget && {
|
|
636
|
+
target: jscTarget
|
|
637
|
+
}, {
|
|
638
|
+
loose: true,
|
|
639
|
+
externalHelpers: false,
|
|
640
|
+
parser: swcParserConfig
|
|
641
|
+
}, shouldMinify && {
|
|
642
|
+
minify: _extends$1({}, swcMinifyOptions, {
|
|
643
|
+
sourceMap: options.sourcemap
|
|
644
|
+
})
|
|
645
|
+
}),
|
|
646
|
+
sourceMaps: options.sourcemap,
|
|
647
|
+
inlineSourcesContent: false
|
|
648
|
+
};
|
|
519
649
|
const sizePlugin = sizeCollector.plugin(cwd);
|
|
520
650
|
const commonPlugins = [
|
|
521
|
-
|
|
651
|
+
swcRenderDirectivePlugin({
|
|
652
|
+
swcParserConfig
|
|
653
|
+
}),
|
|
522
654
|
sizePlugin
|
|
523
655
|
];
|
|
524
656
|
const plugins = (dts ? [
|
|
@@ -561,30 +693,11 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
561
693
|
}),
|
|
562
694
|
json__default.default(),
|
|
563
695
|
pluginWasm.wasm(),
|
|
564
|
-
rollupPluginSwc3.swc({
|
|
565
|
-
include:
|
|
696
|
+
rollupPluginSwc3.swc(_extends$1({
|
|
697
|
+
include: availableESExtensionsRegex,
|
|
566
698
|
exclude: 'node_modules',
|
|
567
|
-
tsconfig: tsConfigPath
|
|
568
|
-
|
|
569
|
-
target: jscTarget
|
|
570
|
-
}, {
|
|
571
|
-
loose: true,
|
|
572
|
-
externalHelpers: false,
|
|
573
|
-
parser: {
|
|
574
|
-
syntax: useTypescript ? 'typescript' : 'ecmascript',
|
|
575
|
-
[useTypescript ? 'tsx' : 'jsx']: true,
|
|
576
|
-
privateMethod: true,
|
|
577
|
-
classPrivateProperty: true,
|
|
578
|
-
exportDefaultFrom: true
|
|
579
|
-
}
|
|
580
|
-
}, minify && {
|
|
581
|
-
minify: _extends$1({}, minifyOptions, {
|
|
582
|
-
sourceMap: options.sourcemap
|
|
583
|
-
})
|
|
584
|
-
}),
|
|
585
|
-
sourceMaps: options.sourcemap,
|
|
586
|
-
inlineSourcesContent: false
|
|
587
|
-
})
|
|
699
|
+
tsconfig: tsConfigPath
|
|
700
|
+
}, swcOptions))
|
|
588
701
|
]).filter(isNotNull);
|
|
589
702
|
return {
|
|
590
703
|
input: entry,
|
|
@@ -603,7 +716,8 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
603
716
|
'MIXED_EXPORTS',
|
|
604
717
|
'PREFER_NAMED_EXPORTS',
|
|
605
718
|
'UNRESOLVED_IMPORT',
|
|
606
|
-
'THIS_IS_UNDEFINED'
|
|
719
|
+
'THIS_IS_UNDEFINED',
|
|
720
|
+
'MODULE_LEVEL_DIRECTIVE' // ignore warnings for directives like `use client`
|
|
607
721
|
].includes(code)) return;
|
|
608
722
|
// If the circular dependency warning is from node_modules, ignore it
|
|
609
723
|
if (code === 'CIRCULAR_DEPENDENCY' && /Circular dependency: node_modules/.test(warning.message)) {
|
|
@@ -614,6 +728,7 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
614
728
|
};
|
|
615
729
|
}
|
|
616
730
|
function hasEsmExport(exportPaths, tsCompilerOptions) {
|
|
731
|
+
var _tsCompilerOptions;
|
|
617
732
|
let hasEsm = false;
|
|
618
733
|
for(const key in exportPaths){
|
|
619
734
|
const exportInfo = exportPaths[key];
|
|
@@ -623,10 +738,10 @@ function hasEsmExport(exportPaths, tsCompilerOptions) {
|
|
|
623
738
|
break;
|
|
624
739
|
}
|
|
625
740
|
}
|
|
626
|
-
return Boolean(hasEsm || (tsCompilerOptions == null ? void 0 :
|
|
741
|
+
return Boolean(hasEsm || ((_tsCompilerOptions = tsCompilerOptions) == null ? void 0 : _tsCompilerOptions.esModuleInterop));
|
|
627
742
|
}
|
|
628
|
-
function buildOutputConfigs(pkg, exportPaths, options, exportCondition, cwd, { tsCompilerOptions
|
|
629
|
-
const { format
|
|
743
|
+
function buildOutputConfigs(pkg, exportPaths, options, exportCondition, cwd, { tsCompilerOptions }, dts) {
|
|
744
|
+
const { format } = options;
|
|
630
745
|
// Add esm mark and interop helper if esm export is detected
|
|
631
746
|
const useEsModuleMark = hasEsmExport(exportPaths, tsCompilerOptions);
|
|
632
747
|
const typings = getTypings(pkg);
|
|
@@ -720,7 +835,7 @@ function _buildEntryConfig() {
|
|
|
720
835
|
return _buildEntryConfig.apply(this, arguments);
|
|
721
836
|
}
|
|
722
837
|
function buildConfig(entry, pkg, exportPaths, bundleConfig, exportCondition, cwd, tsOptions, dts) {
|
|
723
|
-
const { file
|
|
838
|
+
const { file } = bundleConfig;
|
|
724
839
|
const useTypescript = Boolean(tsOptions.tsConfigPath);
|
|
725
840
|
const options = _extends$1({}, bundleConfig, {
|
|
726
841
|
useTypescript
|
|
@@ -914,9 +1029,10 @@ function bundle(entryPath) {
|
|
|
914
1029
|
}
|
|
915
1030
|
function _bundle() {
|
|
916
1031
|
_bundle = _async_to_generator(function*(entryPath, _param = {}) {
|
|
917
|
-
var { cwd: _cwd
|
|
1032
|
+
var { cwd: _cwd } = _param, options = _object_without_properties_loose(_param, [
|
|
918
1033
|
"cwd"
|
|
919
1034
|
]);
|
|
1035
|
+
var _tsConfig, _tsConfig1, _tsConfig2;
|
|
920
1036
|
const cwd = path.resolve(process.cwd(), _cwd || '');
|
|
921
1037
|
assignDefault(options, 'format', 'es');
|
|
922
1038
|
assignDefault(options, 'minify', false);
|
|
@@ -931,10 +1047,10 @@ function _bundle() {
|
|
|
931
1047
|
// has `types` field in package.json or has `types` exports in any export condition for multi-entries
|
|
932
1048
|
const hasTypings = Object.values(exportPaths).some((condition)=>condition.hasOwnProperty('types'));
|
|
933
1049
|
const tsConfig = yield resolveTsConfig(cwd);
|
|
934
|
-
const hasTsConfig = Boolean(tsConfig == null ? void 0 :
|
|
1050
|
+
const hasTsConfig = Boolean((_tsConfig = tsConfig) == null ? void 0 : _tsConfig.tsConfigPath);
|
|
935
1051
|
const defaultTsOptions = {
|
|
936
|
-
tsConfigPath: tsConfig == null ? void 0 :
|
|
937
|
-
tsCompilerOptions: (tsConfig == null ? void 0 :
|
|
1052
|
+
tsConfigPath: (_tsConfig1 = tsConfig) == null ? void 0 : _tsConfig1.tsConfigPath,
|
|
1053
|
+
tsCompilerOptions: ((_tsConfig2 = tsConfig) == null ? void 0 : _tsConfig2.tsCompilerOptions) || {}
|
|
938
1054
|
};
|
|
939
1055
|
// Handle single entry file
|
|
940
1056
|
if (!isMultiEntries) {
|
|
@@ -962,7 +1078,7 @@ function _bundle() {
|
|
|
962
1078
|
}
|
|
963
1079
|
}
|
|
964
1080
|
const bundleOrWatch = (rollupConfig)=>{
|
|
965
|
-
const { input
|
|
1081
|
+
const { input, exportName } = rollupConfig;
|
|
966
1082
|
const exportPath = getExportPath(pkg, cwd, exportName);
|
|
967
1083
|
// Log original entry file relative path
|
|
968
1084
|
const source = typeof input.input === 'string' ? path.relative(cwd, input.input) : exportPath;
|
|
@@ -994,7 +1110,7 @@ function _bundle() {
|
|
|
994
1110
|
});
|
|
995
1111
|
return _bundle.apply(this, arguments);
|
|
996
1112
|
}
|
|
997
|
-
function runWatch({ input
|
|
1113
|
+
function runWatch({ input, output }, metadata) {
|
|
998
1114
|
const watchOptions = [
|
|
999
1115
|
_extends({}, input, {
|
|
1000
1116
|
output: output,
|
|
@@ -1027,7 +1143,7 @@ function runWatch({ input , output }, metadata) {
|
|
|
1027
1143
|
});
|
|
1028
1144
|
return watcher;
|
|
1029
1145
|
}
|
|
1030
|
-
function runBundle({ input
|
|
1146
|
+
function runBundle({ input, output }) {
|
|
1031
1147
|
return rollup.rollup(input).then((bundle)=>{
|
|
1032
1148
|
const writeJobs = output.map((options)=>bundle.write(options));
|
|
1033
1149
|
return Promise.all(writeJobs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bunchee": "./dist/cli.js"
|
|
@@ -45,24 +45,24 @@
|
|
|
45
45
|
},
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@rollup/plugin-commonjs": "24.0.1",
|
|
49
|
-
"@rollup/plugin-json": "6.0.0",
|
|
50
|
-
"@rollup/plugin-node-resolve": "15.0.2",
|
|
51
|
-
"@rollup/plugin-replace": "5.0.2",
|
|
52
|
-
"@rollup/plugin-wasm": "6.1.3",
|
|
53
|
-
"@swc/core": "1.3.46",
|
|
54
|
-
"@swc/helpers": "0.5.0",
|
|
55
|
-
"arg": "5.0.2",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"rollup
|
|
60
|
-
"rollup-plugin-
|
|
61
|
-
"rollup-plugin-swc3": "0.8.1",
|
|
62
|
-
"tslib": "2.5.0"
|
|
48
|
+
"@rollup/plugin-commonjs": "~24.0.1",
|
|
49
|
+
"@rollup/plugin-json": "~6.0.0",
|
|
50
|
+
"@rollup/plugin-node-resolve": "~15.0.2",
|
|
51
|
+
"@rollup/plugin-replace": "~5.0.2",
|
|
52
|
+
"@rollup/plugin-wasm": "~6.1.3",
|
|
53
|
+
"@swc/core": "^1.3.46",
|
|
54
|
+
"@swc/helpers": "^0.5.0",
|
|
55
|
+
"arg": "~5.0.2",
|
|
56
|
+
"magic-string": "~0.30.0",
|
|
57
|
+
"pretty-bytes": "~5.6.0",
|
|
58
|
+
"publint": "~0.1.11",
|
|
59
|
+
"rollup": "~3.20.2",
|
|
60
|
+
"rollup-plugin-dts": "~5.3.0",
|
|
61
|
+
"rollup-plugin-swc3": "~0.8.1",
|
|
62
|
+
"tslib": "~2.5.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"typescript": "
|
|
65
|
+
"typescript": "^4.1 || ^5.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependenciesMeta": {
|
|
68
68
|
"typescript": {
|