File tree Expand file tree Collapse file tree 4 files changed +35
-7
lines changed
js/src/utils/package-json
rollup/src/plugins/with-nx Expand file tree Collapse file tree 4 files changed +35
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { globSync } from 'tinyglobby' ;
2
- import { logger } from '@nx/devkit' ;
2
+ import { logger , normalizePath } from '@nx/devkit' ;
3
3
4
4
export function createEntryPoints (
5
5
additionalEntryPoints : undefined | string [ ] ,
@@ -13,12 +13,13 @@ export function createEntryPoints(
13
13
// Performance impact should be negligible since there shouldn't be that many entry points.
14
14
// Benchmarks show only 1-3% difference in execution time.
15
15
for ( const pattern of additionalEntryPoints ) {
16
- const matched = globSync ( [ pattern ] , {
16
+ const normalizedPattern = normalizePath ( pattern ) ;
17
+ const matched = globSync ( [ normalizedPattern ] , {
17
18
cwd : root ,
18
19
expandDirectories : false ,
19
20
} ) ;
20
21
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.` ) ;
22
23
files . push ( ...matched ) ;
23
24
}
24
25
return files ;
Original file line number Diff line number Diff line change @@ -83,4 +83,28 @@ describe('normalizeOptions', () => {
83
83
tsConfig : 'pkg/tsconfig.json' ,
84
84
} ) ;
85
85
} ) ;
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
+ } ) ;
86
110
} ) ;
Original file line number Diff line number Diff line change @@ -98,11 +98,11 @@ function normalizeRelativePaths(
98
98
) : void {
99
99
for ( const [ fieldName , fieldValue ] of Object . entries ( options ) ) {
100
100
if ( isRelativePath ( fieldValue ) ) {
101
- options [ fieldName ] = join ( projectRoot , fieldValue ) ;
101
+ options [ fieldName ] = normalizePath ( join ( projectRoot , fieldValue ) ) ;
102
102
} else if ( Array . isArray ( fieldValue ) ) {
103
103
for ( let i = 0 ; i < fieldValue . length ; i ++ ) {
104
104
if ( isRelativePath ( fieldValue [ i ] ) ) {
105
- fieldValue [ i ] = join ( projectRoot , fieldValue [ i ] ) ;
105
+ fieldValue [ i ] = normalizePath ( join ( projectRoot , fieldValue [ i ] ) ) ;
106
106
}
107
107
}
108
108
}
Original file line number Diff line number Diff line change 1
1
import {
2
2
logger ,
3
+ normalizePath ,
3
4
type ProjectGraph ,
4
5
readCachedProjectGraph ,
5
6
readJsonFile ,
@@ -353,9 +354,11 @@ function createInput(
353
354
if ( global . NX_GRAPH_CREATION ) return { } ;
354
355
const mainEntryFileName = options . outputFileName || options . main ;
355
356
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
+ ) ;
357
360
options . additionalEntryPoints ?. forEach ( ( entry ) => {
358
- input [ parse ( entry ) . name ] = join ( workspaceRoot , entry ) ;
361
+ input [ parse ( entry ) . name ] = normalizePath ( join ( workspaceRoot , entry ) ) ;
359
362
} ) ;
360
363
return input ;
361
364
}
You can’t perform that action at this time.
0 commit comments