Expose Tether's default export, not the module namespace - #234
Draft
boo-code wants to merge 1 commit into
Draft
Conversation
tether 2.0.0 declares module: dist/js/tether.esm.js, which ends with 'export default Tether', and webpack resolves it through that field. So 'expose-loader?exposes=Tether' put the namespace object on window.Tether: new Tether(...) threw "Tether is not a constructor" and Bootstrap 4 alpha's tooltips and popovers - including the password strength hint on the registration form - stayed broken. expose-loader splits an entry on '|' into globalName and moduleLocalName, so 'Tether|default' assigns the export. Built bundles, before and after: before void 0 === i.Tether && (i.Tether = r) // r is the namespace after var o = r.default; void 0 === i.Tether && (i.Tether = o) // o is the class Reported on PrestaShop/PrestaShop#39088.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tether@2.0.0declaresmodule: dist/js/tether.esm.js, whose last line isexport default Tether, and webpack resolves the package through that field. Soimport 'expose-loader?exposes=Tether!tether'put the module namespace object onwindow.Tether:new Tether(...)threwTether is not a constructorand Bootstrap 4 alpha's tooltips and popovers stayed broken - the password strength hint on the registration form is the reported symptom. expose-loader splits an entry on `Uncaught TypeError: Tether is not a constructorand the strength hint does not appear; after it, no error. Any module using a Bootstrap popover or tooltip in the classic theme is affected the same way, as reported on the thread.Measured, in the built bundle
Same webpack config, production mode, only
_dev/js/theme.jsdiffering:The chain that produces it, read in the installed packages rather than assumed:
npx webpack --mode productionexits 0 andnpx eslint -c .eslintrc.js js/theme.jsexits 0.assets/isgitignored in this repository, so the built output is not in the diff.
Why not the approach in the closed PR
classic-theme#178(ChillCode, closed unmerged 2025-12-26) addednew webpack.ProvidePlugin({Tether: 'tether'}). ProvidePlugin injects a module-scoped variable into modulesthat reference the identifier; it does not set
window.Tether, which is what Bootstrap's dist build looksfor, and it would supply the same namespace object rather than the constructor. It is closed, so it blocks
nothing.
Verification limit
The bundle assignment is measured; I have not opened the registration form in a browser. The reporter
measured the same thing from the other end -
Tether.defaultis the constructor,Tetheris not - and asecond reporter (
JBWModules) hit it through Bootstrap popovers in their own modules.