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

Should not parse require() in mjs+esm #5197

Closed
LingyuCoder opened this issue Jan 3, 2024 · 2 comments · Fixed by #5515
Closed

Should not parse require() in mjs+esm #5197

LingyuCoder opened this issue Jan 3, 2024 · 2 comments · Fixed by #5515
Assignees
Labels
team The issue/pr is created by the member of Rspack.

Comments

@LingyuCoder
Copy link
Collaborator

// a.mjs
import a from './b.js';
var b = require('./c.js');
console.log(a, b);
// webpack did not parse require('./c.js');
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _b_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/b.mjs");


var b = require('./c');

console.log(_b_mjs__WEBPACK_IMPORTED_MODULE_0__["default"], b);
// rspack parsed require('./c.js')
__webpack_require__.r(__webpack_exports__);
/* harmony import */var _b_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./b.mjs */"./src/b.mjs");

var b = __webpack_require__(/*! ./c */"./src/c.js");
console.log(_b_mjs__WEBPACK_IMPORTED_MODULE_0__["default"], b);
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Jan 3, 2024
@LingyuCoder LingyuCoder self-assigned this Jan 3, 2024
@LingyuCoder LingyuCoder changed the title Should not parse require() in mjs and esm Should not parse require() in mjs+esm Jan 3, 2024
@9aoy
Copy link
Collaborator

9aoy commented Jan 6, 2024

image

This problem also causes modern.js to fail in rspack-ecosystem-ci. It is OK in rspack 0.4.5, but it is fail in 0.4.5-canary.

https://github.com/web-infra-dev/rspack-ecosystem-ci/actions/runs/7428373212/job/20215610121

@LingyuCoder
Copy link
Collaborator Author

LingyuCoder commented Jan 8, 2024

image This problem also causes modern.js to fail in rspack-ecosystem-ci. It is OK in rspack 0.4.5, but it is fail in 0.4.5-canary.

https://github.com/web-infra-dev/rspack-ecosystem-ci/actions/runs/7428373212/job/20215610121

Caused by a bug, require() in try catch block should be parsed with optional flag.

Fix #5262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants