-
-
Notifications
You must be signed in to change notification settings - Fork 578
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
refactor(cli): support for .cts
、.mts
and follows type: module
#3222
Conversation
we discussed how to support .ts in #2237 and decide to use transform strategy other than bundle strategy, so use esbuild to prebundle config is not ideal |
I tried to use rspack self-compilation in the code, but the output file seems to have a problem and cannot be imported or required correctly. |
use rspack to bundle config is not ideal which is disscussed in #2237 |
it's a BUG that rspack not supports "type" property of packageJson, but it should not be fixed by bundle config file |
Is it necessary to fallback to ts-node register and only add type: "module" detection and |
i think this should break into two parts type field support and mts|cts support,and we dont plan to support mts|cts |
Why not? Is it because of the complexity of refactoring into a transform strategy in the future? |
jiti
Hey, I have refactored the code and updated the documentation. I used jiti without bundling packages, and the dependency issue mentioned in #2237 has been resolved. I tested jiti because it only runs the config file, so it's very fast, like node VM, unlike ts-node which pollutes the global scope. |
jiti
jiti
runtime.
sorry it seems webpack doesn't support @alexander-akait does webpack have any plan to support mts | cts | ts with type:module config? |
I thought about it, but I still think that it should be on the user side, there are a lot of different tools and approaches, but I opened to discussion |
webpack/webpack-cli#3831 since webpack has supported mts|cts now, we may support it as well, @molvqingtai are you still willing to work on this? |
@hardfist note - we don't use |
Why? You can't handle all possible tools and their output |
ESM/CJS compatibility issues should not be thrown to the user. As you can imagine, when the user does not specify a loader and causes an error, it will be a bad experience to search the document for a solution. |
Using |
@molvqingtai I strongly disagree, but I will not argue, we already tried to do it and faced with a lot of problems when new things appear (syntax/different outputs/just features like swc for |
And yes, don't forget about performance, babel is not fast |
Of course, you can use swc. tailwindlabs/tailwindcss@f1614c8 |
@molvqingtai What about another solutions? Want to say - some big (and not only big) tech companies use forks of tools or self created (with remote cache and etc features), if you don't provide them to use it, it will be a blocker, again - you should allow to use custom tools |
@molvqingtai I'll keep fixing the left issue to get this pr merged ASAP if you don't mind |
closes #3609 |
Of course |
!canary |
@molvqingtai thank you for your great work |
Related issue
Enhanced configuration files, added support for
.cts
and.mts
, and fixed the problem of not following the usertype: module
.summary
cli
will automatically registerloader
for.ts | .cts
files, for.ts
files marked withtype: nodule
or.mts
will be considered as ESM and need to usecli
to specify the loader.Walkthrough
rspack.config.ts:
package.json
tsconfig.json
It should work. 🎉