symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
849 stars 313 forks source link

[Leaflet] Error during installation #2105

Closed Vastuney closed 1 month ago

Vastuney commented 2 months ago

Module build failed: Module not found: "./vendor/symfony/ux-leaflet-map/assets/dist/map_controller.js" contains a reference to the file "@symfony/ux-map/abstract-map-controller". This file can not be found, please check it for typos or update it if the file got moved.

"./vendor/symfony/ux-leaflet-map/assets/dist/map_controller.js" contains a reference to the file "leaflet/dist/leaflet.min.css". This file can not be found, please check it for typos or update it if the file got moved.

Kocal commented 2 months ago

Hi, how did you installed UX Map Leaflet? Did you install UX Map aswell?

Vastuney commented 2 months ago

Hi, how did you installed UX Map Leaflet? Did you install UX Map aswell?

That's right, I installed both libraries - I'm struggling with this again. Either I don't know something, or the error comes from the first line in the map_controllers.js file

import AbstractMapController from '@symfony/ux-map/abstract-map-controller';

should be

import AbstractMapController from '@symfony/ux-map/abstract_map_controller';

Works for me.

Kocal commented 2 months ago

Ah, looks like you are not using Symfony AssetMapper/ImportMap but Webpack Encore?

The component is experimental, so we can break things without worries.

I think we will need to update the following lines to use @symfony/ux-map/abstract_map_controller:

nfreader commented 2 months ago

👍 from me on this. I'm also using Encore and running into the same issue. I tried editing the referenced files locally but didn't have any luck (I'm not a big JS type).

principis commented 2 months ago

Ah, looks like you are not using Symfony AssetMapper/ImportMap but Webpack Encore?

The component is experimental, so we can break things without worries.

I think we will need to update the following lines to use @symfony/ux-map/abstract_map_controller:

* https://github.com/symfony/ux/blob/2.x/src/Map/assets/package.json#L12

* https://github.com/symfony/ux/blob/2.x/src/Map/src/Bridge/Leaflet/assets/src/map_controller.ts#L1-L2

* https://github.com/symfony/ux/blob/2.x/src/Map/src/Bridge/Google/assets/src/map_controller.ts#L10-L11

Still doesn't seem to work. The following does, but I'm not sure if it's compatible with AssetMapper:

import AbstractMapController from '@symfony/ux-map';
smnandre commented 2 months ago

I think we have a way to handle both WebpackEncore and AssetMapper syntax/descriptor :

https://github.com/symfony/ux/blob/2a177d6bd6899f1fd0c965e317840c94fdb7762d/src/LiveComponent/assets/package.json#L11-L28

smnandre commented 2 months ago

I believe this is how we allow import LiveComponent from "@symfony/ux-live-component"

The other way could be to inline the abstract class during compilation/bundling ?

see: https://symfony.com/bundles/ux-live-component/current/index.html#working-with-the-component-in-javascript

rrenteria-dev commented 1 month ago

I'm also facing this issue using symfony/ux-google-map and webpack encore. Like @principis said, if i change the import statement from @symfony/ux-google-map/dist/map_controller.js

from

import AbstractMapController from '@symfony/ux-map/abstract-map-controller';

to

import AbstractMapController from '@symfony/ux-map';

it works

any suggestions?

thanks in advance

Kocal commented 1 month ago

I will take a look

Kocal commented 1 month ago

Good news coming soon 🤩

Kocal commented 1 month ago

PR opened #2199