diff --git a/package.json b/package.json index e9210cbac7..26f3c7d164 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,8 @@ "packageManager": "pnpm@8.9.2", "pnpm": { "patchedDependencies": { - "unplugin@1.6.0": "patches/unplugin@1.6.0.patch" + "unplugin@1.6.0": "patches/unplugin@1.6.0.patch", + "@rspack/core@1.1.6": "patches/@rspack__core@1.1.6.patch" } } } diff --git a/packages/bundles/scripts/tasks.ts b/packages/bundles/scripts/tasks.ts index 7c4bd4b5b9..22bf478860 100644 --- a/packages/bundles/scripts/tasks.ts +++ b/packages/bundles/scripts/tasks.ts @@ -280,7 +280,8 @@ const tasks = [ replaceDeps(fileContent, webpackDevServerDeps.concat([...commonDeps, '@rspack/core', 'webpack-dev-server'])) .replace(/webpack-dev-server\//g, '@ice/bundles/compiled/webpack-dev-server/') .replace(/@rspack\/core\//g, '@ice/bundles/compiled/@rspack/core/') - .replace(/@rspack\/dev-server\//g, '@ice/bundles/compiled/@rspack/dev-server/'), + .replace(/@rspack\/dev-server\//g, '@ice/bundles/compiled/@rspack/dev-server/') + .replace(/"webpack-dev-server"/g, '"@ice/bundles/compiled/webpack-dev-server"'), ); } else { fs.copyFileSync(sourcePath, targetPath); diff --git a/packages/ice/src/bundler/rspack/index.ts b/packages/ice/src/bundler/rspack/index.ts index abe55751db..17ed686b99 100644 --- a/packages/ice/src/bundler/rspack/index.ts +++ b/packages/ice/src/bundler/rspack/index.ts @@ -22,8 +22,7 @@ async function bundler( let compiler: MultiCompiler; let dataLoaderCompiler: Compiler; let devServer: RspackDevServer; - // const { rspack } = await import('@ice/bundles/esm/rspack.js'); - const { rspack } = await import('@rspack/core'); + const { rspack } = await import('@ice/bundles/esm/rspack.js'); // Override the type of rspack, because of rspack is imported from pre-compiled bundle. const rspackConfigs = await getConfig(context, options, rspack as unknown as typeof Rspack); diff --git a/packages/ice/src/bundler/rspack/start.ts b/packages/ice/src/bundler/rspack/start.ts index 07d61038c2..42da902812 100644 --- a/packages/ice/src/bundler/rspack/start.ts +++ b/packages/ice/src/bundler/rspack/start.ts @@ -55,8 +55,7 @@ const start = async ({ ...hooksAPI, }); - // const { RspackDevServer } = await import('@ice/bundles/esm/dev-server.js'); - const { RspackDevServer } = await import('@rspack/dev-server'); + const { RspackDevServer } = await import('@ice/bundles/esm/dev-server.js'); const devServer = new RspackDevServer(devServerConfig, compiler); compiler.hooks.done.tap('done', async stats => { diff --git a/packages/rspack-config/src/index.ts b/packages/rspack-config/src/index.ts index 09b00a3f92..f2a6216df5 100644 --- a/packages/rspack-config/src/index.ts +++ b/packages/rspack-config/src/index.ts @@ -116,7 +116,7 @@ const getConfig: GetConfig = async (options) => { const absoluteOutputDir = path.isAbsolute(outputDir) ? outputDir : path.join(rootDir, outputDir); const hashKey = hash === true ? 'hash:8' : (hash || ''); // @ts-expect-error ManifestPlugin is an custom plugin. - const { rspack: { DefinePlugin, ProvidePlugin, SwcJsMinimizerRspackPlugin, CopyRspackPlugin, ManifestPlugin } } = await import('@rspack/core'); + const { rspack: { DefinePlugin, ProvidePlugin, SwcJsMinimizerRspackPlugin, CopyRspackPlugin, ManifestPlugin } } = await import('@ice/bundles/esm/rspack.js'); const cssFilename = `css/${hashKey ? `[name]-[${hashKey}].css` : '[name].css'}`; // get compile plugins const compilerWebpackPlugins = getCompilerPlugins(rootDir, { diff --git a/patches/@rspack__core@1.1.6.patch b/patches/@rspack__core@1.1.6.patch new file mode 100644 index 0000000000..5990885a43 --- /dev/null +++ b/patches/@rspack__core@1.1.6.patch @@ -0,0 +1,43 @@ +diff --git a/dist/index.js b/dist/index.js +index 5f652a54af3f404485672f104f0f2da71084a9b3..c64b692f5980ada3f75edc491342a56ec19c9845 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -694,6 +694,7 @@ __export(src_exports, { + Compiler: () => Compiler, + ContextReplacementPlugin: () => ContextReplacementPlugin, + CopyRspackPlugin: () => CopyRspackPlugin, ++ ManifestPlugin: () => ManifestPlugin, + CssExtractRspackPlugin: () => CssExtractRspackPlugin, + DefinePlugin: () => DefinePlugin, + DllPlugin: () => DllPlugin, +@@ -758,6 +759,7 @@ __export(exports_exports, { + Compiler: () => Compiler, + ContextReplacementPlugin: () => ContextReplacementPlugin, + CopyRspackPlugin: () => CopyRspackPlugin, ++ ManifestPlugin: () => ManifestPlugin, + CssExtractRspackPlugin: () => CssExtractRspackPlugin, + DefinePlugin: () => DefinePlugin, + DllPlugin: () => DllPlugin, +@@ -5246,6 +5248,14 @@ var CopyRspackPlugin = create2( + } + ); + ++// ++// Customize builtin plugin. ++var ManifestPlugin = create2( ++ import_binding14.BuiltinPluginName.ManifestPlugin, ++ () => { ++ } ++); ++ + // src/builtin-plugin/css-extract/index.ts + var import_binding16 = require("@rspack/binding"); + var import_node_path3 = require("path"); +@@ -20193,6 +20203,7 @@ module.exports = rspack; + Compiler, + ContextReplacementPlugin, + CopyRspackPlugin, ++ ManifestPlugin, + CssExtractRspackPlugin, + DefinePlugin, + DllPlugin, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9b743670aa..c19ab076ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false patchedDependencies: + '@rspack/core@1.1.6': + hash: doltrtdboiowpkwanirvdprb6a + path: patches/@rspack__core@1.1.6.patch unplugin@1.6.0: hash: z2z7uvjbiarznogeja262ejlha path: patches/unplugin@1.6.0.patch @@ -1434,7 +1437,7 @@ importers: version: 0.5.15(react-refresh@0.14.0)(webpack-dev-server@5.0.4)(webpack@5.88.2) '@rspack/core': specifier: 1.1.6 - version: 1.1.6(@swc/helpers@0.5.1) + version: 1.1.6(patch_hash=doltrtdboiowpkwanirvdprb6a)(@swc/helpers@0.5.1) '@rspack/dev-server': specifier: 1.0.10 version: 1.0.10(@rspack/core@1.1.6)(@types/express@4.17.21)(webpack@5.88.2) @@ -1758,7 +1761,7 @@ importers: devDependencies: '@rspack/core': specifier: 1.1.6 - version: 1.1.6(@swc/helpers@0.5.1) + version: 1.1.6(patch_hash=doltrtdboiowpkwanirvdprb6a)(@swc/helpers@0.5.1) '@rspack/dev-server': specifier: 1.0.10 version: 1.0.10(@rspack/core@1.1.6)(@types/express@4.17.21)(webpack@5.88.2) @@ -2396,7 +2399,7 @@ importers: devDependencies: '@rspack/core': specifier: 1.1.6 - version: 1.1.6(@swc/helpers@0.5.1) + version: 1.1.6(patch_hash=doltrtdboiowpkwanirvdprb6a)(@swc/helpers@0.5.1) packages/runtime: dependencies: @@ -8231,7 +8234,7 @@ packages: '@rspack/binding-win32-x64-msvc': 1.1.6 dev: true - /@rspack/core@1.1.6(@swc/helpers@0.5.1): + /@rspack/core@1.1.6(patch_hash=doltrtdboiowpkwanirvdprb6a)(@swc/helpers@0.5.1): resolution: {integrity: sha512-q0VLphOF5VW2FEG7Vbdq3Ke4I74FbELE/8xmKghSalFtULLZ44SoSz8lyotfMim9GXIRFhDokAaH8WICmPxG+g==} engines: {node: '>=16.0.0'} peerDependencies: @@ -8246,6 +8249,7 @@ packages: '@swc/helpers': 0.5.1 caniuse-lite: 1.0.30001690 dev: true + patched: true /@rspack/dev-server@1.0.10(@rspack/core@1.1.6)(@types/express@4.17.21)(webpack@5.88.2): resolution: {integrity: sha512-iDsEtP0jNHRm4LJxL00QFTlOuqkdxIFxnd69h0KrFadmtxAWiDLIe4vYdZXWF74w4MezsJFx6dB2nUM/Ok8utA==} @@ -8253,7 +8257,7 @@ packages: peerDependencies: '@rspack/core': '*' dependencies: - '@rspack/core': 1.1.6(@swc/helpers@0.5.1) + '@rspack/core': 1.1.6(patch_hash=doltrtdboiowpkwanirvdprb6a)(@swc/helpers@0.5.1) chokidar: 3.6.0 connect-history-api-fallback: 2.0.0 express: 4.21.2