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

fix: preserve star export from external module #8217

Merged
merged 2 commits into from
Oct 30, 2024
Merged

Conversation

fi3ework
Copy link
Member

@fi3ework fi3ework commented Oct 25, 2024

Summary

Fix #8206.

Overall changes:

  • A module that is an externalized type of "module" or "module-import" will make export * classified as a new ExportModeType::ReexportFrom. This type will not introduce runtime.
  • The export * from 'x' from be added in modern-module by a new dependency.
  • possible breaking change: Previously, with "module" external type, all star export will wrongly be assigned to the default export of the entry which is totally a wrong result. In this PR, export * will not work anymore.
output of previous implementation with export * from 'react'; export * from 'vue';, react and vue are externalized with type "module".
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE_vue__ from "vue";
var __webpack_modules__ = ({
"945": (function (module) {

module.exports = __WEBPACK_EXTERNAL_MODULE_react__;


}),
"769": (function (module) {

module.exports = __WEBPACK_EXTERNAL_MODULE_vue__;


}),

});
/************************************************************************/
// The module cache
var __webpack_module_cache__ = {};

// The require function
function __webpack_require__(moduleId) {

// Check if module is in cache
var cachedModule = __webpack_module_cache__[moduleId];
if (cachedModule !== undefined) {
return cachedModule.exports;
}
// Create a new module (and put it into the cache)
var module = (__webpack_module_cache__[moduleId] = {
exports: {}
});
// Execute the module function
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);

// Return the exports of the module
return module.exports;

}

/************************************************************************/
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = function(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/runtime/has_own_property
(() => {
__webpack_require__.o = function (obj, prop) {
	return Object.prototype.hasOwnProperty.call(obj, prop);
};

})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = function(exports) {
	if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
		Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
	}
	Object.defineProperty(exports, '__esModule', { value: true });
};

})();
/************************************************************************/
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
  case1: function() { return case1; }
});
/* ESM import */var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(945);

/* ESM reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
/* ESM reexport (unknown) */ for( var __WEBPACK_IMPORT_KEY__ in react__WEBPACK_IMPORTED_MODULE_0__) if(["case1","default"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] =function(key) { return react__WEBPACK_IMPORTED_MODULE_0__[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)
/* ESM reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
/* ESM import */var vue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(769);

/* ESM reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
/* ESM reexport (unknown) */ for( var __WEBPACK_IMPORT_KEY__ in vue__WEBPACK_IMPORTED_MODULE_1__) if(["case1","default"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] =function(key) { return vue__WEBPACK_IMPORTED_MODULE_1__[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)
/* ESM reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);

const case1 = 1

var __webpack_exports__case1 = __webpack_exports__.case1;
var __webpack_exports__default = __webpack_exports__["default"];
export { __webpack_exports__case1 as case1, __webpack_exports__default as default };

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Oct 25, 2024
Copy link

netlify bot commented Oct 25, 2024

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 2628a7c
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/6720ee0689bfc4000879c61d
😎 Deploy Preview https://deploy-preview-8217--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@fi3ework fi3ework marked this pull request as ready for review October 28, 2024 07:37
@fi3ework fi3ework requested a review from ahabhgk October 28, 2024 07:37
@fi3ework fi3ework enabled auto-merge (squash) October 30, 2024 06:32
@fi3ework
Copy link
Member Author

cc @jerrykingxyz PLAT as you're the code owner of some files.

@jerrykingxyz jerrykingxyz disabled auto-merge October 30, 2024 07:16
@jerrykingxyz jerrykingxyz enabled auto-merge (squash) October 30, 2024 07:17
@jerrykingxyz jerrykingxyz merged commit 673bfd6 into main Oct 30, 2024
29 checks passed
@jerrykingxyz jerrykingxyz deleted the export-star branch October 30, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Set external extension, compilation error during dependent export
3 participants