This repository was archived by the owner on May 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +20
-37
lines changed Expand file tree Collapse file tree 5 files changed +20
-37
lines changed Original file line number Diff line number Diff line change @@ -54,32 +54,7 @@ export async function getPackageConfig(
54
54
) ;
55
55
}
56
56
57
- const pcfg = await res . json ( ) ;
58
-
59
- // esm.sh uses exports paths as paths
60
- // so we rewrite all exports paths to point to their internal path and let esm.sh do resolution
61
- // note: strictly speaking we should add ?conditions=... here for the condition set
62
- // but that will require some more wiring
63
- if ( pcfg . exports ) {
64
- // in the conditional expoort case, paths seem to work?
65
- // so go with that
66
- if ( Object . keys ( pcfg . exports ) . every ( ( key ) => ! key . startsWith ( "./" ) ) ) {
67
- pcfg . exports [ "." ] = pcfg . exports ;
68
- } else {
69
- // let esm.sh resolve conditions
70
- for ( const key of Object . keys ( pcfg . exports ) ) {
71
- pcfg . exports [ key ] = key ;
72
- }
73
- }
74
- // wildcard key for esmsh to do its own fallback resolution too
75
- pcfg . exports [ "./*" ] = "./*" ;
76
- }
77
- if ( pcfg . imports ) {
78
- for ( const key of Object . keys ( pcfg . imports ) ) {
79
- pcfg . imports [ key ] = key ;
80
- }
81
- }
82
- return pcfg ;
57
+ return await res . json ( ) ;
83
58
}
84
59
85
60
export async function resolveLatestTarget (
Original file line number Diff line number Diff line change @@ -254,7 +254,8 @@ export default class TraceMap {
254
254
255
255
await Promise . all (
256
256
allDeps . map ( async ( dep ) => {
257
- if ( dep . indexOf ( "*" ) !== - 1 ) {
257
+ // Special wildcard tracing syntax for dynamic imports, todo
258
+ if ( dep . indexOf ( "\x10" ) !== - 1 ) {
258
259
this . log ( "todo" , "Handle wildcard trace " + dep + " in " + resolved ) ;
259
260
return ;
260
261
}
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ export async function createTsAnalysis(
123
123
} ;
124
124
}
125
125
126
+ // We use the special character \x10 as a "wildcard symbol"
126
127
function buildDynamicString (
127
128
node ,
128
129
fileName ,
@@ -149,7 +150,7 @@ function buildDynamicString(
149
150
lastIsWildcard
150
151
) ;
151
152
if ( nextStr . length ) {
152
- lastIsWildcard = nextStr . endsWith ( "* " ) ;
153
+ lastIsWildcard = nextStr . endsWith ( "\x10 " ) ;
153
154
str += nextStr ;
154
155
}
155
156
}
@@ -163,7 +164,7 @@ function buildDynamicString(
163
164
isEsm ,
164
165
lastIsWildcard
165
166
) ;
166
- if ( leftResolved . length ) lastIsWildcard = leftResolved . endsWith ( "* " ) ;
167
+ if ( leftResolved . length ) lastIsWildcard = leftResolved . endsWith ( "\x10 " ) ;
167
168
const rightResolved = buildDynamicString (
168
169
node . right ,
169
170
fileName ,
@@ -186,5 +187,5 @@ function buildDynamicString(
186
187
return './' + fileName;
187
188
}
188
189
}*/
189
- return lastIsWildcard ? "" : "* " ;
190
+ return lastIsWildcard ? "" : "\x10 " ;
190
191
}
Original file line number Diff line number Diff line change @@ -23,5 +23,5 @@ html = `
23
23
pins = await generator . addMappings ( html ) ;
24
24
25
25
assert (
26
- ( await generator . htmlInject ( html , { pins } ) ) . includes ( "https://esm.sh/v " )
26
+ ( await generator . htmlInject ( html , { pins } ) ) . includes ( "https://esm.sh/* " )
27
27
) ;
Original file line number Diff line number Diff line change @@ -7,15 +7,21 @@ const generator = new Generator({
7
7
env : [ "production" , "browser" ] ,
8
8
} ) ;
9
9
10
- await generator . install ( "lit@2.0.0-rc.1 " ) ;
10
+ await generator . install ( "react@18 " ) ;
11
11
const json = generator . getMap ( ) ;
12
12
13
- assert . strictEqual ( json . imports . lit , "https://esm.sh/*lit@2.0.0-rc.1 " ) ;
13
+ assert . strictEqual ( json . imports . react , "https://esm.sh/*react@18.3.1/index.js " ) ;
14
14
15
- const scope = json . scopes [ "https://esm.sh/" ] ;
16
- assert . ok ( scope [ "@lit/reactive-element" ] ) ;
17
- assert . ok ( scope [ "lit-element/lit-element.js" ] ) ;
18
- assert . ok ( scope [ "lit-html" ] ) ;
15
+ // TODO: Reenable lit test when fixed upstream
16
+ // await generator.install("lit@2.0.0-rc.1");
17
+ // const json = generator.getMap();
18
+
19
+ // assert.strictEqual(json.imports.lit, "https://esm.sh/*lit@2.0.0-rc.1/index.js");
20
+
21
+ // const scope = json.scopes["https://esm.sh/"];
22
+ // assert.ok(scope["@lit/reactive-element"]);
23
+ // assert.ok(scope["lit-element/lit-element.js"]);
24
+ // assert.ok(scope["lit-html"]);
19
25
20
26
await generator . install ( "twind" ) ;
21
27
You can’t perform that action at this time.
0 commit comments