Skip to content

[Map] Fix Google/Leaflet bridges when using Webpack Encore#2199

Merged
Kocal merged 2 commits intosymfony:2.xfrom
Kocal:fix-map-bridges-webpack
Sep 24, 2024
Merged

[Map] Fix Google/Leaflet bridges when using Webpack Encore#2199
Kocal merged 2 commits intosymfony:2.xfrom
Kocal:fix-map-bridges-webpack

Conversation

@Kocal
Copy link
Member

@Kocal Kocal commented Sep 23, 2024

Q A
Bug fix? yes
New feature? no
Issues Fix #2105
License MIT

This PR fixes #2105, and ensures Leaflet and GoogleMaps bridges are working fine with Webpack Encore.

To be sure:

  1. I've created a new Symfony app (no --webapp),
  2. Installed Encore, Stimulus, and Map
  3. Added .addAliases({ 'leaflet/dist/leaflet.min.css': 'leaflet/dist/leaflet.css' }) and .enableStimulusBridge('./assets/controllers.json') in webpack.config.js
  4. Created the Map (new Map()) and rendered it (ux_map(map, { style: 'height: ...' }))

I am able to display a Leaflet map:
image

And a GoogleMap maps:
image


The Map rendered on ux.symfony.com is also working (after updating the importmap.php as documented):

image

@carsonbot carsonbot added Bug Bug Fix Map Status: Needs Review Needs to be reviewed labels Sep 23, 2024
@Kocal Kocal force-pushed the fix-map-bridges-webpack branch from 450b96d to 5abfff3 Compare September 23, 2024 22:00
@Kocal Kocal force-pushed the fix-map-bridges-webpack branch from 5abfff3 to b3283f4 Compare September 23, 2024 22:01
@@ -1,8 +1,48 @@
import AbstractMapController from '@symfony/ux-map/abstract-map-controller';
import { Controller } from '@hotwired/stimulus';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely because Rollup has been able to resolve the file when using import AbstractMapController from '@symfony/ux-map', the AbstractMapController is now inlined.

I'm fine with this, especially it removes one useless HTTP request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Copy link
Member

@smnandre smnandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Sep 23, 2024
@Kocal Kocal merged commit 48c5fa1 into symfony:2.x Sep 24, 2024
@Kocal Kocal deleted the fix-map-bridges-webpack branch September 24, 2024 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Bug Fix Map Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Leaflet] Error during installation

4 participants