build!: Allow direct imports and component normalization#2899
Draft
jpandersen87 wants to merge 33 commits intotrussworks:mainfrom
Draft
build!: Allow direct imports and component normalization#2899jpandersen87 wants to merge 33 commits intotrussworks:mainfrom
jpandersen87 wants to merge 33 commits intotrussworks:mainfrom
Conversation
- do not directly import uswds image files (so as not to create library copies, defeating the purpose of peer dependency) - use custom user-configurable uswds image object to use for references to uswds images (icons, govbanner) - icons reworked based on above - remove uswds css logic from vite config - remove vite settings that manipulated output filenames (let vite organize output as close to default as possible) - limit library formats to cjs/es for now - use @uswds/compile for creating uswds assets (provide uswds assets from a fresh init, preventing those assets from being processed via vite and being mutated in unexpected ways) - package.json exports (we can be backward-compatible with new output structure) - package.json scripts (use glob pattern matching for eslint)
- export everything - helper fns moved to local utils - comp props type added / updated
- use env var to determine lib format for build - output formats in dedicated subfolders
- only one type set exported - fix govbanner
- extensions added to all relative imports - type-fest added - prop type adjustements - use component instead of raw elements when relevant - remove use of file/svg mocks - establish lib for lib export code, and src for other things (ex: setupTests)
- commanderjs, tsx added for scripting - build cjs and es formats unbundled and bundled - separate inner component functions from forwardref version - ensure index exports point to forwardref versions - add base props to all components
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.
Summary
This PR makes project-wide changes to allow importing from files directly in addition to the index. Build and project configuration changes were made to ensure the package passes tests from https://arethetypeswrong.github.io/. All components were modified for one of the following reasons:
libSrcfoldersrcfolder reserved for non-library code (ex: setupTests, custom rendering scenarios viavite previeworvite dev)utilsmoduleconstantsmodulefixturesmodule_refprop added to base component that the forwardRef version forwards itsrefto (React 19 is standardizingrefbeing a prop on functional components and removing the need of forwardRef)Some areas where we could use one of the react-uswds components instead of a jsx element (ex: Button, Grid) were updated to use those components instead.
A dedicated build script for handling the logic of building the library in various formats and related dependencies were added. Other build notes:
DTSplugin is configured with an additional option to run afixCjsDeclarationsfunction for the cjs non-bundled export in order to move and rename the cjsd.tsextensions to properd.ctsThe project also now uses the USWDS'
compilepackage via gulpfile to create the default settings css file (with all assets generated exposed).In order to create compatible typescript declarations for both cjs and es modes, the
modulesetting for typescript was changed tonode16. This makes it required to include the extension on all relative imports (reflective of the fact this package is nowesmby default andesmodules have that import extension requirement. TheisolatedModulesoption was also enabled, requiring type import/exports to be explicitly marked astype.The
.usa-tooltip__bodyoverride was removed as its issue appears to have been resolved (uswds/uswds#4458).Related Issues or PRs
N/A
How To Test
@trussworks/react-uswdsdependency instead of from npm for your project