Skip to content

NXT-573: Added Vite Plugin#162

Open
daniel-stoian-lgp wants to merge 13 commits into
developfrom
feature/NXT-573
Open

NXT-573: Added Vite Plugin#162
daniel-stoian-lgp wants to merge 13 commits into
developfrom
feature/NXT-573

Conversation

@daniel-stoian-lgp

@daniel-stoian-lgp daniel-stoian-lgp commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • At least one test case is included for this feature or bug fix
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

Adds support for Vite migration (NXT-573): the Vite/Rollup counterparts of the existing webpack plugins and mixins, so @enact/cli can build and serve Enact apps with Vite.

Must land with (or before) the companion @enact/cli PRcli's config/vite.config.js consumes ViteHtmlPlugin / ViteILibPlugin / ViteWebOSMetaPlugin from this package. The CLI PR fails without it.

New — Vite/Rollup plugins (mirroring where the webpack plugins already live):

New webpack counterpart Purpose
plugins/ViteHtmlPlugin HtmlWebpackPlugin + .ejs Renders the same HTML template (Enact apps ship no index.html); serves in dev, emits index.html in build.
plugins/ViteILibPlugin ILibPlugin Defines the ILIB_* constants (build and the dev dep-optimizer) and copies/serves the iLib + resources/ data. Adds locale filtering via a locales option.
plugins/ViteWebOSMetaPlugin WebOSMetaPlugin Emits/serves appinfo.json + icons + localized appinfo, incl. $-prefixed sys-assets; supplies the <title> fallback.

New mixins (Vite counterparts to the webpack mixins):

  • mixins/vite.js : build-shaping flags (--no-minify, --verbose, --stats), exposed as mixins.applyVite.
  • mixins/vite-framework.js: --framework / --externals via a shared ESM bundle + import map (the analog of webpack's DLL + manifest), incl. theme-repo self-inclusion and --externals-polyfill.
  • mixins/vite-isomorphic.js: --isomorphic: a real vite build --ssr + per-locale prerender + assembly into the webpack-compatible output (fallback index.html + deduped index.<variant>.html + locale-map.json + per-locale appinfo).
  • mixins/vite-snapshot.js: --snapshot: self-contained UMD bundle (App global) + mksnapshot invocation + appinfo.json v8SnapshotFile tagging.
  • plugins/SnapshotPlugin/snapshot-helper-esm.js + snapshot-mock.js: ESM re-implementations of the CJS snapshot helpers. Needed because Rollup hoists CJS requires, so the original helper's in-line ordering (mock window installed before react-dom/client) cannot be reproduced; import order makes it deterministic. Reuses the bundler-agnostic mock-window.js + @enact/core/snapshot.

Refactors that touch the existing webpack path : these are the parts worth review attention. Each extracts logic that both bundlers now need into a shared, dependency-free module, with no intended behavior change to webpack:

Extracted to From Now shared with
plugins/ILibPlugin/ilib-paths.js ILibPlugin/index.js (packageSearch, transformPath, bundleConst) ViteILibPlugin
plugins/PrerenderPlugin/parse-locales.js PrerenderPlugin/index.js (parseLocales, detectLocales) ViteILibPlugin, cli's pack.js
plugins/WebOSMetaPlugin/appinfo.js WebOSMetaPlugin/index.js (props, readAppInfo, rootAppInfo) ViteWebOSMetaPlugin
mixins/framework-libraries.js mixins/framework.js, mixins/externals.js (the react library list, non-runtime @enact package list) mixins/vite-framework.js

Also: index.js exports the three new plugins; mixins/index.js gains applyVite (the webpack apply can't be reused: it mutates webpack-specific config).

Resolution

The Vite path is validated end-to-end against real apps (Sandstone/React 18 and Limestone/React 19, which ships raw @enact source), including a real browser render.

Why this shape: @enact/i18n's runtime loader, the prerender templates, FileXHR, and mock-window.js are all already bundler-agnostic, so the Vite plugins reuse them rather than reimplementing. The webpack-only pieces that had no equivalent (GracefulFsPlugin) are not migrated.

Additional Considerations

Links

NXT-573

Comments

Enact-DCO-1.0-Signed-off-by: Daniel Stoian (daniel.stoian@lgepartner.com)

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.

1 participant