diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3dfa5783eb..b886ec5ada 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: timeout-minutes: 15 strategy: matrix: - # run ut in macOS, as SWC cases will fail in Ubuntu CI + # run ut on macOS, as SWC cases will fail on Ubuntu CI os: [macos-14, windows-latest] steps: diff --git a/e2e/cases/css/inject-styles/index.test.ts b/e2e/cases/css/inject-styles/index.test.ts index a6cce6cc9f..ef10125e7c 100644 --- a/e2e/cases/css/inject-styles/index.test.ts +++ b/e2e/cases/css/inject-styles/index.test.ts @@ -47,7 +47,7 @@ rspackOnlyTest( rspackOnlyTest( 'HMR should work well when `injectStyles` is enabled', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/lazy-compilation/add-initial-chunk/index.test.ts b/e2e/cases/lazy-compilation/add-initial-chunk/index.test.ts index 76993ddfa5..abaad016ec 100644 --- a/e2e/cases/lazy-compilation/add-initial-chunk/index.test.ts +++ b/e2e/cases/lazy-compilation/add-initial-chunk/index.test.ts @@ -1,21 +1,21 @@ import { dev, rspackOnlyTest } from '@e2e/helper'; -import test, { expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; // https://github.com/web-infra-dev/rspack/issues/6633 rspackOnlyTest( 'should render pages correctly when using lazy compilation and add new initial chunk', async ({ page }) => { - // TODO fix this case in Windows + // TODO fix this case on Windows if (process.platform === 'win32') { test.skip(); } + const rsbuild = await dev({ cwd: __dirname, page, }); await expect(page.locator('#test')).toHaveText('Hello World!'); - await rsbuild.close(); }, ); diff --git a/e2e/cases/lazy-compilation/basic/index.test.ts b/e2e/cases/lazy-compilation/basic/index.test.ts index 4e90c63614..fe06cc7e88 100644 --- a/e2e/cases/lazy-compilation/basic/index.test.ts +++ b/e2e/cases/lazy-compilation/basic/index.test.ts @@ -1,24 +1,41 @@ -import { dev, gotoPage, rspackOnlyTest } from '@e2e/helper'; +import { + dev, + expectPoll, + gotoPage, + proxyConsole, + rspackOnlyTest, +} from '@e2e/helper'; import { expect, test } from '@playwright/test'; rspackOnlyTest( 'should render pages correctly when using lazy compilation', async ({ page }) => { - // TODO fix this case in Windows + // TODO fix this case on Windows if (process.platform === 'win32') { test.skip(); } + const { logs, restore } = proxyConsole(); const rsbuild = await dev({ cwd: __dirname, }); await gotoPage(page, rsbuild, 'page1'); await expect(page.locator('#test')).toHaveText('Page 1'); + await expectPoll(() => + logs.some((log) => log.includes('building src/page1/index.js')), + ).toBeTruthy(); + expect( + logs.some((log) => log.includes('building src/page2/index.js')), + ).toBeFalsy(); await gotoPage(page, rsbuild, 'page2'); await expect(page.locator('#test')).toHaveText('Page 2'); + await expectPoll(() => + logs.some((log) => log.includes('building src/page2/index.js')), + ).toBeTruthy(); await rsbuild.close(); + restore(); }, ); diff --git a/e2e/cases/lazy-compilation/dynamic-import/index.test.ts b/e2e/cases/lazy-compilation/dynamic-import/index.test.ts new file mode 100644 index 0000000000..afe4427ab0 --- /dev/null +++ b/e2e/cases/lazy-compilation/dynamic-import/index.test.ts @@ -0,0 +1,37 @@ +import { + dev, + expectPoll, + gotoPage, + proxyConsole, + rspackOnlyTest, +} from '@e2e/helper'; +import { expect, test } from '@playwright/test'; + +rspackOnlyTest( + 'should lazy compile dynamic imported modules', + async ({ page }) => { + // TODO fix this case on Windows + if (process.platform === 'win32') { + test.skip(); + } + + const { logs, restore } = proxyConsole(); + const rsbuild = await dev({ + cwd: __dirname, + page, + }); + + await expectPoll(() => + logs.some((log) => log.includes('building src/index.js')), + ).toBeTruthy(); + expect(logs.some((log) => log.includes('building src/foo.js'))).toBeFalsy(); + + await gotoPage(page, rsbuild, 'index'); + await expectPoll(() => + logs.some((log) => log.includes('building src/foo.js')), + ).toBeTruthy(); + + await rsbuild.close(); + restore(); + }, +); diff --git a/e2e/cases/lazy-compilation/dynamic-import/rsbuild.config.ts b/e2e/cases/lazy-compilation/dynamic-import/rsbuild.config.ts new file mode 100644 index 0000000000..16835443ab --- /dev/null +++ b/e2e/cases/lazy-compilation/dynamic-import/rsbuild.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from '@rsbuild/core'; + +export default defineConfig({ + dev: { + lazyCompilation: true, + }, +}); diff --git a/e2e/cases/lazy-compilation/dynamic-import/src/foo.js b/e2e/cases/lazy-compilation/dynamic-import/src/foo.js new file mode 100644 index 0000000000..3329a7d972 --- /dev/null +++ b/e2e/cases/lazy-compilation/dynamic-import/src/foo.js @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/e2e/cases/lazy-compilation/dynamic-import/src/index.js b/e2e/cases/lazy-compilation/dynamic-import/src/index.js new file mode 100644 index 0000000000..642905a4ca --- /dev/null +++ b/e2e/cases/lazy-compilation/dynamic-import/src/index.js @@ -0,0 +1,5 @@ +console.log('entry'); + +import('./foo').then(({ foo }) => { + console.log(foo); +}); diff --git a/e2e/cases/live-reload/index.test.ts b/e2e/cases/live-reload/index.test.ts index 96b0f3bb21..474e90faee 100644 --- a/e2e/cases/live-reload/index.test.ts +++ b/e2e/cases/live-reload/index.test.ts @@ -18,7 +18,7 @@ test.afterEach(() => { test('should fallback to live-reload when dev.hmr is false', async ({ page, }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/module-federation-v2/index.test.ts b/e2e/cases/module-federation-v2/index.test.ts index 7678150d0b..d072d15677 100644 --- a/e2e/cases/module-federation-v2/index.test.ts +++ b/e2e/cases/module-federation-v2/index.test.ts @@ -29,7 +29,7 @@ export default Button;`, rspackOnlyTest( 'should run module federation in development mode', async ({ page }) => { - // this case often timeout in Windows + // this case often timeout on Windows if (process.platform === 'win32') { test.skip(); } @@ -64,7 +64,7 @@ rspackOnlyTest( rspackOnlyTest( 'should allow remote module to perform HMR', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/module-federation/index.test.ts b/e2e/cases/module-federation/index.test.ts index 338d85372a..21cd5823bb 100644 --- a/e2e/cases/module-federation/index.test.ts +++ b/e2e/cases/module-federation/index.test.ts @@ -97,7 +97,7 @@ rspackOnlyTest( rspackOnlyTest( 'should allow remote module to perform HMR', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/preact/prefresh-context/index.test.ts b/e2e/cases/preact/prefresh-context/index.test.ts index 15ec83a5e6..5ab3909666 100644 --- a/e2e/cases/preact/prefresh-context/index.test.ts +++ b/e2e/cases/preact/prefresh-context/index.test.ts @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'; // TODO: broken since preact 10.26.4 test.skip('HMR should work properly with `createContext`', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/preact/prefresh-disabled/index.test.ts b/e2e/cases/preact/prefresh-disabled/index.test.ts index 8e84a15ada..7f1dae7537 100644 --- a/e2e/cases/preact/prefresh-disabled/index.test.ts +++ b/e2e/cases/preact/prefresh-disabled/index.test.ts @@ -4,7 +4,7 @@ import { dev, rspackOnlyTest } from '@e2e/helper'; import { expect, test } from '@playwright/test'; rspackOnlyTest('HMR should work properly', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on 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 065df0ab94..888d21ac9a 100644 --- a/e2e/cases/preact/prefresh/index.test.ts +++ b/e2e/cases/preact/prefresh/index.test.ts @@ -4,7 +4,7 @@ import { dev, rspackOnlyTest } from '@e2e/helper'; import { expect, test } from '@playwright/test'; rspackOnlyTest('HMR should work properly', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/react/disable-fast-refresh/index.test.ts b/e2e/cases/react/disable-fast-refresh/index.test.ts index 41e40c1a9f..14b385f622 100644 --- a/e2e/cases/react/disable-fast-refresh/index.test.ts +++ b/e2e/cases/react/disable-fast-refresh/index.test.ts @@ -8,7 +8,7 @@ const cwd = __dirname; rspackOnlyTest( 'HMR should work when Fast Refresh is disabled', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on 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 fe767b79bf..3a988376ab 100644 --- a/e2e/cases/server/environments-hmr/index.test.ts +++ b/e2e/cases/server/environments-hmr/index.test.ts @@ -9,7 +9,7 @@ const cwd = __dirname; rspackOnlyTest( 'Multiple environments HMR should work correctly', async ({ page, context }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/server/hmr/index.test.ts b/e2e/cases/server/hmr/index.test.ts index 46c6d7c5f1..6c825101f6 100644 --- a/e2e/cases/server/hmr/index.test.ts +++ b/e2e/cases/server/hmr/index.test.ts @@ -6,7 +6,7 @@ import { expect, test } from '@playwright/test'; const cwd = __dirname; rspackOnlyTest('HMR should work by default', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } @@ -62,7 +62,7 @@ rspackOnlyTest('HMR should work by default', async ({ page }) => { rspackOnlyTest( 'HMR should work when setting dev.port & client', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } @@ -112,7 +112,7 @@ rspackOnlyTest( rspackOnlyTest( 'HMR should work when dev.port is ``', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/server/overlay/index.test.ts b/e2e/cases/server/overlay/index.test.ts index a898d6880b..a2cbd8b1cc 100644 --- a/e2e/cases/server/overlay/index.test.ts +++ b/e2e/cases/server/overlay/index.test.ts @@ -6,7 +6,7 @@ import { expect, test } from '@playwright/test'; const cwd = __dirname; test('should show overlay correctly', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/server/reload-html/index.test.ts b/e2e/cases/server/reload-html/index.test.ts index 5150ab6ba6..12661c788b 100644 --- a/e2e/cases/server/reload-html/index.test.ts +++ b/e2e/cases/server/reload-html/index.test.ts @@ -8,7 +8,7 @@ const cwd = __dirname; rspackOnlyTest( 'should reload page when HTML template changed', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/server/setup-middlewares/index.test.ts b/e2e/cases/server/setup-middlewares/index.test.ts index 45818bb73f..4f8894a325 100644 --- a/e2e/cases/server/setup-middlewares/index.test.ts +++ b/e2e/cases/server/setup-middlewares/index.test.ts @@ -4,7 +4,7 @@ import { expect, test } from '@playwright/test'; test('should apply custom middleware via `setupMiddlewares`', async ({ page, }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/solid/hmr/index.test.ts b/e2e/cases/solid/hmr/index.test.ts index 1433fb51e5..8ea670435d 100644 --- a/e2e/cases/solid/hmr/index.test.ts +++ b/e2e/cases/solid/hmr/index.test.ts @@ -4,7 +4,7 @@ import { dev, rspackOnlyTest } from '@e2e/helper'; import { expect, test } from '@playwright/test'; rspackOnlyTest('HMR should work properly', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/svelte/hmr/index.test.ts b/e2e/cases/svelte/hmr/index.test.ts index 88f5913dda..50d864c97e 100644 --- a/e2e/cases/svelte/hmr/index.test.ts +++ b/e2e/cases/svelte/hmr/index.test.ts @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'; import { pluginSvelte } from '@rsbuild/plugin-svelte'; rspackOnlyTest('HMR should work properly', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/cases/tailwindcss/hmr/index.test.ts b/e2e/cases/tailwindcss/hmr/index.test.ts index 4952305935..ee8287520d 100644 --- a/e2e/cases/tailwindcss/hmr/index.test.ts +++ b/e2e/cases/tailwindcss/hmr/index.test.ts @@ -9,7 +9,7 @@ const getContent = ( `; rspackOnlyTest('should support tailwindcss HMR', async ({ page }) => { - // HMR cases will fail in Windows + // HMR cases will fail on Windows if (process.platform === 'win32') { test.skip(); } diff --git a/e2e/scripts/shared.ts b/e2e/scripts/shared.ts index 4c7cbb859c..8a14c184c1 100644 --- a/e2e/scripts/shared.ts +++ b/e2e/scripts/shared.ts @@ -82,7 +82,7 @@ function isPortAvailable(port: number) { const portMap = new Map(); // Available port ranges: 1024 ~ 65535 -// `10080` is not available in macOS CI, `> 50000` get 'permission denied' in Windows. +// `10080` is not available on macOS CI, `> 50000` get 'permission denied' on Windows. // so we use `15000` ~ `45000`. export async function getRandomPort( defaultPort = Math.ceil(Math.random() * 30000) + 15000, diff --git a/packages/core/src/plugins/output.ts b/packages/core/src/plugins/output.ts index 6301338d29..2965bc660f 100644 --- a/packages/core/src/plugins/output.ts +++ b/packages/core/src/plugins/output.ts @@ -40,7 +40,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 on 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}:/`; diff --git a/website/docs/en/config/dev/lazy-compilation.mdx b/website/docs/en/config/dev/lazy-compilation.mdx index 8d1d4feecc..0376ea8958 100644 --- a/website/docs/en/config/dev/lazy-compilation.mdx +++ b/website/docs/en/config/dev/lazy-compilation.mdx @@ -33,7 +33,7 @@ Although Rspack itself has good performance, the overall build time can still be Lazy compilation is an effective strategy to improve the startup performance of the development phase. Instead of compiling all modules at initialization, it compiles modules on demand as they're needed. This means that developers can quickly see the application running when starting the dev server, and build the required modules in batches. By compiling on demand, unnecessary compilation time can be reduced. As the project scales up, compilation time does not significantly increase, which greatly enhances the development experience. :::tip -Lazy compilation only takes effect during development and has no impact on production builds. +Lazy compilation is only effective for dev builds and does not affect production builds. ::: ## Example diff --git a/website/docs/en/config/source/include.mdx b/website/docs/en/config/source/include.mdx index 8863e66bc5..b517be525d 100644 --- a/website/docs/en/config/source/include.mdx +++ b/website/docs/en/config/source/include.mdx @@ -70,7 +70,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, 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. +In the regular expression example, we use `[\\/]` to match the path separator because different operating systems use different path separators. Using `[\\/]` ensures that the paths can be matched on macOS, Linux and Windows. ::: ## Compile sub dependencies