Skip to content

Commit

Permalink
fix(none): argv overrides (#1675)
Browse files Browse the repository at this point in the history
Forgot to finalize this.

refers:

- none

## Type of change

**PATCH: backwards compatible change**



This PR includes breaking changes to the following core packages:

- none

This PR includes breaking changes to the follow extensions:

- none

## Dependencies

### Adds

- none

### Removes

- none
  • Loading branch information
kellymears committed Sep 16, 2022
1 parent 5c5bffd commit 35836c6
Show file tree
Hide file tree
Showing 75 changed files with 1,341 additions and 1,294 deletions.
2 changes: 0 additions & 2 deletions examples/vue-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
"extends @roots/browserslist-config/current"
],
"devDependencies": {
"@roots/browserslist-config": "latest",
"@roots/bud": "latest",
"@roots/bud-vue": "latest"
},
"dependencies": {
"lodash": "4.17.21",
"vue": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"vue-loader": "^15.9.4"
Expand Down
12 changes: 11 additions & 1 deletion sources/@repo/docs/content/blog/6.4.0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ tags: [release]

<!--truncate-->

## bud.assets
## new: bud.sh

bud.sh is a new config function that allows for executing arbitrary shell commands. It is a wrapper around the [execa](https://github.com/sindresorhus/execa) package.

It's async and returns the `ExecaChildProcess` object. It will pipe the process stdout/stderr to the console automatically.

```js title=bud.config.mjs
await bud.sh('echo "hello world"')
```
## improved: bud.assets
You can now specify copy options to apply to all copy patterns as a second parameter.
Expand Down
9 changes: 0 additions & 9 deletions sources/@repo/docs/content/docs/bud.define.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ id: bud.define
title: bud.define
description: Replace variables in your application code and templates at compile time.
sidebar_label: bud.define
image: 'https://bud.js.org/img/share/docs/bud.define.png'
---

import Tabs from '@theme/Tabs'
Expand Down Expand Up @@ -36,11 +35,3 @@ Replacements will also be made when compiling [html templates](/docs/bud.templat
<!-- ... -->
</html>
```

## Signature

```ts title='@roots/bud-api/types/repository/index.d.ts'
interface Define {
(this: Bud, values: Webpack.DefinePlugin['definitions']): Bud
}
```
10 changes: 0 additions & 10 deletions sources/@repo/docs/content/docs/bud.devtool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,3 @@ Enable sourcemaps only in development (see [bud.when](bud.when) for extra clarit
```js title='bud.config.js'
bud.when(bud.isDevelopment, bud => bud.devtool())
```

## Signature

```ts title='@roots/bud-api/types/repository/index.d.ts'
namespace Repository {
interface Devtool {
(this: Bud, devtool?: Webpack.Configuration['devtool']): Bud
}
}
```
50 changes: 0 additions & 50 deletions sources/@repo/docs/content/docs/bud.entry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ bud.entry({

Bud supports the new Webpack 5 `dependOn` syntax for explicitly defining entrypoint dependencies.

Example react application:

```ts title='bud.config.js'
bud.entry({
react: ['react', 'react-dom'],
Expand All @@ -58,51 +56,3 @@ You can specify assets using [fast-glob syntax](https://git.io/JkGbw).
- `**` matches any number of characters, including `/`, as long as it's the only thing in a path part
- `{}` allows for a comma-separated list of "or" expressions
- `!` at the beginning of a pattern will negate the match

## Specifying entrypoints with hooks

You may also specify entrypoints using the `build/entry` [hook](/docs/bud.hooks/).

```js title='bud.config.js'
bud.hooks.on('build.entry', {
app: ['app.js', 'app.css'],
admin: ['admin.js', 'admin.css'],
})
```

This will completely override whatever is defined. If you want to augment the existing definition you can do so with spread syntax.

```js title='bud.config.js'
bud.hooks.on('build.entry', entrypoints => ({
...entrypoints,
app: ['app.js', 'app.css'],
admin: ['admin.js', 'admin.css'],
})
```
## Signature
```ts title='@roots/bud-api/types/repository/index.d.ts'
namespace Repository {
interface Entry {
(this: Bud, name: string, entrypoint: Entry.Value): Bud
}

interface Entry {
(this: Bud, entrypoints: Entry.Input): Bud
}

namespace Entry {
interface Object {
import?: string[]
dependOn?: string[]
}

interface Input {
[k: string]: Object | Object['import'] | GlobTask['pattern']
}

type Value = GlobTask['pattern'] | Array<GlobTask['pattern']>
}
}
```
2 changes: 1 addition & 1 deletion sources/@repo/docs/content/docs/bud.experiments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_label: bud.experiments

:::warning

These settings are obviously experimental. If you're using `bud.experiments` and you bump into a problem please ensure that
These settings are flagged as experimental by Webpack. If you're using `bud.experiments` and you bump into a problem please ensure that
**bud.js** is doing something wrong before opening an issue in the roots/bud repository. Consider accompanying your issue with
a PR that implements the change you would like to see.

Expand Down
1 change: 0 additions & 1 deletion sources/@repo/docs/content/docs/bud.externals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ id: bud.externals
title: bud.externals
description: Specify a non-standard resolution strategy for modules with a matching name.
sidebar_label: bud.externals
image: 'https://bud.js.org/img/share/docs/bud.externals.png'
---

Specify a non-standard resolution strategy for modules with a matching name.
Expand Down
6 changes: 3 additions & 3 deletions sources/@repo/docs/content/docs/bud.glob.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ description: Globbing function
sidebar_label: bud.glob
---

Glob for matching files. This function is asyncronous but there is a syncronous version provided by [bud.globSync](/docs/bud.globSync)
Glob for matching files. This function is asynchronous but there is a synchronous version provided by [bud.globSync](/docs/bud.globSync)

## Usage

To look for files relative to the project, you can simply pass the search:
To look for files relative to the project root:

```js
const results = await bud.glob('**/*.json')
```

To include additional search terms (matched as `AND`) you can either treat the function as variadic or specify with an array:
To include additional search terms you can either treat the function as variadic or specify with an array:

```js
const results = await bud.glob('**/*.json', '**/*.yml')
Expand Down
6 changes: 3 additions & 3 deletions sources/@repo/docs/content/docs/bud.globSync.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ description: Globbing function
sidebar_label: bud.globSync
---

Glob for matching files. This function is syncronous but there is an asyncronous version provided by [bud.glob](/docs/bud.glob)
Glob for matching files. This function is synchronous but there is an asynchronous version provided by [bud.glob](/docs/bud.glob). The asynchronous version should be preferred.

## Usage

To look for files relative to the project, you can simply pass the search:
To look for files relative to the project root:

```js
const results = bud.globSync('**/*.json')
```

To include additional search terms (matched as `AND`) you can either treat the function as variadic or specify with an array:
To include additional search terms you can either treat the function as variadic or specify with an array:

```js
const results = bud.globSync('**/*.json', '**/*.yml')
Expand Down
8 changes: 4 additions & 4 deletions sources/@repo/docs/content/docs/bud.hooks/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ bud.hooks.async('build.resolve.modules', async modulePaths => [
Callbacks for asynchronous hooks should be registered as asynchronous functions.
## bud.hooks.fromMap
## bud.hooks.fromAsyncMap
Set multiple async hooks at once with `bud.hooks.fromMap`.
Set multiple async hooks at once with `bud.hooks.fromAsyncMap`.
```ts
bud.hooks.fromMap({
bud.hooks.fromAsyncMap({
'build.resolve.modules': async paths => [
...paths,
await fs.promises.realpath('node_modules'),
abud.path('@modules'),
],
})
```
Expand Down
38 changes: 16 additions & 22 deletions sources/@repo/docs/content/docs/bud.make.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,33 @@ For more context on how this might be useful check out [the guide on multi-compi

**bud.make** is an asyncronous function that takes two parameters:

- The **name** of the new compiler, or an [**options**](#options) object to be used when constructing the new instance.
- The **name** of the new compiler, or a context to be used when constructing the new instance.
- An optional callback to use for configuring the compiler.

Example specified with a **name**:

```js
bud.make('scripts', async child => child.entry('app', 'app.js'))
export default async bud => {
bud.make('compiler-a', async child => child.entry('app', 'app.js'))
}
```

Example specified with **options** object:
Example specified with context overrides:

```ts
bud.make(
{
name: 'compiler-a',
dir: bud.path('./compiler-a'),
},
config => {},
)
export default async bud => {
bud.make(
{
name: 'compiler-b',
basedir: bud.path('./compiler-a'),
},
async child => {
child.entry('app', 'app.js')
},
)
}
```

## Options

| Property | Value |
| ---------- | --------------------------------------- |
| name | Compiler name |
| dir | Compiler base directory (absolute path) |
| mode | `development` or `production` |
| context | Context |
| seed | Initializing values |
| services | Service classes |
| extensions | Extension classes |

Related:

- [bud.get](/docs/bud.get)
Expand Down
51 changes: 7 additions & 44 deletions sources/@repo/docs/content/docs/bud.path.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,19 @@ You can use **bud.path** to reference a file or directory's absolute path.

## Usage

```ts
bud.path('@src/scripts/components')
```

If you like you can use `./` to reference project root:

```ts
bud.path('./src/scripts/components')
```

You may also choose to deliniate directories with an `Array` of path segments, rather than a `String`:

```ts
bud.path('@src', 'scripts', 'components')
bud.path('./src', 'scripts', 'components')
```

## Special path handles

The following is a table containing `String` values which fulfill a special role in the context of the **bud.path** function:
The following is a table containing `string` values which fulfill a special role in the context of the **bud.path** function:

| handle | description | default |
| ------------ | -------------------------------- | ---------------- |
Expand All @@ -37,7 +31,7 @@ The following is a table containing `String` values which fulfill a special role
| **@storage** | cache/artifact storage directory | `./.budfiles` |
| **@modules** | modules directory | `./node_modules` |

When one of these handles is used at **the beginning of a path**, the path will be
When one of these handles is used at **the beginning of a string path** (or the first segment in a multi-segment path), the path will be
prefixed with the corresponding directory.

For example, to reference the `./src` directory:
Expand All @@ -46,40 +40,9 @@ For example, to reference the `./src` directory:
bud.path('@src/scripts/components')
```

You can create your own handles for use in the **bud.path** function. But, the handles in this table are standard. Other parts of the bud.js framework or ecosystem may use these handles to reference project directories. So, while they may be freely modified as needed, they should not be removed.

## Managing **bud.path** handles

**bud.setPath** is used to add or modify path handles. There are only two real rules for path handles:

- A path handle must be unique
- A path handle must be a `String` which begins with a `@`

To make a reference to the `./src/scripts/components` directory we could write:

```ts
bud.setPath('@components', '@src/scripts/components')
```
You can create your own handles for use in the **bud.path** function. But, the handles in this table are standard.
Other parts of bud.js or its ecosystem may use these handles to reference project directories. So, while they may be freely modified as needed, they should not be removed or repurposed.

In the future we can utilize that reference:

```ts
bud.path('@components') // => './src/scripts/components'
```

We can redefine the path to source assets like so:

```ts
bud.setPath('@src', 'sources')
```

Lastly, we can define multiple paths in a single call by using an object:

```ts
bud.setPath({
'@src': 'sources',
'@components': '@src/scripts/components',
})
```
## Setting **bud.path** handles

Note that if we were to change `@src` again that `@components` path would still reference the old value. This is something to be aware of.
Use [bud.setPath](/docs/bud.setPath) to define or override a handle value.
7 changes: 0 additions & 7 deletions sources/@repo/docs/content/docs/bud.serve.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ By default bud will serve at the following address:

If port 3000 is already used a new port will be dynamically selected.

## Usage

There is no need to call this function in order to use the development server. Development server functionality is automatically enabled when
the `bud serve` cli command is invoked.

This function is used to configure the development server to run at a specific hostname or port, and/or serve over SSL.

## Specifying server address

:::warning
Expand Down
Loading

0 comments on commit 35836c6

Please sign in to comment.