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
23 changes: 23 additions & 0 deletions .changeset/three-baboons-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"@lynx-js/rspeedy": patch
---

Enable native Rsdoctor plugin by default.

Set `tools.rsdoctor.experiments.enableNativePlugin` to `false` to use the old JS plugin.

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

export default defineConfig({
tools: {
rsdoctor: {
experiments: {
enableNativePlugin: false,
},
},
},
});
```

See [Rsdoctor - 1.0](https://rsdoctor.dev/blog/release/release-note-1_0#-faster-analysis) for more details.
12 changes: 10 additions & 2 deletions packages/rspeedy/core/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ import type { Filename } from './output/filename.js'
import type { Config } from './index.js'

export function applyDefaultRspeedyConfig(config: Config): Config {
const ret = mergeRsbuildConfig(config, {
const ret = mergeRsbuildConfig({
output: {
// We are applying the default filename to the config
// since some plugin(e.g.: `@lynx-js/qrcode-rsbuild-plugin`) will read
// from the `output.filename.bundle` field.
filename: getFilename(config.output?.filename),
},
})

tools: {
rsdoctor: {
experiments: {
enableNativePlugin: true,
},
},
},
}, config)

return ret
}
Expand Down
22 changes: 22 additions & 0 deletions packages/rspeedy/core/test/config/tools/tools.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@ describe('Config - Tools', () => {
})
})

test('tools.rsdoctor', () => {
assertType<Tools>({
rsdoctor: {},
})

assertType<Tools>({
rsdoctor: {
experiments: {
enableNativePlugin: true,
},
},
})

assertType<Tools>({
rsdoctor: {
experiments: {
enableNativePlugin: false,
},
},
})
})

test('tools.rspack', () => {
// Object
assertType<Tools>({
Expand Down
9 changes: 2 additions & 7 deletions packages/rspeedy/core/test/plugins/output.plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,12 +698,7 @@ describe('Plugins - Output', () => {
await rsbuild.unwrapConfig()

expect(rsbuild.getRspeedyConfig().output?.filename).toMatchInlineSnapshot(
`
{
"bundle": "static/bundle/[name].bundle",
"template": "static/bundle/[name].bundle",
}
`,
`"static/bundle/[name].bundle"`,
)
})

Expand Down Expand Up @@ -758,7 +753,7 @@ describe('Plugins - Output', () => {
.toMatchInlineSnapshot(`
{
"bundle": "[name].bundle",
"template": "[name].bundle",
"template": "[name].template",
}
`)
})
Expand Down
27 changes: 27 additions & 0 deletions packages/rspeedy/core/test/plugins/rsdoctor.plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@ describe('Plugins - Rsdoctor', () => {
})

expect(options.supports.banner).toBe(true)

expect(options.experiments?.enableNativePlugin).toBe(true)
})

test('experiments.enableNativePlugin: false', async () => {
vi.stubEnv('RSDOCTOR', 'true')

const { createStubRspeedy } = await import('../createStubRspeedy.js')

const rsbuild = await createStubRspeedy({
tools: {
rsdoctor: {
experiments: {
enableNativePlugin: false,
},
},
},
})

const compiler = await rsbuild.createCompiler<Rspack.Compiler>()

const { options } = compiler.options.plugins.find(
(plugin) => (typeof plugin === 'object'
&& plugin?.['isRsdoctorPlugin'] === true),
) as RsdoctorRspackPlugin<[]>

expect(options.experiments?.enableNativePlugin).toBe(false)
})

test('linter.rules.ecma-version-check', async () => {
Expand Down
Loading