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

feat(v2): presets #1401

Merged
merged 4 commits into from
Apr 27, 2019
Merged

feat(v2): presets #1401

merged 4 commits into from
Apr 27, 2019

Conversation

yangshun
Copy link
Contributor

@yangshun yangshun commented Apr 27, 2019

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.

@yangshun yangshun requested a review from endiliey as a code owner April 27, 2019 05:43
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 27, 2019
}
return new Plugin(options, context);
return new Plugin(context, options);
Copy link
Contributor Author

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.

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Apr 27, 2019

Deploy preview for docusaurus-2 ready!

Built with commit 0792577

https://deploy-preview-1401--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Apr 27, 2019

Deploy preview for docusaurus-preview ready!

Built with commit 0792577

https://deploy-preview-1401--docusaurus-preview.netlify.com

Copy link
Contributor

@endiliey endiliey left a 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);
Copy link
Contributor

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);
Copy link
Contributor

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 ?

@yangshun yangshun merged commit 3619865 into master Apr 27, 2019
@yangshun yangshun deleted the preset branch April 27, 2019 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants