Skip to content

Commit

Permalink
🔨 improve(none): refactor exports to match dir structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kellymears committed Jun 3, 2024
1 parent 51788f9 commit 9e67052
Show file tree
Hide file tree
Showing 236 changed files with 4,525 additions and 1,219 deletions.
2 changes: 1 addition & 1 deletion 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
8 changes: 8 additions & 0 deletions config/vitest/config.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ export default defineConfig({
test: {
...shared,
include: [`tests/integration/**/*.test.ts`],
isolate: true,
pool: `threads`,
poolOptions: {
threads: {
isolate: true,
useAtomics: true,
},
},
setupFiles: [`./config/vitest/setup.integration.ts`],
},
})
10 changes: 0 additions & 10 deletions config/vitest/config.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@ import type {UserConfig} from 'vitest'

import {env} from 'node:process'

import {path} from '@repo/constants'
import GithubActionsReporter from 'vitest-github-actions-reporter'

export default {
dir: path(),
hookTimeout: 240000,
isolate: true,
pool: `threads`,
poolOptions: {
threads: {
isolate: true,
useAtomics: true,
},
},
reporters: env.GITHUB_ACTIONS
? [`basic`, new GithubActionsReporter()]
: [`basic`],
Expand Down
5 changes: 4 additions & 1 deletion config/vitest/config.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import shared from './config.shared'
export default defineConfig({
test: {
...shared,
exclude: [`**/node_modules`, `tests/e2e`],
coverage: {
enabled: false,
},
exclude: [`tests/e2e`, `**/node_modules`],
include: [
`sources/@roots/**/*.test.ts`,
`sources/@roots/**/*.test.tsx`,
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
"@types/react": "18.3.1",
"@typescript-eslint/eslint-plugin": "7.8.0",
"@typescript-eslint/parser": "7.8.0",
"@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 @@ -68,7 +69,6 @@
"sources/@roots/*",
"sources/@repo/*",
"sources/@roots/*/test/**/*",
"sources/@roots/*/src/__fixtures__/*",
"sources/create-bud-app",
"tests/util/project",
"tests/reproductions/*"
Expand All @@ -77,8 +77,5 @@
"volta": {
"node": "20.12.0",
"yarn": "1.22.19"
},
"devDependencies": {
"@vitest/coverage-v8": "1.6.0"
}
}
2 changes: 1 addition & 1 deletion sources/@repo/docs/config/docusaurus.theme.cjs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion sources/@repo/docs/config/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 7 additions & 15 deletions sources/@repo/docs/content/learn/config/files/bud.config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

<ConfigExample>
<ConfigExample title="bud.config">

```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"]]
}
Expand Down
2 changes: 1 addition & 1 deletion sources/@repo/docs/content/learn/config/files/env.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
146 changes: 146 additions & 0 deletions sources/@repo/docs/content/releases/6.11.0.md
Original file line number Diff line number Diff line change
@@ -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
---

<!--This file is generated-->

A bunch of cool features, fixes and improvements.

<!--truncate-->

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 🙏🏼.
Loading

0 comments on commit 9e67052

Please sign in to comment.