Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/sdk-analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- fix: bundle openapi-fetch into sdk-analytics dist to avoid broken .cjs resolution ([#1399](https://github.com/MetaMask/metamask-sdk/pull/1399))

## [0.0.6]
### Changed
Expand Down
8 changes: 3 additions & 5 deletions packages/sdk-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup src/index.ts --dts --format esm,cjs",
"build": "tsup",
"lint": "eslint src --ext .ts,.tsx --ignore-pattern 'src/schema.ts'",
"lint:fix": "eslint src --ext .ts,.tsx --fix --ignore-pattern 'src/schema.ts'",
"lint:changelog": "../../scripts/validate-changelog.sh @metamask/sdk-analytics",
Expand All @@ -28,6 +28,7 @@
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"nock": "^14.0.4",
"openapi-fetch": "^0.13.5",
"prettier": "^3.3.3",
"tsup": "^8.4.0",
"typescript": "^5.8.3",
Expand All @@ -38,8 +39,5 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"license": "MIT",
"dependencies": {
"openapi-fetch": "^0.13.5"
}
"license": "MIT"
}
15 changes: 15 additions & 0 deletions packages/sdk-analytics/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
// Bundle `openapi-fetch` into the output instead of leaving it as a
// runtime `require()`/`import`. Its `require` export condition points to
// `dist/cjs/index.cjs`, and webpack configs that have no rule for `.cjs`
// files (e.g. create-react-app) emit that file as a static asset URL,
// which makes `createClient` resolve to a string at runtime and throw
// "import_openapi_fetch.default is not a function".
// See https://github.com/MetaMask/metamask-sdk/issues/1340
noExternal: ['openapi-fetch'],
});