Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC:hooks > plugins #1217

Closed
sorrycc opened this issue May 30, 2024 · 0 comments · Fixed by #1219
Closed

RFC:hooks > plugins #1217

sorrycc opened this issue May 30, 2024 · 0 comments · Fixed by #1219
Labels

Comments

@sorrycc
Copy link
Member

sorrycc commented May 30, 2024

问题

现状如下。

const { build } = require('@umijs/mako');
await build({
  hooks: {},
  ...
});

调用 @umijs/mako 的方式是这样,基于 hooks 可以通过 js 的方式扩展 mako 内部能力。但缺点是,没有一个官方的 js 层插件编写方式。所以,决定把 hooks 变更为 plugins,plugins = hooks[]。这样,对于用户来说,就可以组织 mako-plugin-foo。

module.exports = {
  name: 'foo',
  load() {},
};

然后这样使用。

const { build } = require('@umijs/mako');
await build({
  plugins: [
    require('mako-plugin-foo'),
  ],
  ...
});

同时上层框架(Smallfish & Bigfish)可以允许其在插件里增删 Mako 插件。

方案

注:在 https://github.com/umijs/toy-rolldown/issues/3 解之后,binding 部分代码会重构,先用简单方案。

1、在 binding 层支持多插件的形式
2、修改上层调用,hooks > plugins
3、修改 api.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant