File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed
Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change 1- import { parse , relative , sep , dirname } from 'node:path' ;
2- import { resolve } from 'node:path/posix' ;
1+ import { resolve , dirname } from 'node:path' ;
32import { fileURLToPath } from 'node:url' ;
43
5- // Convert the current module's URL to a filesystem path,
6- // then calculate the relative path from the system root directory
7- // to this file. This relative path uses platform-specific separators,
8- // so replace them with forward slashes ("/") for consistency and web compatibility.
9- // Finally, prepend a leading slash to form an absolute root-relative path string.
10- //
11- // This produces a POSIX-style absolute path, even on Windows systems.
12- const dir = dirname ( fileURLToPath ( import . meta. url ) ) ;
13- export const ROOT = '/' + relative ( parse ( dir ) . root , dir ) . replaceAll ( sep , '/' ) ;
4+ export const ROOT = dirname ( fileURLToPath ( import . meta. url ) ) ;
145
156/**
167 * @typedef {Object } JSXImportConfig
Original file line number Diff line number Diff line change 1- import { resolve } from 'node:path/posix ' ;
1+ import { resolve } from 'node:path' ;
22
33import { JSX_IMPORTS , ROOT } from '../constants.mjs' ;
44
@@ -14,6 +14,10 @@ export const createImportDeclaration = (
1414 source ,
1515 useDefault = true
1616) => {
17+ // '\' characters shouldn't escape the next character,
18+ // but rather be treated as slashes.
19+ source = source . replaceAll ( '\\' , '\\\\' ) ;
20+
1721 // Side-effect-only import (CSS)
1822 if ( ! importName ) {
1923 return `import "${ source } ";` ;
You can’t perform that action at this time.
0 commit comments