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]: When lib is set to format as esm and bundle as false, when importing files with the same name from the same level and parent level, the filenames in the compiled output will also be the same. #580

Open
superchenwb opened this issue Dec 19, 2024 · 2 comments · Fixed by web-infra-dev/rspack#8834
Assignees
Labels
🐞 bug Something isn't working

Comments

@superchenwb
Copy link

Version

System:
    OS: Windows 11 10.0.26100
    CPU: (32) x64 Intel(R) Core(TM) i9-14900HX
    Memory: 7.51 GB / 31.73 GB
  Browsers:
    Edge: Chromium (130.0.2849.56)
  npmPackages:
    @rslib/core: ^0.1.5 => 0.1.5

Details

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

export default defineConfig({
  source: {
    entry: {
      index: ["./src/**"],
    },
  },
  lib: [
    {
      bundle: false,
      dts: true,
      format: "esm",
    }
  ],
});

When lib is set to format as esm and bundle as false, when importing files with the same name from the same level and parent level, the filenames in the compiled output will also be the same. The example is as follows:

import * as __WEBPACK_EXTERNAL_MODULE__hook_index_js__ from "./hook/index.js";
import * as __WEBPACK_EXTERNAL_MODULE__hook_index_js__ from "../hook/index.js";
const test2 = ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__hook_index_js__.useTest)();
    (0, __WEBPACK_EXTERNAL_MODULE__hook_index_js__.useTest2)();
};
export { test2 };

This is my demo https://github.com/superchenwb/rslib-demo

Reproduce link

https://github.com/superchenwb/rslib-demo

Reproduce Steps

for example:

  1. execute pnpm dev
  2. find the error message in the dist/test/index.js

There are two declarations of WEBPACK_EXTERNAL_MODULE__hook_index_js.

@superchenwb superchenwb added the 🐞 bug Something isn't working label Dec 19, 2024
@Timeless0911
Copy link
Contributor

Timeless0911 commented Dec 19, 2024

@fi3ework WEBPACK_EXTERNAL_MODULE name should deal with relative path level? Maybe a bug in modern-module?

@fi3ework fi3ework self-assigned this Dec 19, 2024
@fi3ework
Copy link
Member

It's a bug of Rspack, we missed this code fragment https://github.com/webpack/webpack/blob/7701ae43203e9d93d661c9a663c41fccd8e242aa/lib/ExternalModule.js#L239-L244 of webpack. I'll fix it.

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

Successfully merging a pull request may close this issue.

3 participants