posthtml / posthtml-expressions

Use variables, JS-like expressions, and even markup-powered logic in your HTML.
Other
123 stars 20 forks source link

Does not work when using Yarn Plug'n'play. #151

Closed Ulyanov-programmer closed 1 year ago

Ulyanov-programmer commented 1 year ago

Hello!

In the process of using the yarn package manager technology, called plug'n'play, i encountered an error when trying to launch.

➤ YN0002: │ posthtml-expressions@npm:1.11.0 doesn't provide posthtml (p3eafc), requested by posthtml-match-helper

A similar error has already happened with another library, and, apparently, it happens because of this:

  1. The plugin tries to import posthtml;
  2. Yarn PnP, following a pre-assembled dependency map, tries to find posthtml;
  3. Yarn sees that posthtml is among the downloaded ones, but looking at the package.json of a plugin doesn't see that it depends on posthtml.
  4. Yarn thinks that such an import is not safe and interrupts the launch, displaying an error in the console.

A solution was found both on the part of the user and on the part of the developer.

Discovered solutions From the `user's` side: Using an `.yarnrc.yml` file enter the code below there, then rebuild the dependency map with the `yarn` command. ```yml # Manually prescribe dependencies for the plugin. packageExtensions: posthtml-expressions@*: dependencies: posthtml: '*' ``` From the `developers'` side: Make the dependency on `posthtml` explicit by moving the line indicating its dependency to the _dependencies_ section. ```json From "devDependencies": { "posthtml": "lasted" } To "dependencies": { "posthtml": "lasted" } ```

Soon I will try to make a PR, where I will move the dependency line from posthtml to the dependencies section. This will solve the problem, according to the experience of another project.