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

Stop reexporting type files #2030

merged 3 commits into from
Apr 22, 2024

Conversation

WenInCode
Copy link
Contributor

πŸ“Œ Summary

Updates the rollup glob pattern to exlude types.js files within the components folder.

πŸ› οΈ Detailed description

It seems like rollup adds all the ts/js files within the components/ folder into the ember-addon/app-js bit in the package.json and expects there to a default export. I think this is because it expects all those files to be components as is the ember convention? This results in noisey errors for our consumers.

I thought we could just add the types pattern under the { exclude: string[] } options in the appReexports but it did not work as I would have expected, or perhaps my glob was not right. So I ended up updating the patterns globs to exclude types.

πŸ“Έ Screenshots

Before:
Screenshot 2024-03-27 at 9 32 36β€―AM

After:
Screenshot 2024-03-27 at 9 59 55β€―AM

πŸ”— External links

appReexports


πŸ‘€ Component checklist

πŸ’¬ Please consider using conventional comments when reviewing this PR.

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
hds-showcase βœ… Ready (Inspect) Visit Preview Apr 19, 2024 5:57pm
hds-website βœ… Ready (Inspect) Visit Preview Apr 19, 2024 5:57pm

@@ -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.

Copy link
Member

@alex-ju alex-ju left a comment

Choose a reason for hiding this comment

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

Left a suggestion for the changelog entry, otherwise it's good to get in

.changeset/slow-scissors-flow.md Outdated Show resolved Hide resolved
@@ -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
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.

Co-authored-by: Alex <alex-ju@users.noreply.github.com>
@WenInCode
Copy link
Contributor Author

@alex-ju thanks for the suggestion and review

@alex-ju
Copy link
Member

alex-ju commented Apr 22, 2024

@alex-ju thanks for the suggestion and review

Feel free to merge whenever time allows

@WenInCode WenInCode merged commit 868c1d5 into main Apr 22, 2024
16 checks passed
@WenInCode WenInCode deleted the ts/fix-default-export-types branch April 22, 2024 19:03
@hashibot-hds hashibot-hds mentioned this pull request Apr 17, 2024
alex-ju added a commit that referenced this pull request Apr 23, 2024
Follow-up on #2030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants