From a1c3daa862421dd891f099e252957fb132f99ca9 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 3 Mar 2026 11:12:16 +0800 Subject: [PATCH] test: replace webpack with rspack in test files --- tests/e2e/allowed-hosts.test.js | 44 ++++++------ tests/e2e/api.test.js | 24 +++---- tests/e2e/app.test.js | 4 +- tests/e2e/built-in-routes.test.js | 6 +- tests/e2e/client-reconnect.test.js | 8 +-- tests/e2e/client.test.js | 14 ++-- tests/e2e/compress.test.js | 8 +-- tests/e2e/entry.test.js | 22 +++--- tests/e2e/headers.test.js | 16 ++--- tests/e2e/history-api-fallback.test.js | 18 ++--- tests/e2e/host.test.js | 10 +-- tests/e2e/hot-and-live-reload.test.js | 20 +++--- tests/e2e/ipc.test.js | 8 +-- tests/e2e/lazy-compilation.test.js | 6 +- tests/e2e/logging.test.js | 4 +- tests/e2e/mime-types.test.js | 6 +- tests/e2e/module-federation.test.js | 10 +-- tests/e2e/multi-compiler.test.js | 24 +++---- tests/e2e/on-listening.test.js | 4 +- tests/e2e/overlay.test.js | 70 +++++++++--------- tests/e2e/port.test.js | 4 +- tests/e2e/progress.test.js | 4 +- tests/e2e/range-header.test.js | 4 +- tests/e2e/server-and-client-transport.test.js | 36 +++++----- tests/e2e/server.test.js | 38 +++++----- tests/e2e/setup-exit-signals.test.js | 4 +- tests/e2e/setup-middlewares.test.js | 4 +- tests/e2e/static-directory.test.js | 16 ++--- tests/e2e/static-public-path.test.js | 22 +++--- tests/e2e/stats.test.js | 6 +- tests/e2e/target.test.js | 8 +-- tests/e2e/watch-files.test.js | 18 ++--- tests/e2e/web-socket-communication.test.js | 10 +-- tests/e2e/web-socket-server-url.test.js | 72 +++++++++---------- tests/e2e/web-socket-server.test.js | 4 +- tests/helpers/test-server.js | 4 +- 36 files changed, 290 insertions(+), 290 deletions(-) diff --git a/tests/e2e/allowed-hosts.test.js b/tests/e2e/allowed-hosts.test.js index e283690..d9cd7e2 100644 --- a/tests/e2e/allowed-hosts.test.js +++ b/tests/e2e/allowed-hosts.test.js @@ -1,5 +1,5 @@ const express = require('express'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { createProxyMiddleware } = require('http-proxy-middleware'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); @@ -16,7 +16,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -89,7 +89,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -162,7 +162,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -235,7 +235,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -309,7 +309,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -384,7 +384,7 @@ describe('allowed hosts', () => { const proxyHost = IPv4; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -458,7 +458,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -535,7 +535,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -612,7 +612,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -690,7 +690,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -768,7 +768,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -846,7 +846,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -924,7 +924,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1005,7 +1005,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1083,7 +1083,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1161,7 +1161,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1239,7 +1239,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1320,7 +1320,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1398,7 +1398,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1480,7 +1480,7 @@ describe('allowed hosts', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1562,7 +1562,7 @@ describe('allowed hosts', () => { let consoleMessages; beforeEach(() => { - compiler = webpack(config); + compiler = rspack(config); pageErrors = []; consoleMessages = []; }); diff --git a/tests/e2e/api.test.js b/tests/e2e/api.test.js index d900a9e..54cdc3e 100644 --- a/tests/e2e/api.test.js +++ b/tests/e2e/api.test.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -50,7 +50,7 @@ describe('API', () => { RspackDevServer: WebpackDevServer, } = require('@rspack/dev-server'); - const compiler = webpack(config); + const compiler = rspack(config); server = new WebpackDevServer({ port }, compiler); await server.start(); @@ -73,7 +73,7 @@ describe('API', () => { describe('latest async API', () => { it('should work with async API', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server({ port }, compiler); await server.start(); @@ -107,7 +107,7 @@ describe('API', () => { }); it('should work with callback API', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server({ port }, compiler); await new Promise((resolve) => { @@ -149,7 +149,7 @@ describe('API', () => { }); it('should catch errors within startCallback', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server( { port, static: 'https://absolute-url.com/somewhere' }, compiler, @@ -172,14 +172,14 @@ describe('API', () => { }); it('should work when using configured manually', async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, entry: [ '@rspack/core/hot/dev-server.js', `@rspack/dev-server/client/index.js?hot=true&live-reload=true"`, path.resolve(__dirname, '../fixtures/client-config/foo.js'), ], - plugins: [...config.plugins, new webpack.HotModuleReplacementPlugin()], + plugins: [...config.plugins, new rspack.HotModuleReplacementPlugin()], }); const server = new Server({ port, hot: false, client: false }, compiler); @@ -213,7 +213,7 @@ describe('API', () => { }); it('should work and allow to rerun dev server multiple times', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server({ port }, compiler); await server.start(); @@ -281,7 +281,7 @@ describe('API', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); ({ page, browser } = await runBrowser()); @@ -380,7 +380,7 @@ describe('API', () => { () => new Promise((resolve) => { devServerPort = 60000 + i; - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server( { port: devServerPort, host: '0.0.0.0' }, compiler, @@ -634,7 +634,7 @@ describe('API', () => { '[ad42::1de2:54c2:c2fa:1234]:8080', ]; - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server(options, compiler); for (const test of tests) { @@ -661,7 +661,7 @@ describe('API', () => { origin: 'https://test.host', }; - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server(options, compiler); await server.start(); diff --git a/tests/e2e/app.test.js b/tests/e2e/app.test.js index a6bc3c6..d74f351 100644 --- a/tests/e2e/app.test.js +++ b/tests/e2e/app.test.js @@ -1,6 +1,6 @@ const fs = require('node:fs'); const path = require('node:path'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const wdm = require('webpack-dev-middleware'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); @@ -98,7 +98,7 @@ describe('app option', () => { describe(`should work using "${appName}" application and "${typeof server === 'function' ? 'custom server' : server}" server`, () => { beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); devServer = new Server( { diff --git a/tests/e2e/built-in-routes.test.js b/tests/e2e/built-in-routes.test.js index 4ea269c..74df6bc 100644 --- a/tests/e2e/built-in-routes.test.js +++ b/tests/e2e/built-in-routes.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const multiConfig = require('../fixtures/multi-public-path-config/webpack.config'); @@ -15,7 +15,7 @@ describe('Built in routes', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server({ port }, compiler); await server.start(); @@ -251,7 +251,7 @@ describe('Built in routes', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(multiConfig); + compiler = rspack(multiConfig); server = new Server({ port }, compiler); await server.start(); diff --git a/tests/e2e/client-reconnect.test.js b/tests/e2e/client-reconnect.test.js index 3f8af26..e2138b2 100644 --- a/tests/e2e/client-reconnect.test.js +++ b/tests/e2e/client-reconnect.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/simple-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -14,7 +14,7 @@ describe('client.reconnect option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server({ port, client: { reconnect: true } }, compiler); @@ -78,7 +78,7 @@ describe('client.reconnect option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server({ port, client: { reconnect: false } }, compiler); @@ -141,7 +141,7 @@ describe('client.reconnect option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server({ port, client: { reconnect: 2 } }, compiler); diff --git a/tests/e2e/client.test.js b/tests/e2e/client.test.js index 0b043e4..63c1def 100644 --- a/tests/e2e/client.test.js +++ b/tests/e2e/client.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/simple-config-other/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -14,7 +14,7 @@ describe('client option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -75,7 +75,7 @@ describe('client option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -143,7 +143,7 @@ describe('client option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -200,7 +200,7 @@ describe('client option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack({ + compiler = rspack({ ...config, devtool: false, }); @@ -274,7 +274,7 @@ describe('client option', () => { } beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new OverrideServer( { @@ -367,7 +367,7 @@ describe('client option', () => { it(`${data.title} ${ data.shouldThrow ? 'should throw' : 'should not throw' }`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server( { diff --git a/tests/e2e/compress.test.js b/tests/e2e/compress.test.js index b7a7fb1..2365f26 100644 --- a/tests/e2e/compress.test.js +++ b/tests/e2e/compress.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/simple-config-other/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -14,7 +14,7 @@ describe('compress option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server({ port }, compiler); @@ -67,7 +67,7 @@ describe('compress option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -126,7 +126,7 @@ describe('compress option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { diff --git a/tests/e2e/entry.test.js b/tests/e2e/entry.test.js index 4e80ca9..4406932 100644 --- a/tests/e2e/entry.test.js +++ b/tests/e2e/entry.test.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -31,7 +31,7 @@ describe('entry', () => { ); it('should work with single entry', async () => { - const compiler = webpack({ ...config, entry: entryFirst }); + const compiler = rspack({ ...config, entry: entryFirst }); const devServerOptions = { port, }; @@ -68,7 +68,7 @@ describe('entry', () => { }); it('should work with single array entry', async () => { - const compiler = webpack({ ...config, entry: [entryFirst, entrySecond] }); + const compiler = rspack({ ...config, entry: [entryFirst, entrySecond] }); const devServerOptions = { port, }; @@ -105,7 +105,7 @@ describe('entry', () => { }); it('should work with object entry', async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, entry: { main: { import: entryFirst }, @@ -147,7 +147,7 @@ describe('entry', () => { }); it('should work with dynamic entry', async () => { - const compiler = webpack({ ...config, entry: () => entryFirst }); + const compiler = rspack({ ...config, entry: () => entryFirst }); const devServerOptions = { port, }; @@ -184,7 +184,7 @@ describe('entry', () => { }); it('should work with dynamic async entry', async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, entry: () => new Promise((resolve) => resolve([entryFirst])), }); @@ -224,7 +224,7 @@ describe('entry', () => { }); it('should work with multiple entries', async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, entry: { foo: entryFirst, @@ -273,7 +273,7 @@ describe('entry', () => { }); it('should work with multiple entries #2', async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, entry: { foo: entryFirst, @@ -322,7 +322,7 @@ describe('entry', () => { }); it('should work with multiple entries and "dependOn"', async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, entry: { foo: { @@ -369,12 +369,12 @@ describe('entry', () => { }); it('should work with empty', async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, entry: {}, }); - new webpack.EntryPlugin(compiler.context, entryFirst, { + new rspack.EntryPlugin(compiler.context, entryFirst, { name: 'main', }).apply(compiler); diff --git a/tests/e2e/headers.test.js b/tests/e2e/headers.test.js index 6bd2efd..462d9eb 100644 --- a/tests/e2e/headers.test.js +++ b/tests/e2e/headers.test.js @@ -1,5 +1,5 @@ const request = require('supertest'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/simple-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -15,7 +15,7 @@ describe('headers option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -74,7 +74,7 @@ describe('headers option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -146,7 +146,7 @@ describe('headers option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -205,7 +205,7 @@ describe('headers option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -266,7 +266,7 @@ describe('headers option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -338,7 +338,7 @@ describe('headers option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -401,7 +401,7 @@ describe('headers option', () => { let req; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { diff --git a/tests/e2e/history-api-fallback.test.js b/tests/e2e/history-api-fallback.test.js index 15161ff..da88af1 100644 --- a/tests/e2e/history-api-fallback.test.js +++ b/tests/e2e/history-api-fallback.test.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/historyapifallback-config/webpack.config'); const config2 = require('../fixtures/historyapifallback-2-config/webpack.config'); @@ -17,7 +17,7 @@ describe('historyApiFallback option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -78,7 +78,7 @@ describe('historyApiFallback option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -141,7 +141,7 @@ describe('historyApiFallback option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config2); + compiler = rspack(config2); server = new Server( { @@ -239,7 +239,7 @@ describe('historyApiFallback option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config3); + compiler = rspack(config3); server = new Server( { @@ -303,7 +303,7 @@ describe('historyApiFallback option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config2); + compiler = rspack(config2); server = new Server( { @@ -438,7 +438,7 @@ describe('historyApiFallback option', () => { beforeEach(async () => { consoleSpy = rs.spyOn(global.console, 'log'); - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -514,7 +514,7 @@ describe('historyApiFallback option', () => { beforeEach(async () => { consoleSpy = rs.spyOn(global.console, 'log'); - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -587,7 +587,7 @@ describe('historyApiFallback option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config3); + compiler = rspack(config3); server = new Server( { diff --git a/tests/e2e/host.test.js b/tests/e2e/host.test.js index 0d3ff9e..a145462 100644 --- a/tests/e2e/host.test.js +++ b/tests/e2e/host.test.js @@ -1,5 +1,5 @@ const http = require('node:http'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -70,7 +70,7 @@ describe('host', () => { for (const host of hosts) { it(`should work using "${host}" host and port as number`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port }; if (host !== '') { @@ -134,7 +134,7 @@ describe('host', () => { }); it(`should work using "${host}" host and port as string`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port: `${port}` }; if (host !== '') { @@ -198,7 +198,7 @@ describe('host', () => { }); it(`should work using "${host}" host and "auto" port`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); process.env.WEBPACK_DEV_SERVER_BASE_PORT = port; @@ -270,7 +270,7 @@ describe('host', () => { // TODO need test on error // it(`should throw an error on invalid host`, async () => { - // const compiler = webpack(config); + // const compiler = rspack(config); // const server = new Server({ port, host: "unknown.unknown" }, compiler); // const runDevServer = async () => { // await server.start(); diff --git a/tests/e2e/hot-and-live-reload.test.js b/tests/e2e/hot-and-live-reload.test.js index 735fb77..d30b932 100644 --- a/tests/e2e/hot-and-live-reload.test.js +++ b/tests/e2e/hot-and-live-reload.test.js @@ -1,7 +1,7 @@ const path = require('node:path'); const WebSocket = require('ws'); const SockJS = require('sockjs-client'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const fs = require('node:fs'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const HTMLGeneratorPlugin = require('../helpers/html-generator-plugin'); @@ -244,7 +244,7 @@ describe('hot and live reload', () => { require.resolve('../fixtures/reload-config/foo.js'), ], plugins: [ - new webpack.HotModuleReplacementPlugin(), + new rspack.HotModuleReplacementPlugin(), new HTMLGeneratorPlugin(), ], }, @@ -327,7 +327,7 @@ describe('hot and live reload', () => { it(`${mode.title} (${webSocketServerTitle})`, async () => { const webpackOptions = { ...reloadConfig, ...mode.webpackOptions }; - const compiler = webpack(webpackOptions); + const compiler = rspack(webpackOptions); const testDevServerOptions = mode.options || {}; const devServerOptions = { port, ...testDevServerOptions }; @@ -577,7 +577,7 @@ describe('hot and live reload', () => { // let consoleMessages; // beforeEach(async () => { -// compiler = webpack(config); +// compiler = rspack(config); // ({ page, browser } = await runBrowser()); @@ -640,9 +640,9 @@ describe('hot and live reload', () => { // let consoleMessages; // beforeEach(async () => { -// compiler = webpack({ +// compiler = rspack({ // ...config, -// plugins: [...config.plugins, new webpack.HotModuleReplacementPlugin()], +// plugins: [...config.plugins, new rspack.HotModuleReplacementPlugin()], // }); // ({ page, browser } = await runBrowser()); @@ -705,10 +705,10 @@ describe('hot and live reload', () => { // let server; // beforeEach(() => { -// compiler = webpack({ +// compiler = rspack({ // ...config, // devServer: { hot: false }, -// plugins: [...config.plugins, new webpack.HotModuleReplacementPlugin()], +// plugins: [...config.plugins, new rspack.HotModuleReplacementPlugin()], // }); // loggerWarnSpy = rs.fn(); @@ -775,7 +775,7 @@ describe('hot and live reload', () => { // let consoleMessages; // beforeEach(async () => { -// compiler = webpack(multiCompilerConfig); +// compiler = rspack(multiCompilerConfig); // ({ page, browser } = await runBrowser()); @@ -838,7 +838,7 @@ describe('hot and live reload', () => { // let consoleMessages; // beforeEach(async () => { -// compiler = webpack(config); +// compiler = rspack(config); // ({ page, browser } = await runBrowser()); diff --git a/tests/e2e/ipc.test.js b/tests/e2e/ipc.test.js index 8e2871c..9a9b100 100644 --- a/tests/e2e/ipc.test.js +++ b/tests/e2e/ipc.test.js @@ -2,7 +2,7 @@ const os = require('node:os'); const net = require('node:net'); const path = require('node:path'); const http = require('node:http'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const httpProxy = require('http-proxy'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); @@ -21,7 +21,7 @@ describe('web socket server URL', () => { const proxyHost = devServerHost; const proxyPort = port1; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, ipc: true, @@ -123,7 +123,7 @@ describe('web socket server URL', () => { const proxyHost = devServerHost; const proxyPort = port1; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, ipc, @@ -239,7 +239,7 @@ describe('web socket server URL', () => { const proxyHost = devServerHost; const proxyPort = port1; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, host: devServerHost, diff --git a/tests/e2e/lazy-compilation.test.js b/tests/e2e/lazy-compilation.test.js index 0a8c13a..d8e24b0 100644 --- a/tests/e2e/lazy-compilation.test.js +++ b/tests/e2e/lazy-compilation.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const lazyCompilationSingleEntryConfig = require('../fixtures/lazy-compilation-single-entry/webpack.config'); const lazyCompilationMultipleEntriesConfig = require('../fixtures/lazy-compilation-multiple-entries/webpack.config'); @@ -9,7 +9,7 @@ describe('lazy compilation', () => { // TODO test run can freeze because webpack does not close `eventsource`; // uncomment after it is fixed on webpack side it.skip('should work with single entry', async () => { - const compiler = webpack(lazyCompilationSingleEntryConfig); + const compiler = rspack(lazyCompilationSingleEntryConfig); const server = new Server({ port }, compiler); await server.start(); @@ -50,7 +50,7 @@ describe('lazy compilation', () => { }); it.skip('should work with multiple entries', async () => { - const compiler = webpack(lazyCompilationMultipleEntriesConfig); + const compiler = rspack(lazyCompilationMultipleEntriesConfig); const server = new Server({ port }, compiler); await server.start(); diff --git a/tests/e2e/logging.test.js b/tests/e2e/logging.test.js index bfc3ca4..ef08dbd 100644 --- a/tests/e2e/logging.test.js +++ b/tests/e2e/logging.test.js @@ -1,6 +1,6 @@ const path = require('node:path'); const fs = require('node:fs'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const HTMLGeneratorPlugin = require('../helpers/html-generator-plugin'); const config = require('../fixtures/client-config/webpack.config'); @@ -192,7 +192,7 @@ describe('logging', () => { it(`${testCase.title} (${ webSocketServer.webSocketServer || 'default' })`, async () => { - const compiler = webpack({ ...config, ...testCase.webpackOptions }); + const compiler = rspack({ ...config, ...testCase.webpackOptions }); const devServerOptions = { port, ...testCase.devServerOptions, diff --git a/tests/e2e/mime-types.test.js b/tests/e2e/mime-types.test.js index 134cf10..178a4c8 100644 --- a/tests/e2e/mime-types.test.js +++ b/tests/e2e/mime-types.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/mime-types-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -14,7 +14,7 @@ describe('mimeTypes option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -77,7 +77,7 @@ describe('mimeTypes option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { diff --git a/tests/e2e/module-federation.test.js b/tests/e2e/module-federation.test.js index 899c64a..3af09fc 100644 --- a/tests/e2e/module-federation.test.js +++ b/tests/e2e/module-federation.test.js @@ -1,5 +1,5 @@ const requireFromString = require('require-from-string'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const simpleConfig = require('../fixtures/module-federation-config/webpack.config'); const objectEntryConfig = require('../fixtures/module-federation-config/webpack.object-entry.config'); @@ -18,7 +18,7 @@ describe('Module federation', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(simpleConfig); + compiler = rspack(simpleConfig); server = new Server({ port }, compiler); await server.start(); @@ -76,7 +76,7 @@ describe('Module federation', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(objectEntryConfig); + compiler = rspack(objectEntryConfig); server = new Server({ port }, compiler); await server.start(); @@ -166,7 +166,7 @@ describe('Module federation', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(multiConfig); + compiler = rspack(multiConfig); server = new Server({ port }, compiler); await server.start(); @@ -224,7 +224,7 @@ describe('Module federation', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(pluginConfig); + compiler = rspack(pluginConfig); server = new Server({ port }, compiler); await server.start(); diff --git a/tests/e2e/multi-compiler.test.js b/tests/e2e/multi-compiler.test.js index 6686339..19ccdcd 100644 --- a/tests/e2e/multi-compiler.test.js +++ b/tests/e2e/multi-compiler.test.js @@ -1,6 +1,6 @@ const path = require('node:path'); const fs = require('node:fs'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const oneWebTargetConfiguration = require('../fixtures/multi-compiler-one-configuration/webpack.config'); const twoWebTargetConfiguration = require('../fixtures/multi-compiler-two-configurations/webpack.config'); @@ -10,7 +10,7 @@ const port = require('../helpers/ports-map')['multi-compiler']; describe('multi compiler', () => { it('should work with one web target configuration and do nothing', async () => { - const compiler = webpack(oneWebTargetConfiguration); + const compiler = rspack(oneWebTargetConfiguration); const devServerOptions = { port, }; @@ -45,7 +45,7 @@ describe('multi compiler', () => { }); it('should work with web target configurations and do nothing', async () => { - const compiler = webpack(twoWebTargetConfiguration); + const compiler = rspack(twoWebTargetConfiguration); const devServerOptions = { port, }; @@ -91,7 +91,7 @@ describe('multi compiler', () => { }); it('should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries', async () => { - const compiler = webpack(twoWebTargetConfiguration); + const compiler = rspack(twoWebTargetConfiguration); const devServerOptions = { port, hot: true, @@ -168,7 +168,7 @@ describe('multi compiler', () => { }); it('should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries', async () => { - const compiler = webpack(twoWebTargetConfiguration); + const compiler = rspack(twoWebTargetConfiguration); const devServerOptions = { port, hot: true, @@ -245,7 +245,7 @@ describe('multi compiler', () => { }); it('should work with web target configurations when only live reload is enabled, and do live reload when changing own entries', async () => { - const compiler = webpack(twoWebTargetConfiguration); + const compiler = rspack(twoWebTargetConfiguration); const devServerOptions = { port, hot: false, @@ -314,7 +314,7 @@ describe('multi compiler', () => { }); it('should work with web target configurations when only live reload is enabled and do live reload when changing other entries', async () => { - const compiler = webpack(twoWebTargetConfiguration); + const compiler = rspack(twoWebTargetConfiguration); const devServerOptions = { port, hot: false, @@ -383,7 +383,7 @@ describe('multi compiler', () => { }); it('should work with universal configuration and do nothing', async () => { - const compiler = webpack(universalConfiguration); + const compiler = rspack(universalConfiguration); const devServerOptions = { port, }; @@ -429,7 +429,7 @@ describe('multi compiler', () => { }); it('should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed', async () => { - const compiler = webpack(universalConfiguration); + const compiler = rspack(universalConfiguration); const devServerOptions = { port, hot: true, @@ -507,7 +507,7 @@ describe('multi compiler', () => { }); it('should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed', async () => { - const compiler = webpack(universalConfiguration); + const compiler = rspack(universalConfiguration); const devServerOptions = { port, hot: true, @@ -579,7 +579,7 @@ describe('multi compiler', () => { }); it('should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries', async () => { - const compiler = webpack(universalConfiguration); + const compiler = rspack(universalConfiguration); const devServerOptions = { port, hot: false, @@ -666,7 +666,7 @@ describe('multi compiler', () => { }); it('should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries', async () => { - const compiler = webpack(universalConfiguration); + const compiler = rspack(universalConfiguration); const devServerOptions = { port, hot: false, diff --git a/tests/e2e/on-listening.test.js b/tests/e2e/on-listening.test.js index 89e0e10..a59d677 100644 --- a/tests/e2e/on-listening.test.js +++ b/tests/e2e/on-listening.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -14,7 +14,7 @@ describe('onListening option', () => { let onListeningIsRunning = false; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { onListening: (devServer) => { diff --git a/tests/e2e/overlay.test.js b/tests/e2e/overlay.test.js index 1ae4900..c4012a8 100644 --- a/tests/e2e/overlay.test.js +++ b/tests/e2e/overlay.test.js @@ -1,6 +1,6 @@ const path = require('node:path'); const fs = require('node:fs'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const waitForExpect = require('wait-for-expect'); const config = require('../fixtures/overlay-config/webpack.config'); @@ -81,7 +81,7 @@ describe('overlay', () => { }); it('should show a warning for initial compilation', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -128,7 +128,7 @@ describe('overlay', () => { }); it('should show an error for initial compilation', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin().apply(compiler); @@ -175,7 +175,7 @@ describe('overlay', () => { }); it('should show a warning and error for initial compilation', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); new WarningPlugin().apply(compiler); @@ -226,7 +226,7 @@ describe('overlay', () => { }); it('should show an ansi formatted error for initial compilation', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin( '  18 | Render ansi formatted text', @@ -275,7 +275,7 @@ describe('overlay', () => { }); it('should show a warning and error for initial compilation and protects against xss', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin('strong').apply(compiler); new ErrorPlugin('strong').apply(compiler); @@ -323,7 +323,7 @@ describe('overlay', () => { }); it('should not show initially, then show on an error, then hide on fix', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, }; @@ -406,7 +406,7 @@ describe('overlay', () => { }); it('should not show initially, then show on an error, then show other error, then hide on fix', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, }; @@ -512,7 +512,7 @@ describe('overlay', () => { }); it('should not show initially, then show on an error and allow to close', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, }; @@ -603,7 +603,7 @@ describe('overlay', () => { mockLaunchEditorCb.mockClear(); const { RspackDevServer: Server } = require('@rspack/dev-server'); - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, }; @@ -647,7 +647,7 @@ describe('overlay', () => { }); it('should not show a warning when "client.overlay" is "false"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -688,7 +688,7 @@ describe('overlay', () => { }); it('should not show a warning when "client.overlay.warnings" is "false"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -731,7 +731,7 @@ describe('overlay', () => { }); it('should not show warning when it is filtered', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin('My special warning').apply(compiler); @@ -773,7 +773,7 @@ describe('overlay', () => { }); it('should show warning when it is not filtered', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin('Unfiltered warning').apply(compiler); @@ -827,7 +827,7 @@ describe('overlay', () => { }); it('should show a warning when "client.overlay" is "true"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -877,7 +877,7 @@ describe('overlay', () => { }); it('should show a warning when "client.overlay.warnings" is "true"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -929,7 +929,7 @@ describe('overlay', () => { }); it('should show a warning when "client.overlay.errors" is "true"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -981,7 +981,7 @@ describe('overlay', () => { }); it('should not show an error when "client.overlay" is "false"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin().apply(compiler); @@ -1022,7 +1022,7 @@ describe('overlay', () => { }); it('should not show an error when "client.overlay.errors" is "false"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin().apply(compiler); @@ -1065,7 +1065,7 @@ describe('overlay', () => { }); it('should not show error when it is filtered', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin('My special error').apply(compiler); @@ -1108,7 +1108,7 @@ describe('overlay', () => { }); it('should show error when it is not filtered', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin('Unfiltered error').apply(compiler); @@ -1162,7 +1162,7 @@ describe('overlay', () => { }); it('should show an error when "client.overlay" is "true"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin().apply(compiler); @@ -1212,7 +1212,7 @@ describe('overlay', () => { }); it('should show overlay when Trusted Types are enabled', async () => { - const compiler = webpack(trustedTypesConfig); + const compiler = rspack(trustedTypesConfig); new ErrorPlugin().apply(compiler); @@ -1275,7 +1275,7 @@ describe('overlay', () => { }); it('should show overlay when Trusted Types are enabled and the "require-trusted-types-for \'script\'" header was used', async () => { - const compiler = webpack(trustedTypesConfig); + const compiler = rspack(trustedTypesConfig); new ErrorPlugin().apply(compiler); @@ -1348,7 +1348,7 @@ describe('overlay', () => { }); it('should not show overlay when Trusted Types are enabled, but policy is not allowed', async () => { - const compiler = webpack(trustedTypesConfig); + const compiler = rspack(trustedTypesConfig); new ErrorPlugin().apply(compiler); @@ -1390,7 +1390,7 @@ describe('overlay', () => { }); it('should show an error when "client.overlay.errors" is "true"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin().apply(compiler); @@ -1442,7 +1442,7 @@ describe('overlay', () => { }); it('should show an error when "client.overlay.warnings" is "true"', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -1494,7 +1494,7 @@ describe('overlay', () => { }); it('should show a warning and hide them after closing connection', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin().apply(compiler); @@ -1567,7 +1567,7 @@ describe('overlay', () => { }); it('should show an error after invalidation', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new ErrorPlugin('Error from compilation', 1).apply(compiler); @@ -1628,7 +1628,7 @@ describe('overlay', () => { }); it('should show a warning after invalidation', async () => { - const compiler = webpack(config); + const compiler = rspack(config); new WarningPlugin('Warning from compilation', 1).apply(compiler); @@ -1689,7 +1689,7 @@ describe('overlay', () => { }); it('should show error for uncaught runtime error', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server( { @@ -1735,7 +1735,7 @@ describe('overlay', () => { }); it('should not show filtered runtime error', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server( { @@ -1777,7 +1777,7 @@ describe('overlay', () => { }); it('should show error for uncaught promise rejection', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server( { @@ -1825,7 +1825,7 @@ describe('overlay', () => { }); it('should not show filtered promise rejection', async () => { - const compiler = webpack(config); + const compiler = rspack(config); const server = new Server( { @@ -1869,7 +1869,7 @@ describe('overlay', () => { }); it('should show overlay when "Content-Security-Policy" is "default-src \'self\'" was used', async () => { - const compiler = webpack({ ...config, devtool: false }); + const compiler = rspack({ ...config, devtool: false }); new ErrorPlugin().apply(compiler); diff --git a/tests/e2e/port.test.js b/tests/e2e/port.test.js index 2502653..33b68bc 100644 --- a/tests/e2e/port.test.js +++ b/tests/e2e/port.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -19,7 +19,7 @@ describe('port', () => { for (const testedPort of ports) { it(`should work using "${testedPort}" port `, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = {}; let usedPort; diff --git a/tests/e2e/progress.test.js b/tests/e2e/progress.test.js index 6412d90..0c7c69e 100644 --- a/tests/e2e/progress.test.js +++ b/tests/e2e/progress.test.js @@ -1,6 +1,6 @@ const path = require('node:path'); const fs = require('node:fs'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const reloadConfig = require('../fixtures/reload-config-2/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -15,7 +15,7 @@ describe('progress', () => { it('should work and log progress in a browser console', async () => { fs.writeFileSync(cssFilePath, 'body { background-color: rgb(0, 0, 255); }'); - const compiler = webpack(reloadConfig); + const compiler = rspack(reloadConfig); const devServerOptions = { port, client: { diff --git a/tests/e2e/range-header.test.js b/tests/e2e/range-header.test.js index 5ff0f00..945362c 100644 --- a/tests/e2e/range-header.test.js +++ b/tests/e2e/range-header.test.js @@ -1,5 +1,5 @@ const request = require('supertest'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/static-config/webpack.config'); const port = require('../helpers/ports-map')['range-header']; @@ -9,7 +9,7 @@ describe("'Range' header", () => { let server; beforeAll(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server({ port }, compiler); diff --git a/tests/e2e/server-and-client-transport.test.js b/tests/e2e/server-and-client-transport.test.js index d3fbc56..3031d7a 100644 --- a/tests/e2e/server-and-client-transport.test.js +++ b/tests/e2e/server-and-client-transport.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const WebsocketServer = require('../../dist/servers/WebsocketServer').default; const defaultConfig = require('../fixtures/provide-plugin-default/webpack.config'); @@ -10,7 +10,7 @@ const port = require('../helpers/ports-map')['server-and-client-transport']; describe('server and client transport', () => { it('should use default web socket server ("ws")', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, }; @@ -46,7 +46,7 @@ describe('server and client transport', () => { }); it('should use "ws" web socket server when specify "ws" value', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, webSocketServer: 'ws', @@ -83,7 +83,7 @@ describe('server and client transport', () => { }); it('should use "ws" web socket server when specify "ws" value using object', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, webSocketServer: { @@ -122,7 +122,7 @@ describe('server and client transport', () => { }); it('should use "sockjs" web socket server when specify "sockjs" value', async () => { - const compiler = webpack(sockjsConfig); + const compiler = rspack(sockjsConfig); const devServerOptions = { port, webSocketServer: 'sockjs', @@ -159,7 +159,7 @@ describe('server and client transport', () => { }); it('should use "sockjs" web socket server when specify "sockjs" value using object', async () => { - const compiler = webpack(sockjsConfig); + const compiler = rspack(sockjsConfig); const devServerOptions = { port, webSocketServer: { @@ -198,7 +198,7 @@ describe('server and client transport', () => { }); it('should use custom web socket server when specify class', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, client: { @@ -238,7 +238,7 @@ describe('server and client transport', () => { }); it('should use custom web socket server when specify class using object', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, client: { @@ -280,7 +280,7 @@ describe('server and client transport', () => { }); it('should use custom web socket server when specify path to class', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, client: { @@ -320,7 +320,7 @@ describe('server and client transport', () => { }); it('should use custom web socket server when specify path to class using object', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, client: { @@ -364,7 +364,7 @@ describe('server and client transport', () => { it('should throw an error on wrong path', async () => { expect.assertions(1); - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, webSocketServer: { @@ -383,7 +383,7 @@ describe('server and client transport', () => { }); it('should use "sockjs" transport, when web socket server is not specify', async () => { - const compiler = webpack(sockjsConfig); + const compiler = rspack(sockjsConfig); const devServerOptions = { port, client: { @@ -422,7 +422,7 @@ describe('server and client transport', () => { }); it('should use "ws" transport, when web socket server is not specify', async () => { - const compiler = webpack(wsConfig); + const compiler = rspack(wsConfig); const devServerOptions = { port, client: { @@ -461,7 +461,7 @@ describe('server and client transport', () => { }); it('should use "sockjs" transport and "sockjs" web socket server', async () => { - const compiler = webpack(sockjsConfig); + const compiler = rspack(sockjsConfig); const devServerOptions = { port, client: { @@ -501,7 +501,7 @@ describe('server and client transport', () => { }); it('should use "ws" transport and "ws" web socket server', async () => { - const compiler = webpack(wsConfig); + const compiler = rspack(wsConfig); const devServerOptions = { port, client: { @@ -541,7 +541,7 @@ describe('server and client transport', () => { }); it('should use custom transport and "sockjs" web socket server', async () => { - const compiler = webpack(customConfig); + const compiler = rspack(customConfig); const devServerOptions = { port, client: { @@ -583,7 +583,7 @@ describe('server and client transport', () => { }); it('should throw an error on invalid path to server transport', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, webSocketServer: { @@ -599,7 +599,7 @@ describe('server and client transport', () => { }); it('should throw an error on invalid path to client transport', async () => { - const compiler = webpack(defaultConfig); + const compiler = rspack(defaultConfig); const devServerOptions = { port, client: { diff --git a/tests/e2e/server.test.js b/tests/e2e/server.test.js index 0a6a6ad..f9f8a9b 100644 --- a/tests/e2e/server.test.js +++ b/tests/e2e/server.test.js @@ -3,7 +3,7 @@ const path = require('node:path'); const fs = require('node:fs'); const request = require('supertest'); const spdy = require('spdy'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/static-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -33,7 +33,7 @@ describe('server option', () => { describe('http', () => { beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -93,7 +93,7 @@ describe('server option', () => { describe('custom-http', () => { beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -153,7 +153,7 @@ describe('server option', () => { describe('https', () => { beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -213,7 +213,7 @@ describe('server option', () => { describe('spdy', () => { beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -283,7 +283,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -366,7 +366,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -457,7 +457,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -546,7 +546,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -644,7 +644,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -719,7 +719,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -798,7 +798,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -871,7 +871,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -954,7 +954,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -1045,7 +1045,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -1141,7 +1141,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -1223,7 +1223,7 @@ describe('server option', () => { let req; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(https, 'createServer'); @@ -1289,7 +1289,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(spdy, 'createServer'); @@ -1370,7 +1370,7 @@ describe('server option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); createServerSpy = rs.spyOn(customHTTP, 'createServer'); diff --git a/tests/e2e/setup-exit-signals.test.js b/tests/e2e/setup-exit-signals.test.js index 71304b4..6a8177b 100644 --- a/tests/e2e/setup-exit-signals.test.js +++ b/tests/e2e/setup-exit-signals.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/simple-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -21,7 +21,7 @@ describe('setupExitSignals option', () => { const signals = ['SIGINT', 'SIGTERM']; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { diff --git a/tests/e2e/setup-middlewares.test.js b/tests/e2e/setup-middlewares.test.js index 5b027e8..1e87084 100644 --- a/tests/e2e/setup-middlewares.test.js +++ b/tests/e2e/setup-middlewares.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -13,7 +13,7 @@ describe('setupMiddlewares option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { setupMiddlewares: (middlewares, devServer) => { diff --git a/tests/e2e/static-directory.test.js b/tests/e2e/static-directory.test.js index 51aac34..212002c 100644 --- a/tests/e2e/static-directory.test.js +++ b/tests/e2e/static-directory.test.js @@ -1,6 +1,6 @@ const path = require('node:path'); const fs = require('node:fs'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const testServer = require('../helpers/test-server'); const config = require('../fixtures/static-config/webpack.config'); @@ -23,7 +23,7 @@ describe('static.directory option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -143,7 +143,7 @@ describe('static.directory option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -228,7 +228,7 @@ describe('static.directory option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -316,7 +316,7 @@ describe('static.directory option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -403,7 +403,7 @@ describe('static.directory option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -612,7 +612,7 @@ describe('static.directory option', () => { cwdSpy = rs .spyOn(process, 'cwd') .mockImplementation(() => path.resolve(staticDirectory)); - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -675,7 +675,7 @@ describe('static.directory option', () => { // the PWD here, and test if /other.html in our "fake" PWD really is not requested. rs.spyOn(process, 'cwd').mockImplementation(() => publicDirectory); - compiler = webpack(config); + compiler = rspack(config); server = new Server( { diff --git a/tests/e2e/static-public-path.test.js b/tests/e2e/static-public-path.test.js index 6ba3612..d1e80f2 100644 --- a/tests/e2e/static-public-path.test.js +++ b/tests/e2e/static-public-path.test.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/static-config/webpack.config'); const port = require('../helpers/ports-map')['static-public-path-option']; @@ -21,7 +21,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -112,7 +112,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -204,7 +204,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -296,7 +296,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -388,7 +388,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -489,7 +489,7 @@ describe('static.publicPath option', () => { .spyOn(process, 'cwd') .mockImplementation(() => staticDirectory); - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -553,7 +553,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -618,7 +618,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -829,7 +829,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -954,7 +954,7 @@ describe('static.publicPath option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { diff --git a/tests/e2e/stats.test.js b/tests/e2e/stats.test.js index 1745d95..52c984c 100644 --- a/tests/e2e/stats.test.js +++ b/tests/e2e/stats.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const HTMLGeneratorPlugin = require('../helpers/html-generator-plugin'); @@ -84,7 +84,7 @@ describe('stats', () => { // }, ]; - if (webpack.version.startsWith('5')) { + if (rspack.version.startsWith('5')) { cases.push({ title: 'should work and respect the "ignoreWarnings" option', webpackOptions: { @@ -110,7 +110,7 @@ describe('stats', () => { for (const testCase of cases) { it(testCase.title, async () => { - const compiler = webpack({ ...config, ...testCase.webpackOptions }); + const compiler = rspack({ ...config, ...testCase.webpackOptions }); const devServerOptions = { port, }; diff --git a/tests/e2e/target.test.js b/tests/e2e/target.test.js index 1ffb284..0d242d5 100644 --- a/tests/e2e/target.test.js +++ b/tests/e2e/target.test.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -29,7 +29,7 @@ describe('target', () => { for (const target of targets) { it(`should work using "${target}" target`, async () => { - const compiler = webpack({ + const compiler = rspack({ ...config, target, ...(target === false || target === 'es5' @@ -92,7 +92,7 @@ describe('target', () => { } it('should work using multi compiler mode with `web` and `webworker` targets', async () => { - const compiler = webpack(workerConfig); + const compiler = rspack(workerConfig); const server = new Server({ port }, compiler); await server.start(); @@ -130,7 +130,7 @@ describe('target', () => { }); it('should work using multi compiler mode with `web` and `webworker` targets with `devServer: false`', async () => { - const compiler = webpack(workerConfigDevServerFalse); + const compiler = rspack(workerConfigDevServerFalse); const server = new Server( { port, diff --git a/tests/e2e/watch-files.test.js b/tests/e2e/watch-files.test.js index 6f6a27c..7fefc44 100644 --- a/tests/e2e/watch-files.test.js +++ b/tests/e2e/watch-files.test.js @@ -1,7 +1,7 @@ const path = require('node:path'); const chokidar = require('chokidar'); const fs = require('node:fs'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/watch-files-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -23,7 +23,7 @@ describe('watchFiles option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -94,7 +94,7 @@ describe('watchFiles option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -165,7 +165,7 @@ describe('watchFiles option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -242,7 +242,7 @@ describe('watchFiles option', () => { // ignore } - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -317,7 +317,7 @@ describe('watchFiles option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -389,7 +389,7 @@ describe('watchFiles option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -470,7 +470,7 @@ describe('watchFiles option', () => { let consoleMessages; beforeEach(async () => { - compiler = webpack(config); + compiler = rspack(config); server = new Server( { @@ -609,7 +609,7 @@ describe('watchFiles option', () => { beforeEach(async () => { chokidarMock.mockClear(); - compiler = webpack(config); + compiler = rspack(config); server = new Server( { diff --git a/tests/e2e/web-socket-communication.test.js b/tests/e2e/web-socket-communication.test.js index 3443109..3b8a0d0 100644 --- a/tests/e2e/web-socket-communication.test.js +++ b/tests/e2e/web-socket-communication.test.js @@ -1,5 +1,5 @@ const WebSocket = require('ws'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const WebsocketServer = require('../../dist/servers/WebsocketServer'); const config = require('../fixtures/client-config/webpack.config'); @@ -15,7 +15,7 @@ describe('web socket communication', () => { it(`should work and close web socket client connection when web socket server closed ("${websocketServer}")`, async () => { WebsocketServer.heartbeatInterval = 100; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, webSocketServer: websocketServer, @@ -63,7 +63,7 @@ describe('web socket communication', () => { it(`should work and terminate client that is not alive ("${websocketServer}")`, async () => { WebsocketServer.heartbeatInterval = 100; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, webSocketServer: websocketServer, @@ -111,7 +111,7 @@ describe('web socket communication', () => { it(`should work and reconnect when the connection is lost ("${websocketServer}")`, async () => { WebsocketServer.heartbeatInterval = 100; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, webSocketServer: websocketServer, @@ -159,7 +159,7 @@ describe('web socket communication', () => { it(`should work and do heartbeat using ("ws" web socket server)`, async () => { WebsocketServer.heartbeatInterval = 100; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { port, webSocketServer: 'ws', diff --git a/tests/e2e/web-socket-server-url.test.js b/tests/e2e/web-socket-server-url.test.js index a4adedd..c2efcbf 100644 --- a/tests/e2e/web-socket-server-url.test.js +++ b/tests/e2e/web-socket-server-url.test.js @@ -1,5 +1,5 @@ const express = require('express'); -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { createProxyMiddleware } = require('http-proxy-middleware'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); @@ -19,7 +19,7 @@ describe('web socket server URL', () => { const proxyHost = devServerHost; const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: devServerPort, @@ -114,7 +114,7 @@ describe('web socket server URL', () => { const proxyHost = Server.internalIPSync('v4'); const proxyPort = port1; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: devServerPort, @@ -210,7 +210,7 @@ describe('web socket server URL', () => { const proxyHost = Server.internalIPSync('v4'); const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -311,7 +311,7 @@ describe('web socket server URL', () => { const proxyHost = Server.internalIPSync('v4'); const proxyPort = port2; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: 'auto', @@ -409,7 +409,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.protocol" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -483,7 +483,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.protocol" option using "auto:" value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -557,7 +557,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.protocol" option using "http:" value and covert to "ws:" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -631,7 +631,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.host" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -705,7 +705,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.host" option using "0.0.0.0" value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -778,7 +778,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.port" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -852,7 +852,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.port" option as string ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -926,7 +926,7 @@ describe('web socket server URL', () => { }); it(`should work with "client.webSocketURL.port" and "webSocketServer.options.port" options as string ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer: { type: webSocketServer, @@ -1009,7 +1009,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.port" option using "0" value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1082,7 +1082,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.pathname" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1156,7 +1156,7 @@ describe('web socket server URL', () => { }); it(`should work with default "/ws" value of the "client.webSocketURL.pathname" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: port1, @@ -1225,7 +1225,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.username" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1298,7 +1298,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.password" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: @@ -1378,7 +1378,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.username" and "client.webSocketURL.password" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1453,7 +1453,7 @@ describe('web socket server URL', () => { }); it(`should work with the custom web socket server "path" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer: { type: webSocketServer, @@ -1528,7 +1528,7 @@ describe('web socket server URL', () => { // Only works for "ws" server it(`should work with the custom web socket server "path" using empty value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer: { type: webSocketServer, @@ -1604,7 +1604,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1683,7 +1683,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending without slash ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1763,7 +1763,7 @@ describe('web socket server URL', () => { // Only works for "ws" server, "sockjs" adds "/" be default, because need do requests like "/custom-ws/info?t=1624462615772" it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending with slash ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1842,7 +1842,7 @@ describe('web socket server URL', () => { // Only works for "ws" server it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" using empty value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -1924,7 +1924,7 @@ describe('web socket server URL', () => { // Only works for "sockjs" server it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "prefix" for compatibility with "sockjs" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -2005,7 +2005,7 @@ describe('web socket server URL', () => { it(`should work when "host" option is IPv4 ("${webSocketServer}")`, async () => { const hostname = Server.internalIPSync('v4'); - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: port1, @@ -2073,7 +2073,7 @@ describe('web socket server URL', () => { it(`should work when "host" option is "local-ip" ("${webSocketServer}")`, async () => { const hostname = Server.internalIPSync('v4'); - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: port1, @@ -2142,7 +2142,7 @@ describe('web socket server URL', () => { it(`should work when "host" option is "local-ipv4" ("${webSocketServer}")`, async () => { const hostname = Server.internalIPSync('v4'); - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: port1, @@ -2210,7 +2210,7 @@ describe('web socket server URL', () => { it(`should work with "server: 'https'" option ("${webSocketServer}")`, async () => { const hostname = '127.0.0.1'; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: port1, @@ -2286,7 +2286,7 @@ describe('web socket server URL', () => { it(`should work with "server: 'spdy'" option ("${webSocketServer}")`, async () => { const hostname = '127.0.0.1'; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: port1, @@ -2363,7 +2363,7 @@ describe('web socket server URL', () => { it(`should work when "port" option is "auto" ("${webSocketServer}")`, async () => { process.env.WEBPACK_DEV_SERVER_BASE_PORT = 50000; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer, port: 'auto', @@ -2435,7 +2435,7 @@ describe('web socket server URL', () => { }); it(`should work with "client.webSocketURL.*" options ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: { @@ -2512,7 +2512,7 @@ describe('web socket server URL', () => { }); it(`should work with the "client.webSocketURL" option as "string" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: `ws://127.0.0.1:${port1}/ws`, @@ -2584,7 +2584,7 @@ describe('web socket server URL', () => { }); it(`should work and throw an error on invalid web socket URL ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: 'unknown://unknown.unknown/unknown', @@ -2631,7 +2631,7 @@ describe('web socket server URL', () => { }); it(`should not work and output disconnect wrong web socket URL ("${webSocketServer}")`, async () => { - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { client: { webSocketURL: 'ws://unknown.unknown/unknown', diff --git a/tests/e2e/web-socket-server.test.js b/tests/e2e/web-socket-server.test.js index 386488e..07bc4d9 100644 --- a/tests/e2e/web-socket-server.test.js +++ b/tests/e2e/web-socket-server.test.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); const config = require('../fixtures/client-config/webpack.config'); const runBrowser = require('../helpers/run-browser'); @@ -9,7 +9,7 @@ describe('web socket server', () => { it('should work allow to disable', async () => { const devServerPort = port; - const compiler = webpack(config); + const compiler = rspack(config); const devServerOptions = { webSocketServer: false, port: devServerPort, diff --git a/tests/helpers/test-server.js b/tests/helpers/test-server.js index a51cf35..e3050b3 100644 --- a/tests/helpers/test-server.js +++ b/tests/helpers/test-server.js @@ -1,4 +1,4 @@ -const webpack = require('@rspack/core'); +const { rspack } = require('@rspack/core'); const { RspackDevServer: Server } = require('@rspack/dev-server'); let server; @@ -14,7 +14,7 @@ function startFullSetup(config, options, done) { options.static = undefined; } - const compiler = webpack(config); + const compiler = rspack(config); server = new Server(options, compiler);