From f84832957d788e22ca0014dd11e520ddcf7dbaa8 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Mon, 10 Jul 2023 14:06:18 -0700 Subject: [PATCH] DEV: use explicit default export in I18n shim (#22519) Currently the I18n module shim return an object. Per AMD/loader.js, the properties on the object becomes named exports of the module, i.e. `import { t } from 'I18n';`. However, this is not how we actually consume this module. We always do `import I18n from 'I18n';`. The returned object from the shim (`window.I18n`) does NOT have a `default` property on it. This is only working because loader.js has a `makeDefaultExport` feature that defaults to true, which we are relying on to synthesize the default export for us. That feature has been noted as undesirable and may some day be deprecated. In Embroider, it specifically disables the feature in loader.js. https://github.com/embroider-build/embroider/issues/539 --- .../javascripts/discourse/public/assets/scripts/module-shims.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/public/assets/scripts/module-shims.js b/app/assets/javascripts/discourse/public/assets/scripts/module-shims.js index 16a61fe5154..442b9319973 100644 --- a/app/assets/javascripts/discourse/public/assets/scripts/module-shims.js +++ b/app/assets/javascripts/discourse/public/assets/scripts/module-shims.js @@ -1,5 +1,5 @@ define("I18n", ["exports"], function (exports) { - return I18n; + exports.default = I18n; }); define("htmlbars-inline-precompile", ["exports"], function (exports) {