Document about alternative JS assets installation with npm packages - #2617
Conversation
| If you're using WebpackEncore, install your assets and restart Encore (not | ||
| needed if you're using AssetMapper): | ||
|
|
||
| .. code-block:: terminal | ||
|
|
||
| $ npm install --force | ||
| $ npm run watch | ||
|
|
There was a problem hiding this comment.
There is no assets for symfony/ux-map, so let's remove this confusing part.
9e2ee48 to
a767b6a
Compare
There was a problem hiding this comment.
Teh way I see this is that we now have 3 different ways of installing this:
(1) PHP-based and uses AssetMapper
.. code-block:: terminal
$ composer require symfony/ux-cropperjs
(2) PHP-based and uses WebpackEncore
.. code-block:: terminal
$ composer require symfony/ux-cropperjs
$ npm install --force
$ npm run watch
(3) JavaScript-based
.. code-block:: terminal
$ npm add @symfony/ux-cropperjs package
My questions:
- Is (3) totally equivalent to (1) and (2)
- If not, in which scenarios would someone use (3) vs (1) or (2)?
Based on the answers to these questions, let's think about the best possible way of showing this information. Thanks.
|
(3) alone is not possible, each UX packages on npm (e.g.: https://www.npmjs.com/package/@symfony/ux-chartjs, https://www.npmjs.com/package/@symfony/ux-translator, ...) mention that the npm package must also install the php package. See #2575 an #691 for more information, but to resume, having standalone JavaScript packages would allow users to install their JavaScript dependencies without needing PHP/Composer, which can be pretty useful in a CI (building Docker images, deploying an app, running JS tests, ...). I would adapt your examples like this: (1) PHP-based and uses AssetMapper $ composer require symfony/ux-cropperjs(2) PHP-based and uses WebpackEncore $ composer require symfony/ux-cropperjs
$ # if user prefers to keep things separated: npm add -D @symfony/ux-cropperjs
$ npm install --force
$ npm run watchWhat do you think about that?
This is exactly why I added you as a reviewer 🤗 |
|
Thanks for the insights. I would expand each installation section as follows: Installation
------------
.. caution::
Before you start, make sure you have `StimulusBundle configured in your app`_.
Run the following command to install this package:
.. code-block:: terminal
$ composer require symfony/ux-cropperjs
If your Symfony application uses `AssetMapper`_, you don't have to do anything else
and can move on to the next section.
If your Symfony application uses `Webpack Encore`_, run the following commands
to install the assets and restart Encore:
.. code-block:: terminal
$ npm install --force
$ npm run watch
.. tip::
The assets of this package are also provided as the standalone `@symfony/ux-cropperjs`_
JavaScript package. This is useful, for example, on continuous integration servers
to build Docker images, run JavaScript tests, etc. without using PHP/Composer.
Usage
-----
[...]
.. _`AssetMapper`: https://symfony.com/doc/current/frontend/asset_mapper.html
.. _`Webpack Encore`: https://symfony.com/doc/current/frontend/encore/index.htmlAlthough docs should be concise, I think it's fine to be a bit verbose/detailed in the I'd mention the scenarios where the JS package is useful. Experts won't need it, but the rest of folks would need this to decide if this is something for them or not. I have a pending question. In the original text, we say things like:
What happens if the reader doesn't have Flex installed? Which steps should be done manually? Thanks |
|
I really like your suggestion, thanks Javier!
If Flex is not installed, then the reader must do (unknown) operations manually:
Which is far from being ideal. |
I would not expose non-experts to manual JS installation for now, as we have not solved the update question as far as I know (@Kocal correct me) |
|
|
||
| .. note:: | ||
|
|
||
| Alternatively, the `@symfony/ux-autocomplete package`_ can be used to install the JavaScript assets without requiring PHP. |
There was a problem hiding this comment.
I would explicitely mention "CI" or "containers" here
|
|
||
| .. note:: | ||
|
|
||
| Alternatively, the `@symfony/stimulus-bundle package`_ can be used to install the JavaScript assets without requiring PHP. |
There was a problem hiding this comment.
Are we sure everything works here ? :| This feels suspicious as some path are hard-coded for controller.json
There was a problem hiding this comment.
Well, you're right, those dist/ files are only needed when you use the AssetMapper, since we tell users to use npm package @symfony/stimulus-bridge when using Encore.
There was a problem hiding this comment.
I will mark this npm package as private for 2.24, and remove it from npm. I will adapt the README.md telling people looks for assets must install @symfony/stimulus-bridge if using Encore.
Let's see in the future if we really need to publish this one.
Thanks!
EDIT: the package is not removable anymore, so I marked it as deprecated, that's the best I can do.
|
@javiereguiluz after some discussions after Simon, I think we will go for the following changes:
Thus, we add documentation where it's necessary, without adding a lot of documentation to already long documents. |
a767b6a to
5cfcf8e
Compare
|
After many iterations, I think we are on something really good. |
0de3b76 to
146eb92
Compare
146eb92 to
9131a71
Compare
Follow #2616