-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: load hexo plugin in the theme's package.json #4771
Conversation
Both the dependencies and devDependencies in the Hexo If you have any other suggestions, please reply here. |
devDependencies are used in the current project for test or build, I think they should be ignored. I am more concerned about peerdependencies. In npm, it should be used to declare the host environment dependency, which is suitable for our plug-ins. However, the actual performance of peerdependencies is different in npm6 (node 14) and npm7. Npm6 will not automatically install peerdependencies dependencies. https://docs.npmjs.com/cli/v7/configuring-npm/package-json#peerdependencies I think we should consider support for peerdependencies in future versions |
I do agree to ignore devDependencies, this will revert #2558 |
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.
Any unit test can be added?
Also, maybe we need a separated Node.js 12 PR before this can be merged. |
PR opened: #4779 |
@stevenjoezhang #4779 is merged. Would you mind rebasing the PR with the latest Also, Would you mind adding a test case for the PR here? Just to make sure |
ce02bcf
to
d363db2
Compare
test/scripts/hexo/load_plugins.js
Outdated
@@ -67,6 +64,10 @@ describe('Load plugins', () => { | |||
|
|||
after(() => fs.rmdir(hexo.base_dir)); | |||
|
|||
afterEach(() => { | |||
createPackageFile('hexo-another-plugin'); |
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.
This line will reset Hexo package.json, to make sure in the following unit tests, hexo-plugin-test
plugin is loaded from theme's package.json, not Hexo package.json
lib/hexo/load_plugins.js
Outdated
ctx.log.error({err}, 'Plugin load failed: %s', magenta(name)); | ||
return Promise.map([ctx.base_dir, ctx.theme_dir], basedir => loadModuleList(ctx, basedir)) | ||
.then(([hexoModuleList, themeModuleList]) => { | ||
return Object.entries(Object.assign(hexoModuleList, themeModuleList)); |
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.
It seems that the plugin defined in the theme will override the one under hexo. The priority in the theme is higher, but the plugin under hexo is added by the user. I think it should have a higher priority.
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.
There are two different considerations:
- The priority in the Hexo
package.json
is higher: If the theme is not maintained, the users will be able to override the outdated plugins defined in themepackage.json
- The priority in the theme is higher: The plugin in Hexo
package.json
may not be compatible with the theme, and the theme could provide a proper version for the users
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.
There are two different considerations:
Yesh, but I prefer the first one. After all, if you use the plugin defined by the theme, you only need to remove the relevant plugins in your package.json. In the second option, I will not be able to cover the plugins inside the theme.
Or take a poll? 😂
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.
👍
What does it do?
Resolve hexojs/hexo-renderer-marked#205 (comment)
See also #4112 #2558 #3890 (comment)
How to test
Screenshots
Pull request tasks