-
Notifications
You must be signed in to change notification settings - Fork 31
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
Typescript esm import with baseUrl #794
Comments
Can you please show us how this is working outside of Quokka? We created a sample repo with the configuration that you provided. If we try and run
If we compile the TypeScript file and then try and run it with node, we get this error:
Please take a look at our repo and let us know what we need to do to get it working outside of Quokka (I'm assuming that our code/configuration isn't quite the same) and then we should be able to help. |
Apologies, that has to do with the esm and me not including "paths" & tsconfig-paths/register in tsconfig to pair with the baseUrl. Making it simpler with commonjs, removing the ".js" extension and using this tsconfg works for {
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"esModuleInterop": true,
"outDir": "dist",
"noImplicitAny": false,
"sourceMap": false,
"baseUrl": "./src",
"paths": {
"*": ["./*"]
}
},
"ts-node": {
"require": ["tsconfig-paths/register"]
}
} // src/index.ts
import { foo } from 'foo';
console.log(foo); I'm guessing this has to do with quokka not using my own tsconfig's paths alongside tsconfig-paths (which I believe is used internally)? Also, for ts-node esm support with tsconfig-paths, you can use a custom loader passed to node. Is there any way to pass a custom loader to quokka? the esm branch start script shows using the custom loader. It it passed to node however and calls ts-node/esm from within |
Using your branch without the
Quokka will use
Quokka does not support custom ESM loaders but it does have its own, which for TypeScript and You didn't mention whether you were able to get |
I accidentally still had esm stuff in .quokka but removing makes commonjs with paths work ✅
Does that mean I should be able to use esm + paths with quokka? This would be my ideal scenario but still get |
Would you mind updating your branch so I can see it working with ESM outside of Quokka? Please also let me know how you're running it with the CLI (i.e. provide command and options). |
I'm going to close this issue as we haven't heard back. If you update the repo, please let us know by replying to this issue and we'll re-open and take a look. |
Hi, the esm branch start script shows using the custom loader.
|
Also per your prior question about cli working with the .js extension, I added an esm-js branch with a modified custom loader and no
|
Thanks for sharing with us. Quokka doesn't allow for custom loaders because of some of the special logic that it needs to do. We have extended Quokka to now attempt to resolve paths when using TypeScript and esm. The latest version of Quokka now supports your project/example. |
That is great, thanks! |
Issue description or question
Typescript esm absolute import from baseUrl module not found error. This is running quokka from an existing ts file
Sample code
tsconfig
.quokka
Quokka.js Console Output
Code editor version
Visual Studio Code v1.68.0
OS name and version
OSX
The text was updated successfully, but these errors were encountered: