File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
packages/@vuepress/core/lib/prepare Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -54,14 +54,17 @@ module.exports = function loadTheme (ctx) {
5454function normalizeThemePath ( resolved ) {
5555 const { entry, name, fromDep } = resolved
5656 if ( fromDep ) {
57- const pkgPath = require . resolve ( name )
58- let packageRootDir = parse ( pkgPath ) . dir
59- // For those cases that "main" field was set to non-index file
60- // e.g. `layouts/Layout.vue`
61- while ( ! fs . existsSync ( `${ packageRootDir } /package.json` ) ) {
62- packageRootDir = resolve ( packageRootDir , '..' )
57+ const packageRoot = require . resolve ( `${ name } /package.json` )
58+ const { main } = require ( packageRoot )
59+ if ( main . endsWith ( '.vue' ) ) {
60+ // For those cases that "main" field is set to an non-index file
61+ // e.g. `layouts/Layout.vue`
62+ return packageRoot
63+ } else {
64+ // For those cases that "index.js" is not at package root
65+ // e.g. `lib/index.js` (#1362)
66+ return parse ( require . resolve ( name ) ) . dir
6367 }
64- return packageRootDir
6568 } else if ( entry . endsWith ( '.js' ) || entry . endsWith ( '.vue' ) ) {
6669 return parse ( entry ) . dir
6770 } else {
You can’t perform that action at this time.
0 commit comments