Skip to content
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

[Stimulus] Create NPM Package for @symfony/stimulus-bundle to Decouple from PHP Components #2575

Open
alinceDev opened this issue Feb 16, 2025 · 3 comments · May be fixed by #2617
Open

[Stimulus] Create NPM Package for @symfony/stimulus-bundle to Decouple from PHP Components #2575

alinceDev opened this issue Feb 16, 2025 · 3 comments · May be fixed by #2617
Labels

Comments

@alinceDev
Copy link

Issue Description:

Currently, certain JavaScript bundles, such as @symfony/stimulus-bundle, are being installed from the vendor package instead of an NPM package. This is evident in the package.json file where the dependency is specified as:

    "@symfony/stimulus-bundle": "file:vendor/symfony/stimulus-bundle/assets",

Problem

This approach creates a tight coupling between the JavaScript and PHP components, making it difficult to manage and install JavaScript dependencies independently. For instance, in a CI environment, this setup requires the installation of PHP components via Composer to install the JavaScript packages, which is not ideal for running tests with Playwright or other JavaScript-focused tasks.

Request

Could you please create an NPM package for @symfony/stimulus-bundle (and potentially other relevant bundles) to allow for independent installation via NPM? This would streamline the setup process, especially in CI environments, and decouple the JavaScript dependencies from the PHP components.

Use Case Example

For example, when setting up a CI pipeline to run Playwright tests, it would be beneficial to install the necessary JavaScript packages directly via NPM without needing to install the PHP components through Composer.

If this issue is already documented and I missed the information, I apologize for the oversight. Thank you for considering this enhancement!

@alinceDev alinceDev added the RFC label Feb 16, 2025
@smnandre
Copy link
Member

Say we do publish on npm the LiveComponent javascript part.

Next release we have a new feature that does work with JS and PHP.

How would you enforce both vendors/symfony/ux-live-component and nodes_modules/vendor/symfony.. are in sync ?

(genuine question)

@Kocal
Copy link
Member

Kocal commented Feb 23, 2025

Maybe we can hook on postinstall npm script and read user's composer.lock to see if the PHP package has the same version.

@Kocal Kocal marked this as a duplicate of #691 Feb 23, 2025
Kocal added a commit that referenced this issue Feb 28, 2025
…PM (Kocal)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

Normalize package.json files, to prepare publication on NPM

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Issues        | Fix #... <!-- 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.
 - 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).
-->

This is a first iteration for #2575: rework our `package.json` files in order to make them more "friendly" and work on npm.

Next steps:
1. Add some verifications, to ensure PHP and JS versions of a same package are identical (and so 100% compatible)
2. See how we can deploy JS packages when creating a new UX releases. I'm thinking about a full automated process using the CI with a workflow listening on tag creation, which will be responsible to upgrade the `version` from `package.json` files, commit, push, and publish to npm)
3. Check if we need to manually create the packages on npm before trying to publishing them

Commits
-------

87bc2b8 Set Map/assets/packages.json private
68a0e8a Remove tree from repository URL in each package.json
bea8d4e Add README.md file for each UX packages assets
7162520 Add LICENSE file for each UX packages assets
4de9061 Normalize package.json files, to prepare publication on NPM
Kocal added a commit that referenced this issue Mar 1, 2025
…tallation and recommended alternatives. (Kocal)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

Document `src/**/assets/README.md` files about direct installation and recommended alternatives.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Issues        | Fix #... <!-- 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.
 - 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).
-->

Follow #2595, related to #2575

Commits
-------

9a4acb1 [CI] Do not run `test` workflow if only `src/**/*.md` files have been modified
d49923b Document `src/**/assets/README.md` files about direct installation and recommended alternatives.
@Kocal
Copy link
Member

Kocal commented Mar 2, 2025

Done in #2595, #2612 and #2617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants