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]: match unexpected environment resources when serving #2956

Open
9aoy opened this issue Jul 18, 2024 · 0 comments
Open

[Bug]: match unexpected environment resources when serving #2956

9aoy opened this issue Jul 18, 2024 · 0 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@9aoy
Copy link
Collaborator

9aoy commented Jul 18, 2024

Version

rsbuild 1.0 beta

Details

When multiple environments exist and their products are dist/main.js (web product) and dist/bundle/main.js (node ​​product)

expect:

  • Match dist/main.js when accessing localhost:3000/mian
  • Match dist/bundle/main.js when accessing localhost:3000/bundle/mian

actual:

  • Matches dist/bundle/main.js when accessing localhost:3000/mian (unexpected)
  • Match dist/bundle/main.js when accessing localhost:3000/bundle/mian

The rsbuild configuration is as follows:

import { defineConfig } from '@rsbuild/core';

export default defineConfig({
  environments: {
    node: {
      output: {
        distPath: {
          root: 'dist/bundle',
        },
      },
    },
   web: {},
  },
});

Reproduce link

none

Reproduce Steps

The root cause of this problem is that when using multiCompiler(Multiple rsbuild environments), webpack-dev-middleware matches resources based on the outputPath + publicPath of each compiler. When the environment node is created before the web, webpack-dev-middleware preferentially matches the resources in node stats.

image

image

https://github.com/webpack/webpack-dev-middleware/blob/master/src/utils/getFilenameFromUrl.js#L68

This can be temporarily solved by adjusting the environment registration order.

@9aoy 9aoy added the 🐞 bug Something isn't working label Jul 18, 2024
@9aoy 9aoy self-assigned this Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant