Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: provide parentUrl to resolveLatestTarget #389

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,176 changes: 751 additions & 425 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
},
"devDependencies": {
"@jspm/core": "^2.0.1",
"@swc/cli": "^0.1.61",
"@swc/core": "^1.3.35",
"@swc/cli": "^0.1.65",
"@swc/core": "^1.7.35",
"@types/vscode": "^1.75.1",
"@vscode/test-electron": "^2.2.3",
"chalk": "^4.1.2",
Expand Down
4 changes: 2 additions & 2 deletions src/common/str.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class Replacer {
const [wsMatch] = this.source.slice(endIndex).match(trimWs) ?? [];
this.source =
this.source.slice(0, endIndex) +
this.source.slice(endIndex + wsMatch?.length ?? 0);
addOffset(this.offsetTable, end, -wsMatch?.length ?? 0);
this.source.slice(endIndex + (wsMatch?.length ?? 0));
addOffset(this.offsetTable, end, -(wsMatch?.length ?? 0));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/providers/jspm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let cdnUrl = "https://ga.jspm.io/";
const systemCdnUrl = "https://ga.system.jspm.io/";
const apiUrl = "https://api.jspm.io/";

const BUILD_POLL_TIME = 5 * 60 * 1000;
const BUILD_POLL_TIME = 60 * 1000;
const BUILD_POLL_INTERVAL = 5 * 1000;

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

if (Date.now() - startTime >= BUILD_POLL_TIME)
throw new JspmError(
`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.`
`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.`
);
}
})();
Expand Down
8 changes: 4 additions & 4 deletions src/trace/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class Resolver {
const subpath = "./" + url.slice(pkgUrl.length);
if (subpath in pcfg.browser) {
const target = pcfg.browser[subpath];
if (target === false) return this.resolveEmpty(parentIsCjs, url);
if (target === false) return this.resolveEmpty(parentIsCjs, url, pkgUrl);
if (!target.startsWith("./"))
throw new Error(
`TODO: External browser map for ${subpath} to ${target} in ${url}`
Expand Down Expand Up @@ -718,7 +718,7 @@ export class Resolver {
return null;
}

async resolveEmpty(cjsEnv: boolean, originalSpecifier: string, parentUrl?: URL) {
async resolveEmpty(cjsEnv: boolean, originalSpecifier: string, parentUrl: string) {
const stdlibTarget = {
registry: "npm",
name: "@jspm/core",
Expand All @@ -729,7 +729,7 @@ export class Resolver {
const pkg = await this.resolveLatestTarget(
stdlibTarget,
provider,
parentUrl?.href
parentUrl
);
return this.resolveExport(
await this.pkgToUrl(pkg, provider),
Expand All @@ -748,7 +748,7 @@ export class Resolver {
cjsEnv: boolean,
parentIsCjs: boolean,
originalSpecifier: string,
parentUrl?: URL
parentUrl?: string
): Promise<string> {
const env = cjsEnv ? this.cjsEnv : this.env;
const pcfg = (await this.getPackageConfig(pkgUrl)) || {};
Expand Down
4 changes: 2 additions & 2 deletions src/trace/tracemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export default class TraceMap {
cjsEnv,
parentIsCjs,
specifier,
new URL(parentUrl)
parentUrl
)
);
this.log(
Expand Down Expand Up @@ -566,7 +566,7 @@ export default class TraceMap {
cjsEnv,
parentIsCjs,
specifier,
new URL(parentUrl)
parentUrl
)
);
this.log(
Expand Down
46 changes: 26 additions & 20 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"scopes": {
"../": {
"#fetch": "../dist/fetch-native.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/core@7.25.2/lib/index.js",
"@babel/plugin-syntax-import-attributes": "https://ga.jspm.io/npm:@babel/plugin-syntax-import-attributes@7.25.6/lib/index.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/core@7.25.8/lib/index.js",
"@babel/plugin-syntax-import-attributes": "https://ga.jspm.io/npm:@babel/plugin-syntax-import-attributes@7.25.7/lib/index.js",
"@babel/preset-typescript": "https://ga.jspm.io/npm:@babel/preset-typescript@7.24.7/lib/index.js",
"@jspm/import-map": "https://ga.jspm.io/npm:@jspm/import-map@1.1.0/dist/map.js",
"es-module-lexer": "https://ga.jspm.io/npm:es-module-lexer@1.5.4/dist/lexer.js",
Expand All @@ -23,40 +23,40 @@
"url": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/url.js"
},
"https://ga.jspm.io/": {
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/core@7.25.2/lib/config/files/index-browser.js",
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/core@7.25.2/lib/config/resolve-targets-browser.js",
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/core@7.25.2/lib/transform-file-browser.js",
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/core@7.25.8/lib/config/files/index-browser.js",
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/core@7.25.8/lib/config/resolve-targets-browser.js",
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/core@7.25.8/lib/transform-file-browser.js",
"#node.js": "https://ga.jspm.io/npm:browserslist@4.24.0/browser.js",
"@ampproject/remapping": "https://ga.jspm.io/npm:@ampproject/remapping@2.3.0/dist/remapping.umd.js",
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.24.7/lib/index.js",
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.25.7/lib/index.js",
"@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/compat-data@7.25.4/native-modules.js",
"@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/compat-data@7.25.4/plugins.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/core@7.25.2/lib/index.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/core@7.25.8/lib/index.js",
"@babel/generator": "https://ga.jspm.io/npm:@babel/generator@7.25.6/lib/index.js",
"@babel/helper-annotate-as-pure": "https://ga.jspm.io/npm:@babel/helper-annotate-as-pure@7.24.7/lib/index.js",
"@babel/helper-annotate-as-pure": "https://ga.jspm.io/npm:@babel/helper-annotate-as-pure@7.25.7/lib/index.js",
"@babel/helper-compilation-targets": "https://ga.jspm.io/npm:@babel/helper-compilation-targets@7.25.2/lib/index.js",
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.25.4/lib/index.js",
"@babel/helper-member-expression-to-functions": "https://ga.jspm.io/npm:@babel/helper-member-expression-to-functions@7.24.8/lib/index.js",
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.25.7/lib/index.js",
"@babel/helper-member-expression-to-functions": "https://ga.jspm.io/npm:@babel/helper-member-expression-to-functions@7.25.7/lib/index.js",
"@babel/helper-module-imports": "https://ga.jspm.io/npm:@babel/helper-module-imports@7.24.7/lib/index.js",
"@babel/helper-module-transforms": "https://ga.jspm.io/npm:@babel/helper-module-transforms@7.25.2/lib/index.js",
"@babel/helper-optimise-call-expression": "https://ga.jspm.io/npm:@babel/helper-optimise-call-expression@7.24.7/lib/index.js",
"@babel/helper-plugin-utils": "https://ga.jspm.io/npm:@babel/helper-plugin-utils@7.24.8/lib/index.js",
"@babel/helper-optimise-call-expression": "https://ga.jspm.io/npm:@babel/helper-optimise-call-expression@7.25.7/lib/index.js",
"@babel/helper-plugin-utils": "https://ga.jspm.io/npm:@babel/helper-plugin-utils@7.25.7/lib/index.js",
"@babel/helper-replace-supers": "https://ga.jspm.io/npm:@babel/helper-replace-supers@7.25.0/lib/index.js",
"@babel/helper-simple-access": "https://ga.jspm.io/npm:@babel/helper-simple-access@7.24.7/lib/index.js",
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/helper-skip-transparent-expression-wrappers@7.24.7/lib/index.js",
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.24.8/lib/index.js",
"@babel/helper-validator-identifier": "https://ga.jspm.io/npm:@babel/helper-validator-identifier@7.24.7/lib/index.js",
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/helper-skip-transparent-expression-wrappers@7.25.7/lib/index.js",
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.25.7/lib/index.js",
"@babel/helper-validator-identifier": "https://ga.jspm.io/npm:@babel/helper-validator-identifier@7.25.7/lib/index.js",
"@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/helper-validator-option@7.24.8/lib/index.js",
"@babel/helpers": "https://ga.jspm.io/npm:@babel/helpers@7.25.6/lib/index.js",
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.24.7/lib/index.js",
"@babel/parser": "https://ga.jspm.io/npm:@babel/parser@7.25.6/lib/index.js",
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.25.7/lib/index.js",
"@babel/parser": "https://ga.jspm.io/npm:@babel/parser@7.25.8/lib/index.js",
"@babel/plugin-syntax-jsx": "https://ga.jspm.io/npm:@babel/plugin-syntax-jsx@7.24.7/lib/index.js",
"@babel/plugin-syntax-typescript": "https://ga.jspm.io/npm:@babel/plugin-syntax-typescript@7.25.4/lib/index.js",
"@babel/plugin-transform-modules-commonjs": "https://ga.jspm.io/npm:@babel/plugin-transform-modules-commonjs@7.24.8/lib/index.js",
"@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/plugin-transform-typescript@7.25.2/lib/index.js",
"@babel/template": "https://ga.jspm.io/npm:@babel/template@7.25.0/lib/index.js",
"@babel/template": "https://ga.jspm.io/npm:@babel/template@7.25.7/lib/index.js",
"@babel/traverse": "https://ga.jspm.io/npm:@babel/traverse@7.25.6/lib/index.js",
"@babel/types": "https://ga.jspm.io/npm:@babel/types@7.25.6/lib/index.js",
"@babel/types": "https://ga.jspm.io/npm:@babel/types@7.25.8/lib/index.js",
"@jridgewell/gen-mapping": "https://ga.jspm.io/npm:@jridgewell/gen-mapping@0.3.5/dist/gen-mapping.umd.js",
"@jridgewell/resolve-uri": "https://ga.jspm.io/npm:@jridgewell/resolve-uri@3.1.2/dist/resolve-uri.umd.js",
"@jridgewell/set-array": "https://ga.jspm.io/npm:@jridgewell/set-array@1.2.1/dist/set-array.umd.js",
Expand All @@ -71,7 +71,7 @@
"color-name": "https://ga.jspm.io/npm:color-name@1.1.3/index.js",
"convert-source-map": "https://ga.jspm.io/npm:convert-source-map@2.0.0/index.js",
"debug": "https://ga.jspm.io/npm:debug@4.3.7/src/browser.js",
"electron-to-chromium/versions": "https://ga.jspm.io/npm:electron-to-chromium@1.5.29/versions.js",
"electron-to-chromium/versions": "https://ga.jspm.io/npm:electron-to-chromium@1.5.37/versions.js",
"escape-string-regexp": "https://ga.jspm.io/npm:escape-string-regexp@1.0.5/index.js",
"fs": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/fs.js",
"gensync": "https://ga.jspm.io/npm:gensync@1.0.0-beta.2/index.js",
Expand All @@ -89,6 +89,12 @@
"supports-color": "https://ga.jspm.io/npm:supports-color@5.5.0/browser.js",
"to-fast-properties": "https://ga.jspm.io/npm:to-fast-properties@2.0.0/index.js",
"yallist": "https://ga.jspm.io/npm:yallist@3.1.1/yallist.js"
},
"https://ga.jspm.io/npm:@babel/helper-replace-supers@7.25.0/": {
"@babel/helper-member-expression-to-functions": "https://ga.jspm.io/npm:@babel/helper-member-expression-to-functions@7.24.8/lib/index.js"
},
"https://ga.jspm.io/npm:@babel/plugin-transform-typescript@7.25.2/": {
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/helper-skip-transparent-expression-wrappers@7.24.7/lib/index.js"
}
}
}
Expand Down
Loading