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]: extensionAlias is undefined when use webpack provider #3548

Closed
beliefgp opened this issue Sep 25, 2024 · 6 comments · Fixed by #3564
Closed

[Bug]: extensionAlias is undefined when use webpack provider #3548

beliefgp opened this issue Sep 25, 2024 · 6 comments · Fixed by #3564
Labels
🐞 bug Something isn't working need reproduction

Comments

@beliefgp
Copy link

beliefgp commented Sep 25, 2024

Version

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M3
    Memory: 87.39 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 129.0.6668.70
    Safari: 17.5
  npmPackages:
    @rsbuild/core: ^1.0.1 => 1.0.6 
    @rsbuild/plugin-less: ^1.0.1 => 1.0.1 
    @rsbuild/plugin-vue: ^1.0.1 => 1.0.1 
    @rsbuild/plugin-webpack-swc: ^1.0.2 => 1.0.2 
    @rsbuild/webpack: ^1.0.5 => 1.0.5

Details

https://github.com/web-infra-dev/rsbuild/blob/main/packages/core/src/plugins/resolve.ts#L48

extensionAlias is undefined when use webpack provider,

use rspack, it is ok

import { defineConfig } from '@rsbuild/core';
import { pluginVue } from '@rsbuild/plugin-vue';
import { webpackProvider } from '@rsbuild/webpack';
import { pluginSwc } from '@rsbuild/plugin-webpack-swc';

export default defineConfig({
  provider: webpackProvider,
  source: {
    entry: {
      main: './src/index.ts'
    },
  },
  plugins: [
    pluginSwc(),
    pluginVue(), 
  ]
});

plugin-webpack has its own rsbuild dependency, should it be changed to peer?

https://github.com/web-infra-dev/rsbuild/blob/main/packages/compat/webpack/package.json#L31

Reproduce link

xxx

Reproduce Steps

npx rsbuild build

@beliefgp beliefgp added the 🐞 bug Something isn't working label Sep 25, 2024
Copy link
Contributor

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

@chenjiahan
Copy link
Member

Can not reproduce this issue:

image

@beliefgp
Copy link
Author

@chenjiahan 这个主要是发生在 @rsbuild/core 和 @rsbuid/webpack 两边版本不同步的情况下,比如这次的问题:
是 @rsbuild/core 1.0.6 增加了 extensionAlias,但是 @rsbuid/webpack 1.0.5 内部依赖的还是 @rsbuild/core@1.0.5 就造成了这次的问题。

按现在的使用方式:

import { webpackProvider } from '@rsbuild/webpack';

export default defineConfig({
  provider: webpackProvider,
});

@rsbuild/webpack 对 @rsbuild/core 的依赖应该放在 peer 里面,而不是 dep 里

@chenjiahan
Copy link
Member

Actually @rsbuid/webpack is not a public package...Are you using Rsbuild + webpack to build your project?

@beliefgp
Copy link
Author

是的,使用的 @rsbuild/core,但因为一些原因,还是需要使用 webpack,所以引入了 @rsbuid/webpack,但目前 @rsbuid/webpack 并没有提供 cli 指令,也不是作为独立包使用的,从现在的使用上来讲,它的定位类似于 rsbuild 的插件。

所以 @rsbuid/webpack 不应该把 @rsbuild/core 放在 dep 里,而应该是放在 peerDep 里。

@chenjiahan
Copy link
Member

Ok, I will adjust the dependency. Please note that @rsbuild/webpack is not a public package and we do not guarantee that the API it provides is stable.

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

Successfully merging a pull request may close this issue.

2 participants