@@ -61,6 +61,9 @@ process.chdir(path.dirname(json));
6161const mjPath = path . relative ( process . cwd ( ) , path . resolve ( __dirname , '..' , '..' , target ) ) ;
6262const mjGlobal = path . join ( '..' , mjPath , 'components' , 'global.js' ) ;
6363
64+ /**
65+ * Determine the module type
66+ */
6467function getType ( ) {
6568 const component = config . component || 'part' ;
6669 if ( component . match ( / \/ ( s v g | c h t m l | c o m m o n ) \/ f o n t s \/ / ) ) return RegExp . $1 + '-font' ;
@@ -69,6 +72,13 @@ function getType() {
6972 return component ;
7073}
7174
75+ /**
76+ * Convert Windows paths to unix paths
77+ */
78+ const normalize = process . platform === 'win32'
79+ ? ( file ) => file . replace ( / \\ / g, '/' )
80+ : ( file ) => file ;
81+
7282/**
7383 * Extract the configuration values
7484 */
@@ -100,7 +110,7 @@ let PACKAGE = [];
100110 */
101111function processList ( base , dir , list , top = true ) {
102112 for ( const item of list ) {
103- const file = path . join ( dir , item ) ;
113+ const file = normalize ( path . join ( dir , item ) ) ;
104114 if ( ! EXCLUDE . has ( file ) ) {
105115 const stat = fs . statSync ( path . resolve ( base , file ) ) ;
106116 if ( stat . isDirectory ( ) ) {
@@ -183,9 +193,9 @@ function processParts(parts) {
183193function processLines ( file , objects ) {
184194 if ( objects . length === 0 ) return [ ] ;
185195 const base = path . dirname ( file ) . replace ( / ^ \. $ / , '' ) ;
186- const dir = ( PREFIX ? path . join ( PREFIX , base ) : base ) ;
196+ const dir = ( PREFIX ? normalize ( path . join ( PREFIX , base ) ) : base ) ;
187197 const dots = dir . replace ( / [ ^ \/ ] + / g, '..' ) || '.' ;
188- const relative = path . join ( dots , '..' , JS , dir , path . basename ( file ) ) . replace ( / \. t s $ / , '.js' ) ;
198+ const relative = normalize ( path . join ( dots , '..' , JS , dir , path . basename ( file ) ) ) . replace ( / \. t s $ / , '.js' ) ;
189199 const name = path . parse ( file ) . name ;
190200 const lines = ( target === 'mjs' ? [ ] : [
191201 '"use strict";' ,
@@ -254,7 +264,7 @@ function getExtraDirectories() {
254264 let prefix = '' ;
255265 let indent = INDENT ;
256266 let postfix = '' ;
257- for ( let name of PREFIX . split ( / \/ / ) ) {
267+ for ( let name of PREFIX . split ( '/' ) ) {
258268 if ( name . match ( / [ ^ a - z A - Z 0 - 9 ] / ) ) {
259269 name = `"${ name } "` ;
260270 }
@@ -271,19 +281,19 @@ function getExtraDirectories() {
271281function processGlobal ( ) {
272282 console . info ( ' ' + COMPONENT + '.ts' ) ;
273283 const lines = ( target === 'cjs' ? [
274- `const {combineWithMathJax} = require('${ GLOBAL } ')` ,
275- `const {VERSION} = require('${ VERSION } ');` ,
284+ `const {combineWithMathJax} = require('${ normalize ( GLOBAL ) } ')` ,
285+ `const {VERSION} = require('${ normalize ( VERSION ) } ');` ,
276286 '' ,
277287 ] : [
278- `import {combineWithMathJax} from '${ GLOBAL } ';` ,
279- `import {VERSION} from '${ VERSION } ';` ,
288+ `import {combineWithMathJax} from '${ normalize ( GLOBAL ) } ';` ,
289+ `import {VERSION} from '${ normalize ( VERSION ) } ';` ,
280290 '' ,
281291 ] ) ;
282292 const [ prefix , indent , postfix ] = getExtraDirectories ( ) ;
283293 const packages = [ ] ;
284294 PACKAGE = PACKAGE . sort ( sortDir ) ;
285295 while ( PACKAGE . length ) {
286- const dir = path . dirname ( PACKAGE [ 0 ] ) . split ( path . sep ) [ 0 ] ;
296+ const dir = path . dirname ( PACKAGE [ 0 ] ) . split ( '/' ) [ 0 ] ;
287297 packages . push ( processPackage ( lines , indent , dir ) ) ;
288298 }
289299 const name = ( ID . match ( / [ ^ a - z A - Z 0 - 9 _ ] / ) ? `"${ ID } "` : ID ) ;
@@ -337,7 +347,7 @@ function processPackage(lines, space, dir) {
337347 if ( path . dirname ( PACKAGE [ 0 ] ) === dir ) {
338348 const file = PACKAGE . shift ( ) ;
339349 const name = path . basename ( file ) ;
340- let relativefile = path . join ( '..' , JS , dir , name ) . replace ( / \. t s $ / , '.js' )
350+ const relativefile = normalize ( path . join ( '..' , JS , dir , name ) . replace ( / \. t s $ / , '.js' ) ) ;
341351 const component = 'module' + ( ++ importCount ) ;
342352 lines . push (
343353 target === 'cjs' ?
0 commit comments