Skip to content

[AssetMapper] JavaScriptImportPathCompiler regex breaks on non-latin characters #58657

Closed
@GregRbs92

Description

@GregRbs92

Symfony version(s) affected

all

Description

I was trying to serve the assets of a compiled Angular application thanks to the AssetMapper in order to have small units of Angular on my pages without having a full Angular application.

Things were working pretty well until I got one of my imported chunks not compiled into the importmap, resulting in a 404 when the chunk was imported.

After a few investigations, I found out that it was because Angular have some functions with a name like ɵɵdefineComponent, with Greek letters, and that these letters are preventing the regex from doing a proper job.

How to reproduce

  1. Follow the installation of AssetMapper as explained in Symfony documentation
  2. Create a new file assets/dependency.js with a method name ɵmyMethod
  3. At the top of app.js add import { ɵmyMethod } from './dependency.js'

=> Look at the importmap generated in the DOM, the file dependency.js was not added to it

Possible Solution

Just adding the unicode character matcher \p{L} along with the already existing \w\s{},* seems to work pretty well as shown in these two regex :

Existing regex (link available in the JavaScriptImportPathCompiler code) where I added a ɵ in the imported function name : https://regex101.com/r/oqY4Ck/1

Fixed regex with \p{L} : https://regex101.com/r/dxEXjq/2

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