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 hashes for modules importing builtins #1688

Merged
merged 1 commit into from
Sep 26, 2024
Merged

Conversation

mbostock
Copy link
Member

getLocalModuleHash was computing the wrong result for modules that import built-ins such as observablehq:stdlib and npm:@observablehq/inputs; it needs to incorporate the Framework version number so that when a new version of Framework is released and the built-in modules may have changed, the hash of the importing local module also changes. (We already do something similar for npm: imports.)

We were also forgetting to handle jsr: imports here.

Related #1555 #1557.

@mbostock mbostock requested a review from Fil September 26, 2024 17:29
export function resolveBuiltin(specifier: string): string {
if (builtins.has(specifier)) return builtins.get(specifier)!;
if (!specifier.startsWith("observablehq:")) throw new Error(`not built-in: ${specifier}`);
return `/_observablehq/${specifier.slice("observablehq:".length)}${extname(specifier) ? "" : ".js"}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took me a moment to figure out what case that was!

one example: import {mutable} from "observablehq:stdlib/mutable.js";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! The primary one is observablehq:stdlib/inputs.css.

@mbostock mbostock merged commit 4ca8e9e into main Sep 26, 2024
4 checks passed
@mbostock mbostock deleted the mbostock/fix-builtin-hash branch September 26, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants