support analyze AMD module format
What problem does this feature solve?
- #2787
What does the proposed API of configuration look like?
https://webpack.js.org/configuration/other-options/#amd
I see that it has already been supported.
Nope, I mean analyze dependencies from an AMD module and bundle its dependencies, for now Rspack only support output an AMD format library if I remember correctly
This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
用systemJs应该都会遇到这个问题,因为systemJs要求引入umd模块必须提前引入amd extra来提供amd环境,在rspack中运行项目就会导致所有用到的umd模块都会因amd环境的存在而导出amd格式,rspack就报错了
I would like to contribute. May I try this?
Hi, I have started working on this issue last weekend. After some research I realised the change is much bigger than I expected. I feel we'd better break it down into 3 stages. Smaller PRs are also easier to review. My plan is to
- add AMD dependencies
- implement AMD plugin and integrate with bundler
- add test cases to verify and fix bugs
So far I have finished stage 1, I will create a draft PR. We can discuss the implementation there.
I will use my branch as feature branch for stage 2 and stage 3.
Great to hear that someone is into that @nilptr That's basically the only thing that's missing and messing the hustle free switch from webpack. We have a bunch of jquery-ui imports that don't work out of the box. Do you know how to fix it before you implement this?
Is this the place to report AMD issues or should I open a new issue?
I'm struggling with Rspack output regarding an AMD build breaking at runtime because of Rspack including the umd wrapper from a dependency:
"../../../../../node_modules/json-logic-js/logic.js": (function (module) {
/* globals define,module */
/*
Using a Universal Module Loader that should be browser, require, and AMD friendly
http://ricostacruz.com/cheatsheets/umdjs.html
*/
;(function(root, factory) {
if (typeof define === "function" && define.amd) {
define(factory);
} else if (true) {
module.exports = factory();
} else {}
}(this, function() {
"use strict";
/* globals console:false */
// ... module code
Where as webpack output contains this instead (which doesn't use the global define function):
/***/ "../../../../../node_modules/json-logic-js/logic.js":
/*!**********************************************************!*\
!*** ../../../../../node_modules/json-logic-js/logic.js ***!
\**********************************************************/
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/* globals define,module */
/*
Using a Universal Module Loader that should be browser, require, and AMD friendly
http://ricostacruz.com/cheatsheets/umdjs.html
*/
;(function(root, factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}(this, function() {
"use strict";
/* globals console:false */
The bundle is built with output.library.type = 'amd' but the environment the bundle is loaded in uses SystemJS and it's AMD extra. As the rspack output uses global define() this breaks as SystemJS creates a System.Register module under the hood which results in the json-logic-js module being empty.