\r\n\r\nIt is inevitable to use `document` in `vitepress` many times, but how to avoid the packaging error when` vitepress` uses the server-side rendering method?\r\n\r\nAre there any third-party plug-in recommendations or configuration items?\n\n### Reproduction\n\n```vue\r\n\u003Cscript setup>\r\n console.log(document)\r\n\u003C/script>\r\n```\r\n\r\n\r\n\n\n### Expected behavior\n\nBuild ok\n\n### System Info\n\n```shell\n\"vitepress\": \"^1.0.0-alpha.4\",\r\n\"vue\": \"^3.2.33\"\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.vuejs.org).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2865],{"name":2866,"color":2867},"question","5D5FAE",1120,"vuejs","vitepress","closed","document is not defined","2023-01-21T14:28:51Z","https://github.com/vuejs/vitepress/issues/1120",0.6739964,{"description":2877,"labels":2878,"number":2882,"owner":2869,"repository":2870,"state":2871,"title":2883,"updated_at":2884,"url":2885,"score":2886},"### Describe the bug\n\nI imported a lib which called document APIs. The minimized reproduction:\r\n\r\n```\r\n\u003Cscript>\r\nconst div = document.createElement('div');\r\nconsole.log(div)\r\n\u003C/script>\r\n\r\n# Hello World\r\n```\r\n\r\nIt works in vitepress dev but fails in vitepress build\n\n### Reproduction\n\nhttps://github.com/Jinjiang/reproductions/tree/vitepress-document-20240219\n\n### Expected behavior\n\nWorks as vitepress dev does\n\n### System Info\n\n```Text\n$ npx envinfo --system --npmPackages vitepress --binaries --browsers\r\n\r\n System:\r\n OS: macOS 14.4\r\n CPU: (8) arm64 Apple M1\r\n Memory: 75.17 MB / 8.00 GB\r\n Shell: 5.9 - /bin/zsh\r\n Binaries:\r\n Node: 20.1.0 - ~/.asdf/installs/nodejs/20.1.0/bin/node\r\n Yarn: 1.22.19 - ~/.asdf/shims/yarn\r\n npm: 9.6.4 - ~/.asdf/plugins/nodejs/shims/npm\r\n Browsers:\r\n Safari: 17.4\r\n npmPackages:\r\n vitepress: 1.0.0-rc.43 => 1.0.0-rc.43\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.dev).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2879],{"name":2880,"color":2881},"bug: pending triage","e99695",3583,"document is not defined when vitepress build","2024-02-27T00:05:55Z","https://github.com/vuejs/vitepress/issues/3583",0.67743844,{"description":2888,"labels":2889,"number":2890,"owner":2869,"repository":2870,"state":2871,"title":2891,"updated_at":2892,"url":2893,"score":2894},"### Describe the bug\n\n\r\n\r\n我的组件库是基于element ui 二次封装 正常打包 且在项目内可以使用\r\n在使用vitepress 开发文档时 运行无任何问题,能正常显示组件\r\n可是打包一堆问题\r\n\n\n### Reproduction\n\n使用element 封装 打包 嵌入vitepress\r\n\n\n### Expected behavior\n\n预期打包成功\n\n### System Info\n\n```shell\nTypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension \".css\" for /Users/allen/Desktop/ode/turborepo/node_modules/.pnpm/registry.npmmirror.com+element-plus@2.2.17_vue@3.2.40/node_modules/element-plus/theme-chalk/el-cascader.css\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.vuejs.org).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[],1465,"vitepress 打包错误","2023-01-21T14:23:01Z","https://github.com/vuejs/vitepress/issues/1465",0.6838701,{"description":2896,"labels":2897,"number":2899,"owner":2869,"repository":2870,"state":2871,"title":2900,"updated_at":2901,"url":2902,"score":2903},"### Describe the bug\n\nI run script that is 'vitepress dev' and the broswer told me that __VP_HASH_MAP__ is not defined\r\nand I couldnt use it in dev mode.\r\nBut when I build and serve it ,it seems correct.\n\n### Reproduction\n\n# enviroments\r\n- vitepress 0.20.10 \r\n- node 14.17.4\r\n\r\n\r\nI run script that is 'vitepress dev' and the broswer told me that __VP_HASH_MAP__ is not defined\r\nand I couldnt use it in dev mode.\r\nBut when I build and serve it ,it seems correct.\n\n### Expected behavior\n\nuse dev correctly\n\n### System Info\n\n```shell\nSystem:\r\n OS: Windows 10 10.0.19042\r\n CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz\r\n Memory: 9.56 GB / 23.86 GB\r\n Binaries:\r\n Node: 16.13.1 - ~\\scoop\\apps\\nvm\\current\\nodejs\\nodejs\\node.EXE\r\n Yarn: 1.22.17 - ~\\scoop\\apps\\yarn\\current\\bin\\yarn.CMD\r\n npm: 8.1.2 - ~\\scoop\\apps\\nvm\\current\\nodejs\\nodejs\\npm.CMD\r\n Browsers:\r\n Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.62)\r\n Internet Explorer: 11.0.19041.1202\r\n npmPackages:\r\n vitepress: ^0.20.10 => 0.20.10\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/coc)\n- [X] Read the [docs](https://vitepress.vuejs.org/).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2898],{"name":2880,"color":2881},485,"__VP_HASH_MAP__ is not defined","2023-01-21T16:20:14Z","https://github.com/vuejs/vitepress/issues/485",0.6883051,{"description":2905,"labels":2906,"number":2908,"owner":2869,"repository":2870,"state":2871,"title":2909,"updated_at":2910,"url":2911,"score":2912},"### Describe the bug\n\nI am writing the package of `controllable-animate` and preparing write doc for this package \r\n\r\nwhen I run npm run docs:dev it works just fine\r\nbut when I run npm run docs:build it failed\r\nand shows an error message:\r\n```sh\r\n✓ building client + server bundles...\r\nbuild error:\r\n ReferenceError: document is not defined\r\n at file:///Users/songwufan/Desktop/newPro/controllable-animate/docs/main/.vitepress/.temp/app.js:4380:3\r\n at ModuleJob.run (internal/modules/esm/module_job.js:183:25)\r\n at async Loader.import (internal/modules/esm/loader.js:178:24)\r\n at async build (file:///Users/songwufan/Desktop/newPro/controllable-animate/node_modules/.pnpm/vitepress@1.0.0-alpha.29_tbpndr44ulefs3hehwpi2mkf2y/node_modules/vitepress/dist/node/serve-fcdc8868.js:42002:24)\r\n```\r\nreproduce steps: \r\nFirst: I try to use `docuement` in vue directive like this: \r\n```ts\r\nif (typeof window !== undefined) {\r\n root = document.documentElement || document.body\r\n}\r\n```\r\nSecond: I use this package in my code :main/.vitepress/theme/index.ts\r\n```ts\r\nimport {\r\n vcontrollableanimate,\r\n} from 'controllable-animate'\r\nexport default {\r\n ...DefaultTheme,\r\n enhanceApp({ app }) {\r\n // app.Plugin\r\n app.directive('controllable-animate', vcontrollableanimate)\r\n },\r\n}\r\n```\n\n### Reproduction\n\nnone\n\n### Expected behavior\n\nIt should work in dev and build mode.\n\n### System Info\n\n```shell\nSystem:\r\n OS: macOS 12.6\r\n CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz\r\n Memory: 103.34 MB / 8.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node\r\n Yarn: 1.22.17 - /usr/local/bin/yarn\r\n npm: 6.14.16 - ~/.nvm/versions/node/v14.19.0/bin/npm\r\n Watchman: 4.9.0 - /usr/local/bin/watchman\r\n Browsers:\r\n Chrome: 107.0.5304.110\r\n Chrome Canary: 110.0.5434.0\r\n Firefox: 97.0.2\r\n Firefox Developer Edition: 106.0\r\n Safari: 15.6.1\r\n npmPackages:\r\n vitepress: 1.0.0-alpha.29 => 1.0.0-alpha.29\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.vuejs.org).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2907],{"name":2880,"color":2881},1638,"Can't build vitepress when I use npm package","2023-01-21T14:20:37Z","https://github.com/vuejs/vitepress/issues/1638",0.6888695,{"description":2914,"labels":2915,"number":2917,"owner":2869,"repository":2870,"state":2871,"title":2918,"updated_at":2919,"url":2920,"score":2921},"**Describe the bug**\r\n\r\nWhen using vitepress with vue v3.1, we are now running into a compilation error as some vitepress components are using `\u003Ctemplate functional>`\r\n\r\nThe related change in vue-next is https://github.com/vuejs/vue-next/commit/467076361a730b7925c88c572793c78637e05ca7\r\n\r\n**To Reproduce**\r\n\r\nSee [this PR in VTU](https://github.com/vuejs/vue-test-utils-next/pull/654) (that uses vitepress for the docs) that fails because of vitepress and vue 3.1 \r\n\r\nIt can easily be reproduced in the current codebase by bumping vue to v3.1 and run `yarn docs-build`:\r\n\r\n```\r\nSyntaxError: \u003Ctemplate functional> is no longer supported in Vue 3, since functional components no longer have significant performance difference from stateful ones. Just use a normal \u003Ctemplate> instead.\r\n at /Users/ced-pro/Code/vue/vitepress/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:196:37\r\n at Array.forEach (\u003Canonymous>)\r\n at parse (/Users/ced-pro/Code/vue/vitepress/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:182:18)\r\n at createDescriptor (/Users/ced-pro/Code/vue/vitepress/node_modules/@vitejs/plugin-vue/dist/index.js:4048:62)\r\n at transformMain (/Users/ced-pro/Code/vue/vitepress/node_modules/@vitejs/plugin-vue/dist/index.js:4344:32)\r\n at Object.transform (/Users/ced-pro/Code/vue/vitepress/node_modules/@vitejs/plugin-vue/dist/index.js:4665:16)\r\n at /Users/ced-pro/Code/vue/vitepress/node_modules/rollup/dist/shared/rollup.js:19875:25 {\r\n loc: {\r\n start: { column: 11, line: 1, offset: 10 },\r\n end: { column: 21, line: 1, offset: 20 },\r\n source: 'functional'\r\n },\r\n id: '/Users/ced-pro/Code/vue/vitepress/dist/client/theme-default/com\r\n```\r\n\r\n**Expected behavior**\r\nvitepress should properly compile with Vue v3.1\r\n\r\n**System Info**\r\n- vitepress version: 0.14\r\n- vite version: 2.3.4\r\n- Node version: 14.17\r\n- OS version: macOS\r\n",[2916],{"name":2880,"color":2881},311,"Functional templates errors with vue v3.1","2023-01-21T16:22:22Z","https://github.com/vuejs/vitepress/issues/311",0.69106454,{"description":2923,"labels":2924,"number":1057,"owner":2869,"repository":2870,"state":2871,"title":2926,"updated_at":2927,"url":2928,"score":2929},"\u003C!--\r\nNOTE:\r\nVitePress is still WIP, and it is not compatible with VuePress.\r\nPlease do not open issue about default theme missing features or something doesn't work like VuePress.\r\n-->\r\n\r\n**Describe the bug**\r\nWhen use a `script` tag without `export` statement in `index.md`, an exception has occurred.\r\n\r\n`ReferenceError: __script is not defined`\r\n**To Reproduce**\r\n\r\nindex.md\r\n```js\r\n# Hello VuePress!\r\n\r\n## title\r\n\r\n\u003Cscript>\r\nconsole.log('test');\r\n// export default {}\r\n\u003C/script>\r\n```\r\n\r\n**Expected behavior**\r\nNo js error.\r\n\r\n**System Info**\r\n- vitepress version: 0.4.1\r\n",[2925],{"name":2880,"color":2881},"ReferenceError: __script is not defined","2023-01-21T16:25:38Z","https://github.com/vuejs/vitepress/issues/53",0.69180393,{"description":2931,"labels":2932,"number":2934,"owner":2869,"repository":2870,"state":2871,"title":2935,"updated_at":2936,"url":2937,"score":2938},"### Describe the bug\n\nvitepress dependency error\n\n### Reproduction\n\nErrors reported during project startup and packaging\n\n### Expected behavior\n\nproject can start and package normally\n\n### System Info\n\n```shell\nError: 'defineEmit' is not exported by node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js, imported by node_modules/vitepress/dist/client/theme-default/components/NavBar.vue?vue&type=script&setup=true&lang.ts\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/coc)\n- [X] Read the [docs](https://vitepress.vuejs.org/).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2933],{"name":2880,"color":2881},357,"Project not working","2023-01-21T16:22:15Z","https://github.com/vuejs/vitepress/issues/357",0.69298446,{"description":2940,"labels":2941,"number":2948,"owner":2869,"repository":2870,"state":2871,"title":2949,"updated_at":2950,"url":2951,"score":2952},"### Describe the bug\n\nWhile running for production : npm run docs:build, then \"SyntaxError: The requested module 'vue' does not provide an export named 'computed'\" occurred.\n\n### Reproduction\n\nTry to build it for production : npm run docs:build\r\n\"devDependencies\": {\r\n \"vitepress\": \"^1.0.0-beta.5\"\r\n }\r\n\n\n### Expected behavior\n\nIt should build the docs for production.\n\n### System Info\n\n```sh\nWindows Machine,\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.dev).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2942,2945],{"name":2943,"color":2944},"build","377ba8",{"name":2946,"color":2947},"has-workaround","1B4515",2593,"While building for production vitepress gives syntax error","2023-09-02T00:04:06Z","https://github.com/vuejs/vitepress/issues/2593",0.6940195,{"description":2954,"labels":2955,"number":2960,"owner":2869,"repository":2870,"state":2871,"title":2961,"updated_at":2962,"url":2963,"score":2964},"### Describe the bug\r\n\r\nwhen run `pnpm dev`, it show error in below file:\r\n\r\n```\r\n.pnpm/ant-design-vue@3.2.15_vue@3.2.45/node_modules/ant-design-vue/es/notification/index.js?v=6778305c\r\n```\r\n\r\nI have console.log `_regeneratorRuntime `, it is normal in original file, and has correct value,but it's `undefined` in that file which is generate by vitepress\r\n\u003Cimg width=\"1335\" alt=\"image\" src=\"https://user-images.githubusercontent.com/20320396/207789183-9f80766b-309b-4a1f-8148-c99de6847ecc.png\">\r\n\r\n\r\n### Reproduction\r\n- vite config\r\n```\r\nserver: {\r\n // target: 'webworker',\r\n host: true,\r\n port: 3001,\r\n fs: {\r\n // for when developing with locally linked theme\r\n allow: ['../..']\r\n }\r\n },\r\n optimizeDeps: {\r\n include: ['sinobest-functions']\r\n },\r\n build: {\r\n // minify: 'terser',\r\n chunkSizeWarningLimit: Infinity\r\n },\r\n json: {\r\n stringify: true\r\n },\r\n ssr: {\r\n format: 'cjs',\r\n noExternal: ['ant-design-vue', '@ant-design/icons-vue', 'sinobest-functions']\r\n },\r\n legacy: {\r\n buildSsrCjsExternalHeuristics: true\r\n },\r\n plugins: [\r\n vueJsx(),\r\n viteCommonjs(),\r\n vitePluginRequire({\r\n fileRegex: /(.js?|.jsx?|.tsx?|.vue)$/\r\n }),\r\n SearchPlugin({\r\n tokenize: 'full'\r\n })\r\n ],\r\n css: {\r\n preprocessorOptions: {\r\n less: {\r\n javascriptEnabled: true\r\n }\r\n }\r\n }\r\n },\r\n\r\n vue: {\r\n reactivityTransform: true\r\n }\r\n```\r\n\r\npnpm run dev\r\n\r\n### Expected behavior\r\n\r\nno error\r\n\r\n### System Info\r\n\r\n```shell\r\n\"dependencies\": {\r\n \"@ant-design/icons-vue\": \"^6.1.0\",\r\n \"ant-design-vue\": \"^3.2.10\",\r\n \"isobject\": \"3.0.1\",\r\n \"sinogear-vue\": \"2.8.0-vite-beta.1\",\r\n \"sinobest-functions\": \"~2.7.0\",\r\n \"@vue/theme\": \"^1.2.2\",\r\n \"vue\": \"^3.2.37\",\r\n \"vitepress\": \"^1.0.0-alpha.31\",\r\n \"vitepress-plugin-search\": \"1.0.4-alpha.15\",\r\n \"vitepress-theme-demoblock\": \"^2.0.0\"\r\n },\r\n \"devDependencies\": {\r\n \"@originjs/vite-plugin-commonjs\": \"^1.0.3\",\r\n \"@vitejs/plugin-vue-jsx\": \"^2.1.1\",\r\n \"cross-env\": \"^7.0.3\",\r\n \"less\": \"^4.1.2\",\r\n \"prettier\": \"^2.7.1\",\r\n \"terser\": \"^5.16.1\",\r\n \"vite-plugin-require\": \"^1.1.10\"\r\n },\r\n \"pnpm\": {\r\n \"peerDependencyRules\": {\r\n \"ignoreMissing\": [\r\n \"@algolia/client-search\"\r\n ]\r\n }\r\n }\r\n```\r\n\r\n\r\n### Additional context\r\n\r\n_No response_\r\n\r\n### Validations\r\n\r\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\r\n- [X] Read the [docs](https://vitepress.vuejs.org).\r\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2956,2957],{"name":2880,"color":2881},{"name":2958,"color":2959},"stale","ededed",1696,"Dev Error: _regeneratorRuntime.mark is not a function","2023-08-12T00:04:34Z","https://github.com/vuejs/vitepress/issues/1696",0.69492537,["Reactive",2966],{},["Set"],["ShallowReactive",2969],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fkWNBEh1EHZjTM0OA7LZBb7BuSkPi2YQaP0rm2DS4J04":-1},"/vuejs/vitepress/2531"]