File tree 2 files changed +15
-9
lines changed
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -365,12 +365,15 @@ export class Bundler {
365
365
}
366
366
} )
367
367
368
+ const isESM = / ^ e s m ? $ / . test ( format )
369
+
368
370
const fileName =
369
- format === 'cjs'
370
- ? `[name][min].js`
371
- : format === 'esm'
372
- ? `[name][min].mjs`
373
- : `[name].[format][min].js`
371
+ config . output . fileName ||
372
+ ( format === 'cjs' || isESM
373
+ ? `[name][min][ext]`
374
+ : `[name].[format][min][ext]` )
375
+
376
+ const extPlaceholder = isESM ? '.mjs' : '.js'
374
377
375
378
return {
376
379
inputConfig : {
@@ -402,7 +405,9 @@ export class Bundler {
402
405
globals : config . globals ,
403
406
format : rollupFormat ,
404
407
dir : path . resolve ( config . output . dir || 'dist' ) ,
405
- entryFileNames : fileName . replace ( / \[ m i n \] / , minPlaceholder ) ,
408
+ entryFileNames : fileName
409
+ . replace ( / \[ m i n \] / , minPlaceholder )
410
+ . replace ( / \[ e x t \] / , extPlaceholder ) ,
406
411
name : config . output . moduleName ,
407
412
banner
408
413
}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Banner } from './utils/get-banner'
5
5
export type Format =
6
6
| RollupFormat
7
7
| 'cjs-min'
8
+ | 'es-min'
8
9
| 'esm-min'
9
10
| 'umd-min'
10
11
| 'iife-min'
@@ -79,13 +80,13 @@ export interface ConfigOutput {
79
80
* Output file name
80
81
*
81
82
* Default value:
82
- * - `[name][min].js` in `cjs` format
83
- * - `[name][min].mjs` in `esm` format
84
- * - `[name][min].[format].js` in `umd` and `iife` formats.
83
+ * - `[name][min][ext]` in `cjs` and `esm` format.
84
+ * - `[name][min].[format].js` in other formats.
85
85
*
86
86
* Placeholders:
87
87
* - `[name]`: The base name of input file. (without extension)
88
88
* - `[format]`: The output format. (without `-min` suffix)
89
+ * - `[ext]`: The extension. It's `.mjs` for `esm` format, `.js` otherwise
89
90
* - `[min]`: It will replaced by `.min` when the format ends with `-min`, otherwise it's an empty string.
90
91
* @cli `--file-name <fileName>`
91
92
*/
You can’t perform that action at this time.
0 commit comments