-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(v2): presets #1401
feat(v2): presets #1401
Conversation
} | ||
return new Plugin(options, context); | ||
return new Plugin(context, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the order here as context is a mandatory parameter but options isn't.
Deploy preview for docusaurus-2 ready! Built with commit 0792577 |
Deploy preview for docusaurus-preview ready! Built with commit 0792577 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just need to rebase or solve the conflict.
I have few comments too
throw new Error(`Error loading '${name}' plugin.`); | ||
} | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
Plugin = require(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that we have import-fresh. can we do it here ?
let preset; | ||
if (presetModule && fs.existsSync(presetModule)) { | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
preset = require(presetModule); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use import-fresh ?
Motivation
Allow plugins to be bundled as presets. The idea is simple. Each preset is like a mini config, and exposes an array of plugins. When loading the config, we simply concat all of them together and derive a final list of plugins.
Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Site builds. This change is backward-compatible since the existing tests which aren't using plugins still pass.
I'll add tests for this later (but before merging) after we've agreed on this API.
Related PRs
NA.