Skip to content

Commit

Permalink
fix: update bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Jan 7, 2025
1 parent 0bc75ef commit 7132b2e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 12 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"packageManager": "[email protected]",
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
"[email protected]": "patches/[email protected]",
"@rspack/[email protected]": "patches/@[email protected]"
}
}
}
3 changes: 2 additions & 1 deletion packages/bundles/scripts/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions packages/ice/src/bundler/rspack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions packages/ice/src/bundler/rspack/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
43 changes: 43 additions & 0 deletions patches/@[email protected]
Original file line number Diff line number Diff line change
@@ -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,
14 changes: 9 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7132b2e

Please sign in to comment.