bunchee 4.4.3 → 4.4.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/bin/cli.js +10 -5
- package/dist/index.js +28 -8
- package/package.json +3 -2
package/dist/bin/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ var fsp = require('fs/promises');
|
|
|
6
6
|
require('rimraf');
|
|
7
7
|
var require$$0 = require('tty');
|
|
8
8
|
var bunchee = require('bunchee');
|
|
9
|
+
require('module');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
|
|
@@ -553,12 +554,17 @@ function lint$1(pkg) {
|
|
|
553
554
|
}
|
|
554
555
|
}
|
|
555
556
|
|
|
556
|
-
var version = "4.4.
|
|
557
|
+
var version = "4.4.4";
|
|
557
558
|
|
|
558
559
|
function relativify(path) {
|
|
559
560
|
return path.startsWith('.') ? path : `./${path}`;
|
|
560
561
|
}
|
|
561
562
|
|
|
563
|
+
async function writeDefaultTsconfig(tsConfigPath) {
|
|
564
|
+
await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
|
|
565
|
+
logger.log(`Detected using TypeScript but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
566
|
+
}
|
|
567
|
+
|
|
562
568
|
// Output with posix style in package.json
|
|
563
569
|
function getDistPath(...subPaths) {
|
|
564
570
|
return `./${DIST}/${subPaths.join('/')}`;
|
|
@@ -687,7 +693,7 @@ async function prepare(cwd) {
|
|
|
687
693
|
let isUsingTs = false;
|
|
688
694
|
// Collect bins and exports entries
|
|
689
695
|
const { bins, exportsEntries } = await collectSourceEntries(sourceFolder);
|
|
690
|
-
const
|
|
696
|
+
const tsConfigPath = path__default.default.join(cwd, 'tsconfig.json');
|
|
691
697
|
const sourceFiles = [
|
|
692
698
|
...exportsEntries.values()
|
|
693
699
|
].concat([
|
|
@@ -696,9 +702,8 @@ async function prepare(cwd) {
|
|
|
696
702
|
const hasTypeScriptFiles = sourceFiles.some((filename)=>isTypescriptFile(filename));
|
|
697
703
|
if (hasTypeScriptFiles) {
|
|
698
704
|
isUsingTs = true;
|
|
699
|
-
if (!fs__default.default.existsSync(
|
|
700
|
-
await
|
|
701
|
-
logger.log(`Detected using TypeScript but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
705
|
+
if (!fs__default.default.existsSync(tsConfigPath)) {
|
|
706
|
+
await writeDefaultTsconfig(tsConfigPath);
|
|
702
707
|
}
|
|
703
708
|
}
|
|
704
709
|
// Configure as ESM package by default if there's no package.json
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ var fsp = require('fs/promises');
|
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var perf_hooks = require('perf_hooks');
|
|
8
|
-
var require$$0 = require('tty');
|
|
9
8
|
var module$1 = require('module');
|
|
9
|
+
var require$$0 = require('tty');
|
|
10
10
|
var rimraf = require('rimraf');
|
|
11
11
|
var pluginWasm = require('@rollup/plugin-wasm');
|
|
12
12
|
var rollupPluginSwc3 = require('rollup-plugin-swc3');
|
|
@@ -244,9 +244,24 @@ const hasAvailableExtension = (filename)=>availableExtensions.has(path__default.
|
|
|
244
244
|
const hasCjsExtension = (filename)=>path__default.default.extname(filename) === '.cjs';
|
|
245
245
|
// TODO: add unit test
|
|
246
246
|
const baseNameWithoutExtension = (filename)=>path__default.default.basename(filename, path__default.default.extname(filename));
|
|
247
|
+
const memoize = (fn, resolver)=>{
|
|
248
|
+
const cache = new Map();
|
|
249
|
+
return (...args)=>{
|
|
250
|
+
const key = resolver ? resolver(...args) : JSON.stringify({
|
|
251
|
+
args
|
|
252
|
+
});
|
|
253
|
+
const existing = cache.get(key);
|
|
254
|
+
if (existing !== undefined) {
|
|
255
|
+
return existing;
|
|
256
|
+
}
|
|
257
|
+
const result = fn(...args);
|
|
258
|
+
cache.set(key, result);
|
|
259
|
+
return result;
|
|
260
|
+
};
|
|
261
|
+
};
|
|
247
262
|
|
|
248
263
|
let hasLoggedTsWarning = false;
|
|
249
|
-
function
|
|
264
|
+
function resolveTypescriptHandler(cwd) {
|
|
250
265
|
let ts;
|
|
251
266
|
const m = new module$1.Module('', undefined);
|
|
252
267
|
m.paths = module$1.Module._nodeModulePaths(cwd);
|
|
@@ -261,7 +276,8 @@ function resolveTypescript(cwd) {
|
|
|
261
276
|
}
|
|
262
277
|
return ts;
|
|
263
278
|
}
|
|
264
|
-
|
|
279
|
+
const resolveTypescript = memoize(resolveTypescriptHandler);
|
|
280
|
+
function resolveTsConfigHandler(cwd) {
|
|
265
281
|
let tsCompilerOptions = {};
|
|
266
282
|
let tsConfigPath;
|
|
267
283
|
tsConfigPath = path.resolve(cwd, 'tsconfig.json');
|
|
@@ -278,10 +294,15 @@ function resolveTsConfig(cwd) {
|
|
|
278
294
|
tsConfigPath
|
|
279
295
|
};
|
|
280
296
|
}
|
|
297
|
+
const resolveTsConfig = memoize(resolveTsConfigHandler);
|
|
281
298
|
async function convertCompilerOptions(cwd, json) {
|
|
282
299
|
const ts = resolveTypescript(cwd);
|
|
283
300
|
return ts.convertCompilerOptionsFromJson(json, './');
|
|
284
301
|
}
|
|
302
|
+
async function writeDefaultTsconfig(tsConfigPath) {
|
|
303
|
+
await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
|
|
304
|
+
logger.log(`Detected using TypeScript but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
305
|
+
}
|
|
285
306
|
|
|
286
307
|
const helpers = {
|
|
287
308
|
cssImport: {
|
|
@@ -878,6 +899,7 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
|
|
|
878
899
|
// common plugins for both dts and ts assets that need to be processed
|
|
879
900
|
const aliasFormat = dts ? ((_bundleConfig_file = bundleConfig.file) == null ? void 0 : _bundleConfig_file.endsWith('.d.cts')) ? 'cjs' : 'esm' : bundleConfig.format;
|
|
880
901
|
const commonPlugins = [
|
|
902
|
+
json__default.default(),
|
|
881
903
|
sizePlugin,
|
|
882
904
|
aliasEntries({
|
|
883
905
|
entry,
|
|
@@ -954,8 +976,7 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
|
|
|
954
976
|
}),
|
|
955
977
|
commonjs__default.default({
|
|
956
978
|
exclude: bundleConfig.external || null
|
|
957
|
-
})
|
|
958
|
-
json__default.default()
|
|
979
|
+
})
|
|
959
980
|
]).filter(isNotNull);
|
|
960
981
|
return {
|
|
961
982
|
input: entry,
|
|
@@ -1474,7 +1495,7 @@ async function bundle(cliEntryPath, { cwd: _cwd, ...options } = {}) {
|
|
|
1474
1495
|
;
|
|
1475
1496
|
const hasBin = Boolean(pkg.bin);
|
|
1476
1497
|
const isFromCli = Boolean(cliEntryPath);
|
|
1477
|
-
let tsConfig =
|
|
1498
|
+
let tsConfig = resolveTsConfig(cwd);
|
|
1478
1499
|
let hasTsConfig = Boolean(tsConfig == null ? void 0 : tsConfig.tsConfigPath);
|
|
1479
1500
|
const defaultTsOptions = {
|
|
1480
1501
|
tsConfigPath: tsConfig == null ? void 0 : tsConfig.tsConfigPath,
|
|
@@ -1536,8 +1557,7 @@ async function bundle(cliEntryPath, { cwd: _cwd, ...options } = {}) {
|
|
|
1536
1557
|
if (hasTypeScriptFiles && !hasTsConfig) {
|
|
1537
1558
|
const tsConfigPath = path.resolve(cwd, 'tsconfig.json');
|
|
1538
1559
|
defaultTsOptions.tsConfigPath = tsConfigPath;
|
|
1539
|
-
await
|
|
1540
|
-
logger.log(`Detected using TypeScript but tsconfig.json is missing, created a ${pc.blue('tsconfig.json')} for you.`);
|
|
1560
|
+
await writeDefaultTsconfig(tsConfigPath);
|
|
1541
1561
|
hasTsConfig = true;
|
|
1542
1562
|
}
|
|
1543
1563
|
const sizeCollector = createOutputState({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.4",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": "./dist/bin/cli.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -112,7 +112,8 @@
|
|
|
112
112
|
"testPathIgnorePatterns": [
|
|
113
113
|
"/node_modules/",
|
|
114
114
|
"<rootDir>/test/integration/.*/*src"
|
|
115
|
-
]
|
|
115
|
+
],
|
|
116
|
+
"testTimeout": 8000
|
|
116
117
|
},
|
|
117
118
|
"packageManager": "pnpm@8.8.0"
|
|
118
119
|
}
|