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

[Feature]: Let the ts configuration file support importing other js files in the form of esmodule #9111

Closed
feifeilian opened this issue Jan 24, 2025 · 2 comments
Assignees
Labels
feat New feature or request

Comments

@feifeilian
Copy link

What problem does this feature solve?

ts配置了ts-node,会报如下错误,应该是 在用ts-node处理esmodule格式的ts文件,但是其中会用esmodule的形式import其他js文件,会报require() of ES Module xxx from xxx not supported;想问下这种使用ts的情况,rspack有没有能兼容里边处理第三方js包的形式?

Image

What does the proposed API of configuration look like?

像webapck一样默认支持处理

@feifeilian feifeilian added feat New feature or request pending triage The issue/PR is currently untouched. labels Jan 24, 2025
@feifeilian
Copy link
Author

是不是ts-node没有处理第三方包的转换,有没有大佬帮看下

@chenjiahan chenjiahan changed the title [Feature]: ts情况下支持esmodule的形式import其他js文件 [Feature]: Let the ts configuration file support importing other js files in the form of esmodule Jan 26, 2025
@chenjiahan chenjiahan self-assigned this Jan 26, 2025
@chenjiahan chenjiahan removed the pending triage The issue/PR is currently untouched. label Jan 26, 2025
@chenjiahan
Copy link
Member

I think this is a ts-node issue, see TypeStrong/ts-node#1997.

A workaround is using tsx instead of ts-node (webpack/webpack-cli#2458 (comment)).

Here is an example:

{
  "scripts": {
    "dev": "cross-env NODE_OPTIONS='--import=tsx' NODE_ENV=development rspack serve",
    "build": "cross-env NODE_OPTIONS='--import=tsx' NODE_ENV=production rspack build"
  },
  "devDependencies": {
    "@rspack/cli": "^1.2.2",
    "@rspack/core": "^1.2.2",
    "cross-env": "^7.0.3",
    "tsx": "^4.19.2",
    "typescript": "^5.7.3"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants