Skip to content

Commit

Permalink
Support CommonJS by properly setting the exports field and using `.…
Browse files Browse the repository at this point in the history
…npmignore` to filter out filtes to ignore (ourzora#225)

* Revert "Revert "Adding exports to protocol-sdk package.json (ourzora#214)" (ourzora#223)"

This reverts commit 8a87809.

* added npm ignore

* applied exports fixes to other dependent package
  • Loading branch information
oveddan authored Mar 4, 2024
1 parent f51ab0b commit 52b16aa
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 78 deletions.
7 changes: 7 additions & 0 deletions .changeset/empty-sloths-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@zoralabs/protocol-deployments": patch
"@zoralabs/zora-1155-contracts": patch
"@zoralabs/protocol-sdk": patch
---

Publishing package in format that supports commonjs imports by specifying exports
18 changes: 18 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# this defines what should be ignored
# for npm publishing. it overrides the .gitignore
# for npm publishing. We need this to be defined separately
# so we can include the dist folder.
tsconfig.build.json
**/*test-integration
**/*.test.ts
.turbo
tsup.config.ts
**/*.env*
wagmi.config.ts
cache
lcov.info
.storage-layout
**/*.puml
**/*.sh
test
out
23 changes: 11 additions & 12 deletions packages/1155-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
"repository": "[email protected]:ourzora/zora-protocol.git",
"author": "Iain <[email protected]>",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/package/index.d.ts",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.cjs"
}
},
"scripts": {
"dev": "FOUNDRY_PROFILE=dev forge test --watch -vvv",
"test": "forge test -vv",
Expand All @@ -25,16 +34,6 @@
"storage-inspect:generate": "./script/storage-check.sh generate ZoraCreator1155Impl ZoraCreator1155FactoryImpl",
"update-contract-version": "node script/update-contract-version.mjs"
},
"files": [
"dist/",
"src/",
"out/",
"addresses/",
"chainConfigs/",
"package/",
"abis/",
"_imagine/"
],
"dependencies": {
"solmate": "6.1.0",
"forge-std": "https://github.com/foundry-rs/forge-std#705263c95892a906d7af65f0f73ce8a4a0c80b80",
Expand Down
10 changes: 10 additions & 0 deletions packages/1155-contracts/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "zoralabs-tsconfig/tsconfig.json",
"compilerOptions": {
"lib": ["es2021", "DOM"],
"baseUrl": ".",
"outDir": "dist"
},
"exclude": ["node_modules/**", "dist/**"],
"include": ["package/**/*.ts"]
}
11 changes: 6 additions & 5 deletions packages/1155-contracts/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { defineConfig } from 'tsup'
import { defineConfig } from "tsup";

export default defineConfig({
entry: ['package/index.ts'],
entry: ["package/index.ts"],
sourcemap: true,
clean: true,
dts: false,
format: ['cjs', 'esm'],
onSuccess: 'tsc --emitDeclarationOnly --declaration --declarationMap'
})
format: ["cjs", "esm"],
onSuccess:
"tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
});
1 change: 1 addition & 0 deletions packages/protocol-deployments/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts
18 changes: 11 additions & 7 deletions packages/protocol-deployments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
"version": "0.1.1",
"repository": "https://github.com/ourzora/zora-protocol",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/src/index.d.ts",
"files": [
"dist/",
"src/",
"json/"
],
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.cjs"
}
},
"scripts": {
"build": "yarn wagmi && yarn bundle-configs && tsup",
"bundle-configs": "tsx scripts/bundle-configs.ts && yarn prettier",
Expand Down
50 changes: 0 additions & 50 deletions packages/protocol-deployments/package/chainConfigs.ts

This file was deleted.

10 changes: 10 additions & 0 deletions packages/protocol-deployments/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "zoralabs-tsconfig/tsconfig.json",
"compilerOptions": {
"lib": ["es2021", "DOM"],
"baseUrl": ".",
"outDir": "dist"
},
"exclude": ["node_modules/**", "dist/**"],
"include": ["src/**/*.ts"]
}
3 changes: 2 additions & 1 deletion packages/protocol-deployments/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export default defineConfig({
clean: true,
dts: false,
format: ["cjs", "esm"],
onSuccess: "tsc --emitDeclarationOnly --declaration --declarationMap",
onSuccess:
"tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
});
1 change: 1 addition & 0 deletions packages/protocol-sdk/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/anvil.ts
13 changes: 11 additions & 2 deletions packages/protocol-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
"version": "0.5.5",
"repository": "https://github.com/ourzora/zora-protocol",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.cjs"
}
},
"scripts": {
"build": "tsup",
"prepack": "yarn build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export default defineConfig({
tsconfig: "tsconfig.build.json",
dts: false,
format: ["cjs", "esm"],
onSuccess: "tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
onSuccess:
"tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
});

0 comments on commit 52b16aa

Please sign in to comment.