vuejs / vitepress

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

feat!: use port 5173 and 4173 for dev and serve #833

Closed JounQin closed 1 year ago

JounQin commented 1 year ago

close #715

JounQin commented 1 year ago

@brc-add

Seems vite@v3 has more breaking change as I expected, can we upgrade to v3 in another PR? (keep 3000 for development for now).

Or can you help to review how to fix the current build error?

8:11:27 AM:  Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/build/repo/docs/.vitepress/.temp/app.js' imported from /opt/build/repo/dist/node/serve-8dc9ef83.js
8:11:27 AM:     at new NodeError (node:internal/errors:372:5)
8:11:27 AM:     at finalizeResolution (node:internal/modules/esm/resolve:437:11)
8:11:27 AM:     at moduleResolve (node:internal/modules/esm/resolve:1009:10)
8:11:27 AM:     at defaultResolve (node:internal/modules/esm/resolve:1218:11)
8:11:27 AM:     at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
8:11:27 AM:     at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
8:11:27 AM:     at ESMLoader.import (node:internal/modules/esm/loader:380:22)
8:11:27 AM:     at importModuleDynamically (node:internal/modules/esm/translators:106:35)
8:11:27 AM:     at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
8:11:27 AM:     at renderPage (file:///opt/build/repo/dist/node/serve-8dc9ef83.js:39530:91) {
8:11:27 AM:   code: 'ERR_MODULE_NOT_FOUND'
brc-dd commented 1 year ago

Don't upgrade Vite version for now. Let's just update the ports.

JounQin commented 1 year ago

Don't upgrade Vite version for now. Let's just update the ports.

@brc-dd

The dev port is created by vite itself, so 3000 will not change if we don't upgrade.

brc-dd commented 1 year ago

It can be passed to createServer too.

JounQin commented 1 year ago

It can be passed to createServer too.

@brc-dd

You mean we change the default port manually to 5173 if the user does not provide one?

brc-dd commented 1 year ago

closing this in favor of #856

Tyh2001 commented 1 year ago

@brc-dd Help me. I have a similar problem. The construction failed. ๐Ÿ™๐Ÿ™๐Ÿ™

Project is here

Err:

PS D:\้กน็›ฎ-ๆˆ‘็š„\vitepress-template> pnpm build 
s\index' imported from D:\้กน็›ฎ-ๆˆ‘็š„\vitepress-template\docs\.vitepress\.temp\app.js
    at new NodeError (node:internal/errors:372:5)
    at finalizeResolution (node:internal/modules/esm/resolve:437:11)
    at moduleResolve (node:internal/modules/esm/resolve:1009:10)
    at defaultResolve (node:internal/modules/esm/resolve:1218:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)    at link (node:internal/modules/esm/module_job:78:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}
โ€‰ELIFECYCLEโ€‰ Command failed with exit code 1.
PS D:\้กน็›ฎ-ๆˆ‘็š„\vitepress-template>
brc-dd commented 1 year ago

@Tyh2001 The issue is with exports of https://github.com/FightingDesign/fighting-design, they should be something like this:

    ".": {
      "import": "./es/index.mjs",
      "require": "./lib/index.cjs",
      "types": "./es/index.d.ts"
    },

Currently they don't have proper extensions.

JounQin commented 1 year ago

@brc-dd types should always be the first exports key.

Tyh2001 commented 1 year ago

@Tyh2001 The issue is with exports of https://github.com/FightingDesign/fighting-design, they should be something like this:

    ".": {
      "import": "./es/index.mjs",
      "require": "./lib/index.cjs",
      "types": "./es/index.d.ts"
    },

Currently they don't have proper extensions.

Thank you very much. It was my negligence. I have solved the problem. Thank you~

brc-dd commented 1 year ago

types should always be the first exports key.

@JounQin Any reference on that? TypeScript's official examples have types at last, but the order shouldn't matter in JSON IG.

JounQin commented 1 year ago

types should always be the first exports key.

@JounQin Any reference on that? TypeScript's official examples have types at last, but the order shouldn't matter in JSON IG.

The documentation seems having been updated. ๐Ÿฅฒ Maybe it doesn't matter for latest TS 4.7 now.

While keys in JSON are ordered in ES spec actually, but I'm on mobile. ๐Ÿ˜…

JounQin commented 1 year ago

https://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order

JounQin commented 1 year ago

@brc-dd I found the 4.7 announcing one at https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing