MetaMask / MetaMask/core

Add smoke tests for CommonJS and ESM builds for each package

Open
#4,386 1 comment 0 reactions 0 assignees View on GitHub
team-wallet-framework wf-ci-tooling
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

Recently, the extension team has encountered issues with dependencies in `core` packages which ship with a default export. [This causes the ESM and CJS builds to act differently, leading to an extremely frustrating experience.](https://consensys.slack.com/archives/C1L7H42BT/p1715800823824669)

Currently, we run tests for each package against a just-in-time, in-memory compiled version of that package, using the TypeScript configuration defined in this repo (thanks to `ts-jest`). We also have a way of statically analyzing `package.json` via the ["Are the Types Wrong?" tool](https://arethetypeswrong.github.io/), and running this would give us some information on better practices we ought to follow when it comes to dual builds.

However, we have no idea whether these builds actually work in various scenarios. What we are missing is a way to run tests against different versions of the compiled JavaScript, simulating various kinds of projects.

## Acceptance Criteria

- We are able to detect and prevent the error with default exports that David Murdoch mentioned in [this Slack message](https://consensys.slack.com/archives/C1L7H42BT/p1715806350459839?thread_ts=1715800823.824669&cid=C1L7H42BT) (also see [this one](https://consensys.slack.com/archives/C1L7H42BT/p1715979254110369?thread_ts=1715800823.824669&cid=C1L7H42BT))
- We are able to detect other kinds of errors that may only pop up in a TypeScript project with different settings and/or in ESM mode or in CommonJS mode and/or using different build tools
- Whatever tests we come up with, it is easy to copy them to other repos so that we can set them up with smoke tests fast

Contributor guide

No contributing guide indexed for this repository

Research direction

Begin with the existing per-package tests that use ts-jest and the repository TypeScript configuration, then inspect package.json and the current compiled-package workflow. Add reusable smoke tests covering CommonJS and ESM builds across the packages and relevant project settings; done means default-export regressions and other build-mode errors are detected and the tests can be copied to other repositories.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.