@@ -11,36 +11,36 @@ export function babelTransform(options: CompileOptions = {}) {
11
11
const rootDirsRelative = [ ...new Set ( getRootsFolderName ( options . entry ) ) ] ;
12
12
const entry = rootDirsRelative . map ( ( item ) => path . resolve ( item ) ) ;
13
13
const onFilesChange : CopyFilesOptions [ 'onFilesChange' ] = ( eventName , filepath , stats ) => {
14
- if ( / \. ( m ? j s | j s x ? | m ? t s | t s x ? | c ? j s ) $ / i . test ( filepath ) ) {
15
- const log = new Log ( ) . name ( ) ;
16
- const dt = getOutputPath ( filepath , options ) ;
17
- if ( / ^ ( a d d | c h a n g e ) $ / . test ( eventName ) && ! / \. d \. t s $ / i . test ( filepath ) ) {
14
+ const log = new Log ( ) . name ( ) ;
15
+ const dt = getOutputPath ( filepath , options ) ;
16
+ if ( / \. ( m ? t s | m ? j s | j s x ? | t s x ? | c ? j s ) (?< ! \. d \. t s ) $ / i . test ( filepath ) ) {
17
+ if ( / ^ ( a d d | c h a n g e ) $ / . test ( eventName ) ) {
18
18
babelCompile ( filepath , { ...options } ) ;
19
- } else if ( / \. d \. t s $ / i. test ( filepath ) ) {
20
- if ( typeof cjs !== 'boolean' ) {
21
- fs . ensureDirSync ( path . dirname ( dt . cjs . path ) ) ;
22
- fs . copyFile ( filepath , dt . cjs . path ) ;
23
- log
24
- . icon ( '🐶' )
25
- . success (
26
- `${ getExt ( filepath ) } ┈┈▶ \x1b[32;1m${ dt . folderFilePath } \x1b[0m => \x1b[34;1m${ dt . cjs . tsFileName } \x1b[0m` ,
27
- ) ;
28
- }
29
- if ( typeof esm !== 'boolean' ) {
30
- fs . ensureDirSync ( path . dirname ( dt . esm . path ) ) ;
31
- fs . copyFile ( filepath , dt . esm . path ) ;
32
- log
33
- . icon ( '🐶' )
34
- . success (
35
- `${ getExt ( filepath ) } ┈┈▶ \x1b[32;1m${ dt . folderFilePath } \x1b[0m => \x1b[34;1m${ dt . esm . tsFileName } \x1b[0m` ,
36
- ) ;
37
- }
38
19
}
39
- if ( / ^ ( u n l i n k | u n l i n k D i r ) $ / . test ( eventName ) ) {
40
- fs . remove ( dt . cjs . path ) ;
41
- fs . remove ( dt . esm . path ) ;
42
- log . icon ( '🗑️' ) . success ( `┈┈▶ \x1b[32;1m${ path . relative ( process . cwd ( ) , filepath ) } \x1b[0m` ) ;
20
+ } else if ( / ^ ( a d d | c h a n g e ) $ / . test ( eventName ) ) {
21
+ if ( typeof cjs !== 'boolean' ) {
22
+ fs . ensureDirSync ( path . dirname ( dt . cjs . path ) ) ;
23
+ fs . copyFile ( filepath , dt . cjs . path ) ;
24
+ log
25
+ . icon ( '🐶' )
26
+ . success (
27
+ `${ getExt ( filepath ) } ┈┈▶ \x1b[32;1m${ dt . folderFilePath } \x1b[0m => \x1b[34;1m${ dt . cjs . tsFileName } \x1b[0m` ,
28
+ ) ;
43
29
}
30
+ if ( typeof esm !== 'boolean' ) {
31
+ fs . ensureDirSync ( path . dirname ( dt . esm . path ) ) ;
32
+ fs . copyFile ( filepath , dt . esm . path ) ;
33
+ log
34
+ . icon ( '🐶' )
35
+ . success (
36
+ `${ getExt ( filepath ) } ┈┈▶ \x1b[32;1m${ dt . folderFilePath } \x1b[0m => \x1b[34;1m${ dt . esm . tsFileName } \x1b[0m` ,
37
+ ) ;
38
+ }
39
+ }
40
+ if ( / ^ ( u n l i n k | u n l i n k D i r ) $ / . test ( eventName ) ) {
41
+ fs . remove ( dt . cjs . path ) ;
42
+ fs . remove ( dt . esm . path ) ;
43
+ log . icon ( '🗑️' ) . success ( `┈┈▶ \x1b[32;1m${ path . relative ( process . cwd ( ) , filepath ) } \x1b[0m` ) ;
44
44
}
45
45
} ;
46
46
const onReady = ( ) => {
0 commit comments