-
Notifications
You must be signed in to change notification settings - Fork 85
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
build!: Allow direct imports and component normalization #2899
Draft
jpandersen87
wants to merge
33
commits into
trussworks:main
Choose a base branch
from
jpandersen87:tree-shaking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
- 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
jpandersen87
changed the title
!build: Allow direct imports and component normalization
build!: Allow direct imports and component normalization
Apr 26, 2024
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:
libSrc
foldersrc
folder reserved for non-library code (ex: setupTests, custom rendering scenarios viavite preview
orvite dev
)utils
moduleconstants
modulefixtures
module_ref
prop added to base component that the forwardRef version forwards itsref
to (React 19 is standardizingref
being 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:
DTS
plugin is configured with an additional option to run afixCjsDeclarations
function for the cjs non-bundled export in order to move and rename the cjsd.ts
extensions to properd.cts
The project also now uses the USWDS'
compile
package 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
module
setting for typescript was changed tonode16
. This makes it required to include the extension on all relative imports (reflective of the fact this package is nowesm
by default andes
modules have that import extension requirement. TheisolatedModules
option was also enabled, requiring type import/exports to be explicitly marked astype
.The
.usa-tooltip__body
override was removed as its issue appears to have been resolved (uswds/uswds#4458).Related Issues or PRs
N/A
How To Test
@trussworks/react-uswds
dependency instead of from npm for your project