mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 00:29:18 +08:00
e7dee94c5c
The previous version of ember-on-resize-modifier depended on ember-modifier@^3.2.7 while discourse had ember-modifier@^4.1.0. As far as Yarn is concerned, it can accomplish this with: node_modules ... ember-modifier 4.1.0 ... ember-on-resize-modifier 1.1.0 ... ember-modifier 3.2.7 ... ... This does NOT work! In a classic build everything is compiled down to AMD modules and at runtime there can only be one uniquely named "ember-modifier" module. When we have duplicates, depending on activation ordering, one of them will randomly win. In practice, it seems like ember-modifier 3.2.7 had "won" in the current build, and we are shipping it to production, you can find these modules in vendor.js like: ```js ;define("ember-modifier/-private/class/modifier", /* ... */, function(/* ... */) { /* the 3.2.7 version with deprecations, etc */ }) /* ... */ ;define("ember-modifier/index", /* ... */) ``` However, ember-auto-import also "found" the 4.1.0 version and in one of the chunk.app.js: ```js d('ember-modifier', /* ... */, function() { return __webpack_require__(/*! ember-modifier */ 227); }); ``` ...and in one of the chunk.vendors.js... ```js /* 227 */ /*!****************************************************!*\ !*** ../node_modules/ember-modifier/dist/index.js ***! \****************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* ...the 4.1.0 version... */ }), ``` So, in practice: * We are brining both copies into the production build * The 3.2.7 modules are available in the AMD loader as "ember-modifier/..." * But 4.1.0 modules are available in the AMD loader as "ember-modifier" * Because mostly it's consumed as `import ... from "ember-modifier";`, the latter end up actually winning * Because the newer code is compatible enough, and the deprecated features are unused, it seems to work ok..? But in the Embroider build, ember-auto-import doesn't emit those shims anymore. It does process most of the core modules through Webpack so the imports get correctly wired up to the 4.1.0 as expected, as they no longer go through/need the runtime AMD loader.js. The older 3.2.7 copy is _still_ shipped in the vendor bundle and registered the same, but not "stomped over" by the EAI shims anymore. Our manual shims (#22703, merged yesterday) are more "polite" and check `require.has(...)` before defining the module, and since `require.has(...)` check for the `/index` alias and returns `true`, our shim does not stomp the 3.2.7 modules either. So then, when our "auxilary bundles" (admin, plugins, etc) tries to import `"ember-modifier", they get the 3.2.7 version. |
||
---|---|---|
.. | ||
images | ||
javascripts | ||
stylesheets |