vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.18k stars 925 forks source link

Wrong way to import layout in docs for extending defaulkt theme[Bug report] #1300

Closed ottopaulsen closed 1 year ago

ottopaulsen commented 1 year ago

Description

In docs: Dafault Theme Reference doc for extending the theme, the described way of importing the Layout component seems not to work any more.

Wrong code:

import ParentLayout from '@vuepress/theme-default/layouts/Layout.vue'

Correct code:

import { Layout as ParentLayout } from "@vuepress/theme-default";

I may be wrong, but this was my discovery when updating from beta.51 to beta.61 today.

Reproduction

See docs

Used Package Manager

npm

System Info

System:
    OS: macOS 13.2.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 1.67 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
  Utilities:
    Git: 2.37.1 - /usr/bin/git
  Browsers:
    Chrome: 112.0.5615.49
    Edge: Not Found
    Firefox: 107.0.1
    Safari: 16.3
  npmPackages:
    @vuepress/bundler-vite: ^2.0.0-beta.61 => 2.0.0-beta.61 
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli: 2.0.0-beta.61 => 2.0.0-beta.61 
    @vuepress/client: 2.0.0-beta.61 => 2.0.0-beta.61 (2.0.0-beta.50-pre.1)
    @vuepress/core:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/markdown:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-active-header-links:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-back-to-top:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-container: 2.0.0-beta.61 => 2.0.0-beta.61 (2.0.0-beta.50-pre.1)
    @vuepress/plugin-docsearch: Not Found
    @vuepress/plugin-external-link-icon:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-git:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-nprogress:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-palette:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-prismjs: 2.0.0-beta.61 => 2.0.0-beta.61 (2.0.0-beta.50-pre.1)
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: 2.0.0-beta.61 => 2.0.0-beta.61 
    @vuepress/plugin-search: 2.0.0-beta.61 => 2.0.0-beta.61 
    @vuepress/plugin-shiki: 2.0.0-beta.61 => 2.0.0-beta.61 
    @vuepress/plugin-theme-data: ^2.0.0-beta.61 => 2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/plugin-toc: Not Found
    @vuepress/shared:  2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/theme-default: ^2.0.0-beta.61 => 2.0.0-beta.50-pre.1 (2.0.0-beta.61)
    @vuepress/utils: 2.0.0-beta.61 => 2.0.0-beta.61 (2.0.0-beta.50-pre.1)
    vue: ^3.2.47 => 3.2.47 
    vue-loader: Not Found
    vue-router: ^4.1.6 => 4.1.6 
    vuepress: 2.0.0-beta.61 => 2.0.0-beta.61 
    vuepress-vite:  2.0.0-beta.61 
    vuepress-webpack: Not Found
github-actions[bot] commented 1 year ago

Hello @ottopaulsen. Please provide a minimal reproduction using a GitHub repository or v2.vuepress.vuejs.org/new. Issues marked with need reproduction will be closed if they have no activity within 7 days.

Mister-Hope commented 1 year ago

Why's it not working? https://github.com/vuepress/vuepress-next/blob/main/ecosystem/theme-default/package.json#L26-L26

ottopaulsen commented 1 year ago

I have to mention that I also changed from Webpack to Vite when I got this problem. Now I got other problems with Vite, so I changed back to Webpack again. It looks like one import works for Webpack and the other for Vite.

Sorry, I am not able to make a reproduction, so if you think this is not a problem, go ahead and close this issue.

Mister-Hope commented 1 year ago

This demo is using default theme extending, and we have

https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/demo/comment2/src/.vuepress/layouts/Layout.vue#L10

CI containing both webpack and vite test, so unless you give a reproduction, I will treat this as your own issue with mistaken config or other reason.

Mister-Hope commented 1 year ago

Closing as no response.