Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add errors reference page #2515

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const nav: ThemeConfig['nav'] = [
{ text: 'Quick Start', link: '/guide/quick-start' },
// { text: 'Style Guide', link: '/style-guide/' },
{ text: 'Glossary', link: '/glossary/' },
{ text: 'Error Reference', link: '/errors/' },
{
text: 'Vue 2 Docs',
link: 'https://v2.vuejs.org'
Expand Down Expand Up @@ -695,7 +696,7 @@ export default defineConfigWithTheme<ThemeConfig>({
markdown: {
config(md) {
md.use(headerPlugin)
// .use(textAdPlugin)
// .use(textAdPlugin)
}
},

Expand Down
8 changes: 8 additions & 0 deletions .vitepress/errors.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineLoader } from 'vitepress'
import { errorMessages } from '@vue/compiler-core'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be including runtime errors here as well. In fact, runtime errors are more important than compiler errors because most of the time compilers run in dev mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runtime errors didn't be exported. We should do it first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ErrorTypeStrings is not exported in runtime-core, but exporting will increase the bundle size of vue itself at the same time. Because vue re-exported all of runtime-core.

Can we have a better way of exporting? How about exporting errors in another package entry, like @vue/runtime-core/errors

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added runtime errors.


export default defineLoader({
load() {
return { errorMessages }
}
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"devDependencies": {
"@types/markdown-it": "^12.2.3",
"@types/node": "^16.9.1",
"@vue/compiler-core": "npm:@vue/compiler-core-canary@minor",
"terser": "^5.14.2"
},
"pnpm": {
Expand Down
49 changes: 29 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions src/errors/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script setup>
import { data } from '../../.vitepress/errors.data.ts'
const hash = location.hash.slice(1)
</script>

# Error Reference {#error-reference}

<table>
<thead>
<tr>
<th>Code</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr v-for="(msg, code) of data.errorMessages" :class="{ highlight: hash === String(code) }">
<td :id="code" v-text="code" />
<td v-text="msg" />
</tr>
</tbody>
</table>

<style scoped>
.highlight {
color: var(--vt-c-yellow-darker);
font-weight: bold;
}
</style>