Skip to content

Migrate web resources build from Parcel to Vite - #3366

Draft
akira28 wants to merge 5 commits into
masterfrom
migrate-parcel-to-vite
Draft

akira28 wants to merge 5 commits into
masterfrom
migrate-parcel-to-vite

Conversation

@akira28

@akira28 akira28 commented Nov 2, 2026

Copy link
Copy Markdown

Replaces Parcel 1 with Vite 8 for building docs-v1.js and styles-v1.css, and Jest with Vitest for the resources/web tests. The IE polyfills are dropped.

What changed

  • Build: one resources/web/vite.config.mjs builds a classic (IIFE) script, the CSS and the fonts. lib/ES/Util.pm calls vite build. Fonts keep their plain names instead of Parcel's hashed ones.
  • Dev (build_docs --open): runs vite build --watch --minify false --sourcemap into its own directory, and nginx serves it directly. There is no HMR any more, only rebuild and reload. Port 8001 is no longer published. Polling on Docker for Mac still works through CHOKIDAR_USEPOLLING.
  • Node 12 → 24 in the base image, because Vite needs it. The nodesource key and repo are updated. It installs and runs on the buster base, including Vite's native bindings.
  • Tests: resources/web tests run under Vitest, so there's no Parcel step for tests. The preview tests stay on Jest, with nock 13 and error-message regexes that work on current Node.
  • Source cleanups the migration needed:
    • Bare specifiers instead of paths into /node_modules.
    • Ramda imported per function (Vitest chokes on its then export).
    • modal.js and mount.js renamed to .jsx.
    • The regex s flag removed in lang-console.js. prettify drops regex flags, and Parcel's Babel step used to rewrite it.
  • CSS: lightningcss can't parse a rule that precss mangles in heading.pcss (&:has(h1.title)). The rule was already dead, so error recovery drops it.
  • Integration specs: updated for plain font names, the new minified-output marker, and no details-polyfill license. Removed the checks for Parcel HMR, the CSS source map and the JS test comment (Vite drops plain comments).

Testing

  • make -C resources/web: 274 Vitest tests pass.
  • make -C preview: 48 Jest tests pass.
  • Full integration suite: 1917 examples, 0 failures.
  • rubocop and pycodestyle are clean.

To check before merging

  • Browser support: the output targets baseline-widely-available, so IE and old browsers are no longer supported. Parcel's Babel step produced ES5 output.
  • Dev flow: I haven't tried build_docs --open in a browser. The integration specs cover the watcher and nginx path.

🤖 Generated with Claude Code

Replace Parcel 1 with Vite for building docs-v1.js and styles-v1.css, and
Jest with Vitest for the web resources tests.

* One `vite.config.mjs` builds both files as a classic script plus CSS and
  fonts. The IE polyfills (details-polyfill, url-search-params-polyfill)
  are dropped.
* `build_docs --open` runs `vite build --watch` (unminified, with a source
  map) and nginx serves its output directly instead of proxying to the
  Parcel dev server. There is no HMR any more, only rebuild and reload.
* Node in the base image goes from 12 to 24, which Vite needs.
* Imports use bare specifiers instead of paths into /node_modules.
* Ramda is imported per function because Vitest chokes on its `then`
  export. Two files that contain JSX are renamed to .jsx.
* lang-console no longer uses a regex `s` flag, which prettify drops and
  Parcel used to compile away.
* The preview tests (still Jest) get nock 13 and error message regexes
  that work on current Node.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

A documentation preview will be available soon.

Request a new doc build by commenting
  • Rebuild this PR: run docs-build
  • Rebuild this PR and all Elastic docs: run docs-build rebuild

run docs-build is much faster than run docs-build rebuild. A rebuild should only be needed in rare situations.

If your PR continues to fail for an unknown reason, the doc build pipeline may be broken. Elastic employees can check the pipeline status here.

@akira28
akira28 marked this pull request as ready for review November 2, 2026 10:40
@akira28
akira28 requested a review from a team as a code owner November 2, 2026 10:40
@akira28
akira28 requested a review from Mpdreamz November 2, 2026 10:40
@akira28
akira28 requested a review from reakaleek November 2, 2026 10:55
akira28 and others added 2 commits November 2, 2026 12:04
* Use `ENV key=value` for the locale variables.
* Install the nodesource and yarn apt keys as `signed-by` keyrings instead
  of with the deprecated `apt-key add`. The yarn key is now a binary
  keyring because apt on buster doesn't accept armored ones there.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great work! The reasons my previous attempt failed was that parcel 2 refused to run the tests the same way and I got into setup and concurrency issues amongst other things.

Let's park this and discuss offline what we want to do, we also have half a plan to migrate all the old asciidoc to markdown and docs-builder.

@akira28
akira28 marked this pull request as draft November 4, 2026 16:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants