LearnNewsExamplesServices
Frontmatter
id7132
titleProduction Mode: Build-Time Parsing with `parse5`
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 30, 2025, 1:02 PM
updatedAtAug 2, 2025, 2:47 PM
githubUrlhttps://github.com/neomjs/neo/issues/7132
authortobiu
commentsCount1
parentIssue7130
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtAug 2, 2025, 2:47 PM

Production Mode: Build-Time Parsing with parse5

Closed v10.3.0 enhancement
tobiu
tobiu commented on Jul 30, 2025, 1:02 PM

Description: For production builds, parsing HTML strings in the main thread is inefficient. Instead, we will pre-process the source code, identify the templates, and replace them with their JSON VDOM representation directly in the build output.

Implementation Details:

  • Tool: parse5 (minified size: ~176KB). This is a robust and spec-compliant HTML parser.
  • Method:
    1. During the build process, use a regular expression to identify the tagged template literals (e.g., html...``).
    2. For each match, use parse5 to parse the string content into an abstract syntax tree (AST).
    3. Convert the parse5 AST into the final Neo.mjs VDOM JSON format.
    4. Replace the original template literal in the source code with the generated JSON object.
tobiu assigned to @tobiu on Jul 30, 2025, 1:02 PM
tobiu added the enhancement label on Jul 30, 2025, 1:02 PM
tobiu added parent issue #7130 on Jul 30, 2025, 1:02 PM
tobiu
tobiu Aug 2, 2025, 2:47 PM

resolved

tobiu closed this issue on Aug 2, 2025, 2:47 PM