bunchee 5.5.0 → 5.6.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/README.md CHANGED
@@ -470,6 +470,20 @@ Bunchee offers a convenient watch mode for rebuilding your library whenever chan
470
470
  #### `target`
471
471
 
472
472
  If you specify `target` option in `tsconfig.json`, then you don't have to pass it again through CLI.
473
+ To target a range of browsers, you can use the `browserslist` field in `package.json`, bunchee will use it to determine the target browsers for the output bundle.
474
+
475
+ For example:
476
+
477
+ ```json
478
+ {
479
+ "browserslist": [
480
+ "last 1 version",
481
+ "> 1%",
482
+ "maintained node versions",
483
+ "not dead"
484
+ ]
485
+ }
486
+ ```
473
487
 
474
488
  #### Package lint
475
489
 
package/dist/bin/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  var path = require('path');
3
- var arg = require('arg');
3
+ var yargs = require('yargs');
4
+ var helpers = require('yargs/helpers');
4
5
  var perf_hooks = require('perf_hooks');
5
6
  var fs = require('fs');
6
7
  var fsp = require('fs/promises');
@@ -12,7 +13,7 @@ var prettyBytes = require('pretty-bytes');
12
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
14
 
14
15
  var path__default = /*#__PURE__*/_interopDefault(path);
15
- var arg__default = /*#__PURE__*/_interopDefault(arg);
16
+ var yargs__default = /*#__PURE__*/_interopDefault(yargs);
16
17
  var fs__default = /*#__PURE__*/_interopDefault(fs);
17
18
  var fsp__default = /*#__PURE__*/_interopDefault(fsp);
18
19
  var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
@@ -77,51 +78,58 @@ function getDefaultExportFromCjs (x) {
77
78
 
78
79
  var picocolors = {exports: {}};
79
80
 
80
- let tty = require$$0__default.default;
81
- let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
82
- let formatter = (open, close, replace = open)=>(input)=>{
83
- let string = "" + input;
84
- let index = string.indexOf(close, open.length);
85
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
86
- };
87
- let replaceClose = (string, close, replace, index)=>{
88
- let start = string.substring(0, index) + replace;
89
- let end = string.substring(index + close.length);
90
- let nextIndex = end.indexOf(close);
91
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
92
- };
93
- let createColors = (enabled = isColorSupported)=>({
94
- isColorSupported: enabled,
95
- reset: enabled ? (s)=>`\x1b[0m${s}\x1b[0m` : String,
96
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
97
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
98
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
99
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
100
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
101
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
102
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
103
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
104
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
105
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
106
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
107
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
108
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
109
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
110
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
111
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
112
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
113
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
114
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
115
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
116
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
117
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
118
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
119
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String
120
- });
121
- picocolors.exports = createColors();
122
- picocolors.exports.createColors = createColors;
81
+ var hasRequiredPicocolors;
123
82
 
124
- var picocolorsExports = picocolors.exports;
83
+ function requirePicocolors () {
84
+ if (hasRequiredPicocolors) return picocolors.exports;
85
+ hasRequiredPicocolors = 1;
86
+ let tty = require$$0__default.default;
87
+ let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
88
+ let formatter = (open, close, replace = open)=>(input)=>{
89
+ let string = "" + input;
90
+ let index = string.indexOf(close, open.length);
91
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
92
+ };
93
+ let replaceClose = (string, close, replace, index)=>{
94
+ let start = string.substring(0, index) + replace;
95
+ let end = string.substring(index + close.length);
96
+ let nextIndex = end.indexOf(close);
97
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
98
+ };
99
+ let createColors = (enabled = isColorSupported)=>({
100
+ isColorSupported: enabled,
101
+ reset: enabled ? (s)=>`\x1b[0m${s}\x1b[0m` : String,
102
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
103
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
104
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
105
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
106
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
107
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
108
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
109
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
110
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
111
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
112
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
113
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
114
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
115
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
116
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
117
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
118
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
119
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
120
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
121
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
122
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
123
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
124
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
125
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String
126
+ });
127
+ picocolors.exports = createColors();
128
+ picocolors.exports.createColors = createColors;
129
+ return picocolors.exports;
130
+ }
131
+
132
+ var picocolorsExports = /*@__PURE__*/ requirePicocolors();
125
133
  var pc = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
126
134
 
127
135
  const defaultColorFn = (text)=>text;
@@ -517,7 +525,7 @@ function lint$1(pkg) {
517
525
  }
518
526
  }
