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]: named import is missing when using export * #859

Closed
Timeless0911 opened this issue Mar 18, 2025 · 3 comments · Fixed by web-infra-dev/rspack#9784
Closed

[Bug]: named import is missing when using export * #859

Timeless0911 opened this issue Mar 18, 2025 · 3 comments · Fixed by web-infra-dev/rspack#9784

Comments

@Timeless0911
Copy link
Contributor

Timeless0911 commented Mar 18, 2025

Version

-

Details

Source

// foo.ts
export const foo = "foo";
// index.ts
import { foo } from "./foo";

export const bar = (): string => {
  return `${foo}-bar`;
};

export * from "./foo";

Actual

// index.js
export * from "./foo.js";
const bar = ()=>`${foo}-bar`;
export { bar };

Expected

import * as __WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__ from "./foo.js";
const bar = ()=>`${__WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__.foo}-bar`;
export { bar };
export * from "./foo.js";

Reproduce link

https://github.com/Timeless0911/rslib-issue-export-star

Reproduce Steps

  1. pnpm i
  2. pnpm build
@Timeless0911 Timeless0911 changed the title [Bug]: module with const enum is missing when using export * [Bug]: module with enum is missing when using export * Mar 19, 2025
@Timeless0911
Copy link
Contributor Author

Timeless0911 commented Mar 19, 2025

  • Use named export may help.
- export * from "./foo";
+ export { foo } from "./foo";
import * as __WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__ from "./foo.js";
const bar = ()=>`${__WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__.foo}-bar`;
var __webpack_exports__foo = __WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__.foo;
export { bar, __webpack_exports__foo as foo };
  • Remove export * from "./foo"; may help.
import * as __WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__ from "./foo.js";
const bar = ()=>`${__WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__.foo}-bar`;
export { bar };

@Timeless0911
Copy link
Contributor Author

Timeless0911 commented Mar 19, 2025

Using module instead of modern-module help but it does not support export *.

import * as __WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__ from "./foo.js";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
var __webpack_exports__ = {};
__webpack_require__.d(__webpack_exports__, {
    bar: ()=>bar
});
const bar = ()=>`${__WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__.foo}-bar`;
var __webpack_exports__bar = __webpack_exports__.bar;
export { __webpack_exports__bar as bar };

@Timeless0911 Timeless0911 changed the title [Bug]: module with enum is missing when using export * [Bug]: named import is missing when using export * Mar 19, 2025
@Timeless0911
Copy link
Contributor Author

Fixed in v0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant