Skip to content

Commit dde3e7d

Browse files
committed
fix: build error
1 parent d9370c5 commit dde3e7d

File tree

5 files changed

+190
-160
lines changed

5 files changed

+190
-160
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
"typescript": "^5.8.3"
1818
},
1919
"peerDependencies": {
20-
"tsup": "8.5.0",
21-
"@rsbuild/core": "1.4.9",
20+
"@rsbuild/core": "1.4.10",
2221
"typescript": "5.8.3"
2322
},
2423
"packageManager": "pnpm@10.13.1"

packages/rsbuild-plugin-web-extension/src/index.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { type RsbuildPlugin, rspack } from "@rsbuild/core";
2-
import ManifestParser from "./manifest/parser.js";
1+
import { type RsbuildPlugin } from "@rsbuild/core";
2+
import { makeManifest } from "./manifest/make-manifest.js";
33

44
interface Options {
55
manifest: chrome.runtime.ManifestV3;
@@ -80,28 +80,8 @@ export const pluginWebExtension = ({ manifest }: Options): RsbuildPlugin => ({
8080
});
8181
});
8282

83-
api.onAfterCreateCompiler(({ compiler }) => {
84-
if (!(compiler instanceof rspack.Compiler)) {
85-
return;
86-
}
87-
88-
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
89-
compilation.hooks.processAssets.tap(
90-
{
91-
name: pluginName,
92-
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
93-
},
94-
() => {
95-
const content = ManifestParser.convertManifestToString(manifest);
96-
97-
const { RawSource } = compiler.webpack.sources;
98-
99-
const source = new RawSource(content);
100-
101-
compilation.emitAsset("manifest.json", source);
102-
}
103-
);
104-
});
83+
api.onAfterBuild(() => {
84+
makeManifest(manifest, api.context.distPath);
10585
});
10686
},
10787
});

packages/rsbuild-plugin-web-extension/src/manifest/make-manifest.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as fs from "node:fs";
22
import { resolve } from "node:path";
3-
import { logger } from "@rsbuild/core";
43
import ManifestParser from "./parser.js";
54

65
export const makeManifest = (
@@ -18,5 +17,5 @@ export const makeManifest = (
1817
ManifestParser.convertManifestToString(manifest)
1918
);
2019

21-
logger.log("Manifest file created");
20+
console.log("Manifest file created");
2221
};

0 commit comments

Comments
 (0)