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

Modify build process to disable code splitting #4334

Closed
wants to merge 1 commit into from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented May 28, 2024

Explanation

The code splitting feature in tsup breaks up source code into logical modules so that if a module is not being used it can be removed by a build tool that supports tree shaking.

However, the modules that tsup creates do not necessary match the files in the original source code, and tsup gives them a random name. This makes it frustrating for developers on a client team who are debugging a core package by inspecting the compiled version, because it is impossible to tell what a chunk file contains without first opening it up.

This commit thus configures tsup to disable the code splitting feature.

References

Fixes #4333.

Testing

  • Run yarn build.
  • Open up the dist directory for a package such as packages/assets-controllers.
  • You shouldn't see any files named chunk-XXXX.js or chunk-XXXX.mjs.

Changelog

(Updated in PR.)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

packages/accounts-controller/package.json Outdated Show resolved Hide resolved
@@ -38,7 +38,7 @@ const config: Options = {

// Split the output into chunks. This is useful for tree-shaking.
// https://tsup.egoist.dev/#code-splitting
splitting: true,
splitting: false,
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 is the actual configuration change which disables the code splitting
/ "chunking" feature.

@mcmire
Copy link
Contributor Author

mcmire commented Jun 27, 2024

@metamaskbot publish-previews

@mcmire
Copy link
Contributor Author

mcmire commented Jun 27, 2024

@metamaskbot publish-preview

@mcmire
Copy link
Contributor Author

mcmire commented Jun 27, 2024

@metamaskbot publish-previews

@mcmire
Copy link
Contributor Author

mcmire commented Jun 27, 2024

The repo is in a state of limbo currently because of a failed release. Once that gets resolved then I'll try creating preview builds again.

The code splitting feature in `tsup` breaks up source code into logical
modules so that if a module is not being used it can be removed by a
build tool that supports tree shaking.

However, the modules that `tsup` creates do not necessary match the
files in the original source code, and `tsup` gives them a random name.
This makes it frustrating for developers on a client team who are
debugging a `core` package by inspecting the compiled version, because
it is impossible to tell what a chunk file contains without first
opening it up.

This commit thus configures `tsup` to disable the code splitting
feature.
@mcmire mcmire marked this pull request as ready for review July 3, 2024 17:50
@mcmire mcmire requested review from a team as code owners July 3, 2024 17:50
@mcmire mcmire marked this pull request as draft July 3, 2024 19:37
@mcmire
Copy link
Contributor Author

mcmire commented Jul 23, 2024

I am going to close this PR, as we need code splitting for Snaps. ts-bridge is close to supporting monorepos anyway.

@mcmire mcmire closed this Jul 23, 2024
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.

tsup's code splitting feature makes core packages difficult to debug
1 participant