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

refactor: delete dependent pre built proxy modules #10427

Merged
merged 4 commits into from Oct 14, 2022
Merged

Conversation

ysy945
Copy link
Contributor

@ysy945 ysy945 commented Oct 11, 2022

For the old version of "esbuild", in order to flatten the dependent pre built products, the agent module will be used to process the "require ('react /jsx runtime. js')" The reason why the path was not directly modified to redirect to the entry is that the products will have a nested structure. The subsequent packaging is also added to prevent secondary packaging.
However, for the current version of "esbuild", even if it is directly redirected to the entry module, the product name is still specified by entryPoints and will not result in secondary packaging or nested products. Therefore, we do not need to use the proxy module now.
After the above code is deleted and added, vite still runs well, and the pre built products and product size will not change. Even if module "A" depends on module "B", using modules "A" and "B" in the project can also extract the same part.
Deleting the agent module will optimize more volumes.

For the old version of "esbuild", in order to flatten the dependent pre built products, the agent module will be used to process the "require ('react /jsx runtime. js')". The reason why the path was not directly modified to redirect to the entry is that the products will have a nested structure. The subsequent wrapper is also added to prevent secondary packaging.
However, for the current version of "esbuild", even if it is directly redirected to the entry module, the product name is still specified by "entryPoints" and will not result in secondary packaging or nested products. Therefore, we do not need to use the proxy module now.
After deleting and adding the above code, “vite” still runs well, and the pre built product and product size will not change.
update the error of typescript
Copy link
Contributor Author

@ysy945 ysy945 left a comment

Choose a reason for hiding this comment

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

update

@ysy945 ysy945 changed the title fix:delete dependent pre built proxy modules fix: delete dependent pre built proxy modules Oct 11, 2022
Copy link
Contributor Author

@ysy945 ysy945 left a comment

Choose a reason for hiding this comment

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

Update file style

@ysy945
Copy link
Contributor Author

ysy945 commented Oct 12, 2022

If the "0.8.34" version of "esbuild" is used for packaging, and the path is directly modified, the nesting problem of the "dist" directory will occur.
image
Therefore, "onLoad" is introduced to load modules so that the products will not be nested. However, this may lead to the problem of secondary packaging. Therefore, 'es module lexer' is used to scan the entry file and generate new content of the package as the return value of "contents".
image
However, for the current version of "esbuild", even if the path is directly modified, the problem of product nesting will not occur
image
So you can delete the proxy module. The comment in the source code is this paragraph:
image
And you can also extract the same module by directly modifying the path in current version of "esbuild"
image

@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Oct 14, 2022

📝 Ran ecosystem CI: Open

suite result
astro ✅ success
histoire ✅ success
iles ✅ success
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt-framework ✅ success
rakkas ✅ success
svelte ✅ success
vite-plugin-ssr ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success
windicss ✅ success

@patak-dev
Copy link
Member

This is great @ysy945 ❤️

Merging (also discussed with @bluwy about it)

@patak-dev patak-dev changed the title fix: delete dependent pre built proxy modules refactor: delete dependent pre built proxy modules Oct 14, 2022
@patak-dev patak-dev merged commit b3b388d into vitejs:main Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants