Skip to content
This repository was archived by the owner on May 17, 2025. It is now read-only.

Commit bbd7930

Browse files
authored
fix: provide parentUrl to resolveLatestTarget (#389)
1 parent 9fea38f commit bbd7930

File tree

7 files changed

+789
-457
lines changed

7 files changed

+789
-457
lines changed

package-lock.json

Lines changed: 751 additions & 425 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
},
5353
"devDependencies": {
5454
"@jspm/core": "^2.0.1",
55-
"@swc/cli": "^0.1.61",
56-
"@swc/core": "^1.3.35",
55+
"@swc/cli": "^0.1.65",
56+
"@swc/core": "^1.7.35",
5757
"@types/vscode": "^1.75.1",
5858
"@vscode/test-electron": "^2.2.3",
5959
"chalk": "^4.1.2",

src/common/str.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export class Replacer {
3030
const [wsMatch] = this.source.slice(endIndex).match(trimWs) ?? [];
3131
this.source =
3232
this.source.slice(0, endIndex) +
33-
this.source.slice(endIndex + wsMatch?.length ?? 0);
34-
addOffset(this.offsetTable, end, -wsMatch?.length ?? 0);
33+
this.source.slice(endIndex + (wsMatch?.length ?? 0));
34+
addOffset(this.offsetTable, end, -(wsMatch?.length ?? 0));
3535
}
3636
}
3737

src/providers/jspm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let cdnUrl = "https://ga.jspm.io/";
1313
const systemCdnUrl = "https://ga.system.jspm.io/";
1414
const apiUrl = "https://api.jspm.io/";
1515

16-
const BUILD_POLL_TIME = 5 * 60 * 1000;
16+
const BUILD_POLL_TIME = 60 * 1000;
1717
const BUILD_POLL_INTERVAL = 5 * 1000;
1818

1919
interface JspmCache {
@@ -150,7 +150,7 @@ async function ensureBuild(resolver: Resolver, pkg: ExactPackage, fetchOpts: any
150150

151151
if (Date.now() - startTime >= BUILD_POLL_TIME)
152152
throw new JspmError(
153-
`Timed out waiting for the build of ${fullName} to be ready on the JSPM CDN. Try again later, or post a JSPM project issue if the issue persists.`
153+
`Timed out waiting for the build of ${fullName} to be ready on the JSPM CDN. Try again later, or post a jspm.io project issue at https://github.com/jspm/project if the problem persists.`
154154
);
155155
}
156156
})();

src/trace/resolver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ export class Resolver {
472472
const subpath = "./" + url.slice(pkgUrl.length);
473473
if (subpath in pcfg.browser) {
474474
const target = pcfg.browser[subpath];
475-
if (target === false) return this.resolveEmpty(parentIsCjs, url);
475+
if (target === false) return this.resolveEmpty(parentIsCjs, url, pkgUrl);
476476
if (!target.startsWith("./"))
477477
throw new Error(
478478
`TODO: External browser map for ${subpath} to ${target} in ${url}`
@@ -718,7 +718,7 @@ export class Resolver {
718718
return null;
719719
}
720720

721-
async resolveEmpty(cjsEnv: boolean, originalSpecifier: string, parentUrl?: URL) {
721+
async resolveEmpty(cjsEnv: boolean, originalSpecifier: string, parentUrl: string) {
722722
const stdlibTarget = {
723723
registry: "npm",
724724
name: "@jspm/core",
@@ -729,7 +729,7 @@ export class Resolver {
729729
const pkg = await this.resolveLatestTarget(
730730
stdlibTarget,
731731
provider,
732-
parentUrl?.href
732+
parentUrl
733733
);
734734
return this.resolveExport(
735735
await this.pkgToUrl(pkg, provider),
@@ -748,7 +748,7 @@ export class Resolver {
748748
cjsEnv: boolean,
749749
parentIsCjs: boolean,
750750
originalSpecifier: string,
751-
parentUrl?: URL
751+
parentUrl?: string
752752
): Promise<string> {
753753
const env = cjsEnv ? this.cjsEnv : this.env;
754754
const pcfg = (await this.getPackageConfig(pkgUrl)) || {};

src/trace/tracemap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export default class TraceMap {
510510
cjsEnv,
511511
parentIsCjs,
512512
specifier,
513-
new URL(parentUrl)
513+
parentUrl
514514
)
515515
);
516516
this.log(
@@ -566,7 +566,7 @@ export default class TraceMap {
566566
cjsEnv,
567567
parentIsCjs,
568568
specifier,
569-
new URL(parentUrl)
569+
parentUrl
570570
)
571571
);
572572
this.log(

test/test.html

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"scopes": {
1111
"../": {
1212
"#fetch": "../dist/fetch-native.js",
13-
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].2/lib/index.js",
14-
"@babel/plugin-syntax-import-attributes": "https://ga.jspm.io/npm:@babel/[email protected].6/lib/index.js",
13+
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].8/lib/index.js",
14+
"@babel/plugin-syntax-import-attributes": "https://ga.jspm.io/npm:@babel/[email protected].7/lib/index.js",
1515
"@babel/preset-typescript": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
1616
"@jspm/import-map": "https://ga.jspm.io/npm:@jspm/[email protected]/dist/map.js",
1717
"es-module-lexer": "https://ga.jspm.io/npm:[email protected]/dist/lexer.js",
@@ -23,40 +23,40 @@
2323
"url": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/url.js"
2424
},
2525
"https://ga.jspm.io/": {
26-
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/[email protected].2/lib/config/files/index-browser.js",
27-
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/[email protected].2/lib/config/resolve-targets-browser.js",
28-
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/[email protected].2/lib/transform-file-browser.js",
26+
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/[email protected].8/lib/config/files/index-browser.js",
27+
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/[email protected].8/lib/config/resolve-targets-browser.js",
28+
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/[email protected].8/lib/transform-file-browser.js",
2929
"#node.js": "https://ga.jspm.io/npm:[email protected]/browser.js",
3030
"@ampproject/remapping": "https://ga.jspm.io/npm:@ampproject/[email protected]/dist/remapping.umd.js",
31-
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.24.7/lib/index.js",
31+
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.25.7/lib/index.js",
3232
"@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/[email protected]/native-modules.js",
3333
"@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/[email protected]/plugins.js",
34-
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].2/lib/index.js",
34+
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].8/lib/index.js",
3535
"@babel/generator": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
36-
"@babel/helper-annotate-as-pure": "https://ga.jspm.io/npm:@babel/helper-annotate-as-pure@7.24.7/lib/index.js",
36+
"@babel/helper-annotate-as-pure": "https://ga.jspm.io/npm:@babel/helper-annotate-as-pure@7.25.7/lib/index.js",
3737
"@babel/helper-compilation-targets": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
38-
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/[email protected].4/lib/index.js",
39-
"@babel/helper-member-expression-to-functions": "https://ga.jspm.io/npm:@babel/helper-member-expression-to-functions@7.24.8/lib/index.js",
38+
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/[email protected].7/lib/index.js",
39+
"@babel/helper-member-expression-to-functions": "https://ga.jspm.io/npm:@babel/helper-member-expression-to-functions@7.25.7/lib/index.js",
4040
"@babel/helper-module-imports": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
4141
"@babel/helper-module-transforms": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
42-
"@babel/helper-optimise-call-expression": "https://ga.jspm.io/npm:@babel/helper-optimise-call-expression@7.24.7/lib/index.js",
43-
"@babel/helper-plugin-utils": "https://ga.jspm.io/npm:@babel/helper-plugin-utils@7.24.8/lib/index.js",
42+
"@babel/helper-optimise-call-expression": "https://ga.jspm.io/npm:@babel/helper-optimise-call-expression@7.25.7/lib/index.js",
43+
"@babel/helper-plugin-utils": "https://ga.jspm.io/npm:@babel/helper-plugin-utils@7.25.7/lib/index.js",
4444
"@babel/helper-replace-supers": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
4545
"@babel/helper-simple-access": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
46-
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/helper-skip-transparent-expression-wrappers@7.24.7/lib/index.js",
47-
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.24.8/lib/index.js",
48-
"@babel/helper-validator-identifier": "https://ga.jspm.io/npm:@babel/helper-validator-identifier@7.24.7/lib/index.js",
46+
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/helper-skip-transparent-expression-wrappers@7.25.7/lib/index.js",
47+
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.25.7/lib/index.js",
48+
"@babel/helper-validator-identifier": "https://ga.jspm.io/npm:@babel/helper-validator-identifier@7.25.7/lib/index.js",
4949
"@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
5050
"@babel/helpers": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
51-
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.24.7/lib/index.js",
52-
"@babel/parser": "https://ga.jspm.io/npm:@babel/[email protected].6/lib/index.js",
51+
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.25.7/lib/index.js",
52+
"@babel/parser": "https://ga.jspm.io/npm:@babel/[email protected].8/lib/index.js",
5353
"@babel/plugin-syntax-jsx": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
5454
"@babel/plugin-syntax-typescript": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
5555
"@babel/plugin-transform-modules-commonjs": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
5656
"@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
57-
"@babel/template": "https://ga.jspm.io/npm:@babel/[email protected].0/lib/index.js",
57+
"@babel/template": "https://ga.jspm.io/npm:@babel/[email protected].7/lib/index.js",
5858
"@babel/traverse": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
59-
"@babel/types": "https://ga.jspm.io/npm:@babel/[email protected].6/lib/index.js",
59+
"@babel/types": "https://ga.jspm.io/npm:@babel/[email protected].8/lib/index.js",
6060
"@jridgewell/gen-mapping": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/gen-mapping.umd.js",
6161
"@jridgewell/resolve-uri": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/resolve-uri.umd.js",
6262
"@jridgewell/set-array": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/set-array.umd.js",
@@ -71,7 +71,7 @@
7171
"color-name": "https://ga.jspm.io/npm:[email protected]/index.js",
7272
"convert-source-map": "https://ga.jspm.io/npm:[email protected]/index.js",
7373
"debug": "https://ga.jspm.io/npm:[email protected]/src/browser.js",
74-
"electron-to-chromium/versions": "https://ga.jspm.io/npm:[email protected].29/versions.js",
74+
"electron-to-chromium/versions": "https://ga.jspm.io/npm:[email protected].37/versions.js",
7575
"escape-string-regexp": "https://ga.jspm.io/npm:[email protected]/index.js",
7676
"fs": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/fs.js",
7777
"gensync": "https://ga.jspm.io/npm:[email protected]/index.js",
@@ -89,6 +89,12 @@
8989
"supports-color": "https://ga.jspm.io/npm:[email protected]/browser.js",
9090
"to-fast-properties": "https://ga.jspm.io/npm:[email protected]/index.js",
9191
"yallist": "https://ga.jspm.io/npm:[email protected]/yallist.js"
92+
},
93+
"https://ga.jspm.io/npm:@babel/[email protected]/": {
94+
"@babel/helper-member-expression-to-functions": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js"
95+
},
96+
"https://ga.jspm.io/npm:@babel/[email protected]/": {
97+
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js"
9298
}
9399
}
94100
}

0 commit comments

Comments
 (0)