Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Requiring es-module-shims locally in AssetMapper causes console error #52547

Copy link
Copy link
Closed
@hashbanged

Description

@hashbanged
Issue body actions

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:

es-module-shims-console-error

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.