web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
9.27k stars 540 forks source link

官网示例报错 #4745

Closed Ezreal09 closed 10 months ago

Ezreal09 commented 10 months ago

System Info

System: OS: macOS 11.7.1 CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz Memory: 224.30 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node Yarn: 1.22.11 - /usr/local/bin/yarn npm: 9.6.7 - ~/.nvm/versions/node/v18.12.1/bin/npm pnpm: 8.6.12 - ~/.nvm/versions/node/v18.12.1/bin/pnpm bun: 1.0.3 - ~/.nvm/versions/node/v18.12.1/bin/bun Browsers: Chrome: 119.0.6045.159 Safari: 14.1.2 npmPackages: @rspack/cli: ^0.4.0 => 0.4.0

Details

按照https://www.rspack.dev/zh/guide/quick-start.html示例来,执行npx rspack build直接报错 image

Reproduce link

No response

Reproduce Steps

官网示例即可

xiaojingzhao commented 10 months ago

Just initializing a react-ts project without changing any code, I also got a javascript parsing error. node: v18.18.2 pnpm: 7.32.0

image image image

Boshen commented 10 months ago

感谢尝试使用 Rspack。

根据 Rspack 0.4 发布公告, 我们需要主动在 module.rules 中添加

{
    test: /.jsx$/,
    loader: 'builtin:swc-loader',
    type: 'javascript/auto',
    options: {
        jsc: {
            parser: {
                syntax: "ecmascript",
                jsx: true
            },
            transform:{
                react: {
                    runtime: "automatic"
                }
            },
        },
    },
}

npm create rspack@latest 暂未对此做适配,我们将尽快修复。

hardfist commented 10 months ago

@xiaojingzhao @Ezreal09 it is fixed now,can you retry

Ezreal09 commented 10 months ago

@xiaojingzhao @Ezreal09 it is fixed now,can you retry

还是不行,建议你们自己按照官方示例「手动安装」部分,然后加上上面的配置试一下。

Ezreal09 commented 10 months ago

感谢尝试使用 Rspack。

根据 Rspack 0.4 发布公告, 我们需要主动在 module.rules 中添加

{
  test: /.jsx$/,
  loader: 'builtin:swc-loader',
  type: 'javascript/auto',
  options: {
      jsc: {
          parser: {
              syntax: "ecmascript",
              jsx: true
          },
          transform:{
              react: {
                  runtime: "automatic"
              }
          },
      },
  },
}

npm create rspack@latest 暂未对此做适配,我们将尽快修复。 需要将默认禁用转换设置为false experiments: { rspackFuture: { disableTransformByDefault: false } }

hardfist commented 10 months ago

@Ezreal09 the npm create rspack is fixed, but website is not updated, will update soon