Open frankfka opened 1 month ago
I'm currently experimenting with using tsup within a Turborepo to build a package for publishing. This package has wagmi as a peerDependency, and wagmi is an ESM requiring input. The package.json for the package is:
tsup
wagmi
peerDependency
input
package.json
{ "name": "...", "version": "0.0.0", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "license": "MIT", "scripts": { "build": "tsup", "clean": "rm -rf dist", "dev": "tsup --watch", "lint": "TIMING=1 eslint \"**/*.ts*\"", "typecheck": "tsc --noEmit" }, "private": true, "dependencies": { "d3-format": "^3.1.0" }, "peerDependencies": { "@tanstack/react-query": "^5.32.1", "@tanstack/react-query-devtools": "^5.32.1", "viem": "^2.9.32", "wagmi": "^2.8.1", "react": "^18.2.0" }, "devDependencies": { "@types/d3-format": "^3.0.4", "eslint": "^8.54.0", "eslint-config-custom": "*", "ts-config": "*", "tsup": "^8.0.2", "typescript": "^5.4.5" } }
Additionally, the config for tsup is:
import { defineConfig } from 'tsup'; export default defineConfig({ entry: ['./index.ts'], format: ['cjs', 'esm'], external: ['react'], dts: true, sourcemap: true, });
I see that tsup generates an output that uses require("wagmi") in dist/index.js. Is there a good way to resolve this?
require("wagmi")
dist/index.js
I'm currently experimenting with using
tsup
within a Turborepo to build a package for publishing. This package haswagmi
as apeerDependency
, andwagmi
is an ESM requiringinput
. Thepackage.json
for the package is:Additionally, the config for
tsup
is:I see that
tsup
generates an output that usesrequire("wagmi")
indist/index.js
. Is there a good way to resolve this?Upvote & Fund