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

BREAKING: Build packages with tsup #3998

Merged
merged 5 commits into from
Mar 7, 2024
Merged

BREAKING: Build packages with tsup #3998

merged 5 commits into from
Mar 7, 2024

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Feb 29, 2024

Explanation

This changes the build system to build all packages with tsup, instead of tsc. tsc is still used for generating the declaration files and type checking, and tsup is used for building the .js and (new) .mjs files. The benefit of this is that we now have a ESM build as well as a CJS build.

References

See MetaMask/utils#144.

Changelog

@metamask/accounts-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/address-book-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/announcement-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/approval-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/assets-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/base-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/build-utils

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/composable-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/controller-utils

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/ens-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/eth-json-rpc-provider

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/gas-fee-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/json-rpc-engine

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/json-rpc-middleware-stream

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/keyring-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/logging-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/message-manager

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/name-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/network-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/notification-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/permission-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/permission-log-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/phishing-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/polling-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/preferences-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/queued-request-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/rate-limit-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/selected-network-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/signature-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/transaction-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

@metamask/user-operation-controller

  • BREAKING: Add ESM build.
    • It's no longer possible to import files from ./dist directly.

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

Copy link

socket-security bot commented Feb 29, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@esbuild/[email protected] None 0 10.4 MB evanw
npm/@esbuild/[email protected] None 0 11.5 MB evanw
npm/@esbuild/[email protected] None 0 9.83 MB evanw
npm/@esbuild/[email protected] None 0 11.5 MB evanw
npm/@esbuild/[email protected] None 0 9.76 MB evanw
npm/@esbuild/[email protected] None 0 10.2 MB evanw
npm/@esbuild/[email protected] None 0 8.85 MB evanw
npm/@esbuild/[email protected] None 0 9.61 MB evanw
npm/@esbuild/[email protected] None 0 9.18 MB evanw
npm/@esbuild/[email protected] None 0 8.85 MB evanw
npm/@esbuild/[email protected] None 0 9.14 MB evanw
npm/@esbuild/[email protected] None 0 9.37 MB evanw
npm/@esbuild/[email protected] None 0 10.4 MB evanw
npm/@esbuild/[email protected] None 0 9.18 MB evanw
npm/@esbuild/[email protected] None 0 9.11 MB evanw
npm/@esbuild/[email protected] None 0 10 MB evanw
npm/@esbuild/[email protected] None 0 9.6 MB evanw
npm/@esbuild/[email protected] None 0 9.59 MB evanw
npm/@esbuild/[email protected] None 0 9.62 MB evanw
npm/@esbuild/[email protected] None 0 9.59 MB evanw
npm/@esbuild/[email protected] None 0 8.98 MB evanw
npm/@esbuild/[email protected] None 0 9.45 MB evanw
npm/@esbuild/[email protected] None 0 9.81 MB evanw
npm/@rollup/[email protected] None 0 1.63 MB lukastaegert
npm/@rollup/[email protected] None 0 2.49 MB lukastaegert
npm/@rollup/[email protected] None 0 2.43 MB lukastaegert
npm/@rollup/[email protected] None 0 2.58 MB lukastaegert
npm/@rollup/[email protected] None 0 2.44 MB lukastaegert
npm/@rollup/[email protected] None 0 2.49 MB lukastaegert
npm/@rollup/[email protected] None 0 2.37 MB lukastaegert
npm/@rollup/[email protected] None 0 2.52 MB lukastaegert
npm/@rollup/[email protected] None 0 2.72 MB lukastaegert
npm/@rollup/[email protected] None 0 2.7 MB lukastaegert
npm/@rollup/[email protected] None 0 2.96 MB lukastaegert
npm/@rollup/[email protected] None 0 2.63 MB lukastaegert
npm/@rollup/[email protected] None 0 3.47 MB lukastaegert
npm/[email protected] None 0 22.2 kB kevinbeaty
npm/[email protected] None 0 5.36 kB sindresorhus
npm/[email protected] environment, filesystem, unsafe Transitive: network, shell +25 224 MB egoist
npm/[email protected] None 0 81.8 kB egoist
npm/[email protected] environment, filesystem +14 531 kB paulmillr
npm/[email protected] environment, filesystem, network, shell +23 224 MB evanw
npm/[email protected] None +1 8.43 kB sindresorhus
npm/[email protected] environment, filesystem 0 14 kB egoist
npm/[email protected] filesystem 0 17.7 kB antonk52
npm/[email protected] None 0 17.1 kB egoist
npm/[email protected] None 0 75.8 kB jdalton
npm/[email protected] filesystem, network, shell +4 52 kB jongleberry
npm/[email protected] None 0 5.49 kB sindresorhus
npm/[email protected] environment, unsafe Transitive: filesystem +25 71.9 MB ai
npm/[email protected] None +15 33.6 MB
npm/[email protected] Transitive: environment, filesystem, network, shell, unsafe +41 3.8 MB alangpierce
npm/[email protected] None +2 36.7 kB dead_horse
npm/[email protected] None +1 30.1 kB dead_horse
npm/[email protected] shell 0 7.82 kB wmhilton
npm/[email protected] None 0 68 kB dsagal2
npm/[email protected] environment, eval, filesystem Transitive: network, shell, unsafe +158 335 MB egoist

View full report↗︎

Copy link

socket-security bot commented Feb 29, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

const { transform: transform3 } = await Promise.resolve().then(() => require("sucrase"));
const result = transform3(code, {
+ // https://github.com/egoist/tsup/issues/1087
+ disableESTransforms: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

tsup uses sucrase to transpile ESM to CJS (unless tree shaking is enabled, but that breaks source maps), and sucrase enables all polyfills by default. Our environment supports all the features, so we don't need these polyfills. This also improves static analysis in LavaMoat.

constraints.pro Outdated
Comment on lines 260 to 262
% Published packages must not have side effects.
gen_enforced_field(WorkspaceCwd, 'sideEffects', false) :-
\+ workspace_field(WorkspaceCwd, 'private', true).
Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't checked every single package for side effects, but it looks like there aren't any. Setting sideEffects: false improves tree shaking in tools like Webpack.

@Mrtenz
Copy link
Member Author

Mrtenz commented Feb 29, 2024

@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/[email protected]

These are expected to have shell / network access.

@SocketSecurity ignore npm/[email protected]

New author is ok.

@Mrtenz Mrtenz marked this pull request as ready for review February 29, 2024 13:05
@Mrtenz Mrtenz requested review from a team as code owners February 29, 2024 13:05
@Mrtenz
Copy link
Member Author

Mrtenz commented Mar 6, 2024

@metamaskbot publish-preview

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Looks good!

@mcmire
Copy link
Contributor

mcmire commented Mar 7, 2024

I am not sure why the check failed, but once this branch is updated against main, it should re-run that check. I will re-run it now.

@Mrtenz Mrtenz merged commit 87a661d into main Mar 7, 2024
139 checks passed
@Mrtenz Mrtenz deleted the mrtenz/tsup branch March 7, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants