-
-
Notifications
You must be signed in to change notification settings - Fork 575
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
Error when using a decorator @connect([email protected]) for a class #3232
Comments
The reason is that reflect-metadata rewrite the and reflect-metadata design for stage 3 of decorator,which require a class decorator to return a function: ref:https://github.com/tc39/proposal-decorators#class-methods |
Maybe related to swc-project/swc#2703 |
Here is a workaround, but may hurt performance, /**
* @type {import('@rspack/cli').Configuration}
*/
module.exports = {
devtool: false,
context: __dirname,
entry: {
main: "./src/main.tsx",
},
output: { chunkFormat: "commonjs" },
builtins: {
html: [
{
template: "./index.html",
},
],
},
module: {
rules: [
{
test: /\.svg$/,
type: "asset",
},
{
test: /\.tsx?$/,
use: [
{
loader: "babel-loader",
},
],
},
],
},
}; .babelrc {
"plugins": [
"babel-plugin-transform-typescript-metadata",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
],
"presets": [
"@babel/preset-typescript"
]
} |
We need time to investigate or port the related babel plugin. |
Since this issue has workaround now, I downgrade the priority. |
since emitDecoratorMetadata needs typecheck evanw/esbuild#257 (comment) and it's out of scope of rspack, so we wouldn't fix it |
System Info
System:
OS: Linux 5.10 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
CPU: (12) x64 AMD EPYC 7Y83 64-Core Processor
Memory: 8.96 GB / 24.96 GB
Container: Yes
Shell: 5.1.4 - /bin/bash
Binaries:
Node: 16.18.0 - /usr/local/nvm/versions/node/v16.18.0/bin/node
Yarn: 1.22.19 - /usr/local/nvm/versions/node/v16.18.0/bin/yarn
npm: 8.19.2 - /usr/local/nvm/versions/node/v16.18.0/bin/npm
Details
When using a decorator @connect([email protected]) for a class while also using the [email protected] package,like:
an error is thrown:
Reproduce link
No response
Reproduce Steps
npm run dev
comman,then you can see the error:The text was updated successfully, but these errors were encountered: