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]: reexport will have duplicate key in object #6934

Closed
spencerHT opened this issue Jun 26, 2024 · 0 comments · Fixed by #6962
Closed

[Bug]: reexport will have duplicate key in object #6934

spencerHT opened this issue Jun 26, 2024 · 0 comments · Fixed by #6962
Labels
bug Something isn't working

Comments

@spencerHT
Copy link

System Info

  System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 175.81 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.19.1 - ~/.nvm/versions/node/v16.19.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.19.1/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v16.19.1/bin/npm
    pnpm: 8.7.0 - ~/.nvm/versions/node/v16.19.1/bin/pnpm
  Browsers:
    Chrome: 126.0.6478.115
    Safari: 17.3.1
  npmPackages:
    @rspack/cli: latest => 0.7.5 
    @rspack/core: latest => 0.7.5 

Details

a.js

export const A = '1';
export const A2 = '2';

b.js

import { A } from './a.js'
export { A };

export * from './a.js'

The Rspack output file:

"./src/b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
  A: function() { return /* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.A; },
  A: function() { return /* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.A; },
  A2: function() { return /* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.A2; }
});

The Webpack output file:

/***/ "./src/b.js":
/*!******************!*\
  !*** ./src/b.js ***!
  \******************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   A: () => (/* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.A),
/* harmony export */   A2: () => (/* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.A2)
/* harmony export */ });
/* harmony import */ var _a_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./a.js */ "./src/a.js");

The Rspack output has duplicated key in a object. This case may not allowed in ES5.

Reproduce link

https://github.com/spencerHT/rspack-reproduce-demo/tree/bug/reexport_duplicate_key

Reproduce Steps

  1. git clone [email protected]:spencerHT/rspack-reproduce-demo.git
  2. git checkout bug/reexport_duplicate_key
  3. pnpm i
  4. pnpm run build:webpack && pnpm run build:rspack
@spencerHT spencerHT added bug Something isn't working pending triage The issue/PR is currently untouched. labels Jun 26, 2024
@h-a-n-a h-a-n-a removed the pending triage The issue/PR is currently untouched. label Jun 27, 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

Successfully merging a pull request may close this issue.

2 participants