Skip to content

Commit

Permalink
✨ improve: config module handling (#2336)
Browse files Browse the repository at this point in the history
## 🚨 Potentially breaking changes

- `bud.context.files` interface has changed. The `module` property is now an async function that returns the module. This is an undocumented internal, but people might be using it..
- deprecated: `@roots/merged-manifest-webpack-plugin`
- deprecated: `@roots/bud-wordpress-manifests`

## Changes

- improve(`@roots/wordpress-theme-json-webpack-plugin`): `theme.json` included in compilation module graph
- improve(`@roots/bud-tailwindcss-theme-json`): Edits to `tailwind.config.js` now result in rebuild of `theme.json`
- improve(`@roots/entrypoints-webpack-plugin`): `entrypoints.json` included in compilation module graph
- improve: config files now lazy loaded.
- new package: `@roots/wordpress-transforms` is a small utility package for translating `@wordpress/*` signifiers to `wp-*` enqueue handles and `wp.*` references. 

## Type of change

**MINOR: feature**
  • Loading branch information
kellymears authored Jun 28, 2023
1 parent 6c4a034 commit 8ca1b78
Show file tree
Hide file tree
Showing 226 changed files with 2,288 additions and 2,327 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ jobs:
- name: yarn
run: yarn

- name: yarn @bud test e2e
run: yarn @bud test e2e
- name: yarn @bud test e2e run
run: yarn @bud test e2e run
4 changes: 2 additions & 2 deletions .github/workflows/test.integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ jobs:
- name: yarn
run: yarn

- name: yarn @bud test integration
run: yarn @bud test integration
- name: yarn @bud test integration run
run: yarn @bud test integration run
4 changes: 2 additions & 2 deletions .github/workflows/test.unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ jobs:
- name: yarn
run: yarn

- name: yarn @bud test unit
run: yarn @bud test unit
- name: yarn @bud test unit run
run: yarn @bud test unit run
2 changes: 0 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ enableMirror: false

enableTelemetry: false

enableTransparentWorkspaces: true

globalFolder: storage/yarn/global

initFields:
Expand Down
19 changes: 13 additions & 6 deletions config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,26 @@
{"path": "../sources/@roots/bud-vue/tsconfig.json"},
{"path": "../sources/@roots/bud-wordpress-dependencies/tsconfig.json"},
{"path": "../sources/@roots/bud-wordpress-externals/tsconfig.json"},
{"path": "../sources/@roots/bud-wordpress-manifests/tsconfig.json"},
{"path": "../sources/@roots/bud-wordpress-theme-json/tsconfig.json"},
{"path": "../sources/@roots/container/tsconfig.json"},
{"path": "../sources/@roots/critical-css-webpack-plugin/tsconfig.json"},
{
"path": "../sources/@roots/critical-css-webpack-plugin/tsconfig.json"
},
{"path": "../sources/@roots/dependencies/tsconfig.json"},
{"path": "../sources/@roots/entrypoints-webpack-plugin/tsconfig.json"},
{"path": "../sources/@roots/filesystem/tsconfig.json"},
{"path": "../sources/@roots/merged-manifest-webpack-plugin/tsconfig.json"},
{"path": "../sources/@roots/sage/tsconfig.json"},
{"path": "../sources/@roots/wordpress-dependencies-webpack-plugin/tsconfig.json"},
{"path": "../sources/@roots/wordpress-externals-webpack-plugin/tsconfig.json"},
{
"path": "../sources/@roots/wordpress-dependencies-webpack-plugin/tsconfig.json"
},
{
"path": "../sources/@roots/wordpress-externals-webpack-plugin/tsconfig.json"
},
{"path": "../sources/@roots/wordpress-hmr/tsconfig.json"},
{"path": "../sources/@roots/wordpress-theme-json-webpack-plugin/tsconfig.json"},
{
"path": "../sources/@roots/wordpress-theme-json-webpack-plugin/tsconfig.json"
},
{"path": "../sources/@roots/wordpress-transforms/tsconfig.json"},
{"path": "../sources/create-bud-app/tsconfig.json"}
]
}
7 changes: 3 additions & 4 deletions config/vitest.unit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ export default {
},
hookTimeout: 60000,
include: [
`sources/@roots/*/src/*.test.{ts,tsx}`,
`sources/@roots/*/src/**/*.test.{ts,tsx}`,
`sources/@roots/*/test/*.{ts,tsx}`,
`sources/@roots/*/test/**/*.{ts,tsx}`,
`tests/unit/*.test.ts`,
`tests/reproductions/*.test.ts`,
`sources/@roots/*/tests/**/*.{ts,tsx}`,
`tests/unit/**/*.test.ts`,
`tests/reproductions/**/*.test.ts`,
],
includeSource: [`sources/@roots/*/src/**/*.{ts,tsx}`],
testTimeout: 60000,
Expand Down
2 changes: 1 addition & 1 deletion contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
login: kellymears
avatar: https://avatars.githubusercontent.com/u/397606?v=4
url: https://github.com/kellymears
contributions: 860
contributions: 869
email: developers@tinypixel.dev
- name: QWp6t
login: QWp6t
Expand Down
6 changes: 3 additions & 3 deletions examples/babel/bud.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export default async bud => {
bud.entry('app', ['app.js', 'app.css']).splitChunks(bud.isProduction)
bud.entry('app', ['app.js', 'app.css'])

bud.babel
.setPresets({
'@babel/preset-env': require.resolve('@babel/preset-env'),
'@babel/preset-env': '@babel/preset-env',
})
.setPlugins({
'@babel/plugin-transform-runtime': [
require.resolve('@babel/plugin-transform-runtime'),
'@babel/plugin-transform-runtime',
{helpers: false},
],
})
Expand Down
2 changes: 1 addition & 1 deletion examples/babel/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import '@src/app.css'

document.querySelector('#root')?.classList.add('init')

module?.hot?.accept(console.error)
if (import.meta.webpackHot) import.meta.webpackHot.accept(console.error)
2 changes: 1 addition & 1 deletion examples/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@examples/basic",
"private": true,
"type": "module",
"browserslist": [
"extends @roots/browserslist-config"
],
"type": "module",
"devDependencies": {
"@roots/bud": "latest"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import './styles.css'

document.querySelector('#root')?.classList.add('init')

module?.hot?.accept()
if (import.meta.webpackHot) import.meta.webpackHot.accept()
11 changes: 1 addition & 10 deletions examples/esbuild/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,4 @@ target.innerHTML = `
</div>
`

/**
* Accept module updates
*
* @see https://webpack.js.org/api/hot-module-replacement
*/
if (module) {
module.hot.accept(err => {
console.error(err)
})
}
if (import.meta.webpackHot) import.meta.webpackHot.accept(console.error)
4 changes: 0 additions & 4 deletions examples/sage/.eslintrc.js

This file was deleted.

9 changes: 0 additions & 9 deletions examples/sage/.prettierrc

This file was deleted.

6 changes: 0 additions & 6 deletions examples/sage/.stylelintrc

This file was deleted.

File renamed without changes.
12 changes: 1 addition & 11 deletions examples/sage/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
{
"name": "@examples/sage",
"private": true,
"packageManager": "npm@8.19.2",
"engines": {
"node": "18.12.1"
},
"browserslist": [
"extends @roots/browserslist-config"
],
"type": "module",
"devDependencies": {
"@roots/bud": "latest",
"@roots/bud-eslint": "latest",
"@roots/bud-prettier": "latest",
"@roots/bud-stylelint": "latest",
"@roots/bud-tailwindcss": "latest",
"@roots/eslint-config": "latest",
"@roots/sage": "latest"
}
}
4 changes: 3 additions & 1 deletion examples/sage/resources/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ const init = () =>

init()

module?.hot?.accept('./components/main.js', init)
if (import.meta.webpackHot) {
import.meta.webpackHot?.accept('./components/main.js', init)
}
14 changes: 3 additions & 11 deletions examples/sage/resources/scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import '@wordpress/edit-post'
import {registerBlockStyle, unregisterBlockStyle} from '@wordpress/blocks'
import domReady from '@wordpress/dom-ready'

/**
* Block styles
*/
domReady(() => {
unregisterBlockStyle('core/button', 'outline')

Expand All @@ -15,11 +12,6 @@ domReady(() => {
})
})

/**
* Accept module updates
*
* @see https://webpack.js.org/api/hot-module-replacement
*/
module?.hot?.accept(err => {
console.err(err)
})
if (import.meta.webpackHot) {
import.meta.webpackHot.accept(console.error)
}
4 changes: 4 additions & 0 deletions examples/sage/resources/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@

@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

body {
background: blue;
}
3 changes: 1 addition & 2 deletions examples/sage/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module.exports = {
export default {
content: ['resources/**/*.{js,css,html}'],
theme: {
extend: {
colors: {
gray: '#f7fafc',
brand: {
gray: '#f7fafc',
},
Expand Down
4 changes: 0 additions & 4 deletions examples/sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
"name": "@examples/sass",
"private": true,
"type": "module",
"packageManager": "npm@8.19.2",
"engines": {
"node": "18.12.1"
},
"bud": {
"extensions": {
"allowlist": [
Expand Down
4 changes: 0 additions & 4 deletions examples/tailwindcss/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"name": "@examples/tailwindcss",
"private": true,
"packageManager": "npm@8.19.2",
"engines": {
"node": "18.12.1"
},
"browserslist": [
"extends @roots/browserslist-config"
],
Expand Down
2 changes: 2 additions & 0 deletions examples/wordpress-theme/bud.config.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setUrl: 3010
setProxyUrl: 8000
6 changes: 0 additions & 6 deletions examples/wordpress-theme/bud.config.json

This file was deleted.

8 changes: 8 additions & 0 deletions examples/wordpress-theme/bud.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
setPublicPath: /app/themes/your-theme-name/dist/

entry:
app: [app.js, app.css]
editor: [editor.js]

wpjson:
enable: true
8 changes: 0 additions & 8 deletions examples/wordpress-theme/bud.production.config.json

This file was deleted.

7 changes: 2 additions & 5 deletions examples/wordpress-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"name": "@examples/wordpress-theme",
"private": true,
"packageManager": "npm@8.19.2",
"engines": {
"node": "18.12.1"
},
"browserslist": [
"extends @roots/browserslist-config"
],
"type": "module",
"devDependencies": {
"@roots/browserslist-config": "latest",
"@roots/bud": "latest",
"@roots/bud-swc": "latest",
"@roots/bud-preset-wordpress": "latest"
}
}
9 changes: 0 additions & 9 deletions examples/wordpress-theme/setup.js

This file was deleted.

7 changes: 7 additions & 0 deletions examples/wordpress-theme/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ import React from 'react'
import {createRoot} from 'react-dom/client'
import {App} from './components/App.js'

import 'lodash'
import 'jquery'

createRoot(document.getElementById('root')).render(<App />)

if (import.meta.webpackHot) {
import.meta.webpackHot.accept(console.error)
}
17 changes: 4 additions & 13 deletions examples/wordpress-theme/src/editor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import '@wordpress/edit-post'
import {
unregisterBlockStyle,
registerBlockStyle,
} from '@wordpress/blocks'
import {unregisterBlockStyle, registerBlockStyle} from '@wordpress/blocks'
import domReady from '@wordpress/dom-ready'

domReady(() => {
Expand All @@ -14,11 +10,6 @@ domReady(() => {
})
})

/**
* Accept module updates
*
* @see https://webpack.js.org/api/hot-module-replacement
*/
module?.hot?.accept(err => {
console.err(err)
})
if (import.meta.webpackHot) {
import.meta.webpackHot.accept(console.error)
}
33 changes: 33 additions & 0 deletions examples/wordpress-theme/theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"__generated__": "⚠️ This file is generated. Do not edit.",
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"color": {
"custom": false,
"customGradient": false
},
"custom": {
"spacing": {},
"typography": {
"font-size": {},
"line-height": {}
}
},
"spacing": {
"padding": true,
"units": [
"px",
"%",
"em",
"rem",
"vw",
"vh"
]
},
"typography": {
"customFontSize": false,
"dropCap": false
}
}
}
Loading

0 comments on commit 8ca1b78

Please sign in to comment.