refactor: share code with vite runtime#15907
Merged
patak-dev merged 13 commits intovitejs:mainfrom Feb 24, 2024
Merged
Conversation
|
|
Member
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 |
sheremet-va
previously approved these changes
Feb 14, 2024
sheremet-va
reviewed
Feb 14, 2024
sheremet-va
reviewed
Feb 14, 2024
bluwy
previously approved these changes
Feb 21, 2024
Member
bluwy
left a comment
There was a problem hiding this comment.
I like this change! Awesome work refactoring this Sapphi.
Member
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI on
|
This was referenced Mar 16, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-mappingand used the original package with patch + replacesrc/runtimesrc/shared/utils.tsandsrc/shared/constants.ts; moved some functions that are used from bothsrc/nodeandsrc/runtimeAdditional context
rollup-plugin-esbuildto remove comments and reduce the number of statements.bias === LEAST_UPPER_BOUNDwithtrueso that some code from@jridgewell/trace-mappingwill be tree shakenpatchedthe change is now merged@jridgewell/resolve-urito 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).