NXT-573: Added Vite Plugin#162
Open
daniel-stoian-lgp wants to merge 13 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Issue Resolved / Feature Added
Adds support for Vite migration (NXT-573): the Vite/Rollup counterparts of the existing webpack plugins and mixins, so
@enact/clican build and serve Enact apps with Vite.New — Vite/Rollup plugins (mirroring where the webpack plugins already live):
plugins/ViteHtmlPluginHtmlWebpackPlugin+.ejsindex.html); serves in dev, emitsindex.htmlin build.plugins/ViteILibPluginILibPluginILIB_*constants (build and the dev dep-optimizer) and copies/serves the iLib +resources/data. Adds locale filtering via alocalesoption.plugins/ViteWebOSMetaPluginWebOSMetaPluginappinfo.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 asmixins.applyVite.mixins/vite-framework.js:--framework/--externalsvia 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 realvite build --ssr+ per-locale prerender + assembly into the webpack-compatible output (fallbackindex.html+ dedupedindex.<variant>.html+locale-map.json+ per-locale appinfo).mixins/vite-snapshot.js:--snapshot: self-contained UMD bundle (Appglobal) +mksnapshotinvocation +appinfo.jsonv8SnapshotFiletagging.plugins/SnapshotPlugin/snapshot-helper-esm.js+snapshot-mock.js: ESM re-implementations of the CJS snapshot helpers. Needed because Rollup hoists CJSrequires, so the original helper's in-line ordering (mock window installed beforereact-dom/client) cannot be reproduced; import order makes it deterministic. Reuses the bundler-agnosticmock-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:
plugins/ILibPlugin/ilib-paths.jsILibPlugin/index.js(packageSearch,transformPath,bundleConst)ViteILibPluginplugins/PrerenderPlugin/parse-locales.jsPrerenderPlugin/index.js(parseLocales,detectLocales)ViteILibPlugin,cli'spack.jsplugins/WebOSMetaPlugin/appinfo.jsWebOSMetaPlugin/index.js(props,readAppInfo,rootAppInfo)ViteWebOSMetaPluginmixins/framework-libraries.jsmixins/framework.js,mixins/externals.js(the react library list, non-runtime@enactpackage list)mixins/vite-framework.jsAlso:
index.jsexports the three new plugins;mixins/index.jsgainsapplyVite(the webpackapplycan'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
@enactsource), including a real browser render.Why this shape:
@enact/i18n's runtime loader, the prerender templates,FileXHR, andmock-window.jsare 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)