File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { dirname , relative , resolve } from "path" ;
2
2
import ts from "typescript" ;
3
3
import slash from "slash" ;
4
+ import { parse } from "url" ;
4
5
5
6
const transformer = ( _ : ts . Program ) => ( context : ts . TransformationContext ) => (
6
7
sourceFile : ts . SourceFile
@@ -28,11 +29,18 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
28
29
return sourceFile ;
29
30
}
30
31
32
+ function isUrl ( s : string ) {
33
+ return parse ( s ) . protocol !== null ;
34
+ }
35
+
31
36
function bindModuleToFile ( moduleName : string ) {
32
37
for ( const { regexp, path } of binds ) {
33
38
const match = regexp . exec ( moduleName ) ;
34
39
if ( match ) {
35
40
const out = path . replace ( / \* / g, match [ 1 ] ) ;
41
+ if ( isUrl ( out ) ) {
42
+ return out ;
43
+ }
36
44
const file = slash ( relative ( sourceDir , resolve ( baseUrl , out ) ) ) ;
37
45
return file [ 0 ] === "." ? file : `./${ file } ` ;
38
46
}
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ export { NoRuntimecodeHere } from "@utils/types-only";
4
4
import { subs , NoRuntimecodeHere } from "@utils" ;
5
5
import "@circular/b" ;
6
6
import { A } from "@circular/a" ;
7
+ import * as path from "path" ;
8
+
9
+ path . sep ;
7
10
8
11
sum . sum ( 2 , 3 ) ;
9
12
Original file line number Diff line number Diff line change 8
8
"declaration" : true ,
9
9
"baseUrl" : " ./" ,
10
10
"paths" : {
11
+ "path" : [" https://external.url/path.js" ],
11
12
"@*" : [" *" ]
12
13
},
13
14
Original file line number Diff line number Diff line change @@ -17,9 +17,11 @@ files.forEach(file => {
17
17
} ) ;
18
18
19
19
function update ( content : string , sourceDir : string ) {
20
- return content . replace ( / " ( @ .* ) " / g, ( _ , moduleName ) => {
21
- return `"${ bindModuleToFile ( moduleName , sourceDir ) } "` ;
22
- } ) ;
20
+ return content
21
+ . replace ( / " ( @ .* ) " / g, ( _ , moduleName ) => {
22
+ return `"${ bindModuleToFile ( moduleName , sourceDir ) } "` ;
23
+ } )
24
+ . replace ( '"path"' , '"https://external.url/path.js"' ) ;
23
25
}
24
26
25
27
function bindModuleToFile ( moduleName : string , sourceDir : string ) {
You can’t perform that action at this time.
0 commit comments