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

chore: Split out data attributes to separate files #75

Closed
wants to merge 1 commit into from

Conversation

nmn
Copy link
Contributor

@nmn nmn commented Apr 4, 2024

Stop-gap solution for #71

This is a simple refactor that splits out all definitions of data-* attributes to separate files. This makes it easier to maintain a separate list of supported attributes internally without the need for patch files etc.

Copy link

github-actions bot commented Apr 4, 2024

compressed-size: runtime library

Size change: +0.01 kB
Total size: 18.77 kB

Filename: gzip (minify) kB size kB change % change
./packages/react-strict-dom/dist/dom/index.js 2.99 (9.00) +0.01 (+0.01) +0.2% (+0.1%)
./packages/react-strict-dom/dist/native/index.js 14.83 (46.38) -0.00 (+0.01) -0.0% (0.0%)
View unchanged
Filename: gzip (minify) kB size kB change % change
./packages/react-strict-dom/dist/dom/runtime.js 0.95 (2.33) 0.00 (0.00) 0.0% (0.0%)

necolas pushed a commit that referenced this pull request Apr 4, 2024
Allow arbitrary data-* props at runtime. On web, the check is only
performed during development.

To workaround Flow's lack of support for typing arbitary data-* props, a
separate type is created just for data-* props which can be used to
maintain an app's list of supported data-* props.

Ref #71
Close #75
@necolas necolas force-pushed the chore/data-attrs branch from 9a15d99 to 43b8181 Compare April 4, 2024 19:21
@necolas
Copy link
Contributor

necolas commented Apr 4, 2024

I reworked this PR to:

  1. not increase the size of the bundles.
  2. not require us to maintain 2 lists of data-* props (1 for Flow, 1 for JS).
  3. not include any data-* props by default, apart from data-testid.

Please take a look and let me know if it still looks OK to you. Thanks!

@necolas
Copy link
Contributor

necolas commented Apr 4, 2024

I'll revisit this to use the approach we took for Stringish which would allow internal overrides without having to rely on code syncs and patch files.

necolas pushed a commit that referenced this pull request Apr 4, 2024
Allow arbitrary data-* props at runtime. On web, the check is only
performed during development.

To workaround Flow's lack of support for typing arbitary data-* props, a
separate type is created just for data-* props which can be used to
maintain an app's list of supported data-* props.

Ref #71
Close #75
@necolas necolas force-pushed the chore/data-attrs branch from 43b8181 to 7b5732a Compare April 4, 2024 23:17
Allow arbitrary data-* props at runtime. On web, the check is only
performed during development.

To workaround Flow's lack of support for typing arbitary data-* props, a
separate type is created just for data-* props which can be used to
maintain an app's list of supported data-* props.

Ref #71
Close #75
@necolas necolas force-pushed the chore/data-attrs branch from 7b5732a to b32baeb Compare April 5, 2024 03:32
@necolas necolas closed this in 6b60c5f Apr 5, 2024
@necolas necolas deleted the chore/data-attrs branch April 5, 2024 03:39
// This type allows Meta to internally override it with an
// internationalization type which is a string at runtime…
// but Flow doesn't know that.
declare type Stringish = string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be a problem for the generated TS types. We should use explicit imports and avoid usage of any "globals".

Copy link
Contributor

@necolas necolas Apr 6, 2024

Choose a reason for hiding this comment

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

Yeah we can fix that pre-existing issue later after fixing internal and syncing

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.

3 participants