Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix: prevent DEBUG env var from crashing ganache (#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch authored Dec 6, 2021
1 parent f06c034 commit 9db625f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/packages/ganache/webpack/polyfills/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const debug = () => () => {};
5 changes: 4 additions & 1 deletion src/packages/ganache/webpack/webpack.browser.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const config: webpack.Configuration = merge({}, base, {
// mcl-wasm may be needed when creating a new @ethereumjs/vm and requires a browser version for browsers
"mcl-wasm": require.resolve("mcl-wasm/browser"),
// ws doesn't work in the browser, isomorphic-ws does
ws: require.resolve("isomorphic-ws/")
ws: require.resolve("isomorphic-ws/"),
// we don't use the debug module internally, so let's just not include it
// in any package.
debug: require.resolve("./polyfills/debug")
}
},
output: {
Expand Down
7 changes: 5 additions & 2 deletions src/packages/ganache/webpack/webpack.common.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ const base: webpack.Configuration = {
]
},
plugins: [
new webpack.DefinePlugin({
new webpack.EnvironmentPlugin({
// replace process.env.INFURA_KEY in our code
"process.env.INFURA_KEY": JSON.stringify(INFURA_KEY)
INFURA_KEY,
// replace process.env.DEBUG in our code, because we don't use it but
// ethereumjs packages do, but we don't implement everything required
DEBUG: false
})
]
};
Expand Down
8 changes: 8 additions & 0 deletions src/packages/ganache/webpack/webpack.node.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const config: webpack.Configuration = merge({}, base, {
filename: "[name].js",
path: path.resolve(__dirname, "../", "dist", "node")
},
resolve: {
extensions: [".ts", ".js"],
alias: {
// we don't use the debug module internally, so let's just not include it
// in any package.
debug: require.resolve("./polyfills/debug")
}
},
plugins: [
// add a shebang at the top of the generated `cli.js`
new webpack.BannerPlugin({
Expand Down

0 comments on commit 9db625f

Please sign in to comment.