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

Error when loading a vite.config.ts file with the sveltekit plugin. #194

Open
thenbe opened this issue Dec 16, 2023 · 1 comment
Open

Error when loading a vite.config.ts file with the sveltekit plugin. #194

thenbe opened this issue Dec 16, 2023 · 1 comment

Comments

@thenbe
Copy link

thenbe commented Dec 16, 2023

jiti fails to load a vite.config.ts file, when that file calls the sveltekit plugin. (like the one that comes with the sveltekit demo app)

Error

[jiti] [transpile] [esm] /home/nbe/projects/playground/repro-jiti-sveltekit/ts.js (4.032ms)
/home/nbe/projects/playground/repro-jiti-sveltekit/ts.js:5
  exports.ts = ts = (await Promise.resolve().then(() => require('typescript'))).default;

SyntaxError: Unexpected identifier 'Promise'

Reproduction

Here is a minimal reproduction which includes only the single file from the sveltekit repo that jiti errors on. The steps are in the readme.

Questions

  1. Is my understanding correct in that we ideally want to instruct jiti to avoid transforming this file, as it is "already ESM"?
  2. Is it fair to assume that closing Top-level await is not supported #72 will also fix this issue?
  3. Are there any other alternatives I could try to work around this in the meantime?

Context

I was taking a stab at fixing a knip issue which is currently blocked by this error.

Environment

Environment

  System:
    OS: Linux 6.1 NixOS 24.05 (Uakari) 24.05 (Uakari)
    CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900K
    Memory: 20.28 GB / 31.13 GB
    Container: Yes
    Shell: 5.9 - /run/current-system/sw/bin/zsh
  Binaries:
    Node: 20.10.0 - /etc/profiles/per-user/nbe/bin/node
    npm: 10.2.3 - /etc/profiles/per-user/nbe/bin/npm
    pnpm: 8.10.5 - /etc/profiles/per-user/nbe/bin/pnpm

@thenbe
Copy link
Author

thenbe commented Mar 14, 2024

I just realized that I forgot to link to the minimal repro 🤦🏼‍♂️

https://github.com/thenbe/repro-jiti-sveltekit

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

No branches or pull requests

1 participant