From 8b36b6b64aa375dca889553884734481e69900a2 Mon Sep 17 00:00:00 2001 From: HL <36248745+honestbonsai@users.noreply.github.com> Date: Tue, 16 Feb 2021 18:02:50 +0000 Subject: [PATCH 1/8] Make core a dep of cli --- src/packages/cli/package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/packages/cli/package.json b/src/packages/cli/package.json index 8d9db27a09..5e3fafcd3b 100644 --- a/src/packages/cli/package.json +++ b/src/packages/cli/package.json @@ -48,10 +48,9 @@ "tooling", "truffle" ], - "devDependencies": { - "@ganache/core": "0.1.0" - }, + "devDependencies": {}, "dependencies": { + "@ganache/core": "0.1.0", "@ganache/colors": "^0.1.0", "@ganache/ethereum": "0.1.0", "@ganache/ethereum-options": "0.1.0", From ea6613aff72e4e01caf078d2db4f260fd9d7fc06 Mon Sep 17 00:00:00 2001 From: HL <36248745+honestbonsai@users.noreply.github.com> Date: Thu, 18 Feb 2021 19:46:24 +0000 Subject: [PATCH 2/8] Make external ganache core work in cli --- src/packages/ganache/index.ts | 5 +++-- src/packages/ganache/package.json | 1 + src/packages/ganache/tsconfig.json | 4 ++++ .../ganache/webpack/webpack.cli.config.ts | 16 +++++++++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/packages/ganache/index.ts b/src/packages/ganache/index.ts index edc13ead4d..f8390a3090 100644 --- a/src/packages/ganache/index.ts +++ b/src/packages/ganache/index.ts @@ -1,6 +1,7 @@ -import Ganache from "@ganache/cli"; +import Ganache, { serverDefaults } from "@ganache/core"; export default { server: Ganache.server, - provider: Ganache.provider + provider: Ganache.provider, + serverDefaults }; diff --git a/src/packages/ganache/package.json b/src/packages/ganache/package.json index cd80c7e24a..f9154fea05 100644 --- a/src/packages/ganache/package.json +++ b/src/packages/ganache/package.json @@ -51,6 +51,7 @@ "truffle" ], "devDependencies": { + "@ganache/core": "^0.1.0", "@ganache/cli": "^0.1.0", "@ganache/flavors": "^0.1.0", "@types/node": "14.14.6", diff --git a/src/packages/ganache/tsconfig.json b/src/packages/ganache/tsconfig.json index 615de82fb7..635f5d492b 100644 --- a/src/packages/ganache/tsconfig.json +++ b/src/packages/ganache/tsconfig.json @@ -15,6 +15,10 @@ { "name": "@ganache/flavors", "path": "../flavors" + }, + { + "name": "@ganache/core", + "path": "../core" } ] } diff --git a/src/packages/ganache/webpack/webpack.cli.config.ts b/src/packages/ganache/webpack/webpack.cli.config.ts index 3c78cea72c..18057d2171 100644 --- a/src/packages/ganache/webpack/webpack.cli.config.ts +++ b/src/packages/ganache/webpack/webpack.cli.config.ts @@ -9,7 +9,21 @@ const config: webpack.Configuration = merge({}, base, { output: { path: path.resolve(__dirname, "../", "dist", "cli") }, - externals: ["bigint-buffer", "leveldown", "secp256k1", "keccak"], + externals: [ + "bigint-buffer", + "leveldown", + "secp256k1", + "keccak", + { + "@ganache/core": path.resolve( + __dirname, + "../", + "dist", + "node", + "ganache.min.js" + ) + } + ], plugins: [ new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true }) ], From 1ed4f0a008bf78d5cf555df0e2ed9a8706eda58c Mon Sep 17 00:00:00 2001 From: HL <36248745+honestbonsai@users.noreply.github.com> Date: Thu, 18 Feb 2021 20:18:53 +0000 Subject: [PATCH 3/8] Export the whole name space not just default --- src/packages/ganache/index.ts | 7 ++++--- src/packages/ganache/webpack/webpack.common.config.ts | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/packages/ganache/index.ts b/src/packages/ganache/index.ts index f8390a3090..2a58c8e92d 100644 --- a/src/packages/ganache/index.ts +++ b/src/packages/ganache/index.ts @@ -1,7 +1,8 @@ -import Ganache, { serverDefaults } from "@ganache/core"; +import Ganache from "@ganache/core"; + +export { serverDefaults } from "@ganache/core"; export default { server: Ganache.server, - provider: Ganache.provider, - serverDefaults + provider: Ganache.provider }; diff --git a/src/packages/ganache/webpack/webpack.common.config.ts b/src/packages/ganache/webpack/webpack.common.config.ts index a3284908e7..05cbdbd63a 100644 --- a/src/packages/ganache/webpack/webpack.common.config.ts +++ b/src/packages/ganache/webpack/webpack.common.config.ts @@ -34,7 +34,6 @@ const base: webpack.Configuration = { output: { filename: "ganache.min.js", library: "Ganache", - libraryExport: "default", libraryTarget: "umd" }, stats: { From ce66c282225759c1ed8c9ce2f55ff2bf853111d7 Mon Sep 17 00:00:00 2001 From: HL <36248745+honestbonsai@users.noreply.github.com> Date: Mon, 22 Feb 2021 16:54:04 +0000 Subject: [PATCH 4/8] Add comment --- src/packages/ganache/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/packages/ganache/index.ts b/src/packages/ganache/index.ts index 2a58c8e92d..dedaae6361 100644 --- a/src/packages/ganache/index.ts +++ b/src/packages/ganache/index.ts @@ -1,3 +1,9 @@ +/* + * This file is the entry point for the resultant bundle dist/node/ganache.min.js + * dist/cli/ganache.min.js will then point dist/node/ganache.min.js + * whenever it references @ganache/core. + * This is so we avoid an extra set of native node modules in dist/cli, just use what's in dist/node. + */ import Ganache from "@ganache/core"; export { serverDefaults } from "@ganache/core"; From b36bb00d87ca640c2d351fd66f7489bec4c97ac4 Mon Sep 17 00:00:00 2001 From: Heyse Li <36248745+honestbonsai@users.noreply.github.com> Date: Tue, 23 Feb 2021 12:05:30 -0500 Subject: [PATCH 5/8] Update src/packages/ganache/index.ts Co-authored-by: David Murdoch --- src/packages/ganache/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/ganache/index.ts b/src/packages/ganache/index.ts index dedaae6361..bc0100dcc4 100644 --- a/src/packages/ganache/index.ts +++ b/src/packages/ganache/index.ts @@ -1,6 +1,6 @@ /* * This file is the entry point for the resultant bundle dist/node/ganache.min.js - * dist/cli/ganache.min.js will then point dist/node/ganache.min.js + * dist/cli/ganache.min.js will then point to dist/node/ganache.min.js * whenever it references @ganache/core. * This is so we avoid an extra set of native node modules in dist/cli, just use what's in dist/node. */ From 477d62df1185e1d58b885a3ea2b42b79ebe1854f Mon Sep 17 00:00:00 2001 From: Heyse Li <36248745+honestbonsai@users.noreply.github.com> Date: Tue, 23 Feb 2021 14:19:16 -0500 Subject: [PATCH 6/8] Update src/packages/cli/package.json Co-authored-by: David Murdoch --- src/packages/cli/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/packages/cli/package.json b/src/packages/cli/package.json index 5e3fafcd3b..4bb4cbd58b 100644 --- a/src/packages/cli/package.json +++ b/src/packages/cli/package.json @@ -48,7 +48,6 @@ "tooling", "truffle" ], - "devDependencies": {}, "dependencies": { "@ganache/core": "0.1.0", "@ganache/colors": "^0.1.0", From 1ac8e79de975304596d2b0e3e7e54b2cf8fab85a Mon Sep 17 00:00:00 2001 From: HL <36248745+honestbonsai@users.noreply.github.com> Date: Fri, 26 Feb 2021 17:38:12 +0000 Subject: [PATCH 7/8] Use path.join's relative path instead of resolve's --- src/packages/ganache/webpack/webpack.cli.config.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/packages/ganache/webpack/webpack.cli.config.ts b/src/packages/ganache/webpack/webpack.cli.config.ts index 18057d2171..25a2c4831f 100644 --- a/src/packages/ganache/webpack/webpack.cli.config.ts +++ b/src/packages/ganache/webpack/webpack.cli.config.ts @@ -15,13 +15,7 @@ const config: webpack.Configuration = merge({}, base, { "secp256k1", "keccak", { - "@ganache/core": path.resolve( - __dirname, - "../", - "dist", - "node", - "ganache.min.js" - ) + "@ganache/core": path.join("../", "node", "ganache.min.js") } ], plugins: [ From 3bba17e4e81c8f56b28519a8c78fdb30eaad3eab Mon Sep 17 00:00:00 2001 From: HL <36248745+honestbonsai@users.noreply.github.com> Date: Tue, 2 Mar 2021 18:02:03 +0000 Subject: [PATCH 8/8] Export named server and provider from dist/node --- src/packages/ganache/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/packages/ganache/index.ts b/src/packages/ganache/index.ts index bc0100dcc4..b44a64612a 100644 --- a/src/packages/ganache/index.ts +++ b/src/packages/ganache/index.ts @@ -8,6 +8,12 @@ import Ganache from "@ganache/core"; export { serverDefaults } from "@ganache/core"; +export const server = Ganache.server; + +// Need to add this type annotation of Ganache.provider +// to prevent a TS error about inferred types and not being portable +export const provider: typeof Ganache.provider = Ganache.provider; + export default { server: Ganache.server, provider: Ganache.provider