bunchee 5.0.0-beta.7 → 5.0.0

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 CHANGED
@@ -3,7 +3,6 @@ var path = require('path');
3
3
  var arg = require('arg');
4
4
  var fs = require('fs');
5
5
  var fsp = require('fs/promises');
6
- require('rimraf');
7
6
  var require$$0 = require('tty');
8
7
  var bunchee = require('bunchee');
9
8
  require('module');
@@ -456,7 +455,7 @@ function lint$1(pkg) {
456
455
  }
457
456
  }
458
457
 
459
- var version = "5.0.0-beta.7";
458
+ var version = "5.0.0";
460
459
 
461
460
  function relativify(path) {
462
461
  return path.startsWith('.') ? path : `./${path}`;
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ var path = require('path');
6
6
  var perf_hooks = require('perf_hooks');
7
7
  var module$1 = require('module');
8
8
  var require$$0 = require('tty');
9
- var rimraf = require('rimraf');
10
9
  var pluginWasm = require('@rollup/plugin-wasm');
11
10
  var rollupPluginSwc3 = require('rollup-plugin-swc3');
12
11
  var commonjs = require('@rollup/plugin-commonjs');
@@ -249,22 +248,6 @@ const getMainFieldExportType = (pkg)=>{
249
248
  // TODO: add unit test
250
249
  const baseNameWithoutExtension = (filename)=>path__default.default.basename(filename, path__default.default.extname(filename));
251
250
  const isTestFile = (filename)=>/\.(test|spec)$/.test(baseNameWithoutExtension(filename));
252
- const memoize = (fn, cacheKey)=>{
253
- const cache = new Map();
254
- return (...args)=>{
255
- const key = cacheKey ? typeof cacheKey === 'function' ? cacheKey(...args) : cacheKey : JSON.stringify({
256
- args
257
- });
258
- const existing = cache.get(key);
259
- if (existing !== undefined) {
260
- return existing;
261
- }
262
- const result = fn(...args);
263
- cache.set(key, result);
264
- return result;
265
- };
266
- };
267
- const memoizeByKey = (fn)=>(cacheKey)=>memoize(fn, cacheKey);
268
251
  function joinRelativePath(...segments) {
269
252
  let result = path__default.default.join(...segments);
270
253
  // If the first segment starts with '.', ensure the result does too.
@@ -280,7 +263,10 @@ async function removeDir(dirPath) {
280
263
  try {
281
264
  const dirStat = await fsp__default.default.stat(dirPath);
282
265
  if (dirStat.isDirectory()) {
283
- await rimraf.rimraf(dirPath);
266
+ await fsp__default.default.rm(dirPath, {
267
+ recursive: true,
268
+ force: true
269
+ });
284
270
  }
285
271
  } catch (err) {
286
272
  if (err.code !== 'ENOENT') {
@@ -297,6 +283,26 @@ async function removeOutputDir(output, cwd) {
297
283
  }
298
284
  }
299
285
 
286
+ const memoize = (fn, cacheKey, cacheArg)=>{
287
+ const cache = cacheArg || new Map();
288
+ return (...args)=>{
289
+ const key = cacheKey ? typeof cacheKey === 'function' ? cacheKey(...args) : cacheKey : JSON.stringify({
290
+ args
291
+ });
292
+ const existing = cache.get(key);
293
+ if (existing !== undefined) {
294
+ return existing;
295
+ }
296
+ const result = fn(...args);
297
+ cache.set(key, result);
298
+ return result;
299
+ };
300
+ };
301
+ const memoizeByKey = (fn)=>{
302
+ const cache = new Map();
303
+ return (cacheKey)=>memoize(fn, cacheKey, cache);
304
+ };
305
+
300
306
  let hasLoggedTsWarning = false;
301
307
  function resolveTypescript(cwd) {
302
308
  let ts;
@@ -331,7 +337,7 @@ function resolveTsConfigHandler(cwd, tsconfig = 'tsconfig.json') {
331
337
  tsConfigPath
332
338
  };
333
339
  }
334
- const resolveTsConfig = memoize(resolveTsConfigHandler);
340
+ const resolveTsConfig = memoizeByKey(resolveTsConfigHandler)();
335
341
  async function convertCompilerOptions(cwd, json) {
336
342
  // Use the original ts handler to avoid memory leak
337
343
  const ts = resolveTypescript(cwd);
@@ -1176,7 +1182,7 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
1176
1182
  // Each process should be unique
1177
1183
  // Each package build should be unique
1178
1184
  // Composing above factors into a unique cache key to retrieve the memoized dts plugin with tsconfigs
1179
- const uniqueProcessId = 'dts-plugin:' + process.pid + (buildContext.pkg.name || '');
1185
+ const uniqueProcessId = 'dts-plugin:' + process.pid + tsConfigPath;
1180
1186
  const dtsPlugin = await memoizeDtsPluginByKey(uniqueProcessId)(tsCompilerOptions, tsConfigPath, cwd);
1181
1187
  typesPlugins.push(dtsPlugin);
1182
1188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "5.0.0-beta.7",
3
+ "version": "5.0.0",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": "./dist/bin/cli.js",
6
6
  "main": "./dist/index.js",
@@ -48,7 +48,6 @@
48
48
  "clean-css": "^5.3.3",
49
49
  "magic-string": "^0.30.8",
50
50
  "pretty-bytes": "^5.6.0",
51
- "rimraf": "^5.0.5",
52
51
  "rollup": "^4.13.0",
53
52
  "rollup-plugin-dts": "^6.1.0",
54
53
  "rollup-plugin-swc3": "^0.11.0",