-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
New API for external plugins #1976
Comments
Looks like the vast majority of plugin users only depends on |
Maybe we can set if (!window.require) {
window.require = function(deps, callback) {
const modules = deps.map(dep => {
if (!(dep in window.require.modules)) {
throw new Error("Invalid dependency name");
}
return window.require.modules[dep];
});
callback(modules);
};
window.require.modules = {};
} // inside modules e.g. pubsubhub
if (window.require && window.require.modules) {
window.require.modules["core/pubsubhub"] = { sub };
} Will probably be longer than this, though... @sidvishnoi, does this idea look okay? |
That's a really cool idea. We won't need to bundle requireJS this way. |
|
I'm not sure we want to support "tapping" into any/all core plugin/hook. How about something like: const myPlugin = {
name: 'plugin-name',
// some custom hook name instead of listening to pubsub events, or, "when": "after-markdown", "when": "before-markdown"
after: 'markdown',
// conf is respecConfig as usual.
// utils is an object of methods as an abstraction over respec internals,
// making us expose as little as required, reducing breaking changes in future.
async run(conf, utils) {
utils.showError(`${conf.unCool} option has invalid value.`)
},
}; This follows pretty much same structure as present ReSpec plugins.
|
It looks promising! Probably needs some experiment by converting existing specs to make sure that we have all required features. |
The current plugin API depends on AMD module system (via requirejs) and exposes internal modules. This blocks #1975 and causes potential breaking changes when any internal functions change.
We may introduce a new API that looks something like webpack one:
@sidvishnoi @marcoscaceres Thoughts?
The text was updated successfully, but these errors were encountered: