From 8033e5e780a694119021d87975cecaeee925c152 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 26 Oct 2024 09:44:57 +0800 Subject: [PATCH 1/3] chore: correct some cases --- .github/workflows/test.yml | 2 +- e2e/cases/assets/assets-retry/index.test.ts | 2 +- .../rspack-config-validate/index.test.ts | 4 +- e2e/cases/css/ignore-css/removeCss.test.ts | 12 ++-- e2e/cases/css/multi-css/index.test.ts | 2 +- .../style-loader-lightningcss/index.test.ts | 2 +- e2e/cases/css/style-loader/index.test.ts | 8 +-- e2e/cases/output/charset/index.test.ts | 2 +- .../preact/prefresh-disabled/index.test.ts | 2 +- e2e/cases/preact/prefresh/index.test.ts | 2 +- .../server/environments-hmr/index.test.ts | 2 +- e2e/cases/solid/hmr/index.test.ts | 2 +- e2e/cases/solid/index.test.ts | 2 +- e2e/cases/svelte/hmr/index.test.ts | 2 +- e2e/cases/svelte/index.test.ts | 2 +- e2e/cases/svg/svg-assets/index.test.ts | 4 +- .../svg/svgr-default-export-url/index.test.ts | 6 +- .../svg/svgr-external-react/index.test.ts | 6 +- e2e/cases/svg/svgr-query-custom/index.test.ts | 2 +- .../index.test.ts | 2 +- e2e/cases/svg/svgr-query-react/index.test.ts | 2 +- e2e/cases/svg/svgr-query-url/index.test.ts | 4 +- e2e/scripts/shared.ts | 2 +- .../compat/plugin-webpack-swc/src/plugin.ts | 8 +-- .../compat/plugin-webpack-swc/src/utils.ts | 2 +- .../tests/__snapshots__/plugin.test.ts.snap | 72 +++++++++---------- .../plugin-webpack-swc/tests/plugin.test.ts | 10 +-- packages/core/src/configChain.ts | 2 +- packages/core/src/helpers/index.ts | 2 +- packages/core/src/loader/ignoreCssLoader.ts | 2 +- packages/core/src/plugins/output.ts | 4 +- packages/core/src/plugins/swc.ts | 2 +- packages/core/src/provider/createCompiler.ts | 2 +- packages/core/src/server/devMiddleware.ts | 2 +- packages/core/src/server/getDevMiddlewares.ts | 2 +- packages/core/src/server/proxy.ts | 2 +- packages/core/src/types/thirdParty.ts | 4 +- .../tests/__snapshots__/builder.test.ts.snap | 2 +- packages/core/tests/builder.test.ts | 4 +- packages/core/tests/mergeConfig.test.ts | 2 +- .../src/AsyncChunkRetryPlugin.ts | 2 +- .../src/runtime/asyncChunkRetry.ts | 6 +- packages/plugin-babel/src/helper.ts | 2 +- .../tests/__snapshots__/index.test.ts.snap | 53 -------------- packages/plugin-solid/tests/index.test.ts | 10 --- .../tests/__snapshots__/index.test.ts.snap | 2 +- packages/plugin-svelte/tests/index.test.ts | 2 +- website/docs/en/config/source/include.mdx | 2 +- website/docs/zh/config/source/include.mdx | 2 +- 49 files changed, 109 insertions(+), 172 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6f2d72541..2de9775ea9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: timeout-minutes: 15 strategy: matrix: - # run ut in MacOS, as SWC cases will fail in Ubuntu CI + # run ut in macOS, as SWC cases will fail in Ubuntu CI os: [macos-14, windows-latest] steps: diff --git a/e2e/cases/assets/assets-retry/index.test.ts b/e2e/cases/assets/assets-retry/index.test.ts index 37a5ac48a1..3d406fa711 100644 --- a/e2e/cases/assets/assets-retry/index.test.ts +++ b/e2e/cases/assets/assets-retry/index.test.ts @@ -185,7 +185,7 @@ test('@rsbuild/plugin-assets-retry should work when blocking async chunk`', asyn logger.level = 'log'; }); -test('@rsbuild/plugin-assets-retry should work when blocking async css chunk`', async ({ +test('@rsbuild/plugin-assets-retry should work when blocking async CSS chunk`', async ({ page, }) => { logger.level = 'verbose'; diff --git a/e2e/cases/config/rspack-config-validate/index.test.ts b/e2e/cases/config/rspack-config-validate/index.test.ts index 1a5224ac98..598e695385 100644 --- a/e2e/cases/config/rspack-config-validate/index.test.ts +++ b/e2e/cases/config/rspack-config-validate/index.test.ts @@ -3,7 +3,7 @@ import { expect } from '@playwright/test'; import { pluginReact } from '@rsbuild/plugin-react'; import stripAnsi from 'strip-ansi'; -rspackOnlyTest('should validate rspack config by default', async () => { +rspackOnlyTest('should validate Rspack config by default', async () => { try { await build({ cwd: __dirname, @@ -44,7 +44,7 @@ rspackOnlyTest('should warn when passing unrecognized keys', async () => { restore(); }); -rspackOnlyTest('should allow to override rspack config validate', async () => { +rspackOnlyTest('should allow to override Rspack config validate', async () => { const { RSPACK_CONFIG_VALIDATE } = process.env; process.env.RSPACK_CONFIG_VALIDATE = 'loose'; diff --git a/e2e/cases/css/ignore-css/removeCss.test.ts b/e2e/cases/css/ignore-css/removeCss.test.ts index 878c9926b3..969bc44819 100644 --- a/e2e/cases/css/ignore-css/removeCss.test.ts +++ b/e2e/cases/css/ignore-css/removeCss.test.ts @@ -1,7 +1,7 @@ import { build } from '@e2e/helper'; import { expect, test } from '@playwright/test'; -test('should ignore css content when build node target', async () => { +test('should ignore CSS content when build node target', async () => { const rsbuild = await build({ cwd: __dirname, rsbuildConfig: { @@ -15,14 +15,14 @@ test('should ignore css content when build node target', async () => { const content = files[Object.keys(files).find((file) => file.endsWith('.js'))!]; - // preserve css modules mapping + // preserve CSS Modules mapping expect(content.includes('"title-class":')).toBeTruthy(); - // remove css content + // remove CSS content expect(content.includes('.title-class')).toBeFalsy(); expect(content.includes('.header-class')).toBeFalsy(); }); -test('should ignore css content when build web-worker target', async () => { +test('should ignore CSS content when build web-worker target', async () => { const rsbuild = await build({ cwd: __dirname, rsbuildConfig: { @@ -36,9 +36,9 @@ test('should ignore css content when build web-worker target', async () => { const content = files[Object.keys(files).find((file) => file.endsWith('.js'))!]; - // preserve css modules mapping + // preserve CSS Modules mapping expect(content.includes('"title-class":')).toBeTruthy(); - // remove css content + // remove CSS content expect(content.includes('.title-class')).toBeFalsy(); expect(content.includes('.header-class')).toBeFalsy(); }); diff --git a/e2e/cases/css/multi-css/index.test.ts b/e2e/cases/css/multi-css/index.test.ts index 1a7e7fef2d..bafe55a00b 100644 --- a/e2e/cases/css/multi-css/index.test.ts +++ b/e2e/cases/css/multi-css/index.test.ts @@ -2,7 +2,7 @@ import path from 'node:path'; import { build, rspackOnlyTest } from '@e2e/helper'; import { expect } from '@playwright/test'; -rspackOnlyTest('should emit multiple css files correctly', async () => { +rspackOnlyTest('should emit multiple CSS files correctly', async () => { const rsbuild = await build({ cwd: __dirname, rsbuildConfig: { diff --git a/e2e/cases/css/style-loader-lightningcss/index.test.ts b/e2e/cases/css/style-loader-lightningcss/index.test.ts index 040eb9fd80..b477b5bb90 100644 --- a/e2e/cases/css/style-loader-lightningcss/index.test.ts +++ b/e2e/cases/css/style-loader-lightningcss/index.test.ts @@ -13,7 +13,7 @@ rspackOnlyTest( // injectStyles worked const files = await rsbuild.unwrapOutputJSON(); - // should inline minified css + // should inline minified CSS const indexJsFile = Object.keys(files).find( (file) => file.includes('index.') && file.endsWith('.js'), )!; diff --git a/e2e/cases/css/style-loader/index.test.ts b/e2e/cases/css/style-loader/index.test.ts index 3f8595e004..55ca5d10b7 100644 --- a/e2e/cases/css/style-loader/index.test.ts +++ b/e2e/cases/css/style-loader/index.test.ts @@ -18,7 +18,7 @@ rspackOnlyTest( const cssFiles = Object.keys(files).filter((file) => file.endsWith('.css')); expect(cssFiles.length).toBe(0); - // should inline minified css + // should inline minified CSS const indexJsFile = Object.keys(files).find( (file) => file.includes('index.') && file.endsWith('.js'), )!; @@ -45,7 +45,7 @@ rspackOnlyTest( ); rspackOnlyTest( - 'hmr should work well when injectStyles is true', + 'HMR should work well when injectStyles is true', async ({ page }) => { // HMR cases will fail in Windows if (process.platform === 'win32') { @@ -88,10 +88,10 @@ rspackOnlyTest( fs.readFileSync(filePath, 'utf-8').replace('20px', '40px'), ); - // css hmr works well + // CSS HMR works well await expect(title).toHaveCSS('font-size', '40px'); - // #test-keep should unchanged when css hmr + // #test-keep should unchanged when CSS HMR await expect(locatorKeep.innerHTML()).resolves.toBe(keepNum); await rsbuild.close(); diff --git a/e2e/cases/output/charset/index.test.ts b/e2e/cases/output/charset/index.test.ts index c309d0a16a..7916ca0337 100644 --- a/e2e/cases/output/charset/index.test.ts +++ b/e2e/cases/output/charset/index.test.ts @@ -20,7 +20,7 @@ test('should allow to set output.charset to ascii', async ({ page }) => { ([name]) => name.endsWith('.js') && name.includes('static/js/index'), )!; - // in rspack is: \\u4f60\\u597D world! + // in Rspack is: \\u4f60\\u597D world! expect( content.toLocaleLowerCase().includes('\\u4f60\\u597d world!'), ).toBeTruthy(); diff --git a/e2e/cases/preact/prefresh-disabled/index.test.ts b/e2e/cases/preact/prefresh-disabled/index.test.ts index 2779078fcf..b6125fc44d 100644 --- a/e2e/cases/preact/prefresh-disabled/index.test.ts +++ b/e2e/cases/preact/prefresh-disabled/index.test.ts @@ -3,7 +3,7 @@ import path from 'node:path'; import { dev, rspackOnlyTest } from '@e2e/helper'; import { expect, test } from '@playwright/test'; -rspackOnlyTest('hmr should work properly', async ({ page }) => { +rspackOnlyTest('HMR should work properly', async ({ page }) => { // HMR cases will fail in Windows if (process.platform === 'win32') { test.skip(); diff --git a/e2e/cases/preact/prefresh/index.test.ts b/e2e/cases/preact/prefresh/index.test.ts index ffea899c72..8739e5dd1a 100644 --- a/e2e/cases/preact/prefresh/index.test.ts +++ b/e2e/cases/preact/prefresh/index.test.ts @@ -3,7 +3,7 @@ import path from 'node:path'; import { dev, rspackOnlyTest } from '@e2e/helper'; import { expect, test } from '@playwright/test'; -rspackOnlyTest('hmr should work properly', async ({ page }) => { +rspackOnlyTest('HMR should work properly', async ({ page }) => { // HMR cases will fail in Windows if (process.platform === 'win32') { test.skip(); diff --git a/e2e/cases/server/environments-hmr/index.test.ts b/e2e/cases/server/environments-hmr/index.test.ts index 64ea809355..fe767b79bf 100644 --- a/e2e/cases/server/environments-hmr/index.test.ts +++ b/e2e/cases/server/environments-hmr/index.test.ts @@ -79,7 +79,7 @@ rspackOnlyTest( await expect(locatorKeep.innerHTML()).resolves.toBe(keepNum); - // index hmr correctly + // index HMR correctly const appPath = join(cwd, 'test-temp-src/App.tsx'); await fs.promises.writeFile( diff --git a/e2e/cases/solid/hmr/index.test.ts b/e2e/cases/solid/hmr/index.test.ts index ffea899c72..8739e5dd1a 100644 --- a/e2e/cases/solid/hmr/index.test.ts +++ b/e2e/cases/solid/hmr/index.test.ts @@ -3,7 +3,7 @@ import path from 'node:path'; import { dev, rspackOnlyTest } from '@e2e/helper'; import { expect, test } from '@playwright/test'; -rspackOnlyTest('hmr should work properly', async ({ page }) => { +rspackOnlyTest('HMR should work properly', async ({ page }) => { // HMR cases will fail in Windows if (process.platform === 'win32') { test.skip(); diff --git a/e2e/cases/solid/index.test.ts b/e2e/cases/solid/index.test.ts index eccb628b06..bd77cbacb4 100644 --- a/e2e/cases/solid/index.test.ts +++ b/e2e/cases/solid/index.test.ts @@ -55,7 +55,7 @@ rspackOnlyTest( }, ); -// test cases for css preprocessors +// test cases for CSS preprocessors for (const name of ['less', 'scss', 'stylus']) { rspackOnlyTest( `should build solid component with ${name}`, diff --git a/e2e/cases/svelte/hmr/index.test.ts b/e2e/cases/svelte/hmr/index.test.ts index 288d928164..15a0b9a450 100644 --- a/e2e/cases/svelte/hmr/index.test.ts +++ b/e2e/cases/svelte/hmr/index.test.ts @@ -4,7 +4,7 @@ import { dev, rspackOnlyTest } from '@e2e/helper'; import { expect, test } from '@playwright/test'; import { pluginSvelte } from '@rsbuild/plugin-svelte'; -rspackOnlyTest('hmr should work properly', async ({ page }) => { +rspackOnlyTest('HMR should work properly', async ({ page }) => { // HMR cases will fail in Windows if (process.platform === 'win32') { test.skip(); diff --git a/e2e/cases/svelte/index.test.ts b/e2e/cases/svelte/index.test.ts index 7d72a57bcd..df611b5921 100644 --- a/e2e/cases/svelte/index.test.ts +++ b/e2e/cases/svelte/index.test.ts @@ -53,7 +53,7 @@ rspackOnlyTest( }, ); -// test cases for css preprocessors +// test cases for CSS preprocessors for (const name of ['less', 'scss', 'stylus']) { rspackOnlyTest( `should build svelte component with ${name}`, diff --git a/e2e/cases/svg/svg-assets/index.test.ts b/e2e/cases/svg/svg-assets/index.test.ts index 8cf1844d61..853e60f563 100644 --- a/e2e/cases/svg/svg-assets/index.test.ts +++ b/e2e/cases/svg/svg-assets/index.test.ts @@ -7,14 +7,14 @@ test('SVGR basic usage', async ({ page }) => { page, }); - // test svg asset + // test SVG asset await expect( page.evaluate( `document.getElementById('test-img').src.includes('static/svg/mobile')`, ), ).resolves.toBeTruthy(); - // test svg asset in css + // test SVG asset in CSS await expect( page.evaluate( `getComputedStyle(document.getElementById('test-css')).backgroundImage.includes('static/svg/mobile')`, diff --git a/e2e/cases/svg/svgr-default-export-url/index.test.ts b/e2e/cases/svg/svgr-default-export-url/index.test.ts index 0f6841dd3e..0c240aba25 100644 --- a/e2e/cases/svg/svgr-default-export-url/index.test.ts +++ b/e2e/cases/svg/svgr-default-export-url/index.test.ts @@ -12,19 +12,19 @@ test('should import default from SVG with SVGR correctly', async ({ page }) => { page.evaluate(`document.getElementById('component').tagName === 'svg'`), ).resolves.toBeTruthy(); - // test svg asset + // test SVG asset await expect( page.evaluate(`document.getElementById('large-img').src`), ).resolves.toMatch(/http:/); - // test svg asset + // test SVG asset await expect( page.evaluate( `document.getElementById('small-img').src.startsWith('data:image/svg')`, ), ).resolves.toBeTruthy(); - // test svg asset in css + // test SVG asset in CSS await expect( page.evaluate( `getComputedStyle(document.getElementById('test-css-small')).backgroundImage.includes('url("data:image/svg')`, diff --git a/e2e/cases/svg/svgr-external-react/index.test.ts b/e2e/cases/svg/svgr-external-react/index.test.ts index 7a70683743..72cc076044 100644 --- a/e2e/cases/svg/svgr-external-react/index.test.ts +++ b/e2e/cases/svg/svgr-external-react/index.test.ts @@ -1,7 +1,7 @@ import { build } from '@e2e/helper'; import { expect, test } from '@playwright/test'; -// It's an old bug when use svgr in css and external react. +// It's an old bug when use svgr in CSS and external react. test('use SVGR and externals react', async ({ page }) => { const rsbuild = await build({ cwd: __dirname, @@ -13,14 +13,14 @@ test('use SVGR and externals react', async ({ page }) => { page.evaluate(`document.getElementById('test-svg').tagName === 'svg'`), ).resolves.toBeTruthy(); - // test svg asset + // test SVG asset await expect( page.evaluate( `document.getElementById('test-img').src.startsWith('data:image/svg')`, ), ).resolves.toBeTruthy(); - // test svg asset in css + // test SVG asset in CSS await expect( page.evaluate( `getComputedStyle(document.getElementById('test-css')).backgroundImage.includes('url("data:image/svg')`, diff --git a/e2e/cases/svg/svgr-query-custom/index.test.ts b/e2e/cases/svg/svgr-query-custom/index.test.ts index d7a5f50d2a..c41d51b242 100644 --- a/e2e/cases/svg/svgr-query-custom/index.test.ts +++ b/e2e/cases/svg/svgr-query-custom/index.test.ts @@ -13,7 +13,7 @@ test('should import default from SVG with custom query correctly', async ({ page.evaluate(`document.getElementById('component').tagName === 'svg'`), ).resolves.toBeTruthy(); - // test svg asset + // test SVG asset await expect( page.evaluate(`document.getElementById('url').src`), ).resolves.toMatch(/http:/); diff --git a/e2e/cases/svg/svgr-query-react-dynamic-import/index.test.ts b/e2e/cases/svg/svgr-query-react-dynamic-import/index.test.ts index fcc70e2104..7a17008fd8 100644 --- a/e2e/cases/svg/svgr-query-react-dynamic-import/index.test.ts +++ b/e2e/cases/svg/svgr-query-react-dynamic-import/index.test.ts @@ -14,7 +14,7 @@ test('should import default from SVG with react query and dynamic import correct page.evaluate(`document.getElementById('component').tagName === 'svg'`), ).resolves.toBeTruthy(); - // test svg asset + // test SVG asset await expect( page.evaluate(`document.getElementById('url').src`), ).resolves.toMatch(/http:/); diff --git a/e2e/cases/svg/svgr-query-react/index.test.ts b/e2e/cases/svg/svgr-query-react/index.test.ts index e6d9e8f26f..e00528ea6a 100644 --- a/e2e/cases/svg/svgr-query-react/index.test.ts +++ b/e2e/cases/svg/svgr-query-react/index.test.ts @@ -13,7 +13,7 @@ test('should import default from SVG with react query correctly', async ({ page.evaluate(`document.getElementById('component').tagName === 'svg'`), ).resolves.toBeTruthy(); - // test svg asset + // test SVG asset await expect( page.evaluate(`document.getElementById('url').src`), ).resolves.toMatch(/http:/); diff --git a/e2e/cases/svg/svgr-query-url/index.test.ts b/e2e/cases/svg/svgr-query-url/index.test.ts index 263beb6556..420dcdf01c 100644 --- a/e2e/cases/svg/svgr-query-url/index.test.ts +++ b/e2e/cases/svg/svgr-query-url/index.test.ts @@ -9,14 +9,14 @@ test('should import svg with SVGR plugin and query URL correctly', async ({ page, }); - // test svg asset + // test SVG asset await expect( page.evaluate( `document.getElementById('test-img').src.includes('static/svg/mobile')`, ), ).resolves.toBeTruthy(); - // test svg asset in css + // test SVG asset in CSS await expect( page.evaluate( `getComputedStyle(document.getElementById('test-css')).backgroundImage.includes('static/svg/mobile')`, diff --git a/e2e/scripts/shared.ts b/e2e/scripts/shared.ts index 4c873daf78..23c0d1db82 100644 --- a/e2e/scripts/shared.ts +++ b/e2e/scripts/shared.ts @@ -159,7 +159,7 @@ export async function dev({ rsbuild.addPlugins([ { - // fix hmr problem temporary (only appears in rsbuild repo, because css-loader is not in node_modules/ ) + // fix HMR problem temporary (only appears in rsbuild repo, because css-loader is not in node_modules/ ) // https://github.com/web-infra-dev/rspack/issues/5723 name: 'fix-react-refresh-in-rsbuild', setup(api) { diff --git a/packages/compat/plugin-webpack-swc/src/plugin.ts b/packages/compat/plugin-webpack-swc/src/plugin.ts index dd88a18250..3869a9fc83 100644 --- a/packages/compat/plugin-webpack-swc/src/plugin.ts +++ b/packages/compat/plugin-webpack-swc/src/plugin.ts @@ -18,9 +18,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * In this plugin, we do: * - Remove Babel loader if exists - * - Add our own swc loader + * - Add our own swc-loader * - Remove JS minifier - * - Add swc minifier plugin + * - Add SWC minifier plugin */ export const pluginSwc = (options: PluginSwcOptions = {}): RsbuildPlugin => ({ name: 'rsbuild-webpack:swc', @@ -63,7 +63,7 @@ export const pluginSwc = (options: PluginSwcOptions = {}): RsbuildPlugin => ({ i > 0 ? CHAIN_ID.RULE.JS + i.toString() : CHAIN_ID.RULE.JS; const rule = chain.module.rule(ruleId); - // Insert swc loader and plugin + // Insert SWC loader and plugin rule .test(test || /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/) .use(CHAIN_ID.USE.SWC) @@ -152,7 +152,7 @@ export const pluginSwc = (options: PluginSwcOptions = {}): RsbuildPlugin => ({ }, }); -/// default swc configuration +/// default SWC configuration export function getDefaultSwcConfig(): TransformConfig { const cwd = process.cwd(); return { diff --git a/packages/compat/plugin-webpack-swc/src/utils.ts b/packages/compat/plugin-webpack-swc/src/utils.ts index d28206149f..1b6b116bad 100644 --- a/packages/compat/plugin-webpack-swc/src/utils.ts +++ b/packages/compat/plugin-webpack-swc/src/utils.ts @@ -139,7 +139,7 @@ export async function finalizeConfig( const objConfig = isUsingFnOptions ? {} : userConfig; const defaultConfig = getDefaultSwcConfig(); - // apply swc default config + // apply SWC default config let swcConfig: ObjPluginSwcOptions = _.merge( {}, defaultConfig, diff --git a/packages/compat/plugin-webpack-swc/tests/__snapshots__/plugin.test.ts.snap b/packages/compat/plugin-webpack-swc/tests/__snapshots__/plugin.test.ts.snap index 29de9cc93a..56a72ade8c 100644 --- a/packages/compat/plugin-webpack-swc/tests/__snapshots__/plugin.test.ts.snap +++ b/packages/compat/plugin-webpack-swc/tests/__snapshots__/plugin.test.ts.snap @@ -946,7 +946,41 @@ exports[`plugin-webpack-swc > should disable react refresh when target is not we } `; -exports[`plugin-webpack-swc > should set correct swc minimizer options in production 1`] = ` +exports[`plugin-webpack-swc > should set SWC minimizer in production 1`] = ` +{ + "minimizer": [ + SwcMinimizerPlugin { + "minifyOptions": { + "cssMinify": undefined, + "jsMinify": { + "format": { + "asciiOnly": false, + }, + "mangle": true, + }, + }, + "name": "swc-minimizer-plugin", + "rsbuildSourceMapConfig": { + "css": false, + "js": undefined, + }, + }, + SwcMinimizerPlugin { + "minifyOptions": { + "cssMinify": {}, + "jsMinify": undefined, + }, + "name": "swc-minimizer-plugin", + "rsbuildSourceMapConfig": { + "css": false, + "js": undefined, + }, + }, + ], +} +`; + +exports[`plugin-webpack-swc > should set correct SWC minimizer options in production 1`] = ` { "minimizer": [ SwcMinimizerPlugin { @@ -981,7 +1015,7 @@ exports[`plugin-webpack-swc > should set correct swc minimizer options in produc } `; -exports[`plugin-webpack-swc > should set correct swc minimizer options using raw swc config 1`] = ` +exports[`plugin-webpack-swc > should set correct SWC minimizer options using raw SWC config 1`] = ` { "minimizer": [ SwcMinimizerPlugin { @@ -1179,40 +1213,6 @@ exports[`plugin-webpack-swc > should set multiple swc-loader 1`] = ` ] `; -exports[`plugin-webpack-swc > should set swc minimizer in production 1`] = ` -{ - "minimizer": [ - SwcMinimizerPlugin { - "minifyOptions": { - "cssMinify": undefined, - "jsMinify": { - "format": { - "asciiOnly": false, - }, - "mangle": true, - }, - }, - "name": "swc-minimizer-plugin", - "rsbuildSourceMapConfig": { - "css": false, - "js": undefined, - }, - }, - SwcMinimizerPlugin { - "minifyOptions": { - "cssMinify": {}, - "jsMinify": undefined, - }, - "name": "swc-minimizer-plugin", - "rsbuildSourceMapConfig": { - "css": false, - "js": undefined, - }, - }, - ], -} -`; - exports[`plugin-webpack-swc > should set swc-loader 1`] = ` { "module": { diff --git a/packages/compat/plugin-webpack-swc/tests/plugin.test.ts b/packages/compat/plugin-webpack-swc/tests/plugin.test.ts index 72bf5f68fc..69c5523200 100644 --- a/packages/compat/plugin-webpack-swc/tests/plugin.test.ts +++ b/packages/compat/plugin-webpack-swc/tests/plugin.test.ts @@ -63,7 +63,7 @@ describe('plugin-webpack-swc', () => { expect(configs).toMatchSnapshot(); }); - it('should set swc minimizer in production', async () => { + it('should set SWC minimizer in production', async () => { process.env.NODE_ENV = 'production'; const rsbuild = await createStubRsbuild({ plugins: [pluginSwc()], @@ -136,7 +136,7 @@ describe('plugin-webpack-swc', () => { process.env.NODE_ENV = 'test'; }); - it('should set correct swc minimizer options in production', async () => { + it('should set correct SWC minimizer options in production', async () => { process.env.NODE_ENV = 'production'; const rsbuild = await createStubRsbuild({ plugins: [ @@ -157,7 +157,7 @@ describe('plugin-webpack-swc', () => { process.env.NODE_ENV = 'test'; }); - it('should set correct swc minimizer options using raw swc config', async () => { + it('should set correct SWC minimizer options using raw SWC config', async () => { process.env.NODE_ENV = 'production'; const rsbuild = await createStubRsbuild({ plugins: [ @@ -180,7 +180,7 @@ describe('plugin-webpack-swc', () => { process.env.NODE_ENV = 'test'; }); - it('should disable swc minify', async () => { + it('should disable SWC minify', async () => { process.env.NODE_ENV = 'production'; const rsbuild = await createStubRsbuild({ plugins: [ @@ -198,7 +198,7 @@ describe('plugin-webpack-swc', () => { process.env.NODE_ENV = 'test'; }); - it('should disable swc minify when raw swc config', async () => { + it('should disable SWC minify when raw SWC config', async () => { process.env.NODE_ENV = 'production'; const rsbuild = await createStubRsbuild({ plugins: [ diff --git a/packages/core/src/configChain.ts b/packages/core/src/configChain.ts index 7af317593f..aa942d380b 100644 --- a/packages/core/src/configChain.ts +++ b/packages/core/src/configChain.ts @@ -105,7 +105,7 @@ export const CHAIN_ID = { JS_DATA_URI: 'js-data-uri', /** Rule for ts */ TS: 'ts', - /** Rule for css */ + /** Rule for CSS */ CSS: 'css', /** Rule for less */ LESS: 'less', diff --git a/packages/core/src/helpers/index.ts b/packages/core/src/helpers/index.ts index 4b94598b83..06cbeb8e59 100644 --- a/packages/core/src/helpers/index.ts +++ b/packages/core/src/helpers/index.ts @@ -83,7 +83,7 @@ export const isSatisfyRspackVersion = async ( ): Promise => { let version = originalVersion; - // The nightly version of rspack is to append `-canary-abc` to the current version + // The nightly version of Rspack is to append `-canary-abc` to the current version if (version.includes('-canary')) { version = version.split('-canary')[0]; } diff --git a/packages/core/src/loader/ignoreCssLoader.ts b/packages/core/src/loader/ignoreCssLoader.ts index 8b054fcefc..4ed92e75fa 100644 --- a/packages/core/src/loader/ignoreCssLoader.ts +++ b/packages/core/src/loader/ignoreCssLoader.ts @@ -10,6 +10,6 @@ export default function (this: LoaderContext, source: string): string { return ''; } - // Preserve css modules export for SSR. + // Preserve CSS Modules export for SSR. return source; } diff --git a/packages/core/src/plugins/output.ts b/packages/core/src/plugins/output.ts index a0fd8f5a60..cf74106fb9 100644 --- a/packages/core/src/plugins/output.ts +++ b/packages/core/src/plugins/output.ts @@ -42,7 +42,7 @@ function getPublicPath({ if (hostname === DEFAULT_DEV_HOST) { const localHostname = 'localhost'; // If user not specify the hostname, it would use 0.0.0.0 - // The http://0.0.0.0:port can't visit in windows, so we shouldn't set publicPath as `//0.0.0.0:${port}/`; + // The http://0.0.0.0:port can't visit in Windows, so we shouldn't set publicPath as `//0.0.0.0:${port}/`; // Relative to docs: // - https://github.com/quarkusio/quarkus/issues/12246 publicPath = `${protocol}://${localHostname}:/`; @@ -140,7 +140,7 @@ export const pluginOutput = (): RsbuildPlugin => ({ .use(rspack.CopyRspackPlugin, [options]); } - // css output + // CSS output if (isUseCssExtract(config, target)) { const extractPluginOptions = config.tools.cssExtract.pluginOptions; diff --git a/packages/core/src/plugins/swc.ts b/packages/core/src/plugins/swc.ts index ffb0766a4d..ad1a6900a5 100644 --- a/packages/core/src/plugins/swc.ts +++ b/packages/core/src/plugins/swc.ts @@ -82,7 +82,7 @@ function getDefaultSwcConfig( } /** - * Provide some swc configs of rspack + * Provide some SWC configs of Rspack */ export const pluginSwc = (): RsbuildPlugin => ({ name: PLUGIN_SWC_NAME, diff --git a/packages/core/src/provider/createCompiler.ts b/packages/core/src/provider/createCompiler.ts index 03af7956d0..b0c3c89a03 100644 --- a/packages/core/src/provider/createCompiler.ts +++ b/packages/core/src/provider/createCompiler.ts @@ -141,7 +141,7 @@ export type MiddlewareCallbacks = { }; export type DevMiddlewareOptions = { - /** To ensure HMR works, the devMiddleware need inject the hmr client path into page when HMR enable. */ + /** To ensure HMR works, the devMiddleware need inject the HMR client path into page when HMR enable. */ clientPaths?: string[]; clientConfig: DevConfig['client']; publicPath?: string; diff --git a/packages/core/src/server/devMiddleware.ts b/packages/core/src/server/devMiddleware.ts index 06bd86c014..5324616829 100644 --- a/packages/core/src/server/devMiddleware.ts +++ b/packages/core/src/server/devMiddleware.ts @@ -99,7 +99,7 @@ export type DevMiddlewareAPI = Middleware & { /** * The rsbuild/server do nothing about compiler, the devMiddleware need do such things to ensure dev works well: * - Call compiler.watch (normally did by rsbuild-dev-middleware). - * - Inject the hmr client path into page (the hmr client rsbuild/server already provide). + * - Inject the HMR client path into page (the HMR client rsbuild/server already provide). * - Notify server when compiler hooks are triggered. */ export type DevMiddleware = (options: DevMiddlewareOptions) => DevMiddlewareAPI; diff --git a/packages/core/src/server/getDevMiddlewares.ts b/packages/core/src/server/getDevMiddlewares.ts index 43bf65384b..84441445a6 100644 --- a/packages/core/src/server/getDevMiddlewares.ts +++ b/packages/core/src/server/getDevMiddlewares.ts @@ -88,7 +88,7 @@ const applyDefaultMiddlewares = async ({ } middlewares.push((req, res, next) => { - // allow hmr request cross-domain, because the user may use global proxy + // allow HMR request cross-domain, because the user may use global proxy res.setHeader('Access-Control-Allow-Origin', '*'); const path = req.url ? url.parse(req.url).pathname : ''; if (path?.includes('hot-update')) { diff --git a/packages/core/src/server/proxy.ts b/packages/core/src/server/proxy.ts index 54763470e4..17497c68bd 100644 --- a/packages/core/src/server/proxy.ts +++ b/packages/core/src/server/proxy.ts @@ -78,7 +78,7 @@ export const createProxyMiddleware = async ( middlewares.push(middleware); // only proxy WebSocket request when user specified - // fix WebSocket error when user forget filter hmr path + // fix WebSocket error when user forget filter HMR path opts.ws && proxyMiddlewares.push(proxyMiddleware); } diff --git a/packages/core/src/types/thirdParty.ts b/packages/core/src/types/thirdParty.ts index c0f9d0af23..595191d7fe 100644 --- a/packages/core/src/types/thirdParty.ts +++ b/packages/core/src/types/thirdParty.ts @@ -63,7 +63,7 @@ export type CSSLoaderExportLocalsConvention = export interface CSSLoaderModulesOptions { /** - * Allows auto enable CSS modules/ICSS based on the filename, query or fragment. + * Allows auto enable CSS Modules/ICSS based on the filename, query or fragment. */ auto?: | boolean @@ -126,7 +126,7 @@ export interface CSSLoaderModulesOptions { */ namedExport?: boolean; /** - * Enables a callback to output the CSS modules mapping JSON. + * Enables a callback to output the CSS Modules mapping JSON. */ getJSON?: (context: { resourcePath: string; diff --git a/packages/core/tests/__snapshots__/builder.test.ts.snap b/packages/core/tests/__snapshots__/builder.test.ts.snap index 457261ef57..a198bfb1c5 100644 --- a/packages/core/tests/__snapshots__/builder.test.ts.snap +++ b/packages/core/tests/__snapshots__/builder.test.ts.snap @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should use rspack as default bundler > apply rspack correctly 1`] = ` +exports[`should use Rspack as the default bundler > apply Rspack correctly 1`] = ` { "context": "", "devtool": "cheap-module-source-map", diff --git a/packages/core/tests/builder.test.ts b/packages/core/tests/builder.test.ts index 673be11072..23d0417006 100644 --- a/packages/core/tests/builder.test.ts +++ b/packages/core/tests/builder.test.ts @@ -1,7 +1,7 @@ import { createRsbuild } from '../src'; -describe('should use rspack as default bundler', () => { - it('apply rspack correctly', async () => { +describe('should use Rspack as the default bundler', () => { + it('apply Rspack correctly', async () => { const { NODE_ENV } = process.env; process.env.NODE_ENV = 'development'; const rsbuild = await createRsbuild({ diff --git a/packages/core/tests/mergeConfig.test.ts b/packages/core/tests/mergeConfig.test.ts index d5e8c2f256..579fa57a1b 100644 --- a/packages/core/tests/mergeConfig.test.ts +++ b/packages/core/tests/mergeConfig.test.ts @@ -296,7 +296,7 @@ describe('mergeRsbuildConfig', () => { }); }); - it('should merge rspack plugins as expected', () => { + it('should merge Rspack plugins as expected', () => { class A { a = 1; diff --git a/packages/plugin-assets-retry/src/AsyncChunkRetryPlugin.ts b/packages/plugin-assets-retry/src/AsyncChunkRetryPlugin.ts index 6bb46b1e74..0a389c6a79 100644 --- a/packages/plugin-assets-retry/src/AsyncChunkRetryPlugin.ts +++ b/packages/plugin-assets-retry/src/AsyncChunkRetryPlugin.ts @@ -19,7 +19,7 @@ function appendWebpackScript(module: any, appendSource: string) { } function appendRspackScript( - module: any, // JsRuntimeModule type is not exported by rspack temporarily */ + module: any, // JsRuntimeModule type is not exported by Rspack temporarily */ appendSource: string, ) { try { diff --git a/packages/plugin-assets-retry/src/runtime/asyncChunkRetry.ts b/packages/plugin-assets-retry/src/runtime/asyncChunkRetry.ts index 9ce0517890..7234eb4758 100644 --- a/packages/plugin-assets-retry/src/runtime/asyncChunkRetry.ts +++ b/packages/plugin-assets-retry/src/runtime/asyncChunkRetry.ts @@ -211,9 +211,9 @@ function ensureChunk(chunkId: string): Promise { const { existRetryTimes, originalSrcUrl, nextRetryUrl, nextDomain } = nextRetry(chunkId); - // At present, we don't consider the switching domain and addQuery of async css chunk - // 1. Async js chunk will be requested first. It is rare for async css chunk to fail alone. - // 2. the code of loading css in webpack runtime is complex and it may be modified by cssExtractPlugin, increase the complexity of this plugin. + // At present, we don't consider the switching domain and addQuery of async CSS chunk + // 1. Async js chunk will be requested first. It is rare for async CSS chunk to fail alone. + // 2. the code of loading CSS in webpack runtime is complex and it may be modified by cssExtractPlugin, increase the complexity of this plugin. const isCssAsyncChunkLoadFailed = Boolean( error?.message?.includes('CSS chunk'), ); diff --git a/packages/plugin-babel/src/helper.ts b/packages/plugin-babel/src/helper.ts index 9d9c634649..7066ef17fa 100644 --- a/packages/plugin-babel/src/helper.ts +++ b/packages/plugin-babel/src/helper.ts @@ -27,7 +27,7 @@ const normalizeToPosixPath = (p: string | undefined) => .normalizeSafe(normalize(p || '')) .replace(/^([a-zA-Z]+):/, (_, m: string) => `/${m.toLowerCase()}`); -// compatible with windows path +// compatible with Windows path const formatPath = (originPath: string) => { if (isAbsolute(originPath)) { return originPath.split(sep).join('/'); diff --git a/packages/plugin-solid/tests/__snapshots__/index.test.ts.snap b/packages/plugin-solid/tests/__snapshots__/index.test.ts.snap index 66de9ef406..09728c977a 100644 --- a/packages/plugin-solid/tests/__snapshots__/index.test.ts.snap +++ b/packages/plugin-solid/tests/__snapshots__/index.test.ts.snap @@ -108,56 +108,3 @@ exports[`plugin-solid > should apply solid preset correctly 1`] = ` }, } `; - -exports[`plugin-solid > should apply solid preset correctly in rspack mode 1`] = ` -{ - "module": { - "rules": [ - { - "test": /\\\\\\.\\(\\?:js\\|jsx\\|mjs\\|cjs\\|ts\\|tsx\\|mts\\|cts\\)\\$/, - "use": [ - { - "loader": "/packages/plugin-babel/compiled/babel-loader/index.js", - "options": { - "babelrc": false, - "compact": false, - "configFile": false, - "parserOpts": { - "plugins": [ - "jsx", - "typescript", - ], - }, - "plugins": [ - [ - "/node_modules//@babel/plugin-proposal-decorators/lib/index.js", - { - "version": "2022-03", - }, - ], - [ - "/node_modules//solid-refresh/dist/babel.cjs", - ], - ], - "presets": [ - [ - "/node_modules//babel-preset-solid/index.js", - {}, - ], - ], - }, - }, - ], - }, - ], - }, - "plugins": [ - RsbuildCorePlugin {}, - ], - "resolve": { - "alias": { - "solid-refresh": "/node_modules//solid-refresh/dist/solid-refresh.mjs", - }, - }, -} -`; diff --git a/packages/plugin-solid/tests/index.test.ts b/packages/plugin-solid/tests/index.test.ts index f69b37213f..e3d95bd209 100644 --- a/packages/plugin-solid/tests/index.test.ts +++ b/packages/plugin-solid/tests/index.test.ts @@ -10,16 +10,6 @@ describe('plugin-solid', () => { }, }; - it('should apply solid preset correctly in rspack mode', async () => { - const rsbuild = await createStubRsbuild({ - rsbuildConfig, - plugins: [pluginSolid(), pluginBabel()], - }); - const config = await rsbuild.unwrapConfig(); - - expect(config).toMatchSnapshot(); - }); - it('should apply solid preset correctly', async () => { const rsbuild = await createStubRsbuild({ rsbuildConfig, diff --git a/packages/plugin-svelte/tests/__snapshots__/index.test.ts.snap b/packages/plugin-svelte/tests/__snapshots__/index.test.ts.snap index 8813300781..d42c1bcfc3 100644 --- a/packages/plugin-svelte/tests/__snapshots__/index.test.ts.snap +++ b/packages/plugin-svelte/tests/__snapshots__/index.test.ts.snap @@ -208,7 +208,7 @@ exports[`plugin-svelte > should support pass custom preprocess options 1`] = ` } `; -exports[`plugin-svelte > should turn off hmr by hand correctly 1`] = ` +exports[`plugin-svelte > should turn off HMR by hand correctly 1`] = ` { "module": { "rules": [ diff --git a/packages/plugin-svelte/tests/index.test.ts b/packages/plugin-svelte/tests/index.test.ts index 7e80ccbf56..b67336c6b9 100644 --- a/packages/plugin-svelte/tests/index.test.ts +++ b/packages/plugin-svelte/tests/index.test.ts @@ -24,7 +24,7 @@ describe('plugin-svelte', () => { expect(config).toMatchSnapshot(); }); - it('should turn off hmr by hand correctly', async () => { + it('should turn off HMR by hand correctly', async () => { const rsbuild = await createStubRsbuild({ rsbuildConfig: { dev: { diff --git a/website/docs/en/config/source/include.mdx b/website/docs/en/config/source/include.mdx index 86d86188fe..f7d8fc7977 100644 --- a/website/docs/en/config/source/include.mdx +++ b/website/docs/en/config/source/include.mdx @@ -62,7 +62,7 @@ export default { The above two methods match the absolute paths of files using "path prefixes" and "regular expressions" respectively. It is worth noting that all referenced modules in the project will be matched. Therefore, you should avoid using overly loose values for matching to prevent compilation performance issues or compilation errors. :::tip -In the regular expression example above, we use `[\\/]` to match the path separator because different operating systems use different path separators. Using `[\\/]` ensures that the paths will match in both MacOS and Windows. +In the regular expression example above, we use `[\\/]` to match the path separator because different operating systems use different path separators. Using `[\\/]` ensures that the paths will match in both POSIX systems (macOS, Linux) and Windows. ::: ## Compile Sub Dependencies diff --git a/website/docs/zh/config/source/include.mdx b/website/docs/zh/config/source/include.mdx index 1eb25a74c6..148f1975c1 100644 --- a/website/docs/zh/config/source/include.mdx +++ b/website/docs/zh/config/source/include.mdx @@ -62,7 +62,7 @@ export default { 上述两种方法分别通过 "路径前缀" 和 "正则表达式" 来匹配文件的绝对路径,值得留意的是,项目中所有被引用的模块都会经过匹配,因此你不能使用过于松散的值进行匹配,避免造成编译性能问题或编译异常。 :::tip -在上述正则表达式的例子中,我们使用 `[\\/]` 来匹配路径分隔符,这是因为不同的操作系统使用了不同的路径分隔符,使用 `[\\/]` 可以保证 macOS 和 Windows 的路径都被匹配到。 +在上述正则表达式的例子中,我们使用 `[\\/]` 来匹配路径分隔符,这是因为不同的操作系统使用了不同的路径分隔符,使用 `[\\/]` 可以保证 POSIX 系统(macOS、Linux)和 Windows 的路径都被匹配到。 ::: ## 编译间接依赖 From 83066cffd4e229686a4e2057b80e1517cbfb7f28 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 26 Oct 2024 09:48:45 +0800 Subject: [PATCH 2/3] fix --- website/docs/en/config/source/include.mdx | 2 +- website/docs/en/guide/advanced/module-federation.mdx | 2 +- website/docs/en/guide/basic/unocss.mdx | 2 +- website/docs/en/guide/faq/hmr.mdx | 2 +- website/docs/zh/guide/advanced/module-federation.mdx | 2 +- website/docs/zh/guide/basic/unocss.mdx | 2 +- website/docs/zh/guide/faq/hmr.mdx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/website/docs/en/config/source/include.mdx b/website/docs/en/config/source/include.mdx index f7d8fc7977..b31bf75991 100644 --- a/website/docs/en/config/source/include.mdx +++ b/website/docs/en/config/source/include.mdx @@ -30,7 +30,7 @@ export default { }; ``` -## Compile Npm Packages +## Compile npm Packages A typical usage scenario is to compile npm packages under node_modules, because some third-party dependencies have ESNext syntax, which may cause them to fail to run on low-version browsers. You can solve the problem by using this config to specify the dependencies that need to be compiled. diff --git a/website/docs/en/guide/advanced/module-federation.mdx b/website/docs/en/guide/advanced/module-federation.mdx index 2989365ba1..068de566bb 100644 --- a/website/docs/en/guide/advanced/module-federation.mdx +++ b/website/docs/en/guide/advanced/module-federation.mdx @@ -27,7 +27,7 @@ Here are the characteristics of several versions: | Version | Description | Features | Use Cases | | ------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | -| MF v2.0 | Enhanced version of Module Federation, implemented based on Module Federation v1.5 | - Provides additional out-of-the-box features such as dynamic TS type hints, Chrome Devtools, preloading, etc.
- More suitable for micro-frontend architecture supporting large-scale Web applications
- Includes all features of Module Federation 1.5
| Projects that need to use advanced capabilities of MF 2.0 | +| MF v2.0 | Enhanced version of Module Federation, implemented based on Module Federation v1.5 | - Provides additional out-of-the-box features such as dynamic TS type hints, Chrome DevTools, preloading, etc.
- More suitable for micro-frontend architecture supporting large-scale Web applications
- Includes all features of Module Federation 1.5
| Projects that need to use advanced capabilities of MF 2.0 | | MF v1.5 | Version built into Rspack | - Supports module export, module loading, dependency sharing capabilities of Module Federation v1.0
- Added runtime plugin functionality, allowing users to extend the behavior and functionality of module federation
| Projects that don't need to use the extra capabilities of MF 2.0 | ### Module Federation v2.0 diff --git a/website/docs/en/guide/basic/unocss.mdx b/website/docs/en/guide/basic/unocss.mdx index 37012d335e..62a9c0473e 100644 --- a/website/docs/en/guide/basic/unocss.mdx +++ b/website/docs/en/guide/basic/unocss.mdx @@ -70,6 +70,6 @@ For more usage details, refer to the [UnoCSS documentation](https://unocss.dev/) ## VS Code Extension -UnoCSS provides a [VSCode Extension](https://unocss.dev/integrations/vscode) plugin for VS Code to decoration and tooltip for matched utilities. +UnoCSS provides a [VS Code Extension](https://unocss.dev/integrations/vscode) plugin for VS Code to decoration and tooltip for matched utilities. You can install this plugin in VS Code to enable more intelligent features. diff --git a/website/docs/en/guide/faq/hmr.mdx b/website/docs/en/guide/faq/hmr.mdx index c97bad777e..f7b0b19ee1 100644 --- a/website/docs/en/guide/faq/hmr.mdx +++ b/website/docs/en/guide/faq/hmr.mdx @@ -56,7 +56,7 @@ export default { }; ``` -To solve this problem, you need to reference the React development artifacts and install React Devtools, then hot reloading will work properly. +To solve this problem, you need to reference the React development artifacts and install React DevTools, then hot reloading will work properly. If you are unsure about the type of React build you are using, you can refer to the [React documentation - Use the Production Build](https://legacy.reactjs.org/docs/optimizing-performance.html#use-the-production-build). diff --git a/website/docs/zh/guide/advanced/module-federation.mdx b/website/docs/zh/guide/advanced/module-federation.mdx index 6100edea9c..d4f6cc0755 100644 --- a/website/docs/zh/guide/advanced/module-federation.mdx +++ b/website/docs/zh/guide/advanced/module-federation.mdx @@ -27,7 +27,7 @@ Module Federation(MF) 目前有多个主要版本,你可以根据你的需 | 版本 | 描述 | 特点 | 使用场景 | | ------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -| MF v2.0 | Module Federation 的增强版本,基于 Module Federation v1.5 实现 | - 开箱即用的提供了一些额外的功能,比如动态 TS 类型提示、Chrome Devtools、预加载等
- 更适用于支持大型 Web 应用的微前端架构
- 包括 Module Federation 1.5 的所有功能
| 需要使用 MF 2.0 进阶能力的项目 | +| MF v2.0 | Module Federation 的增强版本,基于 Module Federation v1.5 实现 | - 开箱即用的提供了一些额外的功能,比如动态 TS 类型提示、Chrome DevTools、预加载等
- 更适用于支持大型 Web 应用的微前端架构
- 包括 Module Federation 1.5 的所有功能
| 需要使用 MF 2.0 进阶能力的项目 | | MF v1.5 | Rspack 内置支持的版本 | - 支持 Module Federation v1.0 的模块导出、模块加载、依赖共享等能力
- 添加了运行时插件功能,允许用户扩展模块联邦的行为、功能
| 不需要使用 MF 2.0 使用的额外能力 | ### Module Federation v2.0 diff --git a/website/docs/zh/guide/basic/unocss.mdx b/website/docs/zh/guide/basic/unocss.mdx index d7ca14beb4..4749b71b42 100644 --- a/website/docs/zh/guide/basic/unocss.mdx +++ b/website/docs/zh/guide/basic/unocss.mdx @@ -68,6 +68,6 @@ export default defineConfig({ ## VS Code 插件 -UnoCSS 提供了 [VSCode 插件](https://unocss.dev/integrations/vscode),用于在 VS Code 中提示 UnoCSS 的 utilities classes。 +UnoCSS 提供了 [VS Code 插件](https://unocss.dev/integrations/vscode),用于在 VS Code 中提示 UnoCSS 的 utilities classes。 你可以在 VS Code 中安装该插件,即可开启更多智能化功能。 diff --git a/website/docs/zh/guide/faq/hmr.mdx b/website/docs/zh/guide/faq/hmr.mdx index 63e9aebd4e..8ffd7b40bb 100644 --- a/website/docs/zh/guide/faq/hmr.mdx +++ b/website/docs/zh/guide/faq/hmr.mdx @@ -56,7 +56,7 @@ export default { }; ``` -为了解决该问题,你需要引用 React 的开发模式产物,同时安装 React Devtools,安装完成后即可实现热更新。 +为了解决该问题,你需要引用 React 的开发模式产物,同时安装 React DevTools,安装完成后即可实现热更新。 如果你不确定当前使用的 React 产物类型,可以参考:[React 官方文档 - Use the Production Build](https://legacy.reactjs.org/docs/optimizing-performance.html#use-the-production-build)。 From ca8e7061fe3be862c1e7319330fce5d8de1fa5c6 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 26 Oct 2024 09:52:02 +0800 Subject: [PATCH 3/3] docs --- website/docs/en/config/source/include.mdx | 2 +- website/docs/zh/config/source/include.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/en/config/source/include.mdx b/website/docs/en/config/source/include.mdx index b31bf75991..ac9ab5a253 100644 --- a/website/docs/en/config/source/include.mdx +++ b/website/docs/en/config/source/include.mdx @@ -62,7 +62,7 @@ export default { The above two methods match the absolute paths of files using "path prefixes" and "regular expressions" respectively. It is worth noting that all referenced modules in the project will be matched. Therefore, you should avoid using overly loose values for matching to prevent compilation performance issues or compilation errors. :::tip -In the regular expression example above, we use `[\\/]` to match the path separator because different operating systems use different path separators. Using `[\\/]` ensures that the paths will match in both POSIX systems (macOS, Linux) and Windows. +In the regular expression example above, we use `[\\/]` to match the path separator because different operating systems use different path separators. Using `[\\/]` ensures that the paths can be matched in macOS, Linux and Windows. ::: ## Compile Sub Dependencies diff --git a/website/docs/zh/config/source/include.mdx b/website/docs/zh/config/source/include.mdx index 148f1975c1..ccdb898687 100644 --- a/website/docs/zh/config/source/include.mdx +++ b/website/docs/zh/config/source/include.mdx @@ -62,7 +62,7 @@ export default { 上述两种方法分别通过 "路径前缀" 和 "正则表达式" 来匹配文件的绝对路径,值得留意的是,项目中所有被引用的模块都会经过匹配,因此你不能使用过于松散的值进行匹配,避免造成编译性能问题或编译异常。 :::tip -在上述正则表达式的例子中,我们使用 `[\\/]` 来匹配路径分隔符,这是因为不同的操作系统使用了不同的路径分隔符,使用 `[\\/]` 可以保证 POSIX 系统(macOS、Linux)和 Windows 的路径都被匹配到。 +在上述正则表达式的例子中,我们使用 `[\\/]` 来匹配路径分隔符,这是因为不同的操作系统使用了不同的路径分隔符,使用 `[\\/]` 可以保证 macOS、Linux 和 Windows 的路径都被匹配到。 ::: ## 编译间接依赖