519
527
 
520
- var version = "5.5.0";
528
+ var version = "5.6.0";
521
529
 
522
530
  function relativify(path) {
523
531
  return path.startsWith('.') ? path : `./${path}`;
@@ -977,57 +985,90 @@ async function lint(cwd) {
977
985
  }
978
986
  await lint$1(await getPackageMeta(cwd));
979
987
  }
980
- function parseCliArgs(argv) {
981
- let args;
982
- args = arg__default.default({
983
- '--cwd': String,
984
- '--no-dts': Boolean,
985
- '--output': String,
986
- '--format': String,
987
- '--watch': Boolean,
988
- '--minify': Boolean,
989
- '--help': Boolean,
990
- '--version': Boolean,
991
- '--runtime': String,
992
- '--target': String,
993
- '--sourcemap': Boolean,
994
- '--env': String,
995
- '--external': String,
996
- '--no-external': Boolean,
997
- '--no-clean': Boolean,
998
- '--prepare': Boolean,
999
- '--tsconfig': String,
1000
- '--dts-bundle': Boolean,
1001
- '-h': '--help',
1002
- '-v': '--version',
1003
- '-w': '--watch',
1004
- '-o': '--output',
1005
- '-f': '--format',
1006
- '-m': '--minify'
1007
- }, {
1008
- permissive: true,
1009
- argv
1010
- });
988
+ async function parseCliArgs(argv) {
989
+ const args = await yargs__default.default(helpers.hideBin(argv)).option('cwd', {
990
+ type: 'string',
991
+ description: 'specify current working directory'
992
+ }).option('dts', {
993
+ coerce (arg) {
994
+ return arg === false ? false : undefined;
995
+ },
996
+ description: 'do not generate types'
997
+ }).option('clean', {
998
+ coerce (arg) {
999
+ return arg === false ? false : undefined;
1000
+ },
1001
+ description: 'do not clean dist folder before building'
1002
+ }).option('output', {
1003
+ type: 'string',
1004
+ alias: 'o',
1005
+ description: 'specify output filename'
1006
+ }).option('format', {
1007
+ type: 'string',
1008
+ alias: 'f',
1009
+ default: 'esm',
1010
+ description: 'type of output (esm, amd, cjs, iife, umd, system)'
1011
+ }).option('watch', {
1012
+ type: 'boolean',
1013
+ alias: 'w',
1014
+ description: 'watch src files changes'
1015
+ }).option('minify', {
1016
+ type: 'boolean',
1017
+ alias: 'm',
1018
+ description: 'compress output'
1019
+ }).option('help', {
1020
+ type: 'boolean',
1021
+ alias: 'h',
1022
+ description: 'output usage information'
1023
+ }).option('runtime', {
1024
+ type: 'string',
1025
+ default: 'browser',
1026
+ description: 'build runtime (nodejs, browser)'
1027
+ }).option('target', {
1028
+ type: 'string',
1029
+ description: 'js features target: swc target es versions'
1030
+ }).option('sourcemap', {
1031
+ type: 'boolean',
1032
+ default: false,
1033
+ description: 'enable sourcemap generation'
1034
+ }).option('env', {
1035
+ type: 'string',
1036
+ description: 'inlined process env variables, separate by comma'
1037
+ }).option('external', {
1038
+ coerce (arg) {
1039
+ return typeof arg === 'string' || typeof arg === 'boolean' ? arg : undefined;
1040
+ },
1041
+ description: 'specify an external dependency, separate by comma'
1042
+ }).option('prepare', {
1043
+ type: 'boolean',
1044
+ description: 'auto configure package.json exports for building'
1045
+ }).option('tsconfig', {
1046
+ type: 'string',
1047
+ description: 'path to tsconfig file'
1048
+ }).option('dts-bundle', {
1049
+ type: 'boolean',
1050
+ description: 'bundle type declaration files'
1051
+ }).version(version).help('help', 'output usage information').showHelpOnFail(true).parse();
1011
1052
  const source = args._[0];
1012
1053
  const parsedArgs = {
1013
1054
  source,
1014
- format: args['--format'],
1015
- file: args['--output'],
1016
- watch: args['--watch'],
1017
- minify: args['--minify'],
1018
- sourcemap: !!args['--sourcemap'],
1019
- cwd: args['--cwd'],
1020
- dts: args['--no-dts'] ? false : undefined,
1021
- dtsBundle: args['--dts-bundle'],
1022
- help: args['--help'],
1023
- version: args['--version'],
1024
- runtime: args['--runtime'],
1025
- target: args['--target'],
1026
- external: !!args['--no-external'] ? null : args['--external'],
1027
- clean: !args['--no-clean'],
1028
- env: args['--env'],
1029
- prepare: !!args['--prepare'],
1030
- tsconfig: args['--tsconfig']
1055
+ format: args['format'],
1056
+ file: args['output'],
1057
+ watch: args['watch'],
1058
+ minify: args['minify'],
1059
+ sourcemap: !!args['sourcemap'],
1060
+ cwd: args['cwd'],
1061
+ dts: args['dts'] === false ? false : undefined,
1062
+ dtsBundle: args['dts-bundle'],
1063
+ help: args['help'],
1064
+ runtime: args['runtime'],
1065
+ target: args['target'],
1066
+ // no-external is a boolean flag, turning external to `false`
1067
+ external: args['external'] === false ? null : args['external'],
1068
+ clean: args['clean'] !== false,
1069
+ env: args['env'],
1070
+ prepare: !!args['prepare'],
1071
+ tsconfig: args['tsconfig']
1031
1072
  };
1032
1073
  return parsedArgs;
1033
1074
  }
@@ -1053,12 +1094,6 @@ async function run(args) {
1053
1094
  clean,
1054
1095
  tsconfig
1055
1096
  };
1056
- if (args.version) {
1057
- return logger.log(version);
1058
- }
1059
- if (args.help) {
1060
- return help();
1061
- }
1062
1097
  if (args.prepare) {
1063
1098
  return await prepare(cwd);
1064
1099
  }
@@ -1066,10 +1101,16 @@ async function run(args) {
1066
1101
  // lint package
1067
1102
  await lint(cwd);
1068
1103
  const { default: ora } = await import('ora');
1069
- const oraInstance = ora({
1104
+ const oraInstance = process.stdout.isTTY ? ora({
1070
1105
  text: 'Building...\n\n',
1071
1106
  color: 'green'
1072
- });
1107
+ }) : {
1108
+ start: ()=>{},
1109
+ stop: ()=>{},
1110
+ clear: ()=>{},
1111
+ stopAndPersist: ()=>{},
1112
+ isSpinning: false
1113
+ };
1073
1114
  const spinner = {
1074
1115
  start: startSpinner,
1075
1116
  stop: stopSpinner
@@ -1149,12 +1190,12 @@ async function run(args) {
1149
1190
  async function main() {
1150
1191
  let params, error;
1151
1192
  try {
1152
- params = parseCliArgs(process.argv.slice(2));
1193
+ params = await parseCliArgs(process.argv);
1153
1194
  } catch (err) {
1154
1195
  error = err;
1155
1196
  }
1156
1197
  if (error || !params) {
1157
- if (!error) help();
1198
+ // if (!error) help()
1158
1199
  return exit(error);
1159
1200
  }
1160
1201
  await run(params);
package/dist/index.d.ts CHANGED
@@ -38,7 +38,9 @@ type PackageMetadata = {
38
38
  exports?: string | Record<string, ExportCondition>;
39
39
  types?: string;
40
40
  typings?: string;
41
+ browserslist?: BrowserslistConfig;
41
42
  };
43
+ type BrowserslistConfig = string | string[] | Record<string, string>;
42
44
 
43
45
  declare function bundle(cliEntryPath: string, { cwd: _cwd, ...options }?: BundleConfig): Promise<void>;
44
46
 
package/dist/index.js CHANGED
@@ -37,51 +37,58 @@ function getDefaultExportFromCjs (x) {
37
37
 
38
38
  var picocolors = {exports: {}};
39
39
 
40
- let tty = require$$0__default.default;
41
- let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
42
- let formatter = (open, close, replace = open)=>(input)=>{
43
- let string = "" + input;
44
- let index = string.indexOf(close, open.length);
45
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
46
- };
47
- let replaceClose = (string, close, replace, index)=>{
48
- let start = string.substring(0, index) + replace;
49
- let end = string.substring(index + close.length);
50
- let nextIndex = end.indexOf(close);
51
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
52
- };
53
- let createColors = (enabled = isColorSupported)=>({
54
- isColorSupported: enabled,
55
- reset: enabled ? (s)=>`\x1b[0m${s}\x1b[0m` : String,
56
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
57
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
58
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
59
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
60
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
61
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
62
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
63
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
64
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
65
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
66
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
67
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
68
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
69
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
70
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
71
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
72
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
73
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
74
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
75
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
76
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
77
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
78
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
79
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String
80
- });
81
- picocolors.exports = createColors();
82
- picocolors.exports.createColors = createColors;
40
+ var hasRequiredPicocolors;
41
+
42
+ function requirePicocolors () {
43
+ if (hasRequiredPicocolors) return picocolors.exports;
44
+ hasRequiredPicocolors = 1;
45
+ let tty = require$$0__default.default;
46
+ let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
47
+ let formatter = (open, close, replace = open)=>(input)=>{
48
+ let string = "" + input;
49
+ let index = string.indexOf(close, open.length);
50
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
51
+ };
52
+ let replaceClose = (string, close, replace, index)=>{
53
+ let start = string.substring(0, index) + replace;
54
+ let end = string.substring(index + close.length);
55
+ let nextIndex = end.indexOf(close);
56
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
57
+ };
58
+ let createColors = (enabled = isColorSupported)=>({
59
+ isColorSupported: enabled,
60
+ reset: enabled ? (s)=>`\x1b[0m${s}\x1b[0m` : String,
61
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
62
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
63
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
64
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
65
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
66
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
67
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
68
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
69
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
70
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
71
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
72
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
73
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
74
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
75
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
76
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
77
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
78
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
79
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
80
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
81
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
82
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
83
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
84
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String
85
+ });
86
+ picocolors.exports = createColors();
87
+ picocolors.exports.createColors = createColors;
88
+ return picocolors.exports;
89
+ }
83
90
 
84
- var picocolorsExports = picocolors.exports;
91
+ var picocolorsExports = /*@__PURE__*/ requirePicocolors();
85
92
  var pc = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
86
93
 
87
94
  const defaultColorFn = (text)=>text;
@@ -1309,7 +1316,7 @@ async function createDtsPlugin(tsCompilerOptions, tsConfigPath, respectExternal,
1309
1316
  const memoizeDtsPluginByKey = memoizeByKey(createDtsPlugin);
1310
1317
  async function buildInputConfig(entry, bundleConfig, exportCondition, buildContext, dts) {
1311
1318
  var _bundleConfig_file, _bundleConfig_file1;
1312
- const { entries, pkg, cwd, tsOptions: { tsConfigPath, tsCompilerOptions }, pluginContext } = buildContext;
1319
+ const { entries, pkg, cwd, tsOptions: { tsConfigPath, tsCompilerOptions }, browserslistConfig, pluginContext } = buildContext;
1313
1320
  const isBinEntry = isBinExportPath(exportCondition.name);
1314
1321
  const hasNoExternal = bundleConfig.external === null;
1315
1322
  var _bundleConfig_external;
@@ -1335,9 +1342,10 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
1335
1342
  exportDefaultFrom: true,
1336
1343
  decorators: true
1337
1344
  };
1345
+ const hasBrowserslistConfig = !!(browserslistConfig && !hasSpecifiedTsTarget);
1338
1346
  const swcOptions = {
1339
1347
  jsc: {
1340
- ...!hasSpecifiedTsTarget && {
1348
+ ...!hasSpecifiedTsTarget && !hasBrowserslistConfig && {
1341
1349
  target: jscTarget
1342
1350
  },
1343
1351
  loose: true,
@@ -1355,7 +1363,12 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
1355
1363
  },
1356
1364
  sourceMaps: bundleConfig.sourcemap,
1357
1365
  inlineSourcesContent: false,
1358
- isModule: true
1366
+ isModule: true,
1367
+ ...hasBrowserslistConfig && {
1368
+ env: {
1369
+ targets: browserslistConfig
1370
+ }
1371
+ }
1359
1372
  };
1360
1373
  const sizePlugin = pluginContext.outputState.plugin(cwd);
1361
1374
  // common plugins for both dts and ts assets that need to be processed
@@ -1816,6 +1829,10 @@ async function bundle(cliEntryPath, { cwd: _cwd, ...options } = {}) {
1816
1829
  await writeDefaultTsconfig(tsConfigPath);
1817
1830
  hasTsConfig = true;
1818
1831
  }
1832
+ let browserslistConfig;
1833
+ if (options.runtime === 'browser') {
1834
+ browserslistConfig = pkg.browserslist;
1835
+ }
1819
1836
  const outputState = createOutputState({
1820
1837
  entries
1821
1838
  });
@@ -1825,6 +1842,7 @@ async function bundle(cliEntryPath, { cwd: _cwd, ...options } = {}) {
1825
1842
  cwd,
1826
1843
  tsOptions: defaultTsOptions,
1827
1844
  useTypeScript: hasTsConfig,
1845
+ browserslistConfig,
1828
1846
  pluginContext: {
1829
1847
  outputState,
1830
1848
  moduleDirectiveLayerMap: new Map()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "5.5.0",
3
+ "version": "5.6.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",
@@ -36,24 +36,24 @@
36
36
  },
37
37
  "license": "MIT",
38
38
  "dependencies": {
39
- "@rollup/plugin-commonjs": "^26.0.1",
39
+ "@rollup/plugin-commonjs": "^28.0.0",
40
40
  "@rollup/plugin-json": "^6.1.0",
41
41
  "@rollup/plugin-node-resolve": "^15.2.3",
42
- "@rollup/plugin-replace": "^5.0.7",
42
+ "@rollup/plugin-replace": "^6.0.1",
43
43
  "@rollup/plugin-wasm": "^6.2.2",
44
44
  "@rollup/pluginutils": "^5.1.0",
45
45
  "@swc/core": "^1.7.14",
46
46
  "@swc/helpers": "^0.5.11",
47
- "arg": "^5.0.2",
48
47
  "clean-css": "^5.3.3",
49
48
  "magic-string": "^0.30.11",
50
49
  "ora": "^8.0.1",
51
50
  "pretty-bytes": "^5.6.0",
52
- "rollup": "^4.19.2",
51
+ "rollup": "^4.24.0",
53
52
  "rollup-plugin-dts": "^6.1.1",
54
53
  "rollup-plugin-swc3": "^0.11.1",
55
- "rollup-preserve-directives": "^1.1.1",
56
- "tslib": "^2.6.2"
54
+ "rollup-preserve-directives": "^1.1.2",
55
+ "tslib": "^2.7.0",
56
+ "yargs": "^17.7.2"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "typescript": "^4.1 || ^5.0"
@@ -74,6 +74,7 @@
74
74
  "@types/clean-css": "^4.2.11",
75
75
  "@types/jest": "29.0.0",
76
76
  "@types/node": "^20.4.1",
77
+ "@types/yargs": "^17.0.33",
77
78
  "bunchee": "link:./",
78
79
  "cross-env": "^7.0.3",
79
80
  "husky": "^9.0.11",
@@ -82,7 +83,7 @@
82
83
  "picocolors": "^1.0.0",
83
84
  "prettier": "^3.0.0",
84
85
  "react": "^18.2.0",
85
- "typescript": "^5.5.2"
86
+ "typescript": "^5.6.2"
86
87
  },
87
88
  "lint-staged": {
88
89
  "*.{js,jsx,ts,tsx,md,json,yml,yaml}": "prettier --write"