-
Notifications
You must be signed in to change notification settings - Fork 168
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: Update build script to generate flow and TS types: #36
Conversation
compressed-size: runtime library Size change: +15.90 kB 🔴
|
Nice! I kind of want to keep flat bundling for OSS. And I wish this wasn't so much more complicated than the current setup (apart from existing flow lib def script). This isn't a modular library and we've previously found benefits in size and app bundling perf from pre-bundling libraries like react. Plus, to retain the most useful perf CI data we need flat bundles. AFAICT the motivation for this change is because flow doesn't support automatically generating lib defs |
One downside of flat bundling is that you can take advantage of tree-shaking in modern bundlers. However, if we stop here, we can keep the flat bundles for the JS code and only keep the separate files for the type-defs.
If we only publish an ESM build to NPM, we can limit what we export so that all the other files are "private".
The |
There's nothing to tree-shake out of this package on web, or even native really. AFAIK, tree-shaking / DCE isn't limited to what's in different files and should work if exports within a file aren't used. So we can focus on the types side of things |
@necolas That makes things simple enough. This PR is now ready. I simply changed the output path from I can probably make this set up work for internal sync as well. |
Update: Made a couple of changes to ensure that no two files in the package have the same name. (Except when there are
For now, I've renamed one of the This work has been done to be compatible with Haste for internal sync. |
Not able to reproduce this failure locally. I don't even have the file that is erroring. :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this patch still allow importing of types from the main package, e.g., import type { StrictHTMLElement } from 'react-strict-dom'
?
file: path.join( | ||
__dirname, | ||
'../packages/react-strict-dom/dist/dom/index.js' | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the www build? That is still being written to dist/dom.www.js
; how is internal use going to work if the types are being picked up from the new flow files but they have references to the @stylexjs/stylex
package instead of stylex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will be transforming the imports while copying the files over during sync.
@necolas Does this look good to merge? (I know you're on a break, so let me know if I should run this by someone else while you're away) |
There's still a few things to update before that. I'll comment over the weekend. Also left some questions above |
Anything that is exported from the entry point can be imported directly. If there are types that are currently not exported from the entrypoint that are supposed to be public, we can add them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The paths to the build files also need to be updated in the performance workflow file.
^ this still needs to be done. Also need to update the paths in the build size badges in the RSD README. They will update to the correct values once I publish the release after this patch |
I pushed fixes for the path updates. However, there's one more path in the |
fda70f0
to
01c6f32
Compare
Let me figure this out. |
This is a known issue with Flow. It causes "untyped" code rather than type errors. We might need to add some checks to cache type-coverage regressions for this. We also need to update the Flow version. I'll do that after this PR has merged. |
Thanks! Merged |
#Fixes #25
Using StyleX as a starting point, overhauling the build scripts.
gen-flow
wrapper aroundflow-api-translator
package.json
to point to the new output filesSkipped these steps as we decided to keep flat bundles for now:
Set up a Babel translation step for publishing to NPM that doesn't pre-bundleSet up a Babel translation step that translates to Haste modules