@@ -11,6 +11,7 @@ import { getMimeType } from './lib/mimetypes.js';
11
11
import { debug , formatPath } from './lib/output-utils.js' ;
12
12
import { getPlugins } from './lib/plugins.js' ;
13
13
import { watch } from './lib/fs-watcher.js' ;
14
+ import { normalizePath } from '../index.js' ;
14
15
15
16
const NOOP = ( ) => { } ;
16
17
@@ -96,7 +97,7 @@ export default function wmrMiddleware(options) {
96
97
watcher . on ( 'change' , filename => {
97
98
NonRollup . watchChange ( resolve ( cwd , filename ) ) ;
98
99
// normalize paths to 'nix:
99
- filename = filename . split ( sep ) . join ( posix . sep ) ;
100
+ filename = normalizePath ( filename ) ;
100
101
101
102
// Delete any generated CSS Modules mapping modules:
102
103
const suffix = / \. m o d u l e \. ( c s s | s [ a c ] s s ) $ / . test ( filename ) ? '.js' : '' ;
@@ -158,7 +159,7 @@ export default function wmrMiddleware(options) {
158
159
let file = resolve ( cwd , osPath ) ;
159
160
160
161
// Rollup-style CWD-relative Unix-normalized path "id":
161
- let id = relative ( cwd , file ) . replace ( / ^ \. \/ / , '' ) . replace ( / ^ [ \0 ] / , '' ) . split ( sep ) . join ( posix . sep ) ;
162
+ let id = normalizePath ( relative ( cwd , file ) . replace ( / ^ \. \/ / , '' ) . replace ( / ^ [ \0 ] / , '' ) ) ;
162
163
163
164
// add back any prefix if there was one:
164
165
file = prefix + file ;
@@ -319,7 +320,7 @@ export const TRANSFORMS = {
319
320
if ( resolved ) {
320
321
spec = typeof resolved == 'object' ? resolved . id : resolved ;
321
322
if ( / ^ ( \/ | \\ | [ a - z ] : \\ ) / i. test ( spec ) ) {
322
- spec = relative ( dirname ( file ) , spec ) . split ( sep ) . join ( posix . sep ) ;
323
+ spec = normalizePath ( relative ( dirname ( file ) , spec ) ) ;
323
324
if ( ! / ^ \. ? \. ? \/ / . test ( spec ) ) {
324
325
spec = './' + spec ;
325
326
}
@@ -330,7 +331,7 @@ export const TRANSFORMS = {
330
331
return spec ;
331
332
}
332
333
333
- spec = relative ( cwd , spec ) . split ( sep ) . join ( posix . sep ) ;
334
+ spec = normalizePath ( relative ( cwd , spec ) ) ;
334
335
if ( ! / ^ ( \/ | [ \w - ] + : ) / . test ( spec ) ) spec = `/${ spec } ` ;
335
336
return spec ;
336
337
}
@@ -340,7 +341,7 @@ export const TRANSFORMS = {
340
341
spec = spec . replace ( / ^ \0 ? ( [ a - z - ] + ) : ( .+ ) $ / , ( s , prefix , spec ) => {
341
342
// \0abc:/abs/disk/path --> /@abc/cwd-relative-path
342
343
if ( spec [ 0 ] === '/' || spec [ 0 ] === sep ) {
343
- spec = relative ( cwd , spec ) . split ( sep ) . join ( posix . sep ) ;
344
+ spec = normalizePath ( relative ( cwd , spec ) ) ;
344
345
}
345
346
return '/@' + prefix + '/' + spec ;
346
347
} ) ;
0 commit comments