\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.",[2897],{"name":2898,"color":2899},"question","5D5FAE",1120,"document is not defined","2023-01-21T14:28:51Z","https://github.com/vuejs/vitepress/issues/1120",0.64198685,{"description":2906,"labels":2907,"number":2912,"owner":2871,"repository":2872,"state":2873,"title":2913,"updated_at":2914,"url":2915,"score":2916},"### Describe the bug\r\n\r\nIt's unclear to me how these two differ, my understanding was that vitepress also calls vite build under the hood.\r\n\r\nHowever, I have a scenario where running `npm run docs:build` (`\"docs:build\": \"vitepress build`) results in\r\n\r\n```\r\n✓ building client + server bundles...\r\nbuild error:\r\nfile:///D:/git/some/path/docs/.vitepress/.temp/app.js:10\r\nimport { v5 } from \"uuid\";\r\n ^^\r\nSyntaxError: Named export 'v5' not found. The requested module 'uuid' is a CommonJS module, which may not support all module.exports as named exports.\r\nCommonJS modules can always be imported via the default export, for example using:\r\n\r\nimport pkg from 'uuid';\r\nconst { v5 } = pkg;\r\n\r\n at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)\r\n at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)\r\n```\r\n\r\nwhile running `npm run build` (`\"build\": \"vite build\"`) works perfectly fine.\r\n\r\nThese both use the same vite config (once in `vite.config.js` and once in the `vite:` property in vitepress' `config.js`, the latter with the `vite.config.js` deleted).\r\n\r\nThe module uuid (9.0.0) is not a CommonJS module, and building without vitepress works fine, so it looks like however `vitepress build` starts the build detects that incorrectly?\r\npackage.json of the uuid package: https://github.com/uuidjs/uuid/blob/4de23a6030e65ac72b3b015680f08e7e292681ed/package.json#L25\r\n\r\nTo be honest I'm not sure if this is a vitepress bug or even lower-level, at this point I'm mostly looking for guidance as to what vitepress build does different to vite build that could result in such differences.\r\n\r\nThanks!\r\n\r\n### Reproduction\r\n\r\nhttps://stackblitz.com/edit/vite-qpoze8?file=package.json\r\n\r\nRun `npm run docs:build` if it doesn't run automatically.\r\n\r\npackage.json of the `postprocessing` package used for repro purposes here:\r\nhttps://github.com/pmndrs/postprocessing/blob/3e6ea9d8fddd2ca2d269e2182752f8199b8248af/package.json#L11\r\n\r\n### Expected behavior\r\n\r\nEither\r\n- Builds both work\r\nor\r\n- can understand the difference between the two better from the docs so I can resolve the issue myself\r\n\r\n### System Info\r\n\r\n```sh\r\nSystem:\r\n OS: Windows 10 10.0.22621\r\n CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\r\n Memory: 31.89 GB / 63.85 GB\r\n Binaries:\r\n Node: 18.13.0 - D:\\Program Files\\nodejs\\node.EXE\r\n Yarn: 1.22.19 - ~\\AppData\\Roaming\\npm\\yarn.CMD\r\n npm: 8.13.2 - D:\\Program Files\\nodejs\\npm.CMD\r\n Browsers:\r\n Chrome: 113.0.5672.127\r\n Edge: Spartan (44.22621.1702.0), Chromium (113.0.1774.35)\r\n Internet Explorer: 11.0.22621.1\r\n npmPackages:\r\n vitepress: ^1.0.0-beta.1 => 1.0.0-beta.1\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] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).\r\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\r\n- [X] Read the [docs](https://vitepress.dev).\r\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2908,2909],{"name":2868,"color":2869},{"name":2910,"color":2911},"stale","ededed",2421,"Different behaviour between `vite build` and `vitepress build` in same project","2023-09-02T00:04:09Z","https://github.com/vuejs/vitepress/issues/2421",0.65395266,{"description":2918,"labels":2919,"number":2920,"owner":2871,"repository":2872,"state":2873,"title":2921,"updated_at":2922,"url":2923,"score":2924},"\r\n**Describe the bug**\r\nvitepress dev docs working but vitepress build docs has errors.\r\n\r\n```\r\n> vitepress dev docs\r\n\r\nvitepress v0.15.3\r\nvite v2.3.7\r\nD:\\vue3-openlayers\\docs\\.vitepress\\config.js\r\n\r\n vite v2.3.7 dev server running at:\r\n\r\n > Local: http://localhost:3000/\r\n > Network: use `--host` to expose\r\n[@vue/compiler-sfc] \u003Cscript setup> is still an experimental proposal.\r\nFollow its status at https://github.com/vuejs/rfcs/pull/227.\r\n\r\n[@vue/compiler-sfc] When using experimental features,\r\nit is recommended to pin your vue dependencies to exact versions to avoid breakage.\r\n```\r\n\r\n```\r\n> vitepress build docs\r\n\r\nvitepress v0.15.3\r\nvite v2.3.7\r\n⠧ building client + server bundles...\r\n(!) Some chunks are larger than 500kb after minification. Consider:\r\n- Using dynamic import() to code-split the application\r\n- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks\r\n- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.\r\n✓ building client + server bundles...\r\n✖ rendering pages...\r\nbuild error:\r\n D:\\vue3-openlayers\\node_modules\\ol\\Map.js:17\r\nimport CompositeMapRenderer from './renderer/Composite.js';\r\n^^^^^^\r\n\r\nSyntaxError: Cannot use import statement outside a module\r\n at wrapSafe (internal/modules/cjs/loader.js:1001:16)\r\n at Module._compile (internal/modules/cjs/loader.js:1049:27)\r\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)\r\n at Module.load (internal/modules/cjs/loader.js:950:32)\r\n at Function.Module._load (internal/modules/cjs/loader.js:791:14)\r\n at Module.require (internal/modules/cjs/loader.js:974:19)\r\n at require (internal/modules/cjs/helpers.js:88:18)\r\n at Module.\u003Canonymous> (D:\\vue3-openlayers\\node_modules\\vitepress\\dist\\client\\app\\temp\\app.js:25:13)\r\n at Module._compile (internal/modules/cjs/loader.js:1085:30)\r\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 1\r\nnpm ERR! vue3-openlayers@0.1.0 docs:build: `vitepress build docs`\r\nnpm ERR! Exit status 1\r\n```\r\n\r\n**Expected behavior**\r\n\r\nsuccess build\r\n\r\n**System Info**\r\n- vitepress version: ^0.15.3\r\n- vite version: 2.3.7\r\n- Node version: v14.13.0\r\n- OS version: win 10\r\n\r\n",[],324,"dev works but build not (Cannot use import statement outside a module)","2023-01-21T14:28:40Z","https://github.com/vuejs/vitepress/issues/324",0.66219413,{"description":2926,"labels":2927,"number":2931,"owner":2871,"repository":2872,"state":2873,"title":2932,"updated_at":2933,"url":2934,"score":2935},"### Is your feature request related to a problem? Please describe.\r\n\r\n- 自定义vue组件库,会用到很多第三方插件,比如:[@wangeditor/editor](https://github.com/nikitasnv/vue-resizable),[vue-resizable](https://github.com/wangeditor-team/wangEditor)等,而这些插件,都会用到window,document等这些变量\r\n\r\n- 当使用 vitepress 构建组件库文档时,`pnpm run build`,就会报错:\r\n```\r\nbuild error:\r\nReferenceError: document is not defined\r\n```\r\n\r\n- 如果都去让第三方插件作者去修改代码,这样也有点不切实际\r\n\r\n\r\n### Describe the solution you'd like\r\n\r\n- vitepress build的时候,能否可以配置关闭SSR?或者有没有别的办法可以解决上述报错?非常感谢\r\n\r\n### Describe alternatives you've considered\r\n\r\n_No response_\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] Read the [Contributing Guidelines](https://github.com/vuejs/vitepress/blob/main/.github/contributing.md).\r\n- [X] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.",[2928],{"name":2929,"color":2930},"build","377ba8",1727,"Allow disabling SSR","2023-01-31T00:04:44Z","https://github.com/vuejs/vitepress/issues/1727",0.66571134,{"description":2937,"labels":2938,"number":2940,"owner":2871,"repository":2872,"state":2873,"title":2941,"updated_at":2942,"url":2943,"score":2944},"### Describe the bug\n\nI ported a site from Vuepress to Vitepress. Everything works in development mode. However, once I try to build it, I get the following error\r\n\r\n```\r\n$ npm run build\r\n\r\n> Chemie-Mitschrift@0.0.2 build\r\n> vitepress build docs\r\n\r\nvitepress v0.21.6\r\n✓ building client + server bundles...\r\n✖ rendering pages...\r\nbuild error:\r\n Error: Cannot find module 'vue'\r\nRequire stack:\r\n- C:\\Users\\Stefnotch\\Documents\\GitHub\\School\\Chemie-Mitschrift\\docs\\.vitepress\\.temp\\app.js\r\n- C:\\Users\\Stefnotch\\Documents\\GitHub\\School\\Chemie-Mitschrift\\node_modules\\vitepress\\dist\\node\\serve-9874c5ac.js\r\n- C:\\Users\\Stefnotch\\Documents\\GitHub\\School\\Chemie-Mitschrift\\node_modules\\vitepress\\dist\\node\\cli.js\r\n- C:\\Users\\Stefnotch\\Documents\\GitHub\\School\\Chemie-Mitschrift\\node_modules\\vitepress\\bin\\vitepress.js\r\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)\r\n at Function.Module._load (node:internal/modules/cjs/loader:772:27)\r\n at Module.require (node:internal/modules/cjs/loader:999:19)\r\n at require (node:internal/modules/cjs/helpers:93:18)\r\n at Module.\u003Canonymous> (C:\\Users\\Stefnotch\\Documents\\GitHub\\School\\Chemie-Mitschrift\\docs\\.vitepress\\.temp\\app.js:23:11) \r\n at Module._compile (node:internal/modules/cjs/loader:1095:14)\r\n at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)\r\n at Module.load (node:internal/modules/cjs/loader:975:32)\r\n at Function.Module._load (node:internal/modules/cjs/loader:816:12)\r\n at Module.require (node:internal/modules/cjs/loader:999:19) {\r\n code: 'MODULE_NOT_FOUND',\r\n requireStack: [\r\n 'C:\\\\Users\\\\Stefnotch\\\\Documents\\\\GitHub\\\\School\\\\Chemie-Mitschrift\\\\docs\\\\.vitepress\\\\.temp\\\\app.js',\r\n 'C:\\\\Users\\\\Stefnotch\\\\Documents\\\\GitHub\\\\School\\\\Chemie-Mitschrift\\\\node_modules\\\\vitepress\\\\dist\\\\node\\\\serve-9874c5ac.js',\r\n 'C:\\\\Users\\\\Stefnotch\\\\Documents\\\\GitHub\\\\School\\\\Chemie-Mitschrift\\\\node_modules\\\\vitepress\\\\dist\\\\node\\\\cli.js',\r\n 'C:\\\\Users\\\\Stefnotch\\\\Documents\\\\GitHub\\\\School\\\\Chemie-Mitschrift\\\\node_modules\\\\vitepress\\\\bin\\\\vitepress.js'\r\n ]\r\n}\r\n ```\n\n### Reproduction\n\n1. Clone https://github.com/ArnoBluemel/Chemie-Mitschrift/\r\n2. `npm install`\r\n3. `npm run build`\r\n\r\n\n\n### Expected behavior\n\nI would have expected it to work. Or fail with a less confusing error message.\n\n### System Info\n\n```shell\nSystem:\r\n OS: Windows 10 10.0.19044\r\n CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz\r\n Memory: 22.96 GB / 31.86 GB\r\n Binaries:\r\n Node: 16.5.0 - C:\\Program Files\\nodejs\\node.EXE\r\n npm: 7.11.2 - C:\\Program Files\\nodejs\\npm.CMD\r\n Browsers:\r\n Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.76)\r\n Internet Explorer: 11.0.19041.1202\n```\n\n\n### Additional context\n\nI did try hunting down the cause of this, but as far as I can tell, some caching is involved. Which makes finding the root cause rather difficult.\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.",[2939],{"name":2868,"color":2869},516,"\"Error: Cannot find module 'vue'\" when building","2023-01-21T16:20:12Z","https://github.com/vuejs/vitepress/issues/516",0.6664864,{"description":2946,"labels":2947,"number":2951,"owner":2871,"repository":2872,"state":2873,"title":2952,"updated_at":2953,"url":2954,"score":2955},"### Describe the bug\r\n\r\nI try to use SolidJS in vitepress,\r\nwhen in development mode, it works ok,\r\nbut when I build, during the render process,\r\nit throws error like:\r\nSyntaxError: The requested module 'solid-js/web' does not provide an export named 'effect'\r\n at async render (file:///home/projects/vite-hnzcih/docs/.vitepress/.temp/app.js:4605:5)\r\n at async renderPage (file:///home/projects/vite-hnzcih/node_modules/vitepress/dist/node/serve-afe9b056.js:41460:19)\r\n at async Promise.all (index 1)\r\n at async Module.build (file:///home/projects/vite-hnzcih/node_modules/vitepress/dist/node/serve-afe9b056.js:42209:7)\r\n\r\n\r\n\r\nimport { template, render } from 'solid-js/web';\r\n ^^^^^^^^\r\nSyntaxError: The requested module 'solid-js/web' does not provide an export named 'template'\r\n\r\n\r\n\r\nI don't know why.\r\nIn pure vite program, it builds success.\r\nIn the reproduction, it seems can't resolve solid-js/web\r\n\r\n\r\n### Reproduction\r\n\r\nhttps://stackblitz.com/edit/vite-hnzcih?file=docs/components/Home.tsx\r\n\r\nrun \r\n```\r\nnpm install && npm run docs:dev\r\n```\r\n it renders ok,\r\nbut run\r\n```\r\n npm install && npm run docs:build\r\n```\r\nit will throw error.\r\n\r\n### Expected behavior\r\n\r\nI hope it builds successfully.\r\n\r\n### System Info\r\n\r\n```shell\r\nSystem:\r\n OS: Linux 5.0 undefined\r\n CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz\r\n Memory: 0 Bytes / 0 Bytes\r\n Shell: 1.0 - /bin/jsh\r\n Binaries:\r\n Node: 16.14.2 - /usr/local/bin/node\r\n Yarn: 1.22.19 - /usr/local/bin/yarn\r\n npm: 7.17.0 - /usr/local/bin/npm\r\n npmPackages:\r\n vitepress: latest => 1.0.0-alpha.23\r\n```\r\n\r\n\r\n### Additional context\r\n\r\nAlter ‘solid-js’ from ‘devDependencies’ to ‘dependencies’ still wasn't working.\r\n\r\n\r\n``` \r\n \"dependencies\": {\r\n \"@babel/core\": \"^7.19.6\",\r\n \"babel-preset-solid\": \"^1.6.1\",\r\n \"solid-js\": \"^1.6.1\",\r\n \"vite-plugin-solid\": \"^2.4.0\",\r\n \"vitepress\": \"latest\"\r\n }\r\n```\r\n\r\n```\r\nimport { defineConfig } from 'vite';\r\nimport solidPlugin from 'vite-plugin-solid';\r\n\r\nexport default defineConfig({\r\n plugins: [solidPlugin()],\r\n server: {\r\n port: 3000,\r\n },\r\n build: {\r\n target: 'esnext',\r\n },\r\n});\r\n```\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.",[2948],{"name":2949,"color":2950},"invalid","ffffff",1586,"use solidjs in vitepress build error","2023-01-28T00:04:04Z","https://github.com/vuejs/vitepress/issues/1586",0.6681268,{"description":2957,"labels":2958,"number":2960,"owner":2871,"repository":2872,"state":2873,"title":2961,"updated_at":2962,"url":2963,"score":2964},"### Describe the bug\r\n\r\nUsing Monaco Editor (applying **[this trick](https://github.com/vuejs/vitepress/issues/1508)**) works with `npm run docs:dev` but is failing with `npm run docs:build`\r\n\r\nIn other words, Monaco Editor works in dev but fails in build. The is **not** related to imports ([ex1](https://github.com/vuejs/vitepress/issues/1508), [ex2](https://github.com/vitejs/vite/discussions/1791#discussioncomment-321046, [ex3](https://twitter.com/youyuxi/status/1355316139144970240?s=20))\r\n\r\nThe error when building reads is about module_not_found (the package is definitely installed & path exists):\r\n\r\n```\r\nError [ERR_MODULE_NOT_FOUND]: Cannot find package '/home/projects/nbwixzanm.github/node_modules/monaco-editor/' imported from /home/projects/nbwixzanm.github/.vitepress/.temp/....\r\n```\r\n\r\nStackblitz:\r\n\u003Cimg width=\"1040\" alt=\"image\" src=\"https://github.com/vuejs/vitepress/assets/1396559/1ce6110a-4d0e-4160-a1df-9148f778ebe3\">\r\n\r\n\r\n### Reproduction\r\n\r\nhttps://github.com/valgaze/vitepress-monaco#setup\r\n\r\nhttps://stackblitz.com/github/valgaze/vitepress-monaco # npm run docs:build\r\n\r\n### Expected behavior\r\n\r\nMonaco Editor should be able to build/bundle and find its folder that exists\r\n\r\n### System Info\r\n\r\n```sh\r\nSystem:\r\n OS: macOS 12.1\r\n CPU: (8) arm64 Apple M1\r\n Memory: 139.38 MB / 16.00 GB\r\n Shell: 3.2.57 - /bin/bash\r\n Binaries:\r\n Node: 18.11.0 - ~/.nvm/versions/node/v18.11.0/bin/node\r\n npm: 8.19.2 - ~/.nvm/versions/node/v18.11.0/bin/npm\r\n Browsers:\r\n Brave Browser: 114.1.52.122\r\n Chrome: 116.0.5845.96\r\n Firefox: 105.0.3\r\n Safari: 15.2\r\n npmPackages:\r\n vitepress: ^1.0.0-rc.4 => 1.0.0-rc.4\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] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).\r\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\r\n- [X] Read the [docs](https://vitepress.dev).\r\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2959],{"name":2868,"color":2869},2832,"Monaco-editor + Vitepress not found on 1.0.0-rc.4 when building?","2023-08-31T00:04:23Z","https://github.com/vuejs/vitepress/issues/2832",0.66939175,["Reactive",2966],{},["Set"],["ShallowReactive",2969],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fyU2DbeE-J3eKwVXmBFUhtfDSwjoKV54jUR3Wf9z7Fc4":-1},"/vuejs/vitepress/257"]