Skip to content

[Map] Allows Bridges JavaScript assets to be installed with npm when using file:vendor/symfony/ux-*-map/assets #2983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2025

Conversation

Kocal
Copy link
Member

@Kocal Kocal commented Aug 8, 2025

Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #2951, #2737
License MIT

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, 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.

@carsonbot carsonbot added Bug Bug Fix Map Status: Needs Review Needs to be reviewed labels Aug 8, 2025
…n using `file:vendor/symfony/ux-*-map/assets`
@Kocal Kocal force-pushed the 2737-no-pnpm-workspace-bis branch from 4689dbc to 1667af7 Compare August 8, 2025 08:51
Comment on lines -57 to -77
- name: Manually replacing "workspace:*" references
run: |
# npm does not support "workspace:*" references, so we need to replace them with the actual package path
for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
PACKAGE=$(echo $PACKAGE_DATA | jq -r '.name')
PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')

echo "🔍 Searching for \"workspace:*\" references in $PACKAGE_PATH/package.json"

# Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
echo "ℹ️ Found \"$PACKAGE_FROM_WORKSPACE\" with \"workspace:*\""

PACKAGE_FROM_WORKSPACE_PATH=$(pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1 | jq -r '.[].path')
echo "ℹ️ The package \"$PACKAGE_FROM_WORKSPACE\" is located in \"$PACKAGE_FROM_WORKSPACE_PATH\" directory"

echo "⚒️ Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"file:$PACKAGE_FROM_WORKSPACE_PATH\" in $PACKAGE_PATH/package.json"
sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"file:$PACKAGE_FROM_WORKSPACE_PATH\"|g" "$PACKAGE_PATH/package.json"
done;
done

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not needed anymore :)

@kbond
Copy link
Member

kbond commented Aug 8, 2025

Thanks Hugo.

@kbond kbond merged commit d1c9b2b into symfony:2.x Aug 8, 2025
24 of 28 checks passed
@Kocal Kocal deleted the 2737-no-pnpm-workspace-bis branch August 8, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Map Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

npm error Unsupported URL Type "catalog:"
3 participants