Skip to content

Commit c38d6fe

Browse files
nyqykknyqykk
and
nyqykk
authored
feat: support remove plugin (#677)
* feat: support remove plugin * fix: fix error * chore: add changeset * chore: remove changeset --------- Co-authored-by: nyqykk <nieyan.kk@bytedance.com>
1 parent 6d8ac4d commit c38d6fe

File tree

4 files changed

+5469
-6120
lines changed

4 files changed

+5469
-6120
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"cy:open": "cypress open --config-file=cypress.config.ts",
2121
"cy:run": "cypress run",
2222
"type:check": "tsc -noEmit",
23-
"changeset": "npx changeset",
2423
"reset": "pnpm -r exec -- rm -rf node_modules && pnpm -r exec -- rm -rf dist && rm -rf node_modules",
2524
"setup": "cross-env DISABLE_GARFISH_CHECK_INTERNAL=true pnpm install",
2625
"ls-lint": "ls-lint",

packages/core/src/garfish.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export class Garfish extends EventEmitter2 {
9595
return this;
9696
}
9797

98+
removePlugin(pluginName: string) {
99+
this.hooks.removePlugin(pluginName);
100+
}
101+
98102
run(options: interfaces.Options = {}) {
99103
if (this.running) {
100104
if (__DEV__) {

packages/hooks/src/pluginSystem.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ export class PluginSystem<T extends Record<string, any>> {
4343
const plugin = this.registerPlugins[pluginName];
4444
assert(plugin, `plugin "${pluginName}" is not registered.`);
4545

46-
for (const key in plugin) {
47-
if (key === 'name') continue;
48-
this.lifecycle[key].remove(plugin[key as string]);
46+
for (const key in this.lifecycle) {
47+
const pluginLife = plugin[key as string];
48+
if (pluginLife) {
49+
this.lifecycle[key].remove(pluginLife);
50+
}
4951
}
5052
}
5153

0 commit comments

Comments
 (0)