diff --git a/.vscode/settings.json b/.vscode/settings.json index 6111d10cf2..2b27f3c278 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,14 +6,13 @@ "**/$KNOWN_TOOLS$/**" ] }, + "editor.tabSize": 2, "eslint.nodePath": ".yarn/sdks/eslint", "eslint.options": { "overrideConfigFile": "config/eslint.config.cjs" }, - "eslint.validate": [ - "javascript", - "typescript" - ], + "eslint.validate": ["javascript", "typescript"], + "explorer.excludeGitIgnore": false, "files.associations": { "*.mdx": "mdx", "*.ts": "typescript", @@ -27,19 +26,18 @@ "**/.hg": true, "**/.svn": true, "**/CVS": true, - "**/Thumbs.db": true, - "**/node_modules": false + "**/node_modules": true, + "**/Thumbs.db": true }, "prettier.configPath": "config/prettier.config.js", "prettier.ignorePath": "config/.prettierignore", "search.exclude": { + ".git": true, + ".yarn": true, "**/.storage": true, "**/node_modules": true, "**/pnp.*": true, - ".git": true, - ".yarn": true, - "storage": true, - "verdaccio": true + "coverage": true }, "typescript.enablePromptUseWorkspaceTsdk": true, "typescript.format.semicolons": "remove", diff --git a/config/tsconfig.json b/config/tsconfig.json index 67c8c490ef..22f9e7d1be 100644 --- a/config/tsconfig.json +++ b/config/tsconfig.json @@ -30,9 +30,9 @@ }, "files": [], "references": [ - {"path": "../sources/@roots/bud-support/tsconfig.json"}, {"path": "../sources/@repo/markdown-kit/tsconfig.json"}, {"path": "../sources/@repo/test-kit/tsconfig.json"}, + {"path": "../sources/@roots/bud-support/tsconfig.json"}, {"path": "../sources/@roots/bud/tsconfig.json"}, {"path": "../sources/@roots/blade-loader/tsconfig.json"}, {"path": "../sources/@roots/bud-api/tsconfig.json"}, @@ -73,15 +73,23 @@ {"path": "../sources/@roots/bud-wordpress-externals/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/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"} ] diff --git a/config/vitest/config.e2e.ts b/config/vitest/config.e2e.ts index e697780e9f..4ab6e25697 100644 --- a/config/vitest/config.e2e.ts +++ b/config/vitest/config.e2e.ts @@ -5,8 +5,7 @@ import shared from './config.shared' export default defineConfig({ test: { ...shared, - include: [`tests/e2e/*.test.ts`], - pool: `threads`, + include: [`tests/e2e/**/*.test.ts`], poolOptions: { threads: { isolate: false, @@ -14,6 +13,5 @@ export default defineConfig({ minThreads: 1, }, }, - watch: false, }, }) diff --git a/config/vitest/config.integration.ts b/config/vitest/config.integration.ts index b46b669ad3..14b5cb9635 100644 --- a/config/vitest/config.integration.ts +++ b/config/vitest/config.integration.ts @@ -6,14 +6,14 @@ export default defineConfig({ test: { ...shared, include: [`tests/integration/**/*.test.ts`], - pool: `forks`, + isolate: true, + pool: `threads`, poolOptions: { - forks: { - maxForks: 1, - minForks: 1, + threads: { + isolate: true, + useAtomics: true, }, }, setupFiles: [`./config/vitest/setup.integration.ts`], - watch: false, }, }) diff --git a/config/vitest/config.shared.ts b/config/vitest/config.shared.ts index 15999834eb..bd5ba8f10a 100644 --- a/config/vitest/config.shared.ts +++ b/config/vitest/config.shared.ts @@ -1,14 +1,14 @@ +import type {UserConfig} from 'vitest' + import {env} from 'node:process' import GithubActionsReporter from 'vitest-github-actions-reporter' -const reporters: Array = [`basic`] -if (env.GITHUB_ACTIONS) reporters.push(new GithubActionsReporter()) - -const shared = { +export default { hookTimeout: 240000, - reporters, + reporters: env.GITHUB_ACTIONS + ? [`basic`, new GithubActionsReporter()] + : [`basic`], testTimeout: 240000, -} - -export default shared + watch: false, +} satisfies UserConfig diff --git a/config/vitest/config.unit.ts b/config/vitest/config.unit.ts index 11edc2f0f4..410807d34a 100644 --- a/config/vitest/config.unit.ts +++ b/config/vitest/config.unit.ts @@ -1,5 +1,3 @@ -import {env} from 'process' - import {defineConfig} from 'vitest/config' import shared from './config.shared' @@ -8,21 +6,14 @@ export default defineConfig({ test: { ...shared, coverage: { - include: [`sources/@roots/*/src/**/*.{ts,tsx}`], - provider: `v8`, + enabled: false, }, - exclude: [`sources/@repo/**/*`, `**/node_modules/**/*`], + exclude: [`tests/e2e`, `**/node_modules`], include: [ - `sources/@roots/*/src/*.test.{ts,tsx}`, - `sources/@roots/*/src/**/*.test.{ts,tsx}`, - `sources/@roots/*/test/*.test.{ts,tsx}`, - `sources/@roots/*/test/**/*.test.{ts,tsx}`, - `sources/@roots/*/tests/*.test.{ts,tsx}`, - `sources/@roots/*/tests/**/*.test.{ts,tsx}`, - `tests/unit/**/*.test.ts`, - `tests/reproductions/**/*.test.ts`, - `tests/integration/*.test.ts`, + `sources/@roots/**/*.test.ts`, + `sources/@roots/**/*.test.tsx`, + `tests/**/*.test.ts`, + `tests/**/*.test.tsx`, ], - includeSource: [`sources/@roots/*/src/**/*.{ts,tsx}`], }, }) diff --git a/config/vitest/reporters.ts b/config/vitest/reporters.ts deleted file mode 100644 index 549f6739b1..0000000000 --- a/config/vitest/reporters.ts +++ /dev/null @@ -1,8 +0,0 @@ -import {env} from 'node:process' - -import GithubActionsReporter from 'vitest-github-actions-reporter' - -const reporters: Array = [`basic`] -if (env.GITHUB_ACTIONS) reporters.push(new GithubActionsReporter()) - -export default reporters diff --git a/examples/babel-advanced/tsconfig.json b/examples/babel-advanced/tsconfig.json index 895d4273ad..7ecf393a65 100644 --- a/examples/babel-advanced/tsconfig.json +++ b/examples/babel-advanced/tsconfig.json @@ -6,7 +6,7 @@ }, "types": ["@roots/bud", "@roots/bud-babel"] }, - "files": ["bud.config.ts"], + "files": ["./bud.config.ts"], "include": ["./src"], "exclude": ["./dist"] } diff --git a/examples/config-json/bud.config.json b/examples/config-json/bud.config.json index 6f7419c5aa..8b3c7a14af 100644 --- a/examples/config-json/bud.config.json +++ b/examples/config-json/bud.config.json @@ -1,13 +1,13 @@ { - entry: ["app", ["app.js"]], + "entry": ["app", ["app.js"]], /** * Comments are okay */ - babel: { - setPluginOptions: [ + "babel": { + "setPluginOptions": [ "@babel/plugin-transform-runtime", - {helpers: false, regenerator: false} + {"helpers": false, "regenerator": false} ] } } diff --git a/examples/critical-css/bud.config.js b/examples/critical-css/bud.config.js index ad6c434a0e..581f6673f0 100644 --- a/examples/critical-css/bud.config.js +++ b/examples/critical-css/bud.config.js @@ -3,6 +3,6 @@ */ export default async bud => { bud.entry(`app`, [`app.css`]).entry(`app2`, [`app2.css`]) - bud.html({template: bud.path(`public/index.html`)}) + bud.html({ template: bud.path(`public/index.html`) }) bud.critical.set(`src`, bud.path(`public/index.html`)).enable() } diff --git a/examples/critical-css/src/app.js b/examples/critical-css/src/app.js index 952351e9aa..d811689972 100644 --- a/examples/critical-css/src/app.js +++ b/examples/critical-css/src/app.js @@ -10,5 +10,6 @@ const changeBg = () => { */ changeBg() -if (import.meta.webpackHot) - import.meta.webpackHot.accept(err => changeBg()) +if (import.meta.webpackHot) { + import.meta.webpackHot.accept(changeBg) +} diff --git a/examples/daisyui/tailwind.config.ts b/examples/daisyui/tailwind.config.ts index 930c3654db..423e4b7abd 100644 --- a/examples/daisyui/tailwind.config.ts +++ b/examples/daisyui/tailwind.config.ts @@ -1,9 +1,6 @@ import type {Config} from 'tailwindcss' -import daisyui from 'daisyui' -const config: Config = { +export default { content: ['src/**/*.js'], - plugins: [daisyui], -} - -export default config + plugins: [await import('daisyui').then(m => m.default)], +} satisfies Config diff --git a/examples/esbuild/bud.config.js b/examples/esbuild/bud.config.js deleted file mode 100644 index a5e4f2e18f..0000000000 --- a/examples/esbuild/bud.config.js +++ /dev/null @@ -1,3 +0,0 @@ -import {bud} from '@roots/bud' - -bud.html().entry({app: 'app.js'}) diff --git a/examples/esbuild/src/demo.js b/examples/esbuild/src/demo.js deleted file mode 100644 index b6054bdb1c..0000000000 --- a/examples/esbuild/src/demo.js +++ /dev/null @@ -1,5 +0,0 @@ -const features = ['fancy', 'ecma'] - -features.map(feat => { - console.log(feat) -}) diff --git a/examples/esbuild/src/demo.ts b/examples/esbuild/src/demo.ts new file mode 100644 index 0000000000..23f8019d51 --- /dev/null +++ b/examples/esbuild/src/demo.ts @@ -0,0 +1 @@ +;['fancy', 'ecma'].map(console.log) diff --git a/examples/esbuild/src/app.js b/examples/esbuild/src/index.js similarity index 100% rename from examples/esbuild/src/app.js rename to examples/esbuild/src/index.js diff --git a/examples/esbuild/tsconfig.json b/examples/esbuild/tsconfig.json index 6bc5d96e00..319fa90068 100644 --- a/examples/esbuild/tsconfig.json +++ b/examples/esbuild/tsconfig.json @@ -3,5 +3,4 @@ "compilerOptions": { "types": ["@roots/bud", "@roots/bud-esbuild"] }, - "files": ["./bud.config.js"] } diff --git a/examples/eslint-bud-config/bud.config.ts b/examples/eslint-bud-config/bud.config.ts new file mode 100644 index 0000000000..43a6a2bad5 --- /dev/null +++ b/examples/eslint-bud-config/bud.config.ts @@ -0,0 +1,5 @@ +import {bud} from '@roots/bud' + +bud.eslint.setRules({ + 'no-console': 'error', +}) diff --git a/examples/eslint-bud-config/package.json b/examples/eslint-bud-config/package.json new file mode 100644 index 0000000000..7a9c3844b5 --- /dev/null +++ b/examples/eslint-bud-config/package.json @@ -0,0 +1,14 @@ +{ + "name": "@examples/eslint-bud-config", + "$schema": "https://bud.js.org/bud.package.json", + "private": true, + "type": "module", + "browserslist": [ + "extends @roots/browserslist-config" + ], + "devDependencies": { + "@roots/bud": "workspace:*", + "@roots/bud-eslint": "workspace:*", + "@roots/eslint-config": "workspace:*" + } +} diff --git a/examples/eslint-bud-config/src/index.js b/examples/eslint-bud-config/src/index.js new file mode 100644 index 0000000000..c67d2dc3d1 --- /dev/null +++ b/examples/eslint-bud-config/src/index.js @@ -0,0 +1 @@ +console.log('error') diff --git a/examples/eslint/tsconfig.json b/examples/eslint-bud-config/tsconfig.json similarity index 77% rename from examples/eslint/tsconfig.json rename to examples/eslint-bud-config/tsconfig.json index 45b556694b..24fb625313 100644 --- a/examples/eslint/tsconfig.json +++ b/examples/eslint-bud-config/tsconfig.json @@ -1,7 +1,7 @@ { "extends": ["@roots/bud/config/tsconfig.json"], "compilerOptions": { - "types": ["@roots/bud", "@roots/bud-eslint"] - } + }, + "files": ["./bud.config.ts"] } diff --git a/examples/eslint/.eslintrc.cjs b/examples/eslint/.eslintrc.cjs index a8047dd8ee..fc72a65501 100644 --- a/examples/eslint/.eslintrc.cjs +++ b/examples/eslint/.eslintrc.cjs @@ -1,3 +1,6 @@ module.exports = { extends: ['@roots/eslint-config'], + rules: { + 'no-console': 'error', + } } diff --git a/examples/eslint/src/index.js b/examples/eslint/src/index.js index 2192cf875c..1aefe25f39 100644 --- a/examples/eslint/src/index.js +++ b/examples/eslint/src/index.js @@ -1,4 +1 @@ -const target = document.querySelector('body') - -target.innerHTML = `

Hello

` - +console.log('eslint should error') diff --git a/examples/node-api/node-script.js b/examples/node-api/node-script.js index 8318b24438..b3579d65e1 100644 --- a/examples/node-api/node-script.js +++ b/examples/node-api/node-script.js @@ -1,4 +1,4 @@ -import {factory} from '@roots/bud' +import { factory } from '@roots/bud' /** * Run this example with: diff --git a/examples/node-api/tsconfig.json b/examples/node-api/tsconfig.json new file mode 100644 index 0000000000..81942537b0 --- /dev/null +++ b/examples/node-api/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "@roots/bud/config/tsconfig.json", + "compilerOptions": { + "paths": { + "@src/*": ["./src/*"] + }, + "types": ["@roots/bud", "@roots/bud-swc"] + }, + "files": ["./node-script.js"], + "include": ["./src"], + "exclude": ["./dist"] +} diff --git a/examples/node-api/webpack.config.js b/examples/node-api/webpack.config.js index 442456cbd3..7e496f2d09 100644 --- a/examples/node-api/webpack.config.js +++ b/examples/node-api/webpack.config.js @@ -1,4 +1,4 @@ -import {factory} from '@roots/bud' +import { factory } from '@roots/bud' /** * Run this example with: diff --git a/examples/sage/bud.config.js b/examples/sage/bud.config.js index 6a6dc444db..97527680fa 100644 --- a/examples/sage/bud.config.js +++ b/examples/sage/bud.config.js @@ -1,22 +1,17 @@ -// @ts-check +import { bud } from '@roots/bud' -/** - * @param {import('@roots/bud').Bud} bud - */ -export default async bud => { - bud - .entry({ - app: ['@scripts/app', '@styles/app'], - editor: ['@scripts/editor', '@styles/editor'], - }) - .copyDir('images') - .watch(['resources/views/*.blade.php']) - .serve(3000) - .proxy('http://example.test') +bud + .entry({ + app: ['@scripts/app', '@styles/app'], + editor: ['@scripts/editor', '@styles/editor'], + }) + .copyDir('images') + .watch(['resources/views/*.blade.php']) + .serve(3000) + .proxy('http://example.test') - bud.wp.json - .useTailwindColors('extend') - .useTailwindFontFamily() - .useTailwindFontSize() - .useTailwindSpacing() -} +bud.wp.json + .useTailwindColors('extend') + .useTailwindFontFamily() + .useTailwindFontSize() + .useTailwindSpacing() diff --git a/examples/swc/tsconfig.json b/examples/swc/tsconfig.json index 9f87f11c91..fbb30b507c 100644 --- a/examples/swc/tsconfig.json +++ b/examples/swc/tsconfig.json @@ -3,5 +3,4 @@ "compilerOptions": { "types": ["@roots/bud", "@roots/bud-swc"] }, - "files": ["./bud.config.ts"] } diff --git a/package.json b/package.json index 2949319944..59903902da 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@vitest/coverage-v8": "1.6.0", "@vitest/ui": "1.6.0", "browserslist": "4.23.0", - "caniuse-lite": "1.0.30001616", + "caniuse-lite": "1.0.30001627", "esbuild": "0.20.2", "eslint": "8.57.0", "eslint-plugin-n": "17.4.0", @@ -69,14 +69,13 @@ "sources/@roots/*", "sources/@repo/*", "sources/@roots/*/test/**/*", - "sources/@roots/*/src/__fixtures__/*", "sources/create-bud-app", "tests/util/project", "tests/reproductions/*" ] }, "volta": { - "node": "20.3.1", + "node": "20.12.0", "yarn": "1.22.19" } } diff --git a/sources/@repo/docs/config/docusaurus.theme.cjs b/sources/@repo/docs/config/docusaurus.theme.cjs index 0bf284ba2c..f75619375a 100644 --- a/sources/@repo/docs/config/docusaurus.theme.cjs +++ b/sources/@repo/docs/config/docusaurus.theme.cjs @@ -1,6 +1,6 @@ const {themes} = require(`prism-react-renderer`) const config = require(`../../../../config/monorepo.config.cjs`) -const releaseData = require(`../generated/releases/data.json`) +const releaseData = require(`../content/releases/data.json`) /** * Color mode diff --git a/sources/@repo/docs/config/index.cjs b/sources/@repo/docs/config/index.cjs index 35e9ef9912..1392867c12 100644 --- a/sources/@repo/docs/config/index.cjs +++ b/sources/@repo/docs/config/index.cjs @@ -34,7 +34,7 @@ module.exports = { title: `${config.name} releases`, }, id: `releases`, - path: docsPath(`generated/releases`), + path: docsPath(`content/releases`), remarkPlugins, routeBasePath: `releases`, showReadingTime: true, diff --git a/sources/@repo/docs/content/learn/config/assets.mdx b/sources/@repo/docs/content/learn/config/assets.mdx index db4eae8354..d0d9836974 100644 --- a/sources/@repo/docs/content/learn/config/assets.mdx +++ b/sources/@repo/docs/content/learn/config/assets.mdx @@ -3,7 +3,7 @@ title: Assets sidebar_label: Assets --- -import ConfigExample from '@site/src/components/example' +import Example from '@site/src/components/example' :::info No need to copy imported assets @@ -23,63 +23,63 @@ For example, given this stylesheet, copying `@src/fonts/MyFont.woff2` would be u The [bud.assets](/reference/bud.assets) function is used to copy files to the output directory. -The simplest way to use it is to pass an array of directories (relative to [your project `@src` directory](#project-paths)) you would like to copy: +The simplest way to use it is to pass an array of directories (relative to [your project `@src` directory](/learn/config/paths)): - + - ```ts title=bud.config.ts + ```ts bud.assets(['images', 'fonts']) ``` - ```js title=bud.config.js + ```js bud.assets(['images', 'fonts']) ``` - ```yml title=bud.config.yml + ```yml assets: [['images', 'fonts']] ``` - ```json title=bud.config.json + ```json { "assets": [["images", "fonts"]] } ``` - + If you want more control over the directory being output to, you can use an array of from/to pairs: - + - ```ts title=bud.config.ts + ```ts bud.assets([ ['images', 'assets/images'], // from `@src/images` to `@dist/assets/images` ['fonts', 'assets/fonts'], // from `@src/fonts` to `@dist/assets/fonts` ]) ``` - ```js title=bud.config.js + ```js bud.assets([ ['images', 'assets/images'], // from `@src/images` to `@dist/assets/images` ['fonts', 'assets/fonts'], // from `@src/fonts` to `@dist/assets/fonts` ]) ``` - ```yml title=bud.config.yml + ```yml assets: [[['images', 'assets/images'], ['fonts', 'assets/fonts']]] ``` - ```json title=bud.config.json + ```json { "assets": [[["images", "assets/images"], ["fonts", "assets/fonts"]]] } ``` - + For complete control, you can pass an object: - + ```ts title=bud.config.ts import type {Bud} from '@roots/bud' @@ -128,6 +128,6 @@ For complete control, you can pass an object: } ``` - + You can learn more about this and other details in the [bud.assets documentation](/reference/bud.assets). diff --git a/sources/@repo/docs/content/learn/config/files/bud.config.mdx b/sources/@repo/docs/content/learn/config/files/bud.config.mdx index 0d68b8c01e..aeacb50cab 100644 --- a/sources/@repo/docs/content/learn/config/files/bud.config.mdx +++ b/sources/@repo/docs/content/learn/config/files/bud.config.mdx @@ -7,42 +7,34 @@ description: Used to configure bud.js import ConfigExample from '@site/src/components/example' import MultiLanguage from '@site/src/components/multi-language' -bud.js config files are the most straight forward way of interfacing with bud.js. +Creating a config file is the standard way of interfacing with bud.js. - The file name should include `bud` in the name. -- The module should be located in the project root or the `./config` directory. +- The module should be located in the project root, `.config` or `config` directory - The module can be written in JavaScript, TypeScript, YML or JSON5. - JavaScript and TypeScript configurations can either export a configuration function or import bud and use it directly. -:::info esbuild-wasm -By default bud.js uses [esbuild-wasm](https://www.npmjs.com/package/esbuild-wasm) to transpile the config file when authored with TypeScript. - -If you prefer you can install [esbuild](https://www.npmjs.com/package/esbuild) and it will be preferred. - -The esbuild team advises that using esbuild is faster than esbuild-wasm, but the benefit of esbuild-wasm is that it doesn't need to be built during installation. - -::: ## Example configurations - + -```ts title=bud.config.ts +```ts bud.entry(`app`, [`app.js`, `app.css`]) ``` -```js title=bud.config.js +```js bud.entry(`app`, [`app.js`, `app.css`]) ``` -```yml title=bud.config.yml +```yml entry: - app - ['app.js', 'app.css'] ``` -```json title=bud.config.json +```json { "entry": ["app", ["app.js", "app.css"]] } diff --git a/sources/@repo/docs/content/learn/config/files/env.mdx b/sources/@repo/docs/content/learn/config/files/env.mdx index 16a8df6a40..d43b227aed 100644 --- a/sources/@repo/docs/content/learn/config/files/env.mdx +++ b/sources/@repo/docs/content/learn/config/files/env.mdx @@ -17,7 +17,7 @@ bud.js supports expansion of environment variables. For example: ```sh title=.env PUBLIC_API_ORIGIN=https://api.example.com -PUBLIC_API_URL=${PUBLIC_API_URL}/endpoint +PUBLIC_API_URL=${PUBLIC_API_ORIGIN}/endpoint ``` ## Public variables diff --git a/sources/@repo/docs/content/learn/config/server.mdx b/sources/@repo/docs/content/learn/config/server.mdx index 7c77ef99a8..f7d43c2243 100644 --- a/sources/@repo/docs/content/learn/config/server.mdx +++ b/sources/@repo/docs/content/learn/config/server.mdx @@ -5,39 +5,39 @@ slug: dev-server sidebar_label: Development server --- -import ConfigExample from '@site/src/components/example' +import Example from '@site/src/components/example' ## Setting the dev URL Use [bud.setUrl](/reference/bud.setUrl) to set the development server URL. - + -```ts title=bud.config.ts +```ts bud.setUrl(3030) // Deltron zero hero not no small feat ``` -```js title=bud.config.js +```js bud.setUrl(3030) // Deltron zero hero not no small feat ``` -```yml title=bud.config.yml +```yml setUrl: 3030 # Deltron zero hero not no small feat ``` -```json title=bud.config.json +```json { "setUrl": 3030 } ``` - + ## Setting the proxy URL Use [bud.setProxyUrl](/reference/bud.setProxyUrl) to set the development server proxy URL. - + ```ts title=bud.config.ts bud.setProxyUrl(`http://example.test`) @@ -57,7 +57,7 @@ setProxyUrl: http://example.test } ``` - + ## Setting public URLs @@ -67,7 +67,7 @@ This is useful in containerized development environments like Docker where the i Here is an example of what this might look like, but it is going to depend heavily on your setup: - + ```ts title=bud.config.ts bud @@ -101,17 +101,16 @@ setPublicProxyUrl: http://example.test } ``` - + ## Advanced configuration -The development server can be configured with [bud.serve](/reference/bud.serve). This is primarily used to handle -configuring bud.js to use an [SSL certificate](/reference/bud.serve#ssl). It exposes all node options so the possibilities -are really open, for better and worse. +The development server can be further configured with [bud.serve](/reference/bud.serve). This is primarily used to handle +configuring bud.js to use an SSL certificate. - + -```ts title=bud.config.ts +```ts bud.serve({ url: new URL(`https://example.test`), cert: `/path/to/example.test.crt`, @@ -119,7 +118,7 @@ bud.serve({ }) ``` -```js title=bud.config.js +```js bud.serve({ url: new URL(`https://example.test`), cert: `/path/to/example.test.crt`, @@ -127,14 +126,14 @@ bud.serve({ }) ``` -```yml title=bud.config.yml +```yml serve: url: https://example.test cert: /path/to/example.test.crt key: /path/to/example.test.key ``` -```json title=bud.config.json +```json { "serve": { "url": "https://example.test", @@ -144,7 +143,7 @@ serve: } ``` - + ## Consider a separate config @@ -154,7 +153,7 @@ Just add `.development` to your `bud.config.*` file name to scope it to developm Or, load a separate file entirely using [bud.addConfig](/reference/bud.addConfig). - + ```ts title=bud.config.development.ts bud.setUrl(3030) @@ -174,5 +173,5 @@ setUrl: 3030 } ``` - + diff --git a/sources/@repo/docs/content/learn/extending/index.mdx b/sources/@repo/docs/content/learn/extending/index.mdx index 823b58660d..92bfc76005 100644 --- a/sources/@repo/docs/content/learn/extending/index.mdx +++ b/sources/@repo/docs/content/learn/extending/index.mdx @@ -1,6 +1,6 @@ --- title: Extending -description: Overview of instantiating bud.js directly from Node +description: Overview of instantiating bud.js from Node sidebar_label: Extending --- @@ -77,7 +77,7 @@ export default class MyExtension extends Extension { ### options -Any extension options can be set in the `options` property. +Extension options can be set in the `options` property. ```ts title=extension.ts import {Extension} from '@roots/bud-framework/extension' @@ -91,7 +91,7 @@ export default class MyExtension extends Extension { } ``` -The `options` property is treated specially (using `getters` and `setters`). +The `options` property is treated specially. Each option value can be expressed as either the literal value itself or a function receives the **bud.js** instance object and returns the value. @@ -225,7 +225,24 @@ export default class MyExtension extends Extension { ### buildBefore -Async callback. Called directly before configuration is constructed and passed to the compiler). +Async callback. Called before final configuration is built. + +```ts title=extension.ts +import {Bud} from '@roots/bud-framework' +import {Extension} from '@roots/bud-framework/extension' + +export default class MyExtension extends Extension { + public label = 'bud-extension' + + public async buildBefore(bud) { + // do something + } +} +``` + +### buildAfter + +Async callback. Called after final configuration is built. ```ts title=extension.ts import {Bud} from '@roots/bud-framework' @@ -331,7 +348,7 @@ export default class MyExtension extends Extension { } ``` -When present **bud.js** will pass the extension directly to the compiler. +When present **bud.js** will pass the extension to the compiler. ### when @@ -355,9 +372,9 @@ export default class MyExtension extends Extension { If `Extension.when` returns `false` the following methods will not be called: -- [buildBefore](#buildBefore) +- [buildBefore](#buildbefore) - [buildAfter](#buildafter) -- [configAfter](#configAfter) +- [configAfter](#configafter) - [make](#make) `Extension.enabled` (a simple `boolean`) will always take precedence over `Extension.when` if it is set. diff --git a/sources/@repo/docs/content/learn/general-use/customizing-loaders.mdx b/sources/@repo/docs/content/learn/general-use/customizing-loaders.mdx index f1e7d78ce0..50f13ebe67 100644 --- a/sources/@repo/docs/content/learn/general-use/customizing-loaders.mdx +++ b/sources/@repo/docs/content/learn/general-use/customizing-loaders.mdx @@ -66,7 +66,7 @@ With automatic resolution: ```js title=bud.config.js export default async bud => { - bud.build.setLoader(`babel-loader`) + bud.build.setLoader('babel-loader') } ``` @@ -75,9 +75,10 @@ With explicit resolution: ```js title=bud.config.js export default async bud => { bud.build.setLoader( - `babel-loader`, - await bud.module.resolve(`babel-loader`), + 'babel-loader', + await bud.module.resolve('babel-loader'), ) +} ``` Using the callback API: @@ -85,9 +86,10 @@ Using the callback API: ```js title=bud.config.js export default async bud => { bud.build.setLoader( - `babel-loader`, - loader => loader.setSrc(`babel-loader`) + 'babel-loader', + loader => loader.setSrc('babel-loader') ) +} ``` ## Items @@ -216,7 +218,7 @@ export default async bud => [@roots/bud-typescript](/extensions/bud-typescript) is an excellent example because it: -- registers a new [loader](#loaders), [item](#items), and [rule](#rule) +- registers a new [loader](#loaders), [item](#items), and [rule](#rules) - modifies an existing [rule](#rules). ```ts diff --git a/sources/@repo/docs/content/releases/6.11.0.md b/sources/@repo/docs/content/releases/6.11.0.md new file mode 100644 index 0000000000..3e8bf2c4c7 --- /dev/null +++ b/sources/@repo/docs/content/releases/6.11.0.md @@ -0,0 +1,146 @@ +--- +slug: "6.11.0" +title: "6.11.0" +description: Release notes for bud.js 6.11.0 +date: 2023-03-09T22:17:25Z +author: kellymears +author_title: Developer +author_url: https://github.com/kellymears +author_image_url: https://avatars.githubusercontent.com/u/397606?v=4 +tags: + - release + - 6 + - 6.11 +--- + + + +A bunch of cool features, fixes and improvements. + + + +If you have any trouble installing try the `--force` flag. + +## Breaking changes + +- There have been some fixes made to [bud.assets](https://bud.js.org/docs/bud.assets) which make the function behave much more predictably. Still, I'm concerned there might be workarounds people are using which will no longer be working around. Check out the documentation and consider replacing complex [bud.assets](https://bud.js.org/docs/bud.assets) calls with the new [bud.copyFile](https://bud.js.org/docs/bud.copyFile) and [bud.copyDir](https://bud.js.org/docs/bud.copyFile) functions. + +- If you are configuring bud.js with JSON or YML you will need to update any functions which accept a single argument which is an array. `bud.config.json` and `bud.config.yml` arguments are now expressed as an array, so there is no good way for the config parser to determine that you actually wanted to pass an array and not multiple params. + + ```diff + assets: + - - 'image.jpeg' + + - ['image.jpeg'] + ``` +- If you have been using the new blade view directives in your Sage project you will need to update them. There is now a single directive to replace all previous directives: `@module`. So, `@js import '@scripts/confetti.js' @endjs` becomes `@module('js') import '@scripts/confetti.js' @endmodule`. This should support all module types now, generically. Built-in support for this feature is still in process for roots/acorn. An example `ModuleDirective` and `EndModuleDirective` class have been updated and included in `@roots/blade-loader/vendor`. + + ```diff + -@js + +@module('js') + console.log('hello') + -@endjs + +@endmodule + ``` + +## Deprecations + +A bunch of extension functions are going to be removed at some point in the future (bud.js 7). Most of these are simple wrappers for the built-in extensions API. + +If you are using a deprecated function you can expect IDE notifications (if you use an IDE that supports the `@deprecated` doctype), but you will also see warnings in the terminal with specific instructions for how to update the call. + +We'll go slow when removing these functions; don't fret about it. This [github issue (#2079)](https://github.com/roots/bud/issues/2079) is dedicated to tracking related function deprecations. + +## Improved WordPress editor support + +Easily add `blocks`, `plugins`, `filters`, `styles`, `variations` and `formats` in production and development with next to no boilerplate along with full hot module reloading (HMR) support. + +[See the updated documentation for specifics on implementing it in your WordPress project](https://bud.js.org/extensions/bud-preset-wordpress/editor-integration). There is also [a new example in the examples directory](https://github.com/roots/bud/tree/main/examples/wordpress-editor) to get a feel for how it comes together. + +This feature is new so I suspect early adopters may bump into issues. But, we've been using the underlying library that powers this for many months now and it seems to work quite well in-house. + +## Improved yml and json config support + +See [the updated documentation](https://bud.js.org/guides/general-use/alternative-config-syntax). Short version: anything you can do in a js file you can now do in a yml file. + +## New functions for copying files + +These two functions are a lot more predictable for you and will be a lot easier to maintain for me. I'd recommend replacing [bud.assets](https://bud.js.org/docs/bud.assets) with them (although I've tried to do what I can to improve it in this release). + +### bud.copyDir + +See [documentation](https://bud.js.org/docs/bud.copyDir) for details. + +### bud.copyFile + +See [documentation](https://bud.js.org/docs/bud.copyFile) for details. + +## Improved errors + +There is better error handling in a few critical areas. Hopefully you'll never notice. + +### Early errors + +Ever make a syntax error in your `bud.config.js` file? Me neither. But if I did the error would happen before bud.js (and it's logger) had even been instantiated. + +Not anymore! + +```sh +Error reading config file: +bud.config.mjs appears to be a bud config file, but it could not be imported. + +Original error follows: +SyntaxError: Unexpected token '}' + at file:///bud/sources/@roots/bud/lib/context/config.js:62:31 + at async Promise.all (index 4) +``` + +### bud.when errors + +If you pass a non-function argument to [bud.when](https://bud.js.org/docs/bud.when) it will throw an error now. I've seen a few people do this and it's an understandable mistake. I'm sorry for the error but it wasn't doing what you wanted before. + +This is the specific mistake I saw most recently. + +```ts +/* This will now throw */ +bud.when( + bud.isProduction, + bud.minimize(), // oops! +) +``` + +The problem is that the function is being called right there! It's whatever value the function returns by the time `bud.when` receives it. It doesn't cause a type error but it's obvious something is wrong. + +The corrected version would just wrap the bud.minimize() call in an arrow function: + +```ts +bud.when( + bud.isProduction, + () => bud.minimize() // corrected +) +``` + +Anyway, there will be instructions in the console if you are bit by this. + +### Unsupported platform errors + +If you run bud.js on Windows outside of a WSL environment, it won't try and stop you, but it also won't work. This is mentioned in both the project README.md and [our Getting Started guide](https://bud.js.org/guides/getting-started), and yet many people still post support requests related to errors experienced while using Windows. + +Now, errors are accompanied by a reminder that the platform is not supported, which should hopefully reduce support request volume. + +If you use Windows and want to see native support for Windows in bud.js please submit an issue and accompanying PR! + +## Improve `bud doctor` + +`bud doctor` now displays additional information about the project and has a couple new checks. + +## Fix: sass/vue/sage (in combination) + +Fixes an issue that could create blank stylesheets (with no error thrown from `vue-loader`). Adds reproduction to prevent regressions. + +## Fix: @roots/bud-prettier `format` command + +Thanks to @nlemoine for fixing the `bud format` command. + +## Docs contributions + +Big thanks to @dsturm for their continued work improving bud.js' documentation πŸ™πŸΌ. diff --git a/sources/@repo/docs/content/releases/6.12.0.md b/sources/@repo/docs/content/releases/6.12.0.md new file mode 100644 index 0000000000..92080dff56 --- /dev/null +++ b/sources/@repo/docs/content/releases/6.12.0.md @@ -0,0 +1,110 @@ +--- +slug: "6.12.0" +title: "6.12.0" +description: Release notes for bud.js 6.12.0 +date: 2023-04-03T08:24:42Z +author: kellymears +author_title: Developer +author_url: https://github.com/kellymears +author_image_url: https://avatars.githubusercontent.com/u/397606?v=4 +tags: + - release + - 6 + - 6.12 +--- + + + +Framework improvements, eslint fixes, better `config` directory support, and more. + + + +:::info Updates available + +There are patches available for [this release](https://bud.js.org/releases/tags/6-12). Please update to [6.12.3](https://bud.js.org/releases/6.12.3). + +::: + +## πŸ“¦ tailwindcss 3.3.0 supported + +bud.js now supports the new configuration options from tailwindcss 3.3.0. tailwind configs can now be authored with typescript or esm. + +## 🧹 default storage location: .budfiles -> os cache dir + +Less junk in your project is always good, right? The new default `@storage` directory is now `[os-cache dir]/bud-nodejs/[hash of project path]`. + +**Breaking change**: If you are explicitly setting the `@storage` directory you need to do it using the `--storage` CLI flag or the `APP_STORAGE_PATH` .env variable. By the time config files have been processed most reads and writes to `@storage` will have already occurred, so `bud.setPath` won't be effective. There will be a warning logged to the console if you are doing this; the main adverse effect will be slower builds when bud.js can't find caches during bootstrapping. + +**Potentially breaking change**: If you are using remote modules (which lets you import modules from cdns like [skypack](https://skypack.dev) without installing locally) the `bud.lock` lockfile will now be written to the root of your project (unless you have configured it to be written somewhere else). + +## ✨ Config files can be written in TypeScript (without extensions) + +bud.js configuration files can now be authored in typescript without installing any additional extensions. if you were previously using the `ts-bud` binary you still can (it executes the bud.js runtime with ts-node), but you can now just use the standard `bud` command (it is faster). `ts-bud` remains available in case you were doing some deeper integration with ts-node. + +The parsing of TypeScript configs is handled with [esbuild-wasm](https://www.npmjs.com/package/esbuild-wasm). I have not been able to measure a meaningful difference in timings using this package instead of [esbuild](https://www.npmjs.com/package/esbuild) and the wasm binary doesn't need to be built so installs are a lot faster. However, if you want to use esbuild instead of esbuild-wasm you can install esbuild as a project dependency and it will be used instead. Again, I don't think it's worth the extra installation time. Especially since the results of config transforms are cached. + +This also applies to eslint, tailwindcss, postcss and babel configs. + +## ✨ Config files can be stored in `./config` directory + +bud.js configuration files can now be stored in the `config` directory. This also applies to eslint, tailwindcss, postcss and babel configs. + +## ✨ @roots/bud-eslint: upgrade eslint-webpack-plugin to v4 + +eslint-webpack-plugin@4 removes need for eslint cache fix + +If you were disabling the fix with `bud.eslint.cacheFix.enable(false)` before you will be prompted to remove that call, as it is now deprecated. + +See [#2191](https://github.com/roots/bud/pull/2191) + +## 🏎️ performance: module resolution caching + +Module paths resolved by `bud.module` are cached to `[cachedir]/resolutions.yml`. This gives a nice performance boost since we can skip a lot of lookups: + +The `resolve` and `import` methods used by `bud.module` treat built-in dependencies as fallbacks. So, if you aren't overriding any built-in dependencies and the cache is valid the net result is more than half as many calls to `importMetaResolve` and `import` statements. + +- sha1 hashes are calculated for files in root and `config/*` and an artifact is output to `[cachedir]/checksum.yml`. +- Hash mismatches in config files or `package.json` will invalidate the `bud.module` resolver cache and the `compiler` cache. + +## 🏎️ performance: reuse context & bud instances + +`bud.context` is now re-used between bootstrap scripts and the cli application. + +## ✨ improve: unified error handling + +Now extending [modern-errors](https://github.com/ehmicky/modern-errors) for unified error handling. + +## 🩹 fix: no postinstall scripts in CI + +There are some reliability issues with postinstall scripts (for @roots/bud-framework and @roots/browserslists-config) running in CI. + +This update disables postinstall scripts when `process.env.CI` is set (default for gh actions). + +See [#2169](https://github.com/roots/bud/pull/2169) + +## ✨ improve(@roots/eslint-config): remove react-in-jsx-scope + +This rule is not really appropriate as a default for modern React. + +See [#2154](https://github.com/roots/bud/pull/2154) + +## πŸ‘©β€πŸ”¬ experimental: pnpm support + +Installs with `pnpm` should work now. They may break again in the future, but we're closer to being able to claim full compatibility. You must install with public hoisting: + +```sh +pnpm install --public-hoist-pattern=* +``` + +pnpm installs peers by default as of pnpm v8 πŸŽ‰, so we suspect that compatibility will be a lot better once people upgrade. + +## πŸ“¦ upgrade ink to v4 + +A ton of workarounds were required to make ink work prior to this upgrade. It's now compatible with react 18 and fully esm πŸŽ‰. + +## πŸ“• Documentation improvements + +- Thanks to @chrillep for improving the `@roots/bud-eslint` documentation example config +- Adds documentation for `bud.config` +- Improves documentation for `bud.define` +- Adds pnpm installation instructions to getting started guide diff --git a/sources/@repo/docs/content/releases/6.12.1.md b/sources/@repo/docs/content/releases/6.12.1.md new file mode 100644 index 0000000000..1090dfe233 --- /dev/null +++ b/sources/@repo/docs/content/releases/6.12.1.md @@ -0,0 +1,58 @@ +--- +slug: "6.12.1" +title: "6.12.1" +description: Release notes for bud.js 6.12.1 +date: 2023-04-26T00:37:57Z +author: kellymears +author_title: Developer +author_url: https://github.com/kellymears +author_image_url: https://avatars.githubusercontent.com/u/397606?v=4 +tags: + - release + - 6 + - 6.12 +--- + + + +Minor release with improvements and fixes for package resolution and caching + + + +:::info Updates available + +There are patches available for [this release](https://bud.js.org/releases/tags/6-12). Please update to [6.12.3](https://bud.js.org/releases/6.12.3). + +::: + +## Fixes + +### Failure installing custom TypeScript version with yarn + +Fixes an error encountered when trying to install a custom version of TypeScript while using `@roots/bud-typescript` with yarn classic. [See #2216](https://github.com/roots/bud/issues/2216). + +This issue is actually an upstream bug in yarn. But, our response sidesteps it and also improves compatibility with pnpm. + +The short version: we don't need to declare `typescript` as a peer dependency because of changes to `bud.module` made in bud v6. It will always try to resolve from the project context before using the built-in as a fallback. + +So, even without peer dependencies defined by the extension, the following call (when made from the `@roots/bud-typescript` context) will always try and resolve the module first from `node_modules/typescript`, and then `node_modules/@roots/bud-typescript/node_modules`. + +```ts +bud.module.resolve(`typescript`, import.meta.url) +``` + +The change that fixes #2216 has also been applied to `@roots/bud-eslint` and `@roots/bud-babel`. We'll apply it to other packages which use `peerDependencies` in future releases. + +## Improvements + +### Include eslint and tailwind configs in build dependencies + +[#2233 Include tailwind & eslint configs in cached build dependencies](https://github.com/roots/bud/pull/2233) adds discovered `tailwind` and `eslint` configs to the map of files the compiler uses to validate the cache. Hopefully changes made to your tailwind config will now be more reliably reflected in your next build without having to use the `--force` flag. Additionally, only modules related to the changed config will be invalidated, which will be much faster than wiping everything. + +### Prevent invoking multiple `esbuild` and/or `esbuild-wasm` modules + +When transforming configuration modules authored in TypeScript bud.js will now prefer `esbuild` or `esbuild-wasm` as defined by `package.json`, if they are included. The built-in `esbuild-wasm` included in `@roots/bud-support` is used as a fallback. This should be a minor improvement for users who are using `esbuild` in some other way as part of their build. + +### Vendor `bind` decorator from `helpful-decorators`. + +`helpful-decorators` is an awesome package but we are only using `bind` from it and it is used in a lot of places. This change eliminates the (modest) overhead associated with all the unused modules. diff --git a/sources/@repo/docs/content/releases/6.12.2.md b/sources/@repo/docs/content/releases/6.12.2.md new file mode 100644 index 0000000000..f71bac3ba6 --- /dev/null +++ b/sources/@repo/docs/content/releases/6.12.2.md @@ -0,0 +1,28 @@ +--- +slug: "6.12.2" +title: "6.12.2" +description: Release notes for bud.js 6.12.2 +date: 2023-04-30T23:19:00Z +author: kellymears +author_title: Developer +author_url: https://github.com/kellymears +author_image_url: https://avatars.githubusercontent.com/u/397606?v=4 +tags: + - release + - 6 + - 6.12 +--- + + + +Adds cached module count to dashboard output for greater transparency into what is being recompiled in development. + + + +:::info Updates available + +There are patches available for [this release](https://bud.js.org/releases/tags/6-12). Please update to [6.12.3](https://bud.js.org/releases/6.12.3). + +::: + + diff --git a/sources/@repo/docs/content/releases/6.12.3.md b/sources/@repo/docs/content/releases/6.12.3.md new file mode 100644 index 0000000000..be9a86131d --- /dev/null +++ b/sources/@repo/docs/content/releases/6.12.3.md @@ -0,0 +1,45 @@ +--- +slug: "6.12.3" +title: "6.12.3" +description: Release notes for bud.js 6.12.3 +date: 2023-05-11T00:48:24Z +author: kellymears +author_title: Developer +author_url: https://github.com/kellymears +author_image_url: https://avatars.githubusercontent.com/u/397606?v=4 +tags: + - release + - 6 + - 6.12 +--- + + + +Bugfixes and bumped dependencies + + + +## Improvements + +### [#2243](https://github.com/roots/bud/pull/2243) improves compatibility with pnpm + +This change finishes work started in 6.12.2 make it less necessary to use [the bud.js .pnpmfile.cjs compatibility shim](https://bud.js.org/guides/general-use/pnpm#pnpmfilecjs-compatibilty-shim). + +You should also now be able to limit hoisting to `@roots` packages, if desired: + +``` +pnpm install --public-hoist-pattern="@roots/*" +``` + +When only hoisting `@roots/*` packages you will need to make sure your app dependencies are explicitly defined. Rule of thumb: if you import it in your app you will need to have it installed in your project. + +The alternative is to hoist everything (same behavior as npm and yarn): + +``` +pnpm install --public-hoist-pattern="*" +``` + +## Fixes + +- Fixes module resolution cache validation when swapping package managers. +- Fixes issue with eslint not outputting to stdout/stderr in some configurations. diff --git a/sources/@repo/docs/content/releases/6.13.1.md b/sources/@repo/docs/content/releases/6.13.1.md new file mode 100644 index 0000000000..0f0a96c498 --- /dev/null +++ b/sources/@repo/docs/content/releases/6.13.1.md @@ -0,0 +1,309 @@ +--- +slug: "6.13.1" +title: "6.13.1" +description: Release notes for bud.js 6.13.1 +date: 2023-06-14T06:06:21Z +author: kellymears +author_title: Developer +author_url: https://github.com/kellymears +author_image_url: https://avatars.githubusercontent.com/u/397606?v=4 +tags: + - release + - 6 + - 6.13 +--- + + + +A feature rich (and mostly backwards compatible) set of improvements and fixes for bud.js. + + + +## ⚠️ Potentially breaking changes + +- `single` runtimeChunk now enabled by default. +- **@roots/bud-eslint**: warnings are not treated as errors by default. +- **@roots/bud-eslint**: errors will cause files to not emit in production. +- **@roots/bud-stylelint**: warnings are not treated as errors by default. +- **@roots/bud-stylelint**: errors will not emit in production. +- **@roots/wordpress-theme-json-webpack-plugin**: exported type `Theme` renamed to `Schema`. +- **@roots/bud-terser**: is replaced by **@roots/bud-minify**. + - you do not need to include this in your project; it is a transitive dependency of **@roots/bud**. + - **bud.terser** deprecated in favor of **bud.minify.js** + - **bud.minimizeCss** deprecated in favor of **bud.minify.css** + +## Core features + +
+ +Enhanced support for tsconfig.json + +

+ +You can now configure `@src`, `@dist`, compilation paths and aliases directly in `tsconfig.json`. Also works with `jsconfig.json`. This is nice for compatibility with the typescript compiler. + +This feature is opt-in for now but will likely become a default in bud v7. To opt in set `bud.useCompilerOptions` to `true` in the config. + +| tsconfig key | value | +| -- | -- | +| `compilerOptions.baseUrl` | Set `@src` directory | +| `compilerOptions.outDir` | Set `@dist` directory | +| `compilerOptions.paths` | Set bud path handles and aliases | +| `include` | Directories containing modules which should be treated as source. Same as calling `bud.compilePaths` | + +

+
+ +Example annotated tsconfig.json + +

+ +```json5 +{ + "extends": ["@roots/bud/config/tsconfig.json"], + "compilerOptions": { + /** + * Source directory + * + * @remarks + * This is the same as calling `bud.setPath(`@src`, `sources`) + */ + "baseUrl": β€œsources", + + /** + * Output directory + * + * @remarks + * This is the same as calling `bud.setPath(`@dist`, `build`) + */ + "outDir": β€œbuild", + + /** + * Path aliases + * + * @remarks + * This is the same as calling `bud.setPath()` and `bud.alias()` + * Only the first path in each value will be used. + */ + "paths": { + "@fonts": ["fonts"], + "@images": ["images"], + "@scripts": ["scripts"], + "@styles": ["styles"] + }, + + /** + * Include type definitions + */ + "types": [ + "@roots/bud", + "@roots/bud-react", + "@roots/bud-postcss", + "webpack/module" // defines import.meta.webpackHot + ] + }, + + /** + * Configuration files + */ + "files": ["bud.config.ts"], + + /** + * Compiler paths + * + * @remarks + * This is the same as calling bud.compilePaths() + */ + "include": ["resources"], + + /** + * Allow bud to reference tsconfig/jsconfig values + */ + "bud": { + "useCompilerOptions": true + } +} +``` + +

+ +
+ +
+ +
+ +TSC compatible module imports + +

+ +With the TypeScript Compiler you can ensure your outputted code is compliant with esmodules by mapping extensions in your import statements. For example, if you want to import a module from `./some-module.ts`, you would likely want to import it like this: + +```ts +import someModule from './some-module.js' +``` + +bud.js works the same way now, in practice. Now, if you want to write your import statements in a way that is compliant with TSC, you can. + +

+ +
+ +
+ +bud.setPath now automatically sets aliased paths + +

+ +If you set a path handle with `bud.setPath` it now sets up a path alias as well. + +

+ +
+ +
+ +JSON schema available + +

+ +JSON schema available at `https://bud.js.org/bud.package.json`. You can optionally add it to `package.json` for validation of `package.json` fields (including bud specific ones): + +```json +{ + "$schema": "https://bud.js.org/bud.package.json" +} +``` + +

+ +
+ +
+ +Improved extension options API + +

+ +Every registered extension option now has a dedicated getter and setter. The getter prefixes the option key with `get` and the setter prefixes it with `set`. + +| Option | Getter | Setter | +| :--- | :--- | :--- | +| bud.extension.optionName | bud.extension.getOptionName() | bud.extension.setOptionName(value) | + +Lastly, know that the `setOptionName` always accepts a callback: + +```ts +bud.extension.setOptionName(value => value) +``` + +### Example + +Let's say `@roots/bud-eslint` has a new option defined (since it does): + +```ts +lintDirtyModulesOnly: EslintPluginOptions['lintDirtyModulesOnly'] +``` + +Previously you could get this value like so: + +```js +bud.eslint.get(`lintDirtyModulesOnly`) +``` + +That still works, but now you have some additional options: + +```js +/** Get the value via a property */ +bud.eslint.lintDirtyModulesOnly +/** Get the value via a function */ +bud.eslint.getLintDirtyModulesOnly() +``` + +Similarly, in addition to `bud.eslint.set`: + +```ts +bud.eslint.set(`lintDirtyModulesOnly`, true) +``` + +You can now set it with a dedicated setter method: + +```ts +bud.eslint.setLintDirtyModulesOnly(true) +``` + +All such setter methods accept a callback: + +```ts +bud.eslint.setLintDirtyModulesOnly(value => !value) +``` + +

+ +
+ +## @roots/bud-postcss + +- The postcss configuration API has gotten a rework. + +Refer to the [updated documentation for more information](https://bud.js.org/extensions/bud-postcss). + +## @roots/bud-eslint + +- New options and methods exposed by `bud.eslint` +- Configure eslint in your bud config + +Refer to the [updated documentation for more information](https://bud.js.org/extensions/bud-eslint). + +## @roots/bud-sass + +- New options and methods exposed by `bud.sass` + +Refer to the [updated documentation for more information](https://bud.js.org/extensions/bud-sass). + +## @roots/bud-stylelint + +- New options and methods exposed by `bud.stylelint` +- Configure stylelint in your bud config + +Refer to the [updated documentation for more information](https://bud.js.org/extensions/bud-stylelint). + +### @roots/bud-swc + +- New options and methods exposed by `bud.swc` +- Override base configuration for js and ts separately + +Refer to the [updated documentation for more information](https://bud.js.org/extensions/bud-swc). + +### @roots/bud-tailwindcss + +- New options and methods exposed by `bud.tailwind` +- Supports configuring tailwindcss directly in bud config + +Refer to the [updated documentation for more information](https://bud.js.org/extensions/bud-tailwindcss). + +### @roots/bud-wordpress-theme-json + +- New options and methods exposed by `bud.wpjson` + +## Other changes + +- `experiments.backCompat` now set to `false`. bud doesn't need backwards compatibility with webpack 4 and the compatibility fixes come with performance penalties related to `Array` objects. +- `snapshot.buildDependencies` uses a hash if `bud.env.get('CI')` is `true`; uses a timestamp otherwise. +- `snapshot.module` uses a hash if `bud.env.get('CI')` is `true`; uses a timestamp otherwise. +- `snapshot.resolve` uses a hash if `bud.env.get('CI')` is `true`; uses a timestamp otherwise. +- `snapshot.resolveBuildDependencies` uses a hash if `bud.env.get('CI')` is `true`; uses a timestamp otherwise. +- `resolveLoader.alias` defined for all registered loaders. +- `resolve.unsafeCache` set to `undefined` (was `false`). default behavior is for `unsafeCache` to be used in development, and not used in production. +- `profile` now set to `true` if `--debug` flag is `true`. +- `performance` now set to `false` (was `{hints: false}`). +- `externalsType` set to `undefined` (was `var`). +- `bud.context.logger` is removed. +- `APP_TITLE` fallback set for projects which use `bud.html`. +- `NO_SCRIPT` fallback set for projects which use `bud.html`. +- Typings for WordPress `theme.json` updated using current schema. +- Build script now in place to help with future updates to WordPress `theme.json`. +- Default css minimizer is now [lightningcss](https://lightningcss.dev) (css parser used by parcel). +- If using `@roots/bud-swc` css minification is handled by swc. +- If using `@roots/bud-esbuild` css minification is handled by esbuild. +- New documentation for [bud.minify](https://bud.js.org/docs/minify). diff --git a/sources/@repo/docs/content/releases/6.14.0.md b/sources/@repo/docs/content/releases/6.14.0.md new file mode 100644 index 0000000000..89eb8de93e --- /dev/null +++ b/sources/@repo/docs/content/releases/6.14.0.md @@ -0,0 +1,110 @@ +--- +slug: "6.14.0" +title: "6.14.0" +description: Release notes for bud.js 6.14.0 +date: 2023-07-06T13:21:05Z +author: kellymears +author_title: Developer +author_url: https://github.com/kellymears +author_image_url: https://avatars.githubusercontent.com/u/397606?v=4 +tags: + - release + - 6 + - 6.14 +--- + + + +Top-level await, lazy compilation of async modules, CLI improvements, performance enhancements, and more. + + + +:::info Updates available + +There are patches available for [this release](https://bud.js.org/releases/tags/6-14). Please update to [6.14.3](https://bud.js.org/releases/6.14.3). + +::: + +## 🚨 Potentially breaking changes + +- deprecated: `@roots/merged-manifest-webpack-plugin` +- deprecated: `@roots/bud-wordpress-manifests` +- `bud.console`: removed. old methods consolidated with `bud.dashboard`. +- `bud.context.files`: interface has changed. The `module` property for each value in `bud.context.files` is now an async function that returns the module. This is an undocumented internal, but some people might be using it. + +## Key changes + +- ✨ feature: top level await (enabled for ESM projects only) +- ✨ feature: creates aliases from [`imports` field of package.json](https://nodejs.org/api/packages.html#imports) +- ✨ feature: dynamic modules now compiled lazily in development +- 🏎️ performance: multi-config builds are now built in parallel +- ✨ improve: config files now lazy loaded +- ✨ 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(`@roots/bud-dashboard`): improved UI +- ✨ add flag: `--entrypoints.html` (same as calling `bud.entrypoints.set('emitHtml', true)`; emits partials containing `