AssetMapperTypeScriptBundle icon indicating copy to clipboard operation
AssetMapperTypeScriptBundle copied to clipboard

symfony 7 documentation

Open Guteres007 opened this issue 1 year ago • 1 comments

In Symfony 7 doesnt working default asset function:

I solved it with: {{ importmap('typescript/app') }}

Guteres007 avatar May 16 '24 19:05 Guteres007

Hi, thank you for the request :pray:
I tried the original example from the doc myself and it work correctly with symfony 7.0 as well as 7.1, so I don't think that having different approaches depending on symfony version is the way to go.

But obviously the doc should be improved.
I see 3 use-case but I may be mistaken (@WebMamba maybe you could advise us on the best practices ?).

  1. You're approach is good when your app has a typescript file as an entrypoint. You define it in importmap.php and then you only call the importmap function once in your twig template.
  2. If your your typescript file isn't supposed to be an entrypoint, you can just import what you need from your original entrypoint :
// assets/app.js
import {MyTypeScriptClass} from "./typescript/my-ts-file.ts"
  1. If you just want to load a raw script, the example from the doc should work.

Now I don't know if we should showcase all these use-cases, some advises from the ux community would be appreciated.

maelanleborgne avatar May 20 '24 13:05 maelanleborgne