jiti
jiti copied to clipboard
Error when loading a `vite.config.ts` file with the `sveltekit` plugin.
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
- Is my understanding correct in that we ideally want to instruct jiti to avoid transforming this file, as it is "already ESM"?
- Is it fair to assume that closing #72 will also fix this issue?
- 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
I just realized that I forgot to link to the minimal repro 🤦🏼♂️
https://github.com/thenbe/repro-jiti-sveltekit
With jiti v2, we have adopted native-ESM support and top level imports supported out of the box for main jiti CLI.