File tree Expand file tree Collapse file tree
js/src/utils/package-json
rollup/src/plugins/with-nx Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { globSync } from 'tinyglobby' ;
2- import { logger } from '@nx/devkit' ;
2+ import { logger , normalizePath } from '@nx/devkit' ;
33
44export function createEntryPoints (
55 additionalEntryPoints : undefined | string [ ] ,
@@ -13,12 +13,13 @@ export function createEntryPoints(
1313 // Performance impact should be negligible since there shouldn't be that many entry points.
1414 // Benchmarks show only 1-3% difference in execution time.
1515 for ( const pattern of additionalEntryPoints ) {
16- const matched = globSync ( [ pattern ] , {
16+ const normalizedPattern = normalizePath ( pattern ) ;
17+ const matched = globSync ( [ normalizedPattern ] , {
1718 cwd : root ,
1819 expandDirectories : false ,
1920 } ) ;
2021 if ( ! matched . length )
21- logger . warn ( `The pattern ${ pattern } did not match any files.` ) ;
22+ logger . warn ( `The pattern ${ normalizedPattern } did not match any files.` ) ;
2223 files . push ( ...matched ) ;
2324 }
2425 return files ;
Original file line number Diff line number Diff line change @@ -83,4 +83,28 @@ describe('normalizeOptions', () => {
8383 tsConfig : 'pkg/tsconfig.json' ,
8484 } ) ;
8585 } ) ;
86+
87+ describe ( 'Windows path handling' , ( ) => {
88+ it ( 'should normalize Windows paths for additionalEntryPoints' , ( ) => {
89+ const windowsPath = './src\\entrypoints\\*.ts' ;
90+ const options = {
91+ main : './src/main.ts' ,
92+ additionalEntryPoints : [ windowsPath ] ,
93+ outputPath : '../dist/test-lib' ,
94+ tsConfig : './tsconfig.json' ,
95+ } ;
96+
97+ const result = normalizeOptions (
98+ 'libs/test-lib' ,
99+ 'libs/test-lib/src' ,
100+ options
101+ ) ;
102+
103+ expect ( result . additionalEntryPoints ) . toBeDefined ( ) ;
104+ result . additionalEntryPoints . forEach ( ( entry ) => {
105+ expect ( entry ) . not . toContain ( '\\' ) ;
106+ expect ( entry ) . toMatch ( / ^ l i b s \/ t e s t - l i b \/ s r c \/ e n t r y p o i n t s \/ \* \. t s $ / ) ;
107+ } ) ;
108+ } ) ;
109+ } ) ;
86110} ) ;
Original file line number Diff line number Diff line change @@ -98,11 +98,11 @@ function normalizeRelativePaths(
9898) : void {
9999 for ( const [ fieldName , fieldValue ] of Object . entries ( options ) ) {
100100 if ( isRelativePath ( fieldValue ) ) {
101- options [ fieldName ] = join ( projectRoot , fieldValue ) ;
101+ options [ fieldName ] = normalizePath ( join ( projectRoot , fieldValue ) ) ;
102102 } else if ( Array . isArray ( fieldValue ) ) {
103103 for ( let i = 0 ; i < fieldValue . length ; i ++ ) {
104104 if ( isRelativePath ( fieldValue [ i ] ) ) {
105- fieldValue [ i ] = join ( projectRoot , fieldValue [ i ] ) ;
105+ fieldValue [ i ] = normalizePath ( join ( projectRoot , fieldValue [ i ] ) ) ;
106106 }
107107 }
108108 }
Original file line number Diff line number Diff line change 11import {
22 logger ,
3+ normalizePath ,
34 type ProjectGraph ,
45 readCachedProjectGraph ,
56 readJsonFile ,
@@ -353,9 +354,11 @@ function createInput(
353354 if ( global . NX_GRAPH_CREATION ) return { } ;
354355 const mainEntryFileName = options . outputFileName || options . main ;
355356 const input : Record < string , string > = { } ;
356- input [ parse ( mainEntryFileName ) . name ] = join ( workspaceRoot , options . main ) ;
357+ input [ parse ( mainEntryFileName ) . name ] = normalizePath (
358+ join ( workspaceRoot , options . main )
359+ ) ;
357360 options . additionalEntryPoints ?. forEach ( ( entry ) => {
358- input [ parse ( entry ) . name ] = join ( workspaceRoot , entry ) ;
361+ input [ parse ( entry ) . name ] = normalizePath ( join ( workspaceRoot , entry ) ) ;
359362 } ) ;
360363 return input ;
361364}
You can’t perform that action at this time.
0 commit comments