-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
refactor: share code with vite runtime #15907
refactor: share code with vite runtime #15907
Conversation
Run & review this pull request in StackBlitz Codeflow. |
I think the idea is that it should only include code that can actually be running. The reason why we are doing it as a separate entry point is to not drag rollup/esbuild and all other dependencies where they are not used.
I don't think that's necessary. From the bundled code point of view, I am very satisfied with the result 👍🏻 And I also like separating runtime code into |
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 like this change! Awesome work refactoring this Sapphi.
/ecosystem-ci run |
📝 Ran ecosystem CI on
|
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.
This is awesome ❤️
Description
This PR dedupes some code by changing the rollup config and sharing the code with the main code base and the runtime code base.
Sharing code between the main bundle and the runtime bundle is challenging because the main code base should not be included in the runtime bundle. Therefore, this pull request accepts the same code to be included in both the main bundle and the runtime bundle. Since the same code is already included in the main bundle and runtime bundle, the file size will not be larger than before.
There's more code that can be shared but I left them for now to keep this PR smaller.
The new directory structure
import 'vite/runtime'
.What I did
rollup.config.ts
,rollup.dts.config.ts
,src/node/tsconfig.json
,vitest.config.ts
@jridgewell/trace-mapping
and used the original package with patch + replacesrc/runtime
src/shared/utils.ts
andsrc/shared/constants.ts
; moved some functions that are used from bothsrc/node
andsrc/runtime
Additional context
rollup-plugin-esbuild
to remove comments and reduce the number of statements.bias === LEAST_UPPER_BOUND
withtrue
so that some code from@jridgewell/trace-mapping
will be tree shakenpatchedthe change is now merged@jridgewell/resolve-uri
to make some code tree-shakenWhat is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).