Skip to content

Commit

Permalink
dual publish (#489)
Browse files Browse the repository at this point in the history
* build esm cjs package

* update chopsticks.js

* update tsconfig and fix path

* fix docs

* fix yarn pack

* no need to remove .buildinfo now that they're created inside dist

---------

Co-authored-by: Ermal Kaleci <ermalkaleci@gmail.com>
  • Loading branch information
qiweiii and ermalkaleci authored Oct 30, 2023
1 parent f8e2ed2 commit 1e4aac2
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 79 deletions.
2 changes: 1 addition & 1 deletion packages/chopsticks/chopsticks.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./lib/cli.js')
require('./dist/cjs/cli.js')
31 changes: 20 additions & 11 deletions packages/chopsticks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "Apache-2.0",
"bin": "./chopsticks.js",
"scripts": {
"clean": "rm -rf lib tsconfig.tsbuildinfo",
"build": "tsc -p ./tsconfig.json",
"clean": "rm -rf dist",
"build": "yarn clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.esm.json",
"script:start": "cd ../..; ts-node --transpile-only -r tsconfig-paths/register packages/chopsticks/src/cli.ts",
"script:run": "cd ../..; LOG_LEVEL=trace ts-node-dev --transpile-only -r tsconfig-paths/register --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/dev.yml",
"dev:karura": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/karura.yml",
Expand Down Expand Up @@ -42,24 +42,33 @@
"typescript": "^5.1.6"
},
"files": [
"lib",
"dist/esm/**",
"dist/cjs/**",
"dist/types/**",
"template",
"chopsticks.js"
],
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./*": {
"types": "./lib/*.d.ts",
"default": "./lib/*.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./plugins/*": {
"types": "./lib/plugins/*.d.ts",
"default": "./lib/plugins/*.js"
"types": "./dist/types/plugins/*.d.ts",
"require": "./dist/cjs/plugins/*.js",
"import": "./dist/esm/plugins/*.js",
"default": "./dist/esm/plugins/*.js"
},
"./package.json": "./package.json"
}
Expand Down
10 changes: 7 additions & 3 deletions packages/chopsticks/src/plugins/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
export { rpc as newBlock, NewBlockParams } from './new-block'
export { rpc as dryRun, DryRunParams } from './dry-run'
export { rpc as newBlock } from './new-block'
export { rpc as dryRun } from './dry-run'
export { rpc as setBlockBuildMode } from './set-block-build-mode'
export { rpc as setHead } from './set-head'
export { rpc as setRuntimeLogLevel } from './set-runtime-log-level'
export { rpc as setStorage } from './set-storage'
export { rpc as timeTravel } from './time-travel'
export { rpc as runBlock, RunBlockParams } from './run-block'
export { rpc as runBlock } from './run-block'

export type { NewBlockParams } from './new-block'
export type { DryRunParams } from './dry-run'
export type { RunBlockParams } from './run-block'
2 changes: 1 addition & 1 deletion packages/chopsticks/src/utils/generate-html-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import path from 'node:path'

export const generateHtmlDiff = async (block: Block, diff: [HexString, HexString | null][]) => {
const { oldState, delta } = await decodeStorageDiff(block, diff)
const htmlTemplate = readFileSync(path.join(__dirname, '../../template/diff.html'), 'utf-8')
const htmlTemplate = readFileSync(path.join(__dirname, '../../../template/diff.html'), 'utf-8')
return template(htmlTemplate)({ left: JSON.stringify(oldState), delta: JSON.stringify(delta) })
}

Expand Down
8 changes: 8 additions & 0 deletions packages/chopsticks/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ES2022",
"outDir": "dist/esm"
},
"references": [{ "path": "../core/tsconfig.esm.json" }, { "path": "../db/tsconfig.esm.json" }]
}
13 changes: 4 additions & 9 deletions packages/chopsticks/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
"rootDir": "src",
"outDir": "dist/cjs",
"declarationDir": "dist/types"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"],
"references": [{ "path": "../core" }, { "path": "../db" }],
"typedocOptions": {
"entryPoints": ["src/types.ts"],
"out": "../../docs-src/chopsticks",
"plugin": "typedoc-plugin-markdown",
"readme": "none"
}
"references": [{ "path": "../core/tsconfig.json" }, { "path": "../db/tsconfig.json" }]
}
7 changes: 7 additions & 0 deletions packages/chopsticks/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"entryPoints": ["src/types.ts"],
"out": "../../docs-src/chopsticks",
"plugin": "typedoc-plugin-markdown",
"readme": "none",
"tsconfig": "tsconfig.esm.json"
}
33 changes: 21 additions & 12 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"scripts": {
"clean": "rm -rf lib tsconfig.tsbuildinfo",
"build": "tsc -p ./tsconfig.json; yarn copyfiles",
"copyfiles": "cp -r src/wasm-executor/*.mjs lib/wasm-executor/",
"clean": "rm -rf dist",
"build": "yarn clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.esm.json && yarn copyfiles",
"copyfiles": "cp -r src/wasm-executor/*.mjs dist/cjs/wasm-executor/ && cp -r src/wasm-executor/*.mjs dist/esm/wasm-executor/",
"docs:prep": "typedoc"
},
"dependencies": {
Expand All @@ -25,23 +25,32 @@
"typescript": "^5.1.6"
},
"files": [
"lib"
"dist/esm/**",
"dist/cjs/**",
"dist/types/**"
],
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./*": {
"types": "./lib/*.d.ts",
"default": "./lib/*.js"
"types": "./dist/esm/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
},
"browser": {
"./lib/wasm-executor/node-wasm-executor.mjs": "./lib/wasm-executor/browser-wasm-executor.mjs",
"./lib/wasm-executor/node-worker.js": "./lib/wasm-executor/browser-worker.js"
"./dist/cjs/wasm-executor/node-wasm-executor.mjs": "./dist/cjs/wasm-executor/browser-wasm-executor.mjs",
"./dist/cjs/wasm-executor/node-worker.js": "./dist/cjs/wasm-executor/browser-worker.js",
"./dist/esm/wasm-executor/node-wasm-executor.mjs": "./dist/esm/wasm-executor/browser-wasm-executor.mjs",
"./dist/esm/wasm-executor/node-worker.js": "./dist/esm/wasm-executor/browser-worker.js"
}
}
7 changes: 7 additions & 0 deletions packages/core/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ES2022",
"outDir": "./dist/esm"
}
}
14 changes: 3 additions & 11 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"lib": ["es2021", "dom", "dom.iterable"],
"isolatedModules": true
"outDir": "./dist/cjs",
"declarationDir": "./dist/types"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"],
"typedocOptions": {
"entryPoints": ["src/index.ts"],
"out": "../../docs-src/core",
"plugin": "typedoc-plugin-markdown",
"readme": "none",
"excludePrivate": true
}
"exclude": ["src/**/*.test.ts"]
}
8 changes: 8 additions & 0 deletions packages/core/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"entryPoints": ["src/index.ts"],
"out": "../../docs-src/core",
"plugin": "typedoc-plugin-markdown",
"readme": "none",
"excludePrivate": true,
"tsconfig": "tsconfig.esm.json"
}
25 changes: 16 additions & 9 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"scripts": {
"clean": "rm -rf lib tsconfig.tsbuildinfo",
"build": "tsc -p ./tsconfig.json"
"clean": "rm -rf dist",
"build": "yarn clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.esm.json"
},
"dependencies": {
"@acala-network/chopsticks-core": "workspace:*",
Expand All @@ -17,18 +17,25 @@
"typescript": "^5.1.6"
},
"files": [
"lib"
"dist/esm/**",
"dist/cjs/**",
"dist/types/**"
],
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./*": {
"types": "./lib/*.d.ts",
"default": "./lib/*.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
}
Expand Down
8 changes: 8 additions & 0 deletions packages/db/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ES2022",
"outDir": "dist/esm"
},
"references": [{ "path": "../core/tsconfig.esm.json" }]
}
7 changes: 3 additions & 4 deletions packages/db/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"lib": ["es2021", "dom", "dom.iterable"],
"isolatedModules": true
"outDir": "dist/cjs",
"declarationDir": "dist/types"
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.test.ts"],
"references": [{ "path": "../core" }]
"references": [{ "path": "../core/tsconfig.json" }]
}
25 changes: 16 additions & 9 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"scripts": {
"clean": "rm -rf lib tsconfig.tsbuildinfo",
"build": "tsc -p ./tsconfig.json"
"clean": "rm -rf dist",
"build": "yarn clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.esm.json"
},
"dependencies": {
"@acala-network/chopsticks": "workspace:*"
Expand All @@ -18,18 +18,25 @@
"typescript": "^5.1.6"
},
"files": [
"lib"
"dist/esm/**",
"dist/cjs/**",
"dist/types/**"
],
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./*": {
"types": "./lib/*.d.ts",
"default": "./lib/*.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
}
Expand Down
8 changes: 8 additions & 0 deletions packages/testing/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ES2022",
"outDir": "dist/esm"
},
"references": [{ "path": "../chopsticks/tsconfig.esm.json" }]
}
10 changes: 3 additions & 7 deletions packages/testing/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"module": "ES2022" // this is required for vitest to work
"outDir": "dist/cjs",
"declarationDir": "dist/types"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"],
"references": [
{
"path": "../chopsticks"
}
]
"references": [{ "path": "../chopsticks/tsconfig.json" }]
}
2 changes: 1 addition & 1 deletion packages/web-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"sourceMap": true
},
"include": ["src/**/*"],
"references": [{ "path": "../core" }, { "path": "../db" }]
"references": [{ "path": "../core/tsconfig.esm.json" }, { "path": "../db/tsconfig.esm.json" }]
}
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"lib": ["es2021"],
"lib": ["es2021", "dom", "dom.iterable"],
"isolatedModules": true,
"module": "CommonJS",
"moduleResolution": "node",
"noUnusedLocals": true,
Expand Down

0 comments on commit 1e4aac2

Please sign in to comment.