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

support analyze AMD module format #4313

Closed
Tracked by #4327
ahabhgk opened this issue Oct 13, 2023 · 8 comments · Fixed by #8389
Closed
Tracked by #4327

support analyze AMD module format #4313

ahabhgk opened this issue Oct 13, 2023 · 8 comments · Fixed by #8389
Labels
feat New feature or request good first issue Good for newcomers pr welcome team The issue/pr is created by the member of Rspack.

Comments

@ahabhgk
Copy link
Collaborator

ahabhgk commented Oct 13, 2023

What problem does this feature solve?

What does the proposed API of configuration look like?

https://webpack.js.org/configuration/other-options/#amd

@ahabhgk ahabhgk added feat New feature or request pending triage The issue/PR is currently untouched. labels Oct 13, 2023
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Oct 13, 2023
@ahabhgk ahabhgk added p3-nice-to-have and removed pending triage The issue/PR is currently untouched. labels Oct 13, 2023
@shaodahong
Copy link

I see that it has already been supported.

@ahabhgk
Copy link
Collaborator Author

ahabhgk commented Oct 13, 2023

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

@ahabhgk ahabhgk changed the title support AMD module format support analyze AMD module format Oct 25, 2023
@olhapi
Copy link

olhapi commented Sep 17, 2024

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?

@jackw
Copy link

jackw commented Nov 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request good first issue Good for newcomers pr welcome team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants