bunchee 3.5.0 → 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 +166 -82
- package/package.json +16 -16
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.5.
|
|
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
|
@@ -10,6 +10,7 @@ var json = require('@rollup/plugin-json');
|
|
|
10
10
|
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
|
11
11
|
var replace = require('@rollup/plugin-replace');
|
|
12
12
|
var prettyBytes = require('pretty-bytes');
|
|
13
|
+
var core = require('@swc/core');
|
|
13
14
|
var MagicString = require('magic-string');
|
|
14
15
|
var module$1 = require('module');
|
|
15
16
|
|
|
@@ -61,39 +62,7 @@ function chunkSizeCollector() {
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
function
|
|
65
|
-
const directives = new Set();
|
|
66
|
-
return {
|
|
67
|
-
name: 'use-directive',
|
|
68
|
-
transform (code, id) {
|
|
69
|
-
const regex = /^(?:['"]use[^'"]+['"][^\n]*|#![^\n]*)/gm;
|
|
70
|
-
const replacedCode = code.replace(regex, (match)=>{
|
|
71
|
-
// replace double quotes with single quotes
|
|
72
|
-
directives.add(match.replace(/["]/g, "'"));
|
|
73
|
-
return '';
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
code: replacedCode,
|
|
77
|
-
map: null
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
renderChunk (code, _, { sourcemap }) {
|
|
81
|
-
if (!directives.size) return null;
|
|
82
|
-
const s = new MagicString__default.default(code);
|
|
83
|
-
s.prepend(`${[
|
|
84
|
-
...directives
|
|
85
|
-
].join('\n')}\n`);
|
|
86
|
-
return {
|
|
87
|
-
code: s.toString(),
|
|
88
|
-
map: sourcemap ? s.generateMap({
|
|
89
|
-
hires: true
|
|
90
|
-
}) : null
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
65
|
+
function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
|
|
97
66
|
try {
|
|
98
67
|
var info = gen[key](arg);
|
|
99
68
|
var value = info.value;
|
|
@@ -107,16 +76,16 @@ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
107
76
|
Promise.resolve(value).then(_next, _throw);
|
|
108
77
|
}
|
|
109
78
|
}
|
|
110
|
-
function _async_to_generator$
|
|
79
|
+
function _async_to_generator$4(fn) {
|
|
111
80
|
return function() {
|
|
112
81
|
var self = this, args = arguments;
|
|
113
82
|
return new Promise(function(resolve, reject) {
|
|
114
83
|
var gen = fn.apply(self, args);
|
|
115
84
|
function _next(value) {
|
|
116
|
-
asyncGeneratorStep$
|
|
85
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
|
|
117
86
|
}
|
|
118
87
|
function _throw(err) {
|
|
119
|
-
asyncGeneratorStep$
|
|
88
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
|
|
120
89
|
}
|
|
121
90
|
_next(undefined);
|
|
122
91
|
});
|
|
@@ -130,7 +99,7 @@ function getPackageMeta(cwd) {
|
|
|
130
99
|
return _getPackageMeta.apply(this, arguments);
|
|
131
100
|
}
|
|
132
101
|
function _getPackageMeta() {
|
|
133
|
-
_getPackageMeta = _async_to_generator$
|
|
102
|
+
_getPackageMeta = _async_to_generator$4(function*(cwd) {
|
|
134
103
|
const pkgFilePath = path__default.default.resolve(cwd, 'package.json');
|
|
135
104
|
let targetPackageJson = {};
|
|
136
105
|
try {
|
|
@@ -157,7 +126,7 @@ function fileExists(filePath) {
|
|
|
157
126
|
return _fileExists.apply(this, arguments);
|
|
158
127
|
}
|
|
159
128
|
function _fileExists() {
|
|
160
|
-
_fileExists = _async_to_generator$
|
|
129
|
+
_fileExists = _async_to_generator$4(function*(filePath) {
|
|
161
130
|
try {
|
|
162
131
|
yield fs__default.default.access(filePath);
|
|
163
132
|
return true;
|
|
@@ -187,7 +156,7 @@ function findSourceEntryFile(cwd, exportPath, exportTypeSuffix, ext) {
|
|
|
187
156
|
return _findSourceEntryFile.apply(this, arguments);
|
|
188
157
|
}
|
|
189
158
|
function _findSourceEntryFile() {
|
|
190
|
-
_findSourceEntryFile = _async_to_generator$
|
|
159
|
+
_findSourceEntryFile = _async_to_generator$4(function*(cwd, exportPath, exportTypeSuffix, ext) {
|
|
191
160
|
const filename = resolveSourceFile(cwd, `${exportPath}${exportTypeSuffix ? `.${exportTypeSuffix}` : ''}.${ext}`);
|
|
192
161
|
if (yield fileExists(filename)) {
|
|
193
162
|
return filename;
|
|
@@ -203,6 +172,7 @@ function _findSourceEntryFile() {
|
|
|
203
172
|
// Map '.' -> './index.[ext]'
|
|
204
173
|
// Map './lite' -> './lite.[ext]'
|
|
205
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
|
|
206
176
|
const availableExtensions = [
|
|
207
177
|
'js',
|
|
208
178
|
'cjs',
|
|
@@ -216,11 +186,12 @@ const availableExportConventions = [
|
|
|
216
186
|
'react-native',
|
|
217
187
|
'edge-light'
|
|
218
188
|
];
|
|
189
|
+
const availableESExtensionsRegex = /\.(m|c)?[jt]sx?$/;
|
|
219
190
|
function getSourcePathFromExportPath(cwd, exportPath, exportType) {
|
|
220
191
|
return _getSourcePathFromExportPath.apply(this, arguments);
|
|
221
192
|
}
|
|
222
193
|
function _getSourcePathFromExportPath() {
|
|
223
|
-
_getSourcePathFromExportPath = _async_to_generator$
|
|
194
|
+
_getSourcePathFromExportPath = _async_to_generator$4(function*(cwd, exportPath, exportType) {
|
|
224
195
|
for (const ext of availableExtensions){
|
|
225
196
|
// ignore package.json
|
|
226
197
|
if (exportPath.endsWith('package.json')) return;
|
|
@@ -243,6 +214,109 @@ function filenameWithoutExtension(file) {
|
|
|
243
214
|
}
|
|
244
215
|
const nonNullable = (n)=>Boolean(n);
|
|
245
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
|
+
|
|
246
320
|
function getTypings(pkg) {
|
|
247
321
|
return pkg.types || pkg.typings;
|
|
248
322
|
}
|
|
@@ -379,7 +453,7 @@ function findExport(name, value, paths, packageType) {
|
|
|
379
453
|
*/ function getExportPaths(pkg) {
|
|
380
454
|
const pathsMap = {};
|
|
381
455
|
const packageType = getPackageType(pkg);
|
|
382
|
-
const { exports: exportsConditions
|
|
456
|
+
const { exports: exportsConditions } = pkg;
|
|
383
457
|
if (exportsConditions) {
|
|
384
458
|
const paths = parseExport(exportsConditions, packageType);
|
|
385
459
|
Object.assign(pathsMap, paths);
|
|
@@ -462,9 +536,10 @@ function getExportConditionDist(pkg, parsedExportCondition, cwd) {
|
|
|
462
536
|
return dist;
|
|
463
537
|
}
|
|
464
538
|
function getTypeFilePath(entryFilePath, exportCondition, cwd) {
|
|
539
|
+
var _exportCondition;
|
|
465
540
|
const name = filenameWithoutExtension(entryFilePath);
|
|
466
541
|
const firstDistPath = exportCondition ? Object.values(exportCondition.export)[0] : undefined;
|
|
467
|
-
const exportName = (exportCondition == null ? void 0 :
|
|
542
|
+
const exportName = ((_exportCondition = exportCondition) == null ? void 0 : _exportCondition.name) || 'index';
|
|
468
543
|
return entryFilePath ? name + '.d.ts' : path.resolve(firstDistPath ? path.dirname(firstDistPath) : path.join(cwd, 'dist'), (exportName === '.' ? 'index' : exportName) + '.d.ts');
|
|
469
544
|
}
|
|
470
545
|
|
|
@@ -511,7 +586,7 @@ function _extends$1() {
|
|
|
511
586
|
};
|
|
512
587
|
return _extends$1.apply(this, arguments);
|
|
513
588
|
}
|
|
514
|
-
const
|
|
589
|
+
const swcMinifyOptions = {
|
|
515
590
|
compress: true,
|
|
516
591
|
format: {
|
|
517
592
|
comments: 'some',
|
|
@@ -537,7 +612,8 @@ function getBuildEnv(envs) {
|
|
|
537
612
|
}, {});
|
|
538
613
|
return envVars;
|
|
539
614
|
}
|
|
540
|
-
function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath
|
|
615
|
+
function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath, tsCompilerOptions }, dts) {
|
|
616
|
+
var _tsCompilerOptions;
|
|
541
617
|
var _options_external;
|
|
542
618
|
const externals = options.noExternal ? [] : [
|
|
543
619
|
pkg.peerDependencies,
|
|
@@ -546,11 +622,35 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
546
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 ? [
|
|
547
623
|
pkg.name
|
|
548
624
|
] : []));
|
|
549
|
-
const { useTypescript
|
|
550
|
-
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
|
+
};
|
|
551
649
|
const sizePlugin = sizeCollector.plugin(cwd);
|
|
552
650
|
const commonPlugins = [
|
|
553
|
-
|
|
651
|
+
swcRenderDirectivePlugin({
|
|
652
|
+
swcParserConfig
|
|
653
|
+
}),
|
|
554
654
|
sizePlugin
|
|
555
655
|
];
|
|
556
656
|
const plugins = (dts ? [
|
|
@@ -593,30 +693,11 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
593
693
|
}),
|
|
594
694
|
json__default.default(),
|
|
595
695
|
pluginWasm.wasm(),
|
|
596
|
-
rollupPluginSwc3.swc({
|
|
597
|
-
include:
|
|
696
|
+
rollupPluginSwc3.swc(_extends$1({
|
|
697
|
+
include: availableESExtensionsRegex,
|
|
598
698
|
exclude: 'node_modules',
|
|
599
|
-
tsconfig: tsConfigPath
|
|
600
|
-
|
|
601
|
-
target: jscTarget
|
|
602
|
-
}, {
|
|
603
|
-
loose: true,
|
|
604
|
-
externalHelpers: false,
|
|
605
|
-
parser: {
|
|
606
|
-
syntax: useTypescript ? 'typescript' : 'ecmascript',
|
|
607
|
-
[useTypescript ? 'tsx' : 'jsx']: true,
|
|
608
|
-
privateMethod: true,
|
|
609
|
-
classPrivateProperty: true,
|
|
610
|
-
exportDefaultFrom: true
|
|
611
|
-
}
|
|
612
|
-
}, minify && {
|
|
613
|
-
minify: _extends$1({}, minifyOptions, {
|
|
614
|
-
sourceMap: options.sourcemap
|
|
615
|
-
})
|
|
616
|
-
}),
|
|
617
|
-
sourceMaps: options.sourcemap,
|
|
618
|
-
inlineSourcesContent: false
|
|
619
|
-
})
|
|
699
|
+
tsconfig: tsConfigPath
|
|
700
|
+
}, swcOptions))
|
|
620
701
|
]).filter(isNotNull);
|
|
621
702
|
return {
|
|
622
703
|
input: entry,
|
|
@@ -635,7 +716,8 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
635
716
|
'MIXED_EXPORTS',
|
|
636
717
|
'PREFER_NAMED_EXPORTS',
|
|
637
718
|
'UNRESOLVED_IMPORT',
|
|
638
|
-
'THIS_IS_UNDEFINED'
|
|
719
|
+
'THIS_IS_UNDEFINED',
|
|
720
|
+
'MODULE_LEVEL_DIRECTIVE' // ignore warnings for directives like `use client`
|
|
639
721
|
].includes(code)) return;
|
|
640
722
|
// If the circular dependency warning is from node_modules, ignore it
|
|
641
723
|
if (code === 'CIRCULAR_DEPENDENCY' && /Circular dependency: node_modules/.test(warning.message)) {
|
|
@@ -646,6 +728,7 @@ function buildInputConfig(entry, pkg, options, cwd, { tsConfigPath , tsCompilerO
|
|
|
646
728
|
};
|
|
647
729
|
}
|
|
648
730
|
function hasEsmExport(exportPaths, tsCompilerOptions) {
|
|
731
|
+
var _tsCompilerOptions;
|
|
649
732
|
let hasEsm = false;
|
|
650
733
|
for(const key in exportPaths){
|
|
651
734
|
const exportInfo = exportPaths[key];
|
|
@@ -655,10 +738,10 @@ function hasEsmExport(exportPaths, tsCompilerOptions) {
|
|
|
655
738
|
break;
|
|
656
739
|
}
|
|
657
740
|
}
|
|
658
|
-
return Boolean(hasEsm || (tsCompilerOptions == null ? void 0 :
|
|
741
|
+
return Boolean(hasEsm || ((_tsCompilerOptions = tsCompilerOptions) == null ? void 0 : _tsCompilerOptions.esModuleInterop));
|
|
659
742
|
}
|
|
660
|
-
function buildOutputConfigs(pkg, exportPaths, options, exportCondition, cwd, { tsCompilerOptions
|
|
661
|
-
const { format
|
|
743
|
+
function buildOutputConfigs(pkg, exportPaths, options, exportCondition, cwd, { tsCompilerOptions }, dts) {
|
|
744
|
+
const { format } = options;
|
|
662
745
|
// Add esm mark and interop helper if esm export is detected
|
|
663
746
|
const useEsModuleMark = hasEsmExport(exportPaths, tsCompilerOptions);
|
|
664
747
|
const typings = getTypings(pkg);
|
|
@@ -752,7 +835,7 @@ function _buildEntryConfig() {
|
|
|
752
835
|
return _buildEntryConfig.apply(this, arguments);
|
|
753
836
|
}
|
|
754
837
|
function buildConfig(entry, pkg, exportPaths, bundleConfig, exportCondition, cwd, tsOptions, dts) {
|
|
755
|
-
const { file
|
|
838
|
+
const { file } = bundleConfig;
|
|
756
839
|
const useTypescript = Boolean(tsOptions.tsConfigPath);
|
|
757
840
|
const options = _extends$1({}, bundleConfig, {
|
|
758
841
|
useTypescript
|
|
@@ -946,9 +1029,10 @@ function bundle(entryPath) {
|
|
|
946
1029
|
}
|
|
947
1030
|
function _bundle() {
|
|
948
1031
|
_bundle = _async_to_generator(function*(entryPath, _param = {}) {
|
|
949
|
-
var { cwd: _cwd
|
|
1032
|
+
var { cwd: _cwd } = _param, options = _object_without_properties_loose(_param, [
|
|
950
1033
|
"cwd"
|
|
951
1034
|
]);
|
|
1035
|
+
var _tsConfig, _tsConfig1, _tsConfig2;
|
|
952
1036
|
const cwd = path.resolve(process.cwd(), _cwd || '');
|
|
953
1037
|
assignDefault(options, 'format', 'es');
|
|
954
1038
|
assignDefault(options, 'minify', false);
|
|
@@ -963,10 +1047,10 @@ function _bundle() {
|
|
|
963
1047
|
// has `types` field in package.json or has `types` exports in any export condition for multi-entries
|
|
964
1048
|
const hasTypings = Object.values(exportPaths).some((condition)=>condition.hasOwnProperty('types'));
|
|
965
1049
|
const tsConfig = yield resolveTsConfig(cwd);
|
|
966
|
-
const hasTsConfig = Boolean(tsConfig == null ? void 0 :
|
|
1050
|
+
const hasTsConfig = Boolean((_tsConfig = tsConfig) == null ? void 0 : _tsConfig.tsConfigPath);
|
|
967
1051
|
const defaultTsOptions = {
|
|
968
|
-
tsConfigPath: tsConfig == null ? void 0 :
|
|
969
|
-
tsCompilerOptions: (tsConfig == null ? void 0 :
|
|
1052
|
+
tsConfigPath: (_tsConfig1 = tsConfig) == null ? void 0 : _tsConfig1.tsConfigPath,
|
|
1053
|
+
tsCompilerOptions: ((_tsConfig2 = tsConfig) == null ? void 0 : _tsConfig2.tsCompilerOptions) || {}
|
|
970
1054
|
};
|
|
971
1055
|
// Handle single entry file
|
|
972
1056
|
if (!isMultiEntries) {
|
|
@@ -994,7 +1078,7 @@ function _bundle() {
|
|
|
994
1078
|
}
|
|
995
1079
|
}
|
|
996
1080
|
const bundleOrWatch = (rollupConfig)=>{
|
|
997
|
-
const { input
|
|
1081
|
+
const { input, exportName } = rollupConfig;
|
|
998
1082
|
const exportPath = getExportPath(pkg, cwd, exportName);
|
|
999
1083
|
// Log original entry file relative path
|
|
1000
1084
|
const source = typeof input.input === 'string' ? path.relative(cwd, input.input) : exportPath;
|
|
@@ -1026,7 +1110,7 @@ function _bundle() {
|
|
|
1026
1110
|
});
|
|
1027
1111
|
return _bundle.apply(this, arguments);
|
|
1028
1112
|
}
|
|
1029
|
-
function runWatch({ input
|
|
1113
|
+
function runWatch({ input, output }, metadata) {
|
|
1030
1114
|
const watchOptions = [
|
|
1031
1115
|
_extends({}, input, {
|
|
1032
1116
|
output: output,
|
|
@@ -1059,7 +1143,7 @@ function runWatch({ input , output }, metadata) {
|
|
|
1059
1143
|
});
|
|
1060
1144
|
return watcher;
|
|
1061
1145
|
}
|
|
1062
|
-
function runBundle({ input
|
|
1146
|
+
function runBundle({ input, output }) {
|
|
1063
1147
|
return rollup.rollup(input).then((bundle)=>{
|
|
1064
1148
|
const writeJobs = output.map((options)=>bundle.write(options));
|
|
1065
1149
|
return Promise.all(writeJobs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "3.5.
|
|
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,21 +45,21 @@
|
|
|
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
|
-
"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"
|
|
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
65
|
"typescript": "^4.1 || ^5.0"
|