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

esm.sh module resolution changed this week without code changes #611

Closed
johnstonmatt opened this issue Apr 25, 2023 · 3 comments
Closed
Labels
deno Not working in Deno

Comments

@johnstonmatt
Copy link

Problem

My deno program now fails to build in CI when it pulls down fresh modules instead of using the cache on my machine. I think the reason I get

error: The source code is invalid, as it does not match the expected hash in the lock file.

is because a week ago my

import CryptoJS from "https://esm.sh/v103/[email protected]?bundle";

resolved to

/* esm.sh - [email protected] */
export * from "https://esm.sh/v103/[email protected]/deno/crypto-js.bundle.js";
export { default } from "https://esm.sh/v103/[email protected]/deno/crypto-js.bundle.js";

and now it resolves to

/* esm.sh - [email protected] */
export * from "https://esm.sh/v103/[email protected]/es2022/crypto-js.bundle.mjs";
export { default } from "https://esm.sh/v103/[email protected]/es2022/crypto-js.bundle.mjs";

Note the difference between the file extensions, js -> mjs. This causes a failure to match the lock file.

I am also seeing this with a separate import:

export { simpleGit } from "https://esm.sh/v103/[email protected]?no-dts&target=deno&deno-std=0.173.0&bundle&deps=@kwsites/[email protected]";

Additional info

  • esm.sh version: v103 (and all others I think)
  • Deno version: 1.32.5
@johnstonmatt johnstonmatt added the deno Not working in Deno label Apr 25, 2023
@ije
Copy link
Member

ije commented Apr 25, 2023

sorry for the extension change, can you please update the lock file? i changed it to .mjs to fix conflict entry name and i made a mistake of purging the build cache of < v116, now all the builds have been stored into CF R2/works kv as immutable.

@johnstonmatt
Copy link
Author

after using deno cache main.ts --reload --lock-write I got:

./main_test.ts (uncaught error)
error: SyntaxError: The requested module '/v117/@kwsites/[email protected]/X-ZHN2LzAuMTczLjA/deno/file-exists.mjs' does not provide an export named 'exists'
    at <anonymous> (https://esm.sh/v117/[email protected]/X-ZC9Aa3dzaXRlcy9maWxlLWV4aXN0c0AxLjEuMQpkc3YvMC4xNzMuMA/deno/simple-git.bundle.mjs:2:163)
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.

when running the module, the .mjs extension seems to have broken the deps I declared for simple-git:

export { simpleGit } from "https://esm.sh/v117/[email protected]?no-dts&target=deno&deno-std=0.173.0&bundle&deps=@kwsites/[email protected]";

@ije
Copy link
Member

ije commented Apr 25, 2023

Screenshot 2023-04-26 at 01 49 32

just checked, the `file-exists` index module(cjs) has a non-standard export syntax which can not be parsed correctly by the `cjs-lexer`, i will fix this (by adding it to the `requireModeAllowList` or fixing the cjs-lexer)

var requireModeAllowList = []string{

@ije ije closed this as completed in 4216942 Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno Not working in Deno
Projects
None yet
Development

No branches or pull requests

2 participants