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

Add NPM workspaces, build using out of the box wp-scripts #506

Merged
merged 22 commits into from
Jun 25, 2024

Conversation

stian-overasen
Copy link
Member

@stian-overasen stian-overasen commented Jun 24, 2024

I suggest we simplify our build setup by using wp-scripts out of the box, removing the unnecessary entry-files.json setup and introducing NPM workspaces to build all project packages independently (and also from root).

  • Introduce NPM workspaces as replacement for entry-files.json system.
  • Use out-of-the-box wp-scripts to build theme scripts and stylesheet without additional webpack config.
  • Embrace the "Lint globally, build locally" concept:
    • Lint entire project from root.
    • Let each package handle it's own dependencies and build process.
  • Add a few additional useful PostCSS extensions. (global data, discard comments)
  • Move theme-json generation into dekode-theme and disable script for now since there is no theme-json folder there currently. (This should not be global in case there are additional themes not using this package).
  • Add Blueprint plugin as template for fast plugin or block library setup.

A note on entry-files.json:

The entry-files.json autodiscovery script was something we made years ago to support the transition away from Yarn while waiting for workspaces support in NPM. Now that NPM support workspaces (and have for a while) and wp-scripts finally have good support for PostCSS, we don't need the entry-files.json setup anymore. With NPM workspaces we can let each package build itself and at the same time handle dependencies and build everything from root. NPM workspaces can also be combined with e.g. Turbo or wireit to speed up build time with parallelization and caching.

@stian-overasen stian-overasen requested a review from olethomas June 24, 2024 15:32
@stian-overasen stian-overasen changed the title Add npm workspaces, lint globally, build locally Add NPM workspaces, build using clean wp-scripts out of the box Jun 24, 2024
@stian-overasen stian-overasen changed the title Add NPM workspaces, build using clean wp-scripts out of the box Add NPM workspaces, build using clean (out of the box) wp-scripts Jun 24, 2024
@stian-overasen stian-overasen changed the title Add NPM workspaces, build using clean (out of the box) wp-scripts Add NPM workspaces, build using out of the box wp-scripts Jun 24, 2024
@stian-overasen stian-overasen marked this pull request as ready for review June 25, 2024 07:36
@luistinygod
Copy link

@stian-overasen This is a great suggestion and thank you for putting all this together!
While we change this, could we also update the INSTALLATION.md (and/or README.md) files to make sure they are in sync with this new process?
How can we facilitate the transition for our teams? Is there a package blueprint that we could use to start a new plugin that needs a build process and that is compatible with this new workspaces setup?

luistinygod
luistinygod previously approved these changes Jun 25, 2024
Copy link

@luistinygod luistinygod left a comment

Choose a reason for hiding this comment

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

Thank you @stian-overasen!

Copy link

Composer package changes
Prod Packages Operation Base Target
dekode/blueprint New - 1.0.0
roots/wordpress Upgraded 6.5.4 6.5.5
roots/wordpress-no-content Upgraded 6.5.4 6.5.5

@stian-overasen
Copy link
Member Author

INSTALLATION.md updated and blueprint plugin added @luistinygod. This plugin demonstrates building both with view/editor assets and possible blocks.

@stian-overasen stian-overasen merged commit 6f5474d into main Jun 25, 2024
5 checks passed
@stian-overasen stian-overasen deleted the npm-workspaces branch June 25, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants