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

[Bug]: Rsbuild compiled vuex-module-decorators error,Normal vuex-module-decorators on webpack 5 #3779

Closed
Dengpei1688 opened this issue Oct 21, 2024 · 5 comments
Labels
🐞 bug Something isn't working need reproduction

Comments

@Dengpei1688
Copy link

Version

最新Rsbuild 版本

chrome浏览器

"vuex-module-decorators": "^0.9.9"

Details

项目为vue2.7 + vuex + ts的项目,在webpack5上运行正常,

迁移到rsbuild上vuex-module-decorators运行报错,

Image

Reproduce link

暂无,请问rsbuild的SWC模式是否有提供对于 vuex-module-decorators 的支持?

Reproduce Steps

请问rsbuild的SWC模式是否有提供对于 vuex-module-decorators 的支持?

import { defineConfig,loadEnv } from '@rsbuild/core'
import { pluginVue2 } from '@rsbuild/plugin-vue2'
import { pluginSass } from '@rsbuild/plugin-sass';
import vueLegacy from 'rsbuild-plugin-vue-legacy'

const path = require("path");
const { getPlatInfo } = require('./config')
getPlatInfo()
const { publicVars } = loadEnv({ prefixes: ['VUE_APP_'] });
export default defineConfig({
    output:{
        assetPrefix: '/',
        distPath:{
            root: 'static-center',
        }
    },
    server:{
        open: true,
        proxy: 
    },
    plugins: [pluginVue2(), vueLegacy(), pluginSass(
        {
        sassLoaderOptions: {
            implementation: require.resolve('sass'),
        },
        }
    )],
    html: {
        mountId: 'app',
        template: './public/index.html',
    },
    source: {
        define: publicVars,
        // 指定入口文件
        entry: {
            index: './src/main.ts',
        },
        include: ['vuex-module-decorators'],
        alias: {
            '@': path.resolve(__dirname, 'src'), // './src',
        },
    },
})

@Dengpei1688 Dengpei1688 added the 🐞 bug Something isn't working label Oct 21, 2024
@9aoy
Copy link
Collaborator

9aoy commented Oct 21, 2024

try source.decorators: 'legacy', it's equivalent to TypeScript's experimentalDecorators: true.
https://rsbuild.dev/config/source/decorators#legacy

@Dengpei1688
Copy link
Author

try source.decorators: 'legacy', it's equivalent to TypeScript's experimentalDecorators: true. https://rsbuild.dev/config/source/decorators#legacy

I have tried, but I have found new errors in the project

Image

@Dengpei1688
Copy link
Author

@9aoy 谢谢回复,

这是tsconfig.json的配置

{
    "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "strict": true,
        "jsx": "preserve",
        "importHelpers": true,
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "sourceMap": true,
        "skipLibCheck": true, //修复elementUi-ts版
        "baseUrl": ".",
        "noImplicitAny": false,
        "types": ["webpack-env"],
        "paths": {
            "@/*": ["src/*"]
        },
        "lib": ["esnext", "dom", "dom.iterable", "scripthost"],
        "noEmit": true,
        "emitDecoratorMetadata": true,
        "isolatedModules": true
    },
    "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
    "exclude": ["node_modules"]
}

Copy link
Contributor

Hello @Dengpei1688. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️

@Dengpei1688
Copy link
Author

Thank you for your guidance, source.decorators: 'legacy'
It is effective.

The issue with the screenshot is due to a TS version problem, which resulted in only valid syntax becoming invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working need reproduction
Projects
None yet
Development

No branches or pull requests

3 participants