You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This proposal would allow for plugins to expose a custom API for other plugins to use. It better follows Rollup's already existing plugin communication design compared to #171 so we can follow a more general implementation of Rollup's api. It also adds the ability to create a new instance of plugins (in case one does not already exist), suggested in #173.
Proof of Concept
Define API:
interfaceAPI{presets: Record<string,unknown>}exportconstunplugin=createUnplugin<Options,API>((options)=>{return{name: 'unplugin-auto-import',api: {//...methods and properties exposed for other pluginspresets: {vue: '...',react: '...',}},buildStart(){constpresets=this.api.presets;// Access own API object through context},};});
interfacePluginImport{/** module name or UnpluginInstance */use: string|UnpluginInstance;/** override context key that the imported plugin's api is injected to */as?: string;/** default creates new instance if one does not already exist, otherwise, creation follows boolean value */create?: boolean;/** if plugin is created, the options to pass to plugin */options?: unknown;/** if plugin is created, execute hooks after */orderAfter?: boolean;}
The text was updated successfully, but these errors were encountered:
This proposal would allow for plugins to expose a custom API for other plugins to use. It better follows Rollup's already existing plugin communication design compared to #171 so we can follow a more general implementation of Rollup's api. It also adds the ability to create a new instance of plugins (in case one does not already exist), suggested in #173.
Proof of Concept
Define API:
Use in another plugin:
Plugin import interface:
The text was updated successfully, but these errors were encountered: