@@ -23,29 +23,28 @@ export async function compile(
23
23
const dirToFiles = await recursiveReaddirFiles ( path . dirname ( entry ) , {
24
24
exclude : / ( t s c o n f i g .j s o n | .( t e s t | s p e c ) .( t s | t s x | j s | j s x ) ) $ / ,
25
25
} ) ;
26
- await Promise . all (
27
- dirToFiles . map ( async ( item ) => {
28
- if ( disableBabel ) {
29
- return ;
30
- }
31
- if ( cjs ) {
32
- const cjsPath = item . path . replace ( entryDir , cjs ) ;
33
- if ( isMatch ( item . path , [ '**/*.[jt]s?(x)' ] ) && ! isMatch ( item . path , [ '**/?(*.)+(spec|test).[jt]s?(x)' , '**/*.d.ts' ] ) ) {
34
- transform ( item . path , { entryDir, cjs, ...other } ) ;
35
- } else {
36
- copyFiles ( item . path , cjsPath ) ;
26
+ if ( ! disableBabel ) {
27
+ await Promise . all (
28
+ dirToFiles . map ( async ( item ) => {
29
+ if ( cjs ) {
30
+ const cjsPath = item . path . replace ( entryDir , cjs ) ;
31
+ if ( isMatch ( item . path , [ '**/*.[jt]s?(x)' ] ) && ! isMatch ( item . path , [ '**/?(*.)+(spec|test).[jt]s?(x)' ] ) ) {
32
+ transform ( item . path , { entryDir, cjs, ...other } ) ;
33
+ } else {
34
+ copyFiles ( item . path , cjsPath ) ;
35
+ }
37
36
}
38
- }
39
- if ( esm ) {
40
- const esmPath = item . path . replace ( entryDir , esm ) ;
41
- if ( isMatch ( item . path , [ '**/*.[jt]s?(x)' ] ) && ! isMatch ( item . path , [ '**/?(*.)+(spec|test).[jt]s?(x)' , '**/*.d.ts' ] ) ) {
42
- transform ( item . path , { entryDir , esm , ... other } ) ;
43
- } else {
44
- copyFiles ( item . path , esmPath ) ;
37
+ if ( esm ) {
38
+ const esmPath = item . path . replace ( entryDir , esm ) ;
39
+ if ( isMatch ( item . path , [ '**/*.[jt]s?(x)' ] ) && ! isMatch ( item . path , [ '**/?(*.)+(spec|test).[jt]s?(x)' ] ) ) {
40
+ transform ( item . path , { entryDir , esm , ... other } ) ;
41
+ } else {
42
+ copyFiles ( item . path , esmPath ) ;
43
+ }
45
44
}
46
- }
47
- } ) ,
48
- ) ;
45
+ } ) ,
46
+ ) ;
47
+ }
49
48
50
49
// Create a Program with an in-memory emit
51
50
const createdFiles : Record < string , string > = { } ;
@@ -57,11 +56,14 @@ export async function compile(
57
56
58
57
const host = ts . createCompilerHost ( tsOptions , true ) ;
59
58
// ts.getParsedCommandLineOfConfigFile('', tsOptions, host)
60
- const files : string [ ] = [ ] ;
61
59
host . readFile = ( file ) => {
62
60
const result = ts . sys . readFile ( file ) ;
63
61
if ( ! / n o d e _ m o d u l e s / . test ( file ) ) {
64
- files . push ( file ) ;
62
+ // const output = path.resolve(tsOptions.outDir || cjs, path.relative(entryDir, file));
63
+ // const outputLib = path.relative(process.cwd(), output);
64
+ // if (/.d.ts$/.test(outputLib)) {
65
+ // createdFiles[outputLib] = result;
66
+ // }
65
67
}
66
68
return result ;
67
69
} ;
0 commit comments