Reproduction:
meteor npm install swiper@6.8.4 and import it on the client import swiper from 'swiper';
- In the package.json, have Meteor recompile swiper:
{
"meteor": {
"nodeModules": {
"recompile": {
"swiper": [
"legacy"
]
}
}
}
}
When running in a legacy browser, there is the error in the node_modules/swiepr/cjs/components/core/core-class.js, which was bundled as part of the modules.js file.
Assignment to read-only properties is not allowed in strict mode
This is caused by:
- The
node_modules/swiepr/cjs/components/core/core-class.js file was already compiled by Babel before the package was published. Babel added the line exports.__esModule = true
- When Meteor compiles the file, Babel adds an import to a babel runtime helper. This runtime helper is imported using ECMAScript import syntax instead of using
require.
- The reify compiler runs, changing the import to be a call to
module.link
When the file is run in the browser:
module.link is called to import the babel helper. module.link also marks the module as being an ecmascript module, setting exports.__esModule to a read only value
- Next, the line babel aded,
exports.__esModule = true, runs. This errors since __esModule is read only.
Reproduction:
meteor npm install swiper@6.8.4and import it on the clientimport swiper from 'swiper';{ "meteor": { "nodeModules": { "recompile": { "swiper": [ "legacy" ] } } } }When running in a legacy browser, there is the error in the
node_modules/swiepr/cjs/components/core/core-class.js, which was bundled as part of themodules.jsfile.This is caused by:
node_modules/swiepr/cjs/components/core/core-class.jsfile was already compiled by Babel before the package was published. Babel added the lineexports.__esModule = truerequire.module.linkWhen the file is run in the browser:
module.linkis called to import the babel helper.module.linkalso marks the module as being an ecmascript module, settingexports.__esModuleto a read only valueexports.__esModule = true, runs. This errors since__esModuleis read only.