Skip to content

[Asset Mapper] JSdoc d.ts import files added into the importmap. #57808

Open
@Machy8

Description

@Machy8

Symfony version(s) affected

7.0

Description

I have the app.js file in the assets directory.
The app.js imports a dependency defined within the importmap.php from node_modules.

importmap.php

'signalizejs' => [
        'path' => './node_modules/signalizejs/src/Signalize.js',
        'entrypoint' => true,
 ],

app.js

import Signalize from 'signalizejs';

This signalizejs is importing a file that contains a JSDoc comment that imports d.ts file.

/** @type {import('../../types/modules/component.d.ts').ComponentScope} */

The component.d.ts file is somehow resolved and added into the importmap:

 "/assets/signalizejs/types/modules/component.d.ts": "/assets/signalizejs/types/modules/component.d-625fe73a5caabc8665cc9f757bcc7f8c.ts",

Other imports however, like

/** @type {import('../../types/modules/component').LifeCycleListeners} */

are not resolved. So there is probably some problem with parsing?

The JSDoc comment imports should not be resolved. I found it by accident in the list of 404 errors in Google Search Console.

How to reproduce

Described above.

Possible Solution

I don't know how the javascript compiler works, but I guess it uses some regular expression so a good way would be to get rid of javascript comments before mapping imports.

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