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

✨ improve(patch): build performance #2596

Merged
merged 18 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 8 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
18 changes: 13 additions & 5 deletions config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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"}
]
Expand Down
4 changes: 1 addition & 3 deletions config/vitest/config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ 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,
maxThreads: 1,
minThreads: 1,
},
},
watch: false,
},
})
10 changes: 5 additions & 5 deletions config/vitest/config.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})
16 changes: 8 additions & 8 deletions config/vitest/config.shared.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {UserConfig} from 'vitest'

import {env} from 'node:process'

import GithubActionsReporter from 'vitest-github-actions-reporter'

const reporters: Array<any> = [`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
21 changes: 6 additions & 15 deletions config/vitest/config.unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {env} from 'process'

import {defineConfig} from 'vitest/config'

import shared from './config.shared'
Expand All @@ -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}`],
},
})
8 changes: 0 additions & 8 deletions config/vitest/reporters.ts

This file was deleted.

2 changes: 1 addition & 1 deletion examples/babel-advanced/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"types": ["@roots/bud", "@roots/bud-babel"]
},
"files": ["bud.config.ts"],
"files": ["./bud.config.ts"],
"include": ["./src"],
"exclude": ["./dist"]
}
8 changes: 4 additions & 4 deletions examples/config-json/bud.config.json
Original file line number Diff line number Diff line change
@@ -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}
]
}
}
2 changes: 1 addition & 1 deletion examples/critical-css/bud.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
5 changes: 3 additions & 2 deletions examples/critical-css/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
9 changes: 3 additions & 6 deletions examples/daisyui/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions examples/esbuild/bud.config.js

This file was deleted.

5 changes: 0 additions & 5 deletions examples/esbuild/src/demo.js

This file was deleted.

1 change: 1 addition & 0 deletions examples/esbuild/src/demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
;['fancy', 'ecma'].map(console.log)
File renamed without changes.
1 change: 0 additions & 1 deletion examples/esbuild/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
"compilerOptions": {
"types": ["@roots/bud", "@roots/bud-esbuild"]
},
"files": ["./bud.config.js"]
}
5 changes: 5 additions & 0 deletions examples/eslint-bud-config/bud.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {bud} from '@roots/bud'

bud.eslint.setRules({
'no-console': 'error',
})
14 changes: 14 additions & 0 deletions examples/eslint-bud-config/package.json
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
1 change: 1 addition & 0 deletions examples/eslint-bud-config/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('error')
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": ["@roots/bud/config/tsconfig.json"],
"compilerOptions": {

"types": ["@roots/bud", "@roots/bud-eslint"]
}
},
"files": ["./bud.config.ts"]
}
3 changes: 3 additions & 0 deletions examples/eslint/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
extends: ['@roots/eslint-config'],
rules: {
'no-console': 'error',
}
}
5 changes: 1 addition & 4 deletions examples/eslint/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
const target = document.querySelector('body')

target.innerHTML = `<div><h1>Hello</h1></div>`

console.log('eslint should error')
2 changes: 1 addition & 1 deletion examples/node-api/node-script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {factory} from '@roots/bud'
import { factory } from '@roots/bud'

/**
* Run this example with:
Expand Down
12 changes: 12 additions & 0 deletions examples/node-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion examples/node-api/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {factory} from '@roots/bud'
import { factory } from '@roots/bud'

/**
* Run this example with:
Expand Down
35 changes: 15 additions & 20 deletions examples/sage/bud.config.js
Original file line number Diff line number Diff line change
@@ -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()
1 change: 0 additions & 1 deletion examples/swc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
"compilerOptions": {
"types": ["@roots/bud", "@roots/bud-swc"]
},
"files": ["./bud.config.ts"]
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
Loading
Loading