bunchee 2.1.4 → 2.1.6

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.
Files changed (3) hide show
  1. package/dist/cli.js +14 -4
  2. package/dist/lib.js +31 -16
  3. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -27,7 +27,7 @@ var logger = {
27
27
  }
28
28
  };
29
29
 
30
- var version = "2.1.4";
30
+ var version = "2.1.6";
31
31
 
32
32
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
33
33
  try {
@@ -208,15 +208,25 @@ function run(args) {
208
208
  }
209
209
  function _run() {
210
210
  _run = _asyncToGenerator(function(args) {
211
- var source, format, watch, minify, sourcemap, target, runtime, dts, cwd, file, cliArgs, _tmp, entry, bundle, timeStart, timeEnd, err, duration;
211
+ var source, format, watch, minify, sourcemap, target, runtime, dts, cwd, file, cliArgs, entry, bundle, timeStart, timeEnd, err, duration;
212
212
  return __generator(this, function(_state) {
213
213
  switch(_state.label){
214
214
  case 0:
215
215
  source = args.source, format = args.format, watch = args.watch, minify = args.minify, sourcemap = args.sourcemap, target = args.target, runtime = args.runtime, dts = args.dts;
216
216
  cwd = args.cwd || process.cwd();
217
217
  file = args.file ? path__default["default"].resolve(cwd, args.file) : undefined;
218
- _tmp = {};
219
- cliArgs = (_tmp.dts = dts, _tmp.file = file, _tmp.format = format, _tmp.cwd = cwd, _tmp.target = target, _tmp.runtime = runtime, _tmp.external = args.external || [], _tmp.watch = !!watch, _tmp.minify = !!minify, _tmp.sourcemap = sourcemap === false ? false : true, _tmp);
218
+ cliArgs = {
219
+ dts: dts,
220
+ file: file,
221
+ format: format,
222
+ cwd: cwd,
223
+ target: target,
224
+ runtime: runtime,
225
+ external: args.external || [],
226
+ watch: !!watch,
227
+ minify: !!minify,
228
+ sourcemap: sourcemap === false ? false : true
229
+ };
220
230
  if (args.version) {
221
231
  return [
222
232
  2,
package/dist/lib.js CHANGED
@@ -7,7 +7,7 @@ var rollupPluginSwc3 = require('rollup-plugin-swc3');
7
7
  var commonjs = require('@rollup/plugin-commonjs');
8
8
  var shebang = require('rollup-plugin-preserve-shebang');
9
9
  var json = require('@rollup/plugin-json');
10
- var nodeResolve = require('@rollup/plugin-node-resolve');
10
+ var pluginNodeResolve = require('@rollup/plugin-node-resolve');
11
11
  var module$1 = require('module');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -17,7 +17,6 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
17
17
  var commonjs__default = /*#__PURE__*/_interopDefaultLegacy(commonjs);
18
18
  var shebang__default = /*#__PURE__*/_interopDefaultLegacy(shebang);
19
19
  var json__default = /*#__PURE__*/_interopDefaultLegacy(json);
20
- var nodeResolve__default = /*#__PURE__*/_interopDefaultLegacy(nodeResolve);
21
20
 
22
21
  var rootDir = process.cwd();
23
22
  var config = {
@@ -255,9 +254,9 @@ function buildInputConfig(entry, pkg, options, param) {
255
254
  incremental: false,
256
255
  jsx: (tsCompilerOptions == null ? void 0 : tsCompilerOptions.jsx) || "react"
257
256
  })
258
- }),
257
+ })
259
258
  ] : [
260
- nodeResolve__default["default"]({
259
+ pluginNodeResolve.nodeResolve({
261
260
  preferBuiltins: runtime === "node",
262
261
  extensions: [
263
262
  ".mjs",
@@ -290,7 +289,7 @@ function buildInputConfig(entry, pkg, options, param) {
290
289
  }),
291
290
  sourceMaps: options.sourcemap,
292
291
  inlineSourcesContent: false
293
- }),
292
+ })
294
293
  ]).filter(isNotNull);
295
294
  return {
296
295
  input: entry,
@@ -334,7 +333,7 @@ function buildOutputConfigs(options, pkg, param) {
334
333
  var dtsDir = typings ? path.dirname(path.resolve(config.rootDir, typings)) : path.resolve(config.rootDir, "dist");
335
334
  // file base name without extension
336
335
  var name = file ? file.replace(new RegExp("" + path.extname(file) + "$"), "") : undefined;
337
- var dtsFile = file ? name + ".d.ts" : (exportCondition == null ? void 0 : exportCondition.name) ? path.resolve(dtsDir, (exportCondition.name === "." ? "index" : exportCondition.name) + ".d.ts") : typings;
336
+ var dtsFile = file ? name + ".d.ts" : (exportCondition == null ? void 0 : exportCondition.name) ? path.resolve(dtsDir, (exportCondition.name === "." ? "index" : exportCondition.name) + ".d.ts") : typings && path.resolve(config.rootDir, typings);
338
337
  // If there's dts file, use `output.file`
339
338
  var dtsPathConfig = dtsFile ? {
340
339
  file: dtsFile
@@ -388,7 +387,7 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
388
387
  buildOutputConfigs(_extends$1({}, cliArgs, {
389
388
  format: "es",
390
389
  useTypescript: useTypescript
391
- }), pkg, typescriptOptions),
390
+ }), pkg, typescriptOptions)
392
391
  ];
393
392
  } else {
394
393
  // multi outputs with specified format
@@ -408,7 +407,7 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
408
407
  file: file,
409
408
  format: cliArgs.format || fallbackFormat,
410
409
  useTypescript: useTypescript
411
- }), pkg, typescriptOptions),
410
+ }), pkg, typescriptOptions)
412
411
  ];
