Closed JounQin closed 1 year ago
Can you try with the chore/vite-3
branch? Most of the ESM related issues are fixed there.
Can you try with the
chore/vite-3
branch? Most of the ESM related issues are fixed there.
I don't think so?
https://github.com/vuejs/vitepress/blob/chore/vite-3/src/node/index.ts
For example, no .js
extensions are added.
That file is processed by Rollup which adds the extensions. In dist/client
, there aren't any extensions, because we don't need them there. Those files are used by VIte which understands that stuff in ESM contexts too. Try testing it out locally (pnpm i && pnpm docs-build && pnpm pack
, pnpm add -D path/to/vitepress.tgz
), it should work with type: module
in your package.json.
Can you try with the
chore/vite-3
branch? Most of the ESM related issues are fixed there.I don't think so?
https://github.com/vuejs/vitepress/blob/chore/vite-3/src/node/index.ts
For example, no
.js
extensions are added.
I also encountered this problem when I run yarn docs:build
, and don't know how to solute it , Because none of the files in my project have the .js
extension , How can I rename.js
to .cjs
😰, at first I think it is vue-eslint-parser
cause , but seem to doesn't work😥
I remove the config "type": "module",
in package.json
and it works ,
I remove the config
"type": "module",
inpackage.json
and it works ,
It's not a solution. 😂
Actually, I had tried applying moduleResolution: nodenext
on client only (node part already has extensions on imports). Got everything to work except for the docsearch package. That package has certain issues with that mode.
@brc-dd
moduleResolution: nodenext
is not the thing, type: "module"
in user's package.json
is.
moduleResolution: nodenext
is not the thing,type: "module"
in user'spackage.json
is.
I meant in VitePress' tsconfig (to resolve this issue).
moduleResolution: nodenext
is not the thing,type: "module"
in user'spackage.json
is.I meant in VitePress' tsconfig (to resolve this issue).
Oh, right, thanks for fixing this issue.
Oh, right, thanks for fixing this issue.
I tried but I'm still not able to fix this because of some issue with @docsearch/js
. Probably has something to do with its exports or the (broken) types they are generating. In main
, we are patching its types. In chore/vite3
, I removed those stuff as its typings are somewhat better now, but IG to support this we'd have to again do the ugly stuff.
Is chore/vite3
the branch you're working on? I'd like to take a look to see whether there is anything I can help.
Is
chore/vite3
the branch you're working on?
Yeah, chore/vite-3
. But that moduleResolution
thing is not there as I wasn't able to make it work.
OK, I'll add it locally and manually.
@brc-dd See #1136
Okay, so now there is another issue. VitePress is unable to resolve custom theme if its in TS (and user has not added moduleResolution: nodenext to their tsconfig.json) :/
Okay, so now there is another issue. VitePress is unable to resolve custom theme if its in TS (and user has not added moduleResolution: nodenext to their tsconfig.json) :/
I'm not sure why? Can it be tested easily?
Can it be tested easily?
git clone https://github.com/vuejs/vitepress -b chore/vite-3
cd vitepress
pnpm i && pnpm build && pnpm pack
cd ..
mkdir foo
cd foo
pnpm add -D ../vitepress/vitepress-1.0.0-alpha.4.tgz vue typescript
mkdir .vitepress
mkdir .vitepress/theme
echo "export { default } from 'vitepress/theme'" >.vitepress/theme/index.ts
echo "# Hello VitePress" > index.md
pnpm vitepress build
I'm not sure why?
Probably has something to with our aliases.
I'm not sure why?
Probably has something to with our aliases.
Thanks, I'll take a look tonight.
Any progress on the issue? It's currently blocking me from setting up CI/CD pipeline
It seems I definitely forgot about this issue, I'll spend some time on it tonight.
Sorry, no time again.
Is your feature request related to a problem? Please describe.
The outputs ESM entries are not fully compatible with native ESM actually, take the following as example
https://unpkg.com/browse/vitepress@1.0.0-alpha.4/dist/client/index.js
All relative file paths should be ended with correct
.js
extension, and/index.js
can not be omitted anymore.That's being said, we should use
moduleResolution: "Node16"
instead.And when the user enables
type: "module"
in theirpackage.json
or.vitepress/package.json
, all temporary.js
files in.vitepress/.temp
would be considered as ESM only, and now it would emit error:Describe the solution you'd like
Enable
moduleResolution: "Node16"
and add apackage.json
into.vitepress/.temp
withtype: "commonjs"
for now, and migrate all outputs files as pure ESM later.Describe alternatives you've considered
We can use
.cjs
files extensions for files outputs in.vitepress/.temp
Additional context
Reference https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing
Validations