Skip to content

Conversation

@sapphi-red
Copy link
Member

Description

image

Unable to parse HTML; parse5 error code unexpected-character-in-attribute-name
 at {"file":"/index.html","line":16,"column":1}

Currently when Vite fails to parse a HTML, the error above is shown. But this at {"file": ... } part is not clickable.
This PR changes that part to be like below and make it clickable.

Unable to parse HTML; parse5 error code unexpected-character-in-attribute-name
 at C:/foo/bar/vite/playground/assets/index.html:16:1

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added feat: html p2-nice-to-have Not breaking anything but nice to have (priority) labels Dec 12, 2022
}

await traverseHtml(html, htmlPath, (node) => {
await traverseHtml(html, filename, (node) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This htmlPath argument is only passed to handleParseError, so it's safe to change.

export async function traverseHtml(
html: string,
filePath: string,
visitor: (node: DefaultTreeAdapterMap['node']) => void,
): Promise<void> {
// lazy load compiler
const { parse } = await import('parse5')
const ast = parse(html, {
sourceCodeLocationInfo: true,
onParseError: (e: ParserError) => {
handleParseError(e, html, filePath)
},
})
traverseNodes(ast, visitor)
}

@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Dec 12, 2022

📝 Ran ecosystem CI: Open

suite result
astro ✅ success
histoire ✅ success
iles ✅ success
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt-framework ✅ success
previewjs ✅ success
rakkas ✅ success
sveltekit ❌ failure
vite-plugin-ssr ✅ success
vite-plugin-react ✅ success
vite-plugin-react-swc ✅ success
vite-plugin-svelte ❌ failure
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success
windicss ✅ success

@patak-dev
Copy link
Member

/ecosystem-ci run sveltekit vite-plugin-svelte

@patak-dev patak-dev merged commit 2e15f3d into vitejs:main Dec 12, 2022
@sapphi-red sapphi-red deleted the feat/html-error-position branch December 13, 2022 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: html p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants