-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(components): enable prefix override #861
Conversation
Codecov Report
@@ Coverage Diff @@
## main #861 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 123 154 +31
Lines 1562 2065 +503
Branches 108 131 +23
==========================================
+ Hits 1562 2065 +503
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…nto prefix-override # Conflicts: # libs/components/src/shared/utils/index.spec.ts
beforeAll(async () => { | ||
await customElements.whenDefined(COMPONENT_TAG); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably not needed now as we have this code in the pattern itself, right?
beforeAll(async () => { | ||
await customElements.whenDefined(COMPONENT_TAG); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
beforeAll(async () => { | ||
await customElements.whenDefined(COMPONENT_TAG); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar question
custom prefix for custom elements
To enable integration of vivid components in micro-frontend architecture, where dev teams work on a same HTML document but with different - conflicting - versions of Vivid components. such scenarios require isolating custom-elements registration within the same document.
A similar scenario, where the need arises, is teams upgrading major - breaking changes - versions and prefer updating components gradually.
the feature yet exists in browsers as a proposal for scoped-elements is yet to be finalized.
A workaround for having same components (with different versions) at the same scope would be to customized their prefix and be registered under a pseudo prefix (e.g.
<dashboard-badge>
).a recommendation by the FAST team is allow library-consuming teams to run the registration on their environment. meaning refactor our simple side-effects imports to a more controlled modules but this adds more work from consumers.
or register a custom prefix for the components you are exporting
Considering the above suggestions but keep the simplicity of consumption, this PR proposes keeping the simple side-effect imports but enable providing a parameter to be considered by the import.meta object.
With that, devs would be able to simple import with query parameter to define their desired prefix
Build constraints
note that the query parameter doesn't delegate to nested imports within a module so any other imports within
/node_modules/@vonage/vivid/badge/index.js
can't access theprefix
parameter.that means rollup build must contain the meta code within each component output
index.js
. to better understand, check button's build (which fails to access theprefix
parameter)Compositions:
composite components (using context.tagFor to integrate other components) aren't aware of the custom context unless integrated components are imported with the sameprefix
query parameter.in the following, icon is resolved asvwc-icon
while its integrated, container has resolved as desireddashboard-badge
.This is due to the existing import within the badge moduleimport '../icon';
which isn't resolved with that same meta contextto keep providing an ergonomic interface we should either log a warning for the prefix difference, or totally remove side effecting imports from within integrating components and document the necessity for authors to include the prerequisite imports. meaning an author wanting to use badge will need to also import icon.👆Resolved to dynamically importing components modules
Testing
TBD
Suggestions -