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

Align JavaScript component names with USWDS #414

Merged
merged 3 commits into from
Mar 1, 2024

Conversation

aduth
Copy link
Contributor

@aduth aduth commented Mar 1, 2024

🛠 Summary of changes

Updates JavaScript components to ensure that their names match those exported by USWDS. This is an inconsistency within USWDS itself between its package directory names and the corresponding exported JavaScript component name.

Why?

  • This package is meant to operate as a drop-in replacement for USWDS, so its exported members should match 1-to-1

📜 Testing Plan

Verify the modified test passes:

npm run build
node --test test/components/index.test.js

Comment on lines +15 to +18
const [, exports] = /** @type {RegExpMatchArray} */ (
uswdsComponentsIndex.match(/module\.exports = \{([\s\S]+)\};/)
);
const uswdsComponentKeys = Array.from(exports.matchAll(/(?:\s+([a-zA-Z]+)),/g))
Copy link
Contributor Author

@aduth aduth Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered pulling in a library like cjs-module-lexer for this, though we already have some regular expressions above for parsing the ESM from this project.

Co-authored-by: Zach Margolis <[email protected]>
@aduth aduth merged commit 287f111 into main Mar 1, 2024
5 checks passed
@aduth aduth deleted the aduth-sync-uswds-js-component-exports branch March 1, 2024 22:34
@aduth
Copy link
Contributor Author

aduth commented Mar 4, 2024

Sad thing is I discovered this is the inverse of a breaking change we previously implemented in 7.0.0 🙈

  • The following JavaScript named exports have been renamed or removed:
    • navigation is renamed to header
    • validator is renamed to validation

https://github.com/18F/identity-design-system/pull/321/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed

Hopefully this'll stick. I don't love that the names are inconsistent with package directory in USWDS (which is where the names header and validation come from), but I think I'd rather be consistent with how USWDS exposes these in their main index.

@aduth aduth mentioned this pull request Mar 4, 2024
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.

2 participants