Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions api-reports/rspeedy.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,35 @@
"collapsed": true,
"collapsible": true,
"items": [
{
"text": "buildCache",
"link": "api/rspeedy/rspeedy.performance.buildcache",
"collapsed": true,
"collapsible": true,
"items": [
{
"text": "buildDependencies",
"link": "api/rspeedy/rspeedy.buildcache.builddependencies",
"collapsed": true,
"collapsible": false,
"items": []
},
{
"text": "cacheDigest",
"link": "api/rspeedy/rspeedy.buildcache.cachedigest",
"collapsed": true,
"collapsible": false,
"items": []
},
{
"text": "cacheDirectory",
"link": "api/rspeedy/rspeedy.buildcache.cachedirectory",
"collapsed": true,
"collapsible": false,
"items": []
}
]
},
{
"text": "chunkSplit",
"link": "api/rspeedy/rspeedy.performance.chunksplit",
Expand Down Expand Up @@ -461,6 +490,13 @@
"collapsible": false,
"items": []
},
{
"text": "preEntry",
"link": "api/rspeedy/rspeedy.source.preentry",
"collapsed": true,
"collapsible": false,
"items": []
},
{
"text": "transformImport",
"link": "api/rspeedy/rspeedy.source.transformimport",
Expand Down
47 changes: 47 additions & 0 deletions docs/en/api/rspeedy/rspeedy.buildcache.builddependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@lynx-js/rspeedy](./rspeedy.md) &gt; [BuildCache](./rspeedy.buildcache.md) &gt; [buildDependencies](./rspeedy.buildcache.builddependencies.md)

## BuildCache.buildDependencies property

> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

An array of files containing build dependencies. Rspack will use the hash of each of these files to invalidate the persistent cache.

**Signature:**

```typescript
buildDependencies?: string[] | undefined;
```

## Remarks

Rspeedy will use the following configuration files as the default build dependencies:

- `package.json`

- `tsconfig.json` (or `source.tsconfigPath`<!-- -->)

- `.env`<!-- -->, `.env.*`

- `tailwindcss.config.*`

When using Rspeedy CLI, it will also automatically add `lynx.config.js` to the build dependencies.

## Example

Add `postcss.config.js` to the build dependencies.

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
performance: {
buildCache: {
buildDependencies: ['postcss.config.js'],
},
},
})
```

33 changes: 33 additions & 0 deletions docs/en/api/rspeedy/rspeedy.buildcache.cachedigest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@lynx-js/rspeedy](./rspeedy.md) &gt; [BuildCache](./rspeedy.buildcache.md) &gt; [cacheDigest](./rspeedy.buildcache.cachedigest.md)

## BuildCache.cacheDigest property

> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Add additional cache digests, the previous build cache will be invalidated when any value in the array changes.

**Signature:**

```typescript
cacheDigest?: Array<string | undefined> | undefined;
```

## Example

Add `process.env.SOME_ENV` to the cache digest.

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
performance: {
buildCache: {
cacheDigest: [process.env.SOME_ENV],
},
},
})
```

16 changes: 16 additions & 0 deletions docs/en/api/rspeedy/rspeedy.buildcache.cachedirectory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@lynx-js/rspeedy](./rspeedy.md) &gt; [BuildCache](./rspeedy.buildcache.md) &gt; [cacheDirectory](./rspeedy.buildcache.cachedirectory.md)

## BuildCache.cacheDirectory property

> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

The output directory of the cache files.

**Signature:**

```typescript
cacheDirectory?: string | undefined;
```
27 changes: 27 additions & 0 deletions docs/en/api/rspeedy/rspeedy.buildcache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@lynx-js/rspeedy](./rspeedy.md) &gt; [BuildCache](./rspeedy.buildcache.md)

## BuildCache interface

> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Enable or configure persistent build cache.

This feature is experimental and may be changed in the future.

**Signature:**

```typescript
export interface BuildCache
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [buildDependencies?](./rspeedy.buildcache.builddependencies.md) | | string\[\] \| undefined | **_(BETA)_** _(Optional)_ An array of files containing build dependencies. Rspack will use the hash of each of these files to invalidate the persistent cache. |
| [cacheDigest?](./rspeedy.buildcache.cachedigest.md) | | Array&lt;string \| undefined&gt; \| undefined | **_(BETA)_** _(Optional)_ Add additional cache digests, the previous build cache will be invalidated when any value in the array changes. |
| [cacheDirectory?](./rspeedy.buildcache.cachedirectory.md) | | string \| undefined | **_(BETA)_** _(Optional)_ The output directory of the cache files. |

4 changes: 2 additions & 2 deletions docs/en/api/rspeedy/rspeedy.createrspeedy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ The `createRspeedy` method can let you create a Rspeedy instance and you can cus
**Signature:**

```typescript
export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv, environment }: CreateRspeedyOptions): Promise<RspeedyInstance>;
export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv, environment, callerName, }: CreateRspeedyOptions): Promise<RspeedyInstance>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { cwd, rspeedyConfig, loadEnv, environment } | [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) | |
| { cwd, rspeedyConfig, loadEnv, environment, callerName, } | [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) | |

**Returns:**

Expand Down
43 changes: 43 additions & 0 deletions docs/en/api/rspeedy/rspeedy.createrspeedyoptions.callername.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@lynx-js/rspeedy](./rspeedy.md) &gt; [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) &gt; [callerName](./rspeedy.createrspeedyoptions.callername.md)

## CreateRspeedyOptions.callerName property

The name of the framework or tool that is currently invoking Rsbuild. This allows plugins to tailor their behavior based on the calling context.

**Signature:**

```typescript
callerName?: string;
```

## Example

Rsbuild plugins can access this value via `api.context.callerName`<!-- -->.

```js
export function myPlugin() {
return {
name: 'my-plugin',
setup(api) {
// Log the name of the tool invoking Rsbuild
console.log(`Called by: ${api.context.callerName}`);

// Conditionally apply plugin logic based on caller
if (api.context.callerName === 'rspeedy') {
api.modifyRsbuildConfig((config) => {
// Apply rspeedy-specific config changes
return config;
});
} else if (api.context.callerName === 'rslib') {
api.modifyRsbuildConfig((config) => {
// Apply rslib-specific config changes
return config;
});
}
}
};
}
```

1 change: 1 addition & 0 deletions docs/en/api/rspeedy/rspeedy.createrspeedyoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface CreateRspeedyOptions

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [callerName?](./rspeedy.createrspeedyoptions.callername.md) | | string | _(Optional)_ The name of the framework or tool that is currently invoking Rsbuild. This allows plugins to tailor their behavior based on the calling context. |
| [cwd?](./rspeedy.createrspeedyoptions.cwd.md) | | string | _(Optional)_ The root path of the current build. |
| [environment?](./rspeedy.createrspeedyoptions.environment.md) | | CreateRsbuildOptions\['environment'\] | _(Optional)_ Only build specified environments. For example, passing <code>['lynx']</code> will only build the <code>lynx</code> environment. If not specified or passing an empty array, all environments will be built. |
| [loadEnv?](./rspeedy.createrspeedyoptions.loadenv.md) | | CreateRsbuildOptions\['loadEnv'\] | _(Optional)_ Rspeedy automatically loads the .env file by default, utilizing the \[Rsbuild API\](https://rsbuild.dev/api/javascript-api/core\#load-env-variables). You can use the environment variables defined in the .env file within your code by accessing them via <code>import.meta.env.FOO</code> or <code>process.env.Foo</code>. |
Expand Down
3 changes: 2 additions & 1 deletion docs/en/api/rspeedy/rspeedy.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default defineConfig({

| Function | Description |
| --- | --- |
| [createRspeedy({ cwd, rspeedyConfig, loadEnv, environment })](./rspeedy.createrspeedy.md) | The <code>createRspeedy</code> method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime. |
| [createRspeedy({ cwd, rspeedyConfig, loadEnv, environment, callerName, })](./rspeedy.createrspeedy.md) | The <code>createRspeedy</code> method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime. |
| [defineConfig(config)](./rspeedy.defineconfig.md) | The <code>defineConfig</code> method is a helper function used to get TypeScript intellisense. |
| [loadConfig(loadConfigOptions)](./rspeedy.loadconfig.md) | Load the build config by the config path. |
| [mergeRspeedyConfig(configs)](./rspeedy.mergerspeedyconfig.md) | Merge multiple Rspeedy configuration objects. |
Expand All @@ -30,6 +30,7 @@ export default defineConfig({

| Interface | Description |
| --- | --- |
| [BuildCache](./rspeedy.buildcache.md) | <p>**_(BETA)_** Enable or configure persistent build cache.</p><p>This feature is experimental and may be changed in the future.</p> |
| [ChunkSplit](./rspeedy.chunksplit.md) | [Performance.chunkSplit](./rspeedy.performance.chunksplit.md) is used to configure the chunk splitting strategy. |
| [ChunkSplitBySize](./rspeedy.chunksplitbysize.md) | [Performance.chunkSplit](./rspeedy.performance.chunksplit.md) is used to configure the chunk splitting strategy. |
| [ChunkSplitCustom](./rspeedy.chunksplitcustom.md) | [Performance.chunkSplit](./rspeedy.performance.chunksplit.md) is used to configure the chunk splitting strategy. |
Expand Down
50 changes: 50 additions & 0 deletions docs/en/api/rspeedy/rspeedy.performance.buildcache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@lynx-js/rspeedy](./rspeedy.md) &gt; [Performance](./rspeedy.performance.md) &gt; [buildCache](./rspeedy.performance.buildcache.md)

## Performance.buildCache property

> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Enable or configure persistent build cache.

This feature is experimental and may be changed in the future.

**Signature:**

```typescript
buildCache?: BuildCache | boolean | undefined;
```

## Example 1

Enable persistent build cache.

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
performance: {
buildCache: true,
},
})
```

## Example 2

Customize build cache.

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
performance: {
buildCache: {
cacheDigest: [process.env.SOME_ENV],
buildDependencies: ['postcss.config.js'],
},
},
})
```

1 change: 1 addition & 0 deletions docs/en/api/rspeedy/rspeedy.performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Performance

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [buildCache?](./rspeedy.performance.buildcache.md) | | [BuildCache](./rspeedy.buildcache.md) \| boolean \| undefined | <p>**_(BETA)_** _(Optional)_ Enable or configure persistent build cache.</p><p>This feature is experimental and may be changed in the future.</p> |
| [chunkSplit?](./rspeedy.performance.chunksplit.md) | | [ChunkSplit](./rspeedy.chunksplit.md) \| [ChunkSplitBySize](./rspeedy.chunksplitbysize.md) \| [ChunkSplitCustom](./rspeedy.chunksplitcustom.md) \| undefined | _(Optional)_ [Performance.chunkSplit](./rspeedy.performance.chunksplit.md) is used to configure the chunk splitting strategy. |
| [printFileSize?](./rspeedy.performance.printfilesize.md) | | PerformanceConfig\['printFileSize'\] \| undefined | <p>_(Optional)_ Whether to print the file sizes after production build.</p><p>[Performance.printFileSize](./rspeedy.performance.printfilesize.md)</p><p>See [Rsbuild - performance.printFileSize](https://rsbuild.dev/config/performance/print-file-size) for details.</p> |
| [profile?](./rspeedy.performance.profile.md) | | boolean \| undefined | _(Optional)_ Whether capture timing information in the build time and the runtime, the same as the [profile](https://rspack.dev/config/other-options#profile) config of Rspack. |
Expand Down
26 changes: 17 additions & 9 deletions docs/en/api/rspeedy/rspeedy.source.entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ If no value is provided, the default value `'./src/index.js'` will be used.
```js
import { defineConfig } from '@lynx-js/rspeedy'
export default defineConfig({
entry: './src/pages/main/index.js',
source: {
entry: './src/pages/main/index.js',
},
})
```

Expand All @@ -34,7 +36,9 @@ export default defineConfig({
```js
import { defineConfig } from '@lynx-js/rspeedy'
export default defineConfig({
entry: ['./src/prefetch.js', './src/pages/main/index.js'],
source: {
entry: ['./src/prefetch.js', './src/pages/main/index.js'],
},
})
```

Expand All @@ -45,9 +49,11 @@ export default defineConfig({
```js
import { defineConfig } from '@lynx-js/rspeedy'
export default defineConfig({
entry: {
foo: './src/pages/foo/index.js',
bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
source: {
entry: {
foo: './src/pages/foo/index.js',
bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
},
},
})
```
Expand All @@ -59,10 +65,12 @@ export default defineConfig({
```js
import { defineConfig } from '@lynx-js/rspeedy'
export default defineConfig({
entry: {
foo: './src/pages/foo/index.js',
bar: {
import: ['./src/prefetch.js', './src/pages/bar'],
source: {
entry: {
foo: './src/pages/foo/index.js',
bar: {
import: ['./src/prefetch.js', './src/pages/bar'],
},
},
},
})
Expand Down
1 change: 1 addition & 0 deletions docs/en/api/rspeedy/rspeedy.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface Source
| [entry?](./rspeedy.source.entry.md) | | [Entry](./rspeedy.entry.md) \| undefined | _(Optional)_ The [Entry](./rspeedy.entry.md) option is used to set the entry module. |
| [exclude?](./rspeedy.source.exclude.md) | | Rspack.RuleSetCondition\[\] \| undefined | _(Optional)_ The <code>source.exclude</code> is used to specify JavaScript files that should be excluded from compilation. |
| [include?](./rspeedy.source.include.md) | | Rspack.RuleSetCondition\[\] \| undefined | _(Optional)_ The <code>source.include</code> is used to specify additional JavaScript files that need to be compiled. |
| [preEntry?](./rspeedy.source.preentry.md) | | string \| string\[\] \| undefined | _(Optional)_ Add a script before the entry file of each page. This script will be executed before the page code. It can be used to execute global logics, such as injecting polyfills, setting global styles, etc. |
| [transformImport?](./rspeedy.source.transformimport.md) | | [TransformImport](./rspeedy.transformimport.md)<!-- -->\[\] \| undefined | _(Optional)_ The [TransformImport](./rspeedy.transformimport.md) option transforms the import paths to enable modular imports from subpaths of third-party packages, similar to the functionality provided by [babel-plugin-import](https://npmjs.com/package/babel-plugin-import)<!-- -->. |
| [tsconfigPath?](./rspeedy.source.tsconfigpath.md) | | string \| undefined | _(Optional)_ Configure a custom <code>tsconfig.json</code> file path to use, can be a relative or absolute path. Defaults to be <code>./tsconfig.json</code>. |

Loading