Description
Symfony version(s) affected
6.3, 6.4-dev, 6.4.0-beta3
Description
Using the default remotely-hosted shims works as expected. If requiring the polyfills as a local vendor asset, an error occurs:
Javascript console
es-module-shims.index-50eab39155ca286f16894eb2ba1c2740.js:7 Uncaught SyntaxError: Invalid or unexpected token (at es-module-shims.index-50eab39155ca286f16894eb2ba1c2740.js:7:12535)
The generated file (assets/vendor/es-module-shims/es-module-shims.index.js
) appears to be mangled.
For projects not needing the shim support, explicitly disabling it removes the error. Including it as a CDN asset, however, means the user will need to write a server CSP allowing the remote host, which may be undesirable. In Apache2:
security.conf
Header always set Content-Security-Policy "script-src blob: https://ga.jspm.io;"
How to reproduce
In a Symfony ^6.3 project using AssetMapper, require ES Module Shims as a local dependency:
./bin/console importmap:require es-module-shims
[OK] Package "es-module-shims" added to importmap.php.
Use the new package normally by importing "es-module-shims".
Load the project page in a browser and review the inspector console for errors:
Possible Solution
A workaround if IE11 support isn't needed is to just disable the polyfill:
config/packages/asset_mapper.yaml
framework:
asset_mapper:
# The paths to make available to the asset mapper.
paths:
- assets/
importmap_polyfill: false
Additional Context
No response