Draft
Conversation
To simplify maintenance and reduce merge conflicts and manual merge resolution on assets that get regenerated frequently (eg /dist) this removes dist from being tracked. BUT it also makes it so that the repo rebuilds it automatically anywhere it is actually needed: local start up, CI build validation, website deploy, and npm packaging.
Packagers should use the package.sh script. Full stop. Opting out of files removes specificity of inclusion in the package.
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.
Goal
This branch changes the repository so
packages/cfpb-design-system/dist/is no longer tracked onmain, while still allowing us to generatedistwhen we need it:The branch achieves that by moving from a "commit built artifacts back to
main" model to a "build artifacts from source when needed" model.1:
distis now ignoredThe branch adds
packages/cfpb-design-system/dist/to.gitignore.That means:
2: Package generation
package.jsonnow defines:yarn build-packageyarn buildThat means:
yarn build-packageyarn tokensvite.config.packages.jsyarn bulidyarn build-packagevite.config.packages.jsThis is the important piece in the new approach. If
distis not tracked,yarn build-packagebecomes the way to create the package artifacts.3: Local dev creates
distup frontyarn startnow begins by runningyarn build-packagebefore it starts the local site/dev processThat is important because the docs site consumes
distdirectly. Without that upfront build the docs app could start against missing assets.4: CI now validates builds instead of committing
.github.workflows.build.ymlnow does this on pushes and PRs against main:yarn buildbundle exec jekyll build5: Pages deploy still rebuilds from source
.github/workflows/pages.ymlcalls./scripts/update-gh-pages.sh.That script:
maingh-pagesas a worktreeyarn installyarn after-installyarn build-decapgh-pagesyarn build-decapitself runs:yarn installyarn after-installyarn buildbundle exec jekyll buildSo the Pages flow still works without tracked package
distbecause it rebuilds all required assets from source before Jekyll output is published.Notes
Why The Website Still Works
The website is not independent of package
dist. It consumes it.Examples:
docs/assets/css/main.scssimports@cfpb/cfpb-design-system/dist/index.cssdocs/_layouts/default.htmlloads/dist/index.cssand/dist/main.jsdocs/admin/index.htmlloads../dist/admin-decap-cms.jsThat means the website depends on two different generated artifact sets:
distfromyarn build-packagedistfrom the docs Vite buildThis new workflow is valid because
yarn buildproduces both of those before Jekyll runs.Package Publishing Still Works
The desired operating model is:
Under that assumption, the package path is works.
The relevant sequence is:
yarn build-packagepackages/cfpb-design-systemscripts/release.shalready runsyarn buildbeforenpm publish, so the release flow still builds package artifacts before publishing.The important behavior change is in team process:
Tokens And Generated Source Files
yarn build-packagestarts by runningyarn tokens, which uses Style Dictionary and writes generated CSS under:packages/cfpb-design-system/src/elements/abstracts/packages/cfpb-design-system/src/elements/cfpb-button/Those generated source CSS files are still tracked in git. They are separate from
packages/cfpb-design-system/dist/.So there are two different classes of generated output:
src/elements/...packages/cfpb-design-system/dist/That matters because the branch stops tracking bundled
dist, not every generated file in the repo.What Now Becomes Critical
Because
distis no longer committed, a few commands become necessary infrastructure:yarn build-packageyarn buildyarn build-decapIf any of those fail, there is no committed
distonmainto fall back to.In practice that means:
This is less forgiving of broken build steps than what we have today.
Wrap up
This branch does allow the project to stop tracking
packages/cfpb-design-system/dist/onmain, while still generatingdistwhen needed for local development, the website, and package creation.The core idea is:
The moving pieces that make that work are:
.gitignoreignoring packagedistyarn build-packageas the accepted package artifact builderyarn buildcomposing package and docs buildsyarn startgenerating package artifacts before local docs workThe only real DX requirement is that we continues treating
yarn build-packageandyarn buildas mandatory build steps.Changes
Testing
Screenshots
Checklist
Testing checklist
Browsers
Check the current browser support cutoff list for browsers that are advisable
to prioritize for testing.
Accessibility
Other