vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Cannot access 'DefaultTheme' before initialization #1210

Closed wuchaoxin closed 1 year ago

wuchaoxin commented 1 year ago

MRE: brc-dd/vp-default-theme-bug


Describe the bug

I want to use element-plus.

I refer to the issue 603 and brc-dd/vitepress-element-plus-demo

It works in 1.0.0-alpha.4, but building in 1.0.0-alpha.8 gives an error

build error: ReferenceError: Cannot access 'DefaultTheme' before initialization

Reproduction

In 1.0.0-alpha.8 version,create a file .vitepress\theme\index.js

import DefaultTheme from 'vitepress/theme'
import { install } from 'element-plus'
import 'element-plus/dist/index.css'

export default {
  ...DefaultTheme,
  enhanceApp({ app }) {
    install(app)
  }
}

Expected behavior

No error in building

System Info

System:
    OS: macOS 12.2.1
    CPU: (8) x64 Apple M1
    Memory: 29.13 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.19.1 - ~/.nvm/versions/node/v14.19.1/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 6.14.16 - ~/.nvm/versions/node/v14.19.1/bin/npm
  Browsers:
    Chrome: 104.0.5112.101
    Safari: 15.3

Additional context

No response

Validations

Sepush commented 1 year ago

get the same error when build it works fine on dev

Sepush commented 1 year ago

引入第三方组件库方式建议参考 vitepress-template

didn't use third party lib still get this error

Tyh2001 commented 1 year ago

引入第三方组件库方式建议参考 vitepress-template

Tyh2001 commented 1 year ago

引入第三方组件库方式建议参考 vitepress-template

didn't use third party lib still get this error

有项目地址吗?

Sepush commented 1 year ago

引入第三方组件库方式建议参考 vitepress-template

didn't use third party lib still get this error

有项目地址吗?

you can try to bump up you template to alpha8 I think you will get this error

wuchaoxin commented 1 year ago

引入第三方组件库方式建议参考 vitepress-template

Your project version is 1.0.0-alpha.4, try using 1.0.0-alpha.8

你的项目版本号和描述不一致,请注意看下描述。

Tyh2001 commented 1 year ago

引入第三方组件库方式建议参考 vitepress-template

didn't use third party lib still get this error

有项目地址吗?

you can try to bump up you template to alpha8 I think you will get this error

不,经过我的测试,在 alpha8 版本中,构建会有错误,可以看下: https://github.com/vuejs/vitepress/issues/1209

Sepush commented 1 year ago

引入第三方组件库方式建议参考 vitepress-template

didn't use third party lib still get this error

有项目地址吗?

you can try to bump up you template to alpha8 I think you will get this error

不,经过我的测试,在 alpha8 版本中,构建会有错误,可以看下: #1209

that's why we talk about here

Tyh2001 commented 1 year ago

应该是版本问题 先使用 alpha4 版本比较稳定一些

brc-dd commented 1 year ago

I am not able to reproduce this:

image

Sepush commented 1 year ago

I am not able to reproduce this:

image

https://github.com/Sepush/envd-docs/tree/up try this branch it work fine on dev mode but when I run pnpm docs:buid it will get this error image

wuchaoxin commented 1 year ago

I am not able to reproduce this:

image

This problem seems to be caused by Team Page. It works fine when I comment out Team Page.

Sepush commented 1 year ago

I am not able to reproduce this: image

This problem seems to be caused by Team Page. It works fine when I comment out Team Page.

this also works for me seems this issue couse by VPTeamPage