Repository navigation
feat: add Vite support for exported web components - #13148
Merged
Merged
Conversation
vursen
marked this pull request as draft
February 24, 2022 08:12
Contributor
| protected String getBootstrapJS(JsonValue initialUIDL, | ||
| BootstrapContext context) { | ||
| boolean productionMode = context.getSession().getConfiguration() | ||
| .isProductionMode(); |
There was a problem hiding this comment.
NULL_DEREFERENCE: object returned by context.getSession().getConfiguration() could be null and is dereferenced at line 1255.
(at-me in a reply with help or ignore)
vursen
force-pushed
the
feat/vite/exported-web-components
branch
from
February 25, 2022 14:00
f52cee0 to
2d17c21
Compare
vursen
force-pushed
the
feat/vite/exported-web-components
branch
from
February 25, 2022 20:21
f874da1 to
92b934f
Compare
vursen
marked this pull request as ready for review
February 27, 2022 15:16
4 of 7 tasks
Artur-
reviewed
Feb 28, 2022
mcollovati
reviewed
Mar 8, 2022
caalador
reviewed
Mar 8, 2022
|
Kudos, SonarCloud Quality Gate passed!
|
platosha
approved these changes
Mar 11, 2022
Collaborator
|
This ticket/PR has been released with Vaadin 23.1.0.alpha1 and is also targeting the upcoming stable 23.1.0 version. |
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.








Description
This PR adds Vite support for exported web components making it possible to build and run them with Vite in development and production modes.
A brief overview of the differences between Webpack and Vite implementations:
Webpack:
When there is any component marked as exported, in addition to
bundle-***.js, Webpack will build anexport-***.jschunk that containsgenerated-flow-imports. The Flow client will be generated by Flow as a separate script.Once an exported web component is requested,
WebComponentBootstrapHandleris the one that is in charge of generating a bootstrap script to initialize this web component.The current Webpack implementation of
WebComponentBootstrapHandleris based onBootstrapHandler. It dynamically builds an HTML bootstrap document injecting all the scripts required for the exported web component to work to the document's head. There is where it will inject the Flow client as a separate script and theexport-***.jschunk, getting it from the chunk stats file.Eventually, the handler serializes the head of the resulting HTML document into a set of javascript instructions and sends them to the browser as a result.
Vite:
When there is any component marked as exported, Vite will build
vaadin-web-component.tsand inject it toweb-component.html. It is worth noting thatvaadin-web-component.tsincludes bothgenerated-flow-importsand the Flow client.For Vite, the
WebComponentBootstrapHandlerlogic was modified so that it instead takesweb-component.htmlas an initial bootstrap document. The bootstrap document already contains the actual link tovaadin-web-component.tswhich isinjected by Vite. All the other scripts required for the exported web component to work, such as the
@Pushannotation script, the handler injects dynamically. An advantage of this approach is that it doesn't require any chunk stats so that it works pretty much the same way asIndexHtmlRequestHandler.Eventually, the handler serializes the head of the resulting HTML document into a set of javascript instructions and sends them to the browser as a result.
Fixes #12298
Type of change
Checklist