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

tsconfig-paths dont work with esm modules #711

Closed
bhvngt opened this issue Nov 9, 2021 · 6 comments
Closed

tsconfig-paths dont work with esm modules #711

bhvngt opened this issue Nov 9, 2021 · 6 comments

Comments

@bhvngt
Copy link

bhvngt commented Nov 9, 2021

Issue description or question

I am using quokkajs from an intellij module that is configured as esm package.

My .quokka file is

{
  "nativeEsm": true,
  "env": {
    "params": {
      "runner": "--experimental-specifier-resolution=node"
    }
  }
}

Since as per this issue tsconfig-paths does not work with esm modules, I am using typescript-transform-paths to transform path mappings. However, I believe is not supported by quokka.

Just wanted to check if you have plan to support path mapping functionality using this module or through some alternate form of solution.

tsconfig.json is

	"compilerOptions": {
		"target": "esnext",
		"module": "esnext",
		"plugins": [
			{ "transform": "typescript-transform-paths" },
			{ "transform": "typescript-transform-paths", "afterDeclarations": true }
                 ],
		"baseUrl": "./",
		"paths": {
			"$src/*": ["src/*"]
		}
         }

Is this issue related to Quokka not outputting the expected results of your code?: Yes

Sample code

src/m1/a.ts

export const x = "Hello";

src/m2/b.ts

import {x} from "$src/m1/a.";
console.log(x);

Quokka.js Console Output

Cannot find module '/Volumes/DATA/User/Projects/p1/src/m1/a.js' imported from ./src/m2/b.js

Code editor version

intellij 2021.2.3

OS name and version

OSX

@smcenlly
Copy link
Member

smcenlly commented Nov 9, 2021

Could you please detail how you are running your code using the command line so that we can see how it's executing outside of Quokka?

@bhvngt
Copy link
Author

bhvngt commented Nov 10, 2021

There is a pending issue LeDDGroup/typescript-transform-paths#134 that is blocking esm compatibility with ts-node and typescript-transform-paths. Hopefully it will get fixed soon since the blocking issue TypeStrong/ts-node#1439 at ts-node repo has been merged.

@smcenlly
Copy link
Member

There is a pending issue LeDDGroup/typescript-transform-paths#134 that is blocking esm compatibility with ts-node and typescript-transform-paths. Hopefully it will get fixed soon since the blocking issue TypeStrong/ts-node#1439 at ts-node repo has been merged.

Since the issue is not related to Quokka itself and it is not currently possible to run the code either with Quokka or outside of Quokka, we will close the issue. If/when it is possible to run the code outside of Quokka, if it doesn't work for you please raise a feature request or else respond to this issue and we will re-open and investigate for you.

@bhvngt
Copy link
Author

bhvngt commented Nov 11, 2021

@smcenlly There are some custom loaders which uses combination of ts-node and tsconfig-paths. I haven't tried them but was curious if that is something that can be passed to quokka's env.params.runner option via --loader flag as a user defined configuration?

@smcenlly
Copy link
Member

In order to operate with ESM, Quokka has its own ESM loader. Part of the loader includes integration to support ts-node's ESM functionality. We have no plans at this stage to support custom ESM loaders for Quokka.

At this point in time, while we support ESM, we are careful of how much we expose outside of our internals as the node API is experimental and has already broken once (in the last couple of months).

If you can run your code with ts-node outside of Quokka, we can investigate support for this for you.

@bhvngt
Copy link
Author

bhvngt commented Nov 12, 2021

Make sense @smcenlly. Making path aliasing work with esm, ts-node, tsconfig-paths have been quite crazy. Will ping you if I find something that works well with ts-node

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

2 participants