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: Use tsup and refactor exports #2210

Merged
merged 4 commits into from
Feb 26, 2024
Merged

BREAKING: Use tsup and refactor exports #2210

merged 4 commits into from
Feb 26, 2024

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Feb 22, 2024

This swaps out the build system for tsup, and adds a proper ESM build to each package. In addition to that, the following changes have been made:

  • All packages with Node.js-specific code have been refactored to make them browser compatible. Node.js exports were moved to a separate /node export, i.e., @metamask/snaps-utils/node.
    • This also applies to the React Native webview service in snaps-controllers, which can now be imported from @metamask/snaps-controllers/react-native.
  • The snaps-simulator package is no longer published to NPM. We were previously using it for snaps-jest, but it's no longer used now.

This pull request consists of the following pull requests:

Copy link

socket-security bot commented Feb 22, 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.41 MB lukastaegert
npm/@rollup/[email protected] None 0 2.58 MB lukastaegert
npm/@rollup/[email protected] None 0 2.43 MB lukastaegert
npm/@rollup/[email protected] None 0 2.47 MB lukastaegert
npm/@rollup/[email protected] None 0 2.37 MB lukastaegert
npm/@rollup/[email protected] None 0 2.54 MB lukastaegert
npm/@rollup/[email protected] None 0 2.73 MB lukastaegert
npm/@rollup/[email protected] None 0 2.73 MB lukastaegert
npm/@rollup/[email protected] None 0 2.93 MB lukastaegert
npm/@rollup/[email protected] None 0 2.64 MB lukastaegert
npm/@rollup/[email protected] None 0 3.44 MB lukastaegert
npm/@sindresorhus/[email protected] None 0 58.9 kB sindresorhus
npm/[email protected] None 0 22.2 kB kevinbeaty
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] environment, filesystem 0 14 kB egoist
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] environment, unsafe Transitive: filesystem, shell +38 466 MB ai
npm/[email protected] environment, filesystem +15 35.8 MB lukastaegert
npm/[email protected] Transitive: environment, filesystem, network, shell, unsafe +39 3.75 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] None +1 356 kB sebmaster
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 +170 731 MB egoist
npm/[email protected] None 0 19.3 kB domenic
npm/[email protected] None +4 529 kB domenic

🚮 Removed packages: npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@mole-inc/[email protected], npm/@sindresorhus/[email protected], npm/@swc/[email protected], npm/@szmarczak/[email protected], npm/@tokenizer/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Copy link

socket-security bot commented Feb 22, 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]

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

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@33f01f1). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2210   +/-   ##
=======================================
  Coverage        ?   96.60%           
=======================================
  Files           ?      337           
  Lines           ?     7599           
  Branches        ?     1175           
=======================================
  Hits            ?     7341           
  Misses          ?      258           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Mrtenz Mrtenz changed the title Use tsup and refactor exports BREAKING: Use tsup and refactor exports Feb 23, 2024
@Mrtenz Mrtenz marked this pull request as ready for review February 23, 2024 12:51
@Mrtenz Mrtenz requested a review from a team as a code owner February 23, 2024 12:51
This changes all packages to be built with `tsup`, instead of SWC.
`tsup` uses `esbuild` under the hood, so performance should be
comparable.

More context here: MetaMask/utils#144.
…js (#2211)

This refactors all packages to be browser-first: All APIs and packages
used should be compatible with browsers. This means no use of Node.js
builtins, or native packages. Node-specific APIs have been moved to a
separate export `/node` (e.g., `@metamask/snaps-controllers/node`). For
the `snaps-controllers` package I've also added a `/react-native`
export, which exports the React Native webview service.

This also means we can remove the "browser" field from the packages that
were using it.

## Breaking changes

- Anything that uses Node.js was removed from the default export, and
needs to be imported from `/node`.
- The React Native webview service was moved, and needs to be imported
from `/react-native`.
@Mrtenz
Copy link
Member Author

Mrtenz commented Feb 26, 2024

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

// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const { default: baseConfig } = require('../../tsup.config');

delete baseConfig.entry;
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

deepmerge merges arrays by default, so then tsup would build all TypeScript files. Since we disable splitting here, we only want index.ts to be built.

@Mrtenz Mrtenz merged commit d7488a9 into main Feb 26, 2024
150 checks passed
@Mrtenz Mrtenz deleted the tsup branch February 26, 2024 09:55
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.

2 participants