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

Switch from PNPM to Bun, incl. dropping Jest & esbuild #1021

Merged
merged 6 commits into from
Jan 17, 2025

Conversation

vorburger
Copy link
Member

@vorburger vorburger commented Jan 15, 2025

Changing this (see diff on Files changed tab) breaks the UI - see the web/README.md for how to reproduce:

script.js:19 Uncaught ReferenceError: exports is not defined
    at script.js:19:23

due to the TSC generated web-out/script.js containing this - whatever this means:

Object.defineProperty(exports, "__esModule", { value: true });

@edewit you might have a clue about how to fix this? (If you even agree that "type": "module" is recommended? I read it is.)

@vorburger
Copy link
Member Author

Oh, even with my still too limited understanding of the Web ecosystem, I gather it's due to "module": "commonjs" in web/tsconfig.json... but changing that to e.g. this:

 "module": "Node16",
 "moduleResolution": "node16",

then causes pnpm test && pnpm run tsc && pnpm run build (see web/README.md) to STILL fail with:

> [email protected] test /home/vorburger/git/github.com/enola-dev/enola/web
> jest

Error: Jest: Failed to parse the TypeScript config file /home/vorburger/git/github.com/enola-dev/enola/web/jest.config.ts
  TSError: ⨯ Unable to compile TypeScript:
error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.

    at readConfigFileAndSetRootDir (/home/vorburger/git/github.com/enola-dev/enola/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:116:13)
    at async readInitialOptions (/home/vorburger/git/github.com/enola-dev/enola/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-config/build/index.js:403:13)
    at async readConfig (/home/vorburger/git/github.com/enola-dev/enola/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-config/build/index.js:147:48)
    at async readConfigs (/home/vorburger/git/github.com/enola-dev/enola/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-config/build/index.js:424:26)
    at async runCLI (/home/vorburger/git/github.com/enola-dev/enola/web/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected]_/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/home/vorburger/git/github.com/enola-dev/enola/web/node_modules/.pnpm/[email protected]_@[email protected][email protected]_@[email protected][email protected]_/node_modules/jest-cli/build/run.js:130:37)
 ELIFECYCLE  Test failed. See above for more details.

How does one do this right?!

PS: This is from & for #1019 ...

@edewit
Copy link
Contributor

edewit commented Jan 15, 2025

node is not the right target as you want to target the web, try and change it to "target": "ESNext",

@vorburger vorburger changed the title fix (web): Enable type=module in package.json Switch from PNPM to Bun, incl. dropping Jest & esbuild - so much simpler, yay! Jan 17, 2025
@vorburger vorburger changed the title Switch from PNPM to Bun, incl. dropping Jest & esbuild - so much simpler, yay! Switch from PNPM to Bun, incl. dropping Jest & esbuild Jan 17, 2025
@vorburger
Copy link
Member Author

@edewit FYI I've just switched from https://pnpm.io to going all-in on https://bun.sh ... this SO much simpler!

Enough already with pulling my hairs because CommonJS vs ES Modules (ESM), TS vs JS, separate bundlers and test frameworks.

Bun "just works" - it's very cool. https://deno.com actually looks even better at least for backend, but less as frontend "runner" (like here).

@vorburger vorburger marked this pull request as ready for review January 17, 2025 21:08
@vorburger vorburger merged commit 115130a into enola-dev:main Jan 17, 2025
9 checks passed
@vorburger vorburger deleted the web-package-type-module branch January 17, 2025 21:18
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