Skip to content

[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

@superchenwb

Description

@superchenwb

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.

Metadata

Metadata

Assignees

Labels

🐞 bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions