Skip to content
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: TUP-700 @tacc/core-components - package #433

Conversation

wesleyboar
Copy link
Member

@wesleyboar wesleyboar commented Feb 22, 2024

Overview

Create a @tacc/core-components Node package.

Related

Changes

Note

  1. I followed Create a Component Library Fast 🚀 (using Vite's library mode).
  2. I used NPM workspaces because I saw NX documentation mention support for it.
  • documented core-components
  • configured core-components
  • added vite-plugin-lib-inject-css dependency

Testing

New Build Command

  1. npm ci
  2. npx nx build core-components
  3. No error.
Log
$ npm ci
npm WARN deprecated @types/[email protected]: This is a stub types definition. browserslist provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated [email protected]: Use your platform's native atob() and btoa() methods instead
npm WARN deprecated @vitest/[email protected]: v8 coverage is moved to @vitest/coverage-v8 package
npm WARN deprecated [email protected]: Use your platform's native DOMException instead
npm WARN deprecated [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1

added 1725 packages, and audited 1727 packages in 35s

276 packages are looking for funding
  run `npm fund` for details

14 vulnerabilities (13 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
$ npx nx build core-components

> nx run core-components:build:production  [local cache]

vite v5.0.11 building for production...
✓ 436 modules transformed.
dist/assets/Section.css                                0.03 kB │ gzip:   0.05 kB
dist/assets/Button.css                                 0.15 kB │ gzip:   0.13 kB
dist/assets/FormField.css                              0.16 kB │ gzip:   0.13 kB
dist/assets/SectionTableWrapper.css                    0.25 kB │ gzip:   0.16 kB
dist/assets/Collapse.css                               0.29 kB │ gzip:   0.19 kB
dist/assets/SectionHeader.css                          0.45 kB │ gzip:   0.26 kB
dist/assets/ShowMore.css                               0.50 kB │ gzip:   0.27 kB
dist/assets/DescriptionList.css                        1.23 kB │ gzip:   0.47 kB
dist/assets/LoadingSpinner.css                         1.26 kB │ gzip:   0.50 kB
dist/assets/SectionContent.css                         1.30 kB │ gzip:   0.39 kB
dist/assets/Paginator.css                              1.40 kB │ gzip:   0.56 kB
dist/assets/InfiniteScrollTable.css                    1.52 kB │ gzip:   0.59 kB
dist/assets/HistoryBadge.css                           1.83 kB │ gzip:   0.55 kB
dist/assets/Checkbox.css                               1.92 kB │ gzip:   0.57 kB
dist/assets/TextCopyField.css                          1.98 kB │ gzip:   0.54 kB
dist/assets/Pill.css                                   2.28 kB │ gzip:   0.69 kB
dist/assets/Sidebar.css                                2.34 kB │ gzip:   0.73 kB
dist/assets/DropdownSelector.css                       3.15 kB │ gzip:   1.06 kB
dist/assets/Message.css                                4.81 kB │ gzip:   1.06 kB
dist/lib/Icon/index.js                                 0.05 kB │ gzip:   0.07 kB
dist/lib/Pill/index.js                                 0.05 kB │ gzip:   0.07 kB
dist/lib/Button/index.js                               0.06 kB │ gzip:   0.07 kB
dist/lib/Message/index.js                              0.06 kB │ gzip:   0.07 kB
dist/lib/Sidebar/index.js                              0.06 kB │ gzip:   0.07 kB
dist/lib/Checkbox/index.js                             0.06 kB │ gzip:   0.08 kB
dist/lib/Collapse/index.js                             0.06 kB │ gzip:   0.08 kB
dist/lib/ShowMore/index.js                             0.06 kB │ gzip:   0.08 kB
dist/lib/Paginator/index.js                            0.06 kB │ gzip:   0.08 kB
dist/lib/InlineMessage/index.js                        0.06 kB │ gzip:   0.08 kB
dist/lib/TextCopyField/index.js                        0.06 kB │ gzip:   0.08 kB
dist/lib/LoadingSpinner/index.js                       0.06 kB │ gzip:   0.08 kB
dist/lib/SectionMessage/index.js                       0.06 kB │ gzip:   0.08 kB
dist/lib/DescriptionList/index.js                      0.07 kB │ gzip:   0.08 kB
dist/lib/DropdownSelector/index.js                     0.07 kB │ gzip:   0.08 kB
dist/lib/InfiniteScrollTable/index.js                  0.07 kB │ gzip:   0.09 kB
dist/lib/Section/index.js                              0.07 kB │ gzip:   0.08 kB
dist/lib/Form/index.js                                 0.08 kB │ gzip:   0.08 kB
dist/lib/HistoryBadge/index.js                         0.08 kB │ gzip:   0.09 kB
dist/lib/SectionHeader/index.js                        0.08 kB │ gzip:   0.09 kB
dist/lib/SectionTableWrapper/index.js                  0.08 kB │ gzip:   0.09 kB
dist/lib/SectionContent/index.js                       0.20 kB │ gzip:   0.15 kB
dist/lib/InlineMessage/InlineMessage.js                0.34 kB │ gzip:   0.23 kB
dist/lib/Icon/Icon.js                                  0.39 kB │ gzip:   0.27 kB
dist/lib/HistoryBadge/HistoryBadge.js                  0.58 kB │ gzip:   0.37 kB
dist/lib/SectionMessage/SectionMessage.js              0.62 kB │ gzip:   0.33 kB
dist/lib/Pill/Pill.js                                  0.94 kB │ gzip:   0.49 kB
dist/lib/DropdownSelector/DropdownSelector.js          1.01 kB │ gzip:   0.58 kB
dist/lib/Checkbox/Checkbox.js                          1.23 kB │ gzip:   0.62 kB
dist/lib/TextCopyField/TextCopyField.js                1.26 kB │ gzip:   0.64 kB
dist/lib/SectionHeader/SectionHeader.js                1.41 kB │ gzip:   0.67 kB
dist/index.js                                          1.70 kB │ gzip:   0.46 kB
dist/Badge-W4AS3xw2.mjs                                1.92 kB │ gzip:   0.93 kB
dist/lib/Button/Button.js                              1.99 kB │ gzip:   0.81 kB
dist/lib/SectionContent/SectionContent.js              2.09 kB │ gzip:   0.93 kB
dist/lib/LoadingSpinner/LoadingSpinner.js              2.47 kB │ gzip:   1.12 kB
dist/lib/Paginator/Paginator.js                        2.57 kB │ gzip:   0.97 kB
dist/lib/Section/Section.js                            3.35 kB │ gzip:   1.23 kB
dist/lib/SectionTableWrapper/SectionTableWrapper.js    3.37 kB │ gzip:   1.33 kB
dist/utils-OW3A2J3p.mjs                                3.39 kB │ gzip:   1.50 kB
dist/lib/DescriptionList/DescriptionList.js            3.50 kB │ gzip:   1.57 kB
dist/Input-HVmkVBHZ.mjs                                5.49 kB │ gzip:   2.11 kB
dist/lib/Message/Message.js                            7.56 kB │ gzip:   2.87 kB
dist/lib/Collapse/Collapse.js                          9.04 kB │ gzip:   2.99 kB
dist/lib/ShowMore/ShowMore.js                         11.48 kB │ gzip:   4.02 kB
dist/Transition-3X2EcsU0.mjs                          12.16 kB │ gzip:   3.76 kB
dist/index-j9GOmHnh.mjs                               23.60 kB │ gzip:   6.03 kB
dist/lib/Form/FormField.js                            25.86 kB │ gzip:   6.89 kB
dist/lib/Sidebar/Sidebar.js                           29.58 kB │ gzip:   8.33 kB
dist/lib/InfiniteScrollTable/InfiniteScrollTable.js  186.22 kB │ gzip:  40.95 kB
dist/index-sjH1LaA_.mjs                              668.74 kB │ gzip: 155.83 kB

[vite:dts] Start generate declaration files...
✓ built in 8.16s
[vite:dts] Declaration files built in 3635ms.


 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target build for project core-components (119ms)
 
   Nx read the output from the cache instead of running the command for 1 out of 1 tasks.

Regression

  1. Follow Local Dev Setup but with --skip-nx-cache appended to each nx command.
  2. No log errors.
  3. No UI changes compared to main.

UI

Regression Test (Minimal)
Manage.Account.mov
Projects.Allocations.mov
Login.mov
System.Status.mov
Tickets.mov

Issues

Note

  1. Requires opinionated dependencies, like reactstrap and formik
    Solution:
    1. Report a GitHub Issue, because it affects consumers.
    2. Replace dependencies that are easy to replace with simple code.
    3. Make optional the features that rely on dependencies. Make those dependencies optional (a, b).
  2. I delay using JsDoc to get automatic documentation until v1, because v0 does not need extensive documentation, because it already has familiar users (who copy/pasted the code).

@wesleyboar wesleyboar changed the title test(@tacc/core-components): TUP-700 (WIP) feat: TUP-700 @tacc/core-components Feb 22, 2024
wesleyboar and others added 19 commits February 22, 2024 16:05
1. import & use `dts`
    - Fixes build error:
      > error TS2307: Cannot find module './….module.css' or its corresponding type declarations.
      > … import styles from './….module.css';

2. `"composite": true`
    - Fixes Typescript lint error:
      > Referenced project '/…/tup-ui/libs/core-components/tsconfig.lib.json' must have setting "composite": true.

3. `"declaration": true,`
    - Seemingly caused by `"composite": true`.
    - Fixes Vite build error:
    > \> nx run core-components:build:production
    > error TS6304: Composite projects may not disable declaration emit.
"So the consuming application is aware that it must have React installed to use this package."
— https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#dependencies
"To prevent the CSS files from being accidentally removed by the consumer's tree-shaking efforts…"
—https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#side-effects
Move the changes from thsoe commits to be in core-components package.json, not root package.json.

- style: tup-700 peerDependencies

    "So the consuming application is aware that it must have React installed to use this package."
    — https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#dependencies

- feat: tup-700 add CSS as sideEffects

    "To prevent the CSS files from being accidentally removed by the consumer's tree-shaking efforts…"
    — https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#side-effects

- feat: tup-700 ensure build before publish
Resolve all commented code in `vite.config.ts`.

- `outDir` DELETED cuz `rollupOptions` > `output` exists
- `reportCompressedSize` RESTORED cuz why not & it was already there
- `commonjsOptions` & `transformMixedEsModules` DELETED cuz…
    - no `require` i.e. common js modules
- `lib`'s `name` and `fileName` DELETED cuz…
    - `rollupOptions` > `output` > `assetFileNames` exists
    - `rollupOptions` > `output` > `entryFileNames` exists
wesleyboar and others added 3 commits May 9, 2024 17:41
…CC/tup-ui into feat/TUP-700-core-components-node-pkg
Only 1 root package-lock.json in an Nx project such as tup-ui.

Having this may have been cause of errors when starting CMS.
@wesleyboar wesleyboar changed the base branch from main to epic/TUP-700-core-components-node-pkg May 16, 2024 17:27
@wesleyboar wesleyboar marked this pull request as ready for review May 16, 2024 17:57
@wesleyboar wesleyboar changed the title feat: TUP-700 @tacc/core-components feat: TUP-700 @tacc/core-components - package May 16, 2024
@wesleyboar wesleyboar merged commit 2f710be into epic/TUP-700-core-components-node-pkg May 16, 2024
1 check passed
@wesleyboar wesleyboar deleted the feat/TUP-700-core-components-node-pkg branch May 16, 2024 18:01
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