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

Stop reexporting type files #2030

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slow-scissors-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hashicorp/design-system-components": patch
---

Fixed default export warnings by preventing `types.js` files from being reexported
6 changes: 0 additions & 6 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
"./components/hds/alert/description.js": "./dist/_app_/components/hds/alert/description.js",
"./components/hds/alert/index.js": "./dist/_app_/components/hds/alert/index.js",
"./components/hds/alert/title.js": "./dist/_app_/components/hds/alert/title.js",
"./components/hds/alert/types.js": "./dist/_app_/components/hds/alert/types.js",
"./components/hds/app-footer/copyright.js": "./dist/_app_/components/hds/app-footer/copyright.js",
"./components/hds/app-footer/index.js": "./dist/_app_/components/hds/app-footer/index.js",
"./components/hds/app-footer/item.js": "./dist/_app_/components/hds/app-footer/item.js",
Expand All @@ -133,7 +132,6 @@
"./components/hds/button-set/index.js": "./dist/_app_/components/hds/button-set/index.js",
"./components/hds/button/index.js": "./dist/_app_/components/hds/button/index.js",
"./components/hds/card/container.js": "./dist/_app_/components/hds/card/container.js",
"./components/hds/card/types.js": "./dist/_app_/components/hds/card/types.js",
"./components/hds/code-block/copy-button.js": "./dist/_app_/components/hds/code-block/copy-button.js",
"./components/hds/code-block/description.js": "./dist/_app_/components/hds/code-block/description.js",
"./components/hds/code-block/index.js": "./dist/_app_/components/hds/code-block/index.js",
Expand Down Expand Up @@ -197,10 +195,8 @@
"./components/hds/form/visibility-toggle/index.js": "./dist/_app_/components/hds/form/visibility-toggle/index.js",
"./components/hds/icon-tile/index.js": "./dist/_app_/components/hds/icon-tile/index.js",
"./components/hds/interactive/index.js": "./dist/_app_/components/hds/interactive/index.js",
"./components/hds/interactive/types.js": "./dist/_app_/components/hds/interactive/types.js",
"./components/hds/link/inline.js": "./dist/_app_/components/hds/link/inline.js",
"./components/hds/link/standalone.js": "./dist/_app_/components/hds/link/standalone.js",
"./components/hds/link/types.js": "./dist/_app_/components/hds/link/types.js",
"./components/hds/menu-primitive/index.js": "./dist/_app_/components/hds/menu-primitive/index.js",
"./components/hds/modal/body.js": "./dist/_app_/components/hds/modal/body.js",
"./components/hds/modal/footer.js": "./dist/_app_/components/hds/modal/footer.js",
Expand Down Expand Up @@ -254,11 +250,9 @@
"./components/hds/text/code.js": "./dist/_app_/components/hds/text/code.js",
"./components/hds/text/display.js": "./dist/_app_/components/hds/text/display.js",
"./components/hds/text/index.js": "./dist/_app_/components/hds/text/index.js",
"./components/hds/text/types.js": "./dist/_app_/components/hds/text/types.js",
"./components/hds/toast/index.js": "./dist/_app_/components/hds/toast/index.js",
"./components/hds/tooltip-button/index.js": "./dist/_app_/components/hds/tooltip-button/index.js",
"./components/hds/yield/index.js": "./dist/_app_/components/hds/yield/index.js",
"./components/hds/yield/types.js": "./dist/_app_/components/hds/yield/types.js",
"./helpers/hds-link-to-models.js": "./dist/_app_/helpers/hds-link-to-models.js",
"./helpers/hds-link-to-query.js": "./dist/_app_/helpers/hds-link-to-query.js",
"./modifiers/hds-clipboard.js": "./dist/_app_/modifiers/hds-clipboard.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/components/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const plugins = [
// "app" tree. Things in here should also be in publicEntrypoints above, but
// not everything in publicEntrypoints necessarily needs to go here.
addon.appReexports([
'components/**/*.js',
'components/**/!(*types).js',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we are following this pattern for type location going forward, should I also update the helper and modifiers pattern below?

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently the hds modifiers and helpers live under the same folder(s). which folder structure are you envisioning?

Types next to the files:

packages/components/src/helpers/hds-link-to-models.ts
packages/components/src/helpers/hds-link-to-models.types.ts
packages/components/src/modifiers/hds-clipboard.ts
packages/components/src/modifiers/hds-clipboard.types.ts

Creation of parent folders (is it possible? does it work in Ember?):

packages/components/src/helpers/hds-link-to-models/index.ts
packages/components/src/helpers/hds-link-to-models/types.ts
packages/components/src/modifiers/hds-clipboard/index.ts
packages/components/src/modifiers/hds-clipboard/types.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a very good question. I'm not sure what the answer is atm, and so maybe it's best not to address this now.

I'll try out the above options just to see what it looks like/what works. It would be nice if it could be consistent across all components/modifiers/helpers/etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not super familiar with app reexports - if the types are removed does this mean that a consumer in a v1 addon can't import things from type files (like enums etc), or is that still possible since they are included in the public entrypoints above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya I believe that is handled by the publicEntrypoints. CUT currently re-exports the types (whoops!) but we also have an index file that imports and exports all the types. That file is not part of the appReexports but it is accessible from cloud-ui.

Copy link
Contributor

Choose a reason for hiding this comment

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

appReexports is a compatability layer tat only needed for v1 apps with hbs/js, with current setup it would still export types

Copy link
Member

Choose a reason for hiding this comment

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

We currently don't have type files for helpers and modifiers, so I wouldn't worry about it just now.

'helpers/**/*.js',
'modifiers/**/*.js',
]),
Expand Down Expand Up @@ -86,4 +86,4 @@ export default {
output: addon.output(),
plugins: plugins,
external: ['ember-modifier', 'prismjs'],
};
};