413
412
  }
414
413
  }
@@ -475,6 +474,24 @@ function _objectWithoutPropertiesLoose(source, excluded) {
475
474
  }
476
475
  return target;
477
476
  }
477
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
478
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
479
+ if (it) return (it = it.call(o)).next.bind(it);
480
+ if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
481
+ if (it) o = it;
482
+ var i = 0;
483
+ return function() {
484
+ if (i >= o.length) return {
485
+ done: true
486
+ };
487
+ return {
488
+ done: false,
489
+ value: o[i++]
490
+ };
491
+ };
492
+ }
493
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
494
+ }
478
495
  var __generator = undefined && undefined.__generator || function(thisArg, body) {
479
496
  var f, y, t, g, _ = {
480
497
  label: 0,
@@ -589,8 +606,8 @@ function getSourcePathFromExportPath(cwd, exportPath) {
589
606
  "ts",
590
607
  "tsx"
591
608
  ];
592
- for(var _i = 0; _i < exts.length; _i++){
593
- var ext = exts[_i];
609
+ for(var _iterator = _createForOfIteratorHelperLoose(exts), _step; !(_step = _iterator()).done;){
610
+ var ext = _step.value;
594
611
  // ignore package.json
595
612
  if (exportPath.endsWith("package.json")) return;
596
613
  if (exportPath === ".") exportPath = "./index";
@@ -606,7 +623,7 @@ function bundle(entryPath) {
606
623
  }
607
624
  function _bundle() {
608
625
  _bundle = _asyncToGenerator(function(entryPath, _param) {
609
- var cwd, options, pkg, packageExports, _tmp, isSingleEntry, hasMultiEntries, bundleOrWatch, hasSpecifiedEntryFile, err, hasTypings, _tmp1, assetsJobs, typesJobs, rollupConfig;
626
+ var cwd, options, pkg, packageExports, isSingleEntry, hasMultiEntries, bundleOrWatch, hasSpecifiedEntryFile, err, hasTypings, assetsJobs, typesJobs, rollupConfig;
610
627
  function buildEntryConfig(packageExports, dtsOnly) {
611
628
  var configs = Object.keys(packageExports).map(function(entryExport) {
612
629
  var source = getSourcePathFromExportPath(config.rootDir, entryExport);
@@ -640,8 +657,7 @@ function _bundle() {
640
657
  options.dts = true;
641
658
  }
642
659
  pkg = getPackageMeta(config.rootDir);
643
- _tmp = {};
644
- packageExports = pkg.exports || _tmp;
660
+ packageExports = pkg.exports || {};
645
661
  isSingleEntry = typeof packageExports === "string";
646
662
  hasMultiEntries = packageExports && !isSingleEntry && Object.keys(packageExports).length > 0;
647
663
  if (isSingleEntry) {
@@ -673,8 +689,7 @@ function _bundle() {
673
689
  Promise.reject(err)
674
690
  ];
675
691
  }
676
- _tmp1 = {};
677
- hasTypings = !!getTypings(pkg) || typeof packageExports === "object" && Array.from(Object.values(packageExports || _tmp1)).some(function(condition) {
692
+ hasTypings = !!getTypings(pkg) || typeof packageExports === "object" && Array.from(Object.values(packageExports || {})).some(function(condition) {
678
693
  return condition.hasOwnProperty("types");
679
694
  });
680
695
  // If there's no entry file specified, should enable dts bundling based on package.json exports info
@@ -740,7 +755,7 @@ function runWatch(param, metadata) {
740
755
  "node_modules/**"
741
756
  ]
742
757
  }
743
- }),
758
+ })
744
759
  ];
745
760
  var watcher = rollup.watch(watchOptions);
746
761
  var startTime = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": {
6
6
  "bunchee": "./dist/cli.js"
@@ -40,11 +40,11 @@
40
40
  "dependencies": {
41
41
  "@rollup/plugin-commonjs": "22.0.2",
42
42
  "@rollup/plugin-json": "4.1.0",
43
- "@rollup/plugin-node-resolve": "13.3.0",
44
- "@swc/core": "^1.3.0",
43
+ "@rollup/plugin-node-resolve": "14.1.0",
44
+ "@swc/core": "^1.3.5",
45
45
  "arg": "5.0.0",
46
- "rollup": "2.74.1",
47
- "rollup-plugin-dts": "4.2.2",
46
+ "rollup": "2.79.1",
47
+ "rollup-plugin-dts": "4.2.3",
48
48
  "rollup-plugin-preserve-shebang": "1.0.1",
49
49
  "rollup-plugin-swc3": "0.6.0",
50
50
  "tslib": "2.4.0"