Skip to content

Commit d1c9b2b

Browse files
committed
bug #2983 [Map] Allows Bridges JavaScript assets to be installed with npm when using file:vendor/symfony/ux-*-map/assets (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [Map] Allows Bridges JavaScript assets to be installed with `npm` when using `file:vendor/symfony/ux-*-map/assets` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Docs? | no <!-- required for new features --> | Issues | Fix #2951, #2737 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Update/add documentation as required (we can help!) - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Alternative to #2982. Moving the `"`@symfony`/ux-map": "workspace:*"` requirements **outside the package.json** allows the Bridges JavaScript assets to be installed with `npm` when ``@symfony`/ux-leaflet-map` (or ``@symfony`/ux-google-map`) is using constraint version `file:vendor/symfony/ux-leaflet-map/assets` (or `file:vendor/symfony/ux-google-map/assets`) in the user application. This is possible to this super feature from pnpm: [packageExtensions](https://pnpm.io/settings#packageextensions), which allows to override some part of package definitions in file `pnpm-workspace.yaml`: - this file is read by pnpm and understand that ``@symfony`/ux-map` is a dependency of ``@symfony`/ux-leaflet-map` and ``@symfony`/ux-google-map` 🎉 - this file is totally unknown to npm, no `workspace:*` anymore in any `package.json` 🎉 It is not possible to defines `packageExtensions.devDependencies`, so I used `packageExtensions.dependencies` instead but that's fine. ``@symfony`/ux-map` is not referenced in any `package.json` when running `pnpm pack` in `src/Bridge/*/assets`. Commits ------- 1667af7 [Map] Allows Bridges JavaScript assets to be installed with `npm` when using `file:vendor/symfony/ux-*-map/assets`
2 parents 968f1f1 + 1667af7 commit d1c9b2b

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

.github/workflows/app-tests.yaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,6 @@ jobs:
5454
working-directory: test_apps/encore-app
5555
dependency-versions: highest
5656

57-
- name: Manually replacing "workspace:*" references
58-
run: |
59-
# npm does not support "workspace:*" references, so we need to replace them with the actual package path
60-
for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
61-
PACKAGE=$(echo $PACKAGE_DATA | jq -r '.name')
62-
PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
63-
64-
echo "🔍 Searching for \"workspace:*\" references in $PACKAGE_PATH/package.json"
65-
66-
# Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
67-
jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
68-
echo "ℹ️ Found \"$PACKAGE_FROM_WORKSPACE\" with \"workspace:*\""
69-
70-
PACKAGE_FROM_WORKSPACE_PATH=$(pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1 | jq -r '.[].path')
71-
echo "ℹ️ The package \"$PACKAGE_FROM_WORKSPACE\" is located in \"$PACKAGE_FROM_WORKSPACE_PATH\" directory"
72-
73-
echo "⚒️ Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"file:$PACKAGE_FROM_WORKSPACE_PATH\" in $PACKAGE_PATH/package.json"
74-
sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"file:$PACKAGE_FROM_WORKSPACE_PATH\"|g" "$PACKAGE_PATH/package.json"
75-
done;
76-
done
77-
7857
- working-directory: test_apps/encore-app
7958
run: npm install --install-links
8059

pnpm-lock.yaml

Lines changed: 11 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ overrides:
1111
'@swup/plugin>prettier': link:node_modules/.ignored
1212
'@swup/plugin>shelljs': link:node_modules/.ignored
1313
'@swup/plugin>shelljs-live': link:node_modules/.ignored
14+
15+
packageExtensions:
16+
'@symfony/ux-google-map':
17+
dependencies:
18+
'@symfony/ux-map': 'workspace:*'
19+
20+
'@symfony/ux-leaflet-map':
21+
dependencies:
22+
'@symfony/ux-map': 'workspace:*'

src/Map/src/Bridge/Google/assets/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"devDependencies": {
5151
"@googlemaps/js-api-loader": "^1.16.6",
5252
"@hotwired/stimulus": "^3.0.0",
53-
"@symfony/ux-map": "workspace:*",
5453
"@testing-library/dom": "^10.4.0",
5554
"@testing-library/jest-dom": "^6.6.3",
5655
"@testing-library/user-event": "^14.6.1",

src/Map/src/Bridge/Leaflet/assets/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
},
5050
"devDependencies": {
5151
"@hotwired/stimulus": "^3.0.0",
52-
"@symfony/ux-map": "workspace:*",
5352
"@testing-library/dom": "^10.4.0",
5453
"@testing-library/jest-dom": "^6.6.3",
5554
"@testing-library/user-event": "^14.6.1",

0 commit comments

Comments
 (0)