11const fse = require ( 'fs-extra' ) ;
2- const { globSync } = require ( 'glob' ) ;
32const path = require ( 'path' ) ;
43const { default : getDynamicModuleMap } = require ( '../../scripts/parse-dynamic-modules.mjs' ) ;
4+ const { toPosixPath, posixGlobSync, posixRelative } = require ( './utils' ) ;
55
6- const root = process . cwd ( ) ;
6+ const root = toPosixPath ( process . cwd ( ) ) ;
77
8- const sourceFiles = globSync ( `${ root } /src/*/` )
8+ const sourceFiles = posixGlobSync ( `${ root } /src/*/` )
99 . map ( ( name ) => name . replace ( / \/ $ / , '' ) ) ;
10-
11- const indexTypings = globSync ( `${ root } /src/index.d.ts` ) ;
10+
11+ const indexTypings = posixGlobSync ( `${ root } /src/index.d.ts` ) ;
1212
1313const ENV_AGNOSTIC_ROOT = `${ root } /dist/dynamic`
1414
@@ -23,9 +23,9 @@ async function copyTypings(files, dest) {
2323
2424async function createPackage ( file ) {
2525 const fileName = file . split ( '/' ) . pop ( ) ;
26- const esmSource = globSync ( `${ root } /dist/esm/${ fileName } /**/index.js` ) [ 0 ] ;
27- const cjsSource = globSync ( `${ root } /dist/cjs/${ fileName } /**/index.js` ) [ 0 ] ;
28- const typingsSource = globSync ( `${ root } /dist/esm/${ fileName } /**/index.d.ts` ) [ 0 ]
26+ const esmSource = posixGlobSync ( `${ root } /dist/esm/${ fileName } /**/index.js` ) [ 0 ] ;
27+ const cjsSource = posixGlobSync ( `${ root } /dist/cjs/${ fileName } /**/index.js` ) [ 0 ] ;
28+ const typingsSource = posixGlobSync ( `${ root } /dist/esm/${ fileName } /**/index.d.ts` ) [ 0 ]
2929 /**
3030 * Prevent creating package.json for directories with no JS files (like CSS directories)
3131 */
@@ -39,14 +39,14 @@ async function createPackage(file) {
3939 // ensure the directory exists
4040 fse . ensureDirSync ( destDir )
4141
42- const esmRelative = path . relative ( file , esmSource ) . replace ( '/dist' , '' ) ;
43- const cjsRelative = path . relative ( file , cjsSource ) . replace ( '/dist' , '' ) ;
44- const tsRelative = path . relative ( file , typingsSource ) . replace ( '/dist' , '' )
42+ const esmRelative = posixRelative ( file , esmSource ) . replace ( '/dist' , '' ) ;
43+ const cjsRelative = posixRelative ( file , cjsSource ) . replace ( '/dist' , '' ) ;
44+ const tsRelative = posixRelative ( file , typingsSource ) . replace ( '/dist' , '' )
4545 const content = {
4646 main : cjsRelative ,
4747 module : esmRelative ,
4848 } ;
49- const typings = globSync ( `${ root } /src/${ fileName } /*.d.ts` ) ;
49+ const typings = posixGlobSync ( `${ root } /src/${ fileName } /*.d.ts` ) ;
5050 const cmds = [ ] ;
5151 content . typings = tsRelative ;
5252 cmds . push ( copyTypings ( typings , `${ root } /dist/${ fileName } ` ) ) ;
0 commit comments