-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add web component dev guide #77
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Web Component Development | ||
|
||
These should be viewed as a set of 'best practice' guidelines or recommendations when developing web components geared toward the uPortal ecosystem. While web components can be built in a variety of ways, the goal is a simple and consistent approach in development, style, and deployment. | ||
|
||
## Build Pipeline | ||
Until the frontend is more separated from the backend, the webjar > maven > resource-server is the approach uPortal takes to host the web components for usage on the site. | ||
|
||
LIT & Typescript (Transpiled to ES6+) | ||
v | ||
Linters | ||
v | ||
Pre-commit hooks | ||
v | ||
Deployed to Sonatype | ||
v | ||
Bundled as a webjar | ||
v | ||
Deployed to Maven | ||
Comment on lines
+14
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't Sonatype and Maven central the same? |
||
v | ||
Pulled into uPortal projects via the resource-server | ||
v | ||
Pull into an HTML page via a link from the resource-server | ||
|
||
## Technology | ||
To keep this document concise, please refer to the reference implementation for details / examples of the various configurations. | ||
|
||
### NPM | ||
https://www.npmjs.com/ | ||
|
||
The build is handled via NPM. | ||
|
||
### Lerna | ||
https://lerna.js.org/ | ||
https://github.com/ChristianMurphy/lerna-webjar | ||
Comment on lines
+32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm, a couple thoughts on this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you see a value-add in keeping multiple web components bundled in the same repository? If we could go down to a single web component per repo, and then drop lerna, that'd definitely help simplify the toolset and allow web components the flexibility to be revised in isolation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, but there are trade offs. If the components are not using the same technologies and interdependent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense. I'll note there are two flavors of build flows (npm/yarn & lerna) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lerna is for most intents and purposes deprecated, replaced by native monorepo workspace support in package managers, removing it from uPortal web components is something I hope to do sometime. Yarn and pnpm could also be options, but lately they've been trending towards a new style of module loading called plug and play, which can break random modules and can be challenging to debug without fairly in depth knowledge of node js packaging conventions and module loading rules. I'd steer clear of these to keep the guide more beginner friendly. |
||
|
||
Builds the webjar | ||
|
||
### Lit | ||
https://lit.dev/ | ||
|
||
Lightweight method of creating Web Components. | ||
|
||
### Typescript | ||
https://www.typescriptlang.org/ | ||
|
||
Type checking. | ||
Comment on lines
+43
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may also be nice to include https://github.com/plantain-00/type-coverage#readme and encourage a minimum amount of typing (I personally prefer 100% types, but 90% could be a good baseline) |
||
|
||
### ESLint | ||
https://eslint.org/ | ||
|
||
Linter for Javascript. | ||
Comment on lines
+48
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ESLint starts with all rules off, and without framework specific guidance.
{
"root": true,
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:wc/best-practice",
"plugin:lit/recommended"
]
} |
||
|
||
### StyleLint | ||
https://stylelint.io/ | ||
|
||
Linter for CSS. | ||
Comment on lines
+53
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stylelint will need to be
|
||
|
||
### Remark | ||
https://github.com/remarkjs/remark-lint | ||
|
||
Linter for markdown. | ||
Comment on lines
+58
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also need a ruleset https://github.com/remarkjs/remark-lint#presets |
||
|
||
### Prettier | ||
https://prettier.io/ | ||
|
||
Consistent code format for MD, HTML, CSS, etc. | ||
|
||
### Editor Config | ||
|
||
Consistent code style in the IDE. | ||
Comment on lines
+68
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels optional with prettier, fine with keeping it though |
||
|
||
## Reference Implementation | ||
|
||
The following web component aims to follow these best practices: | ||
|
||
``` | ||
TBD - build out a web component that follows these guidelines and interacts with uPortal (ideally with CRUD operations for example's sake) | ||
``` |
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.
Ideally pre-commit hooks would trigger the linters automatically