Skip to content

Commit

Permalink
Merge pull request #3406 from NomicFoundation/fix-solcjs-in-bundled-h…
Browse files Browse the repository at this point in the history
…ardhat

Make solcjs compilation work when Hardhat is bundled
  • Loading branch information
fvictorio committed Dec 8, 2022
2 parents 41f5e7b + 7154371 commit 42d38ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-jobs-hug.md
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Fixed an issue that caused compilation with solcjs to not work when Hardhat is bundled
8 changes: 8 additions & 0 deletions packages/hardhat-core/src/internal/solidity/compiler/index.ts
Expand Up @@ -41,6 +41,14 @@ export class Compiler implements ICompiler {
*/
private _loadCompilerSources(compilerPath: string) {
const Module = module.constructor as any;

// if Hardhat is bundled (for example, in the vscode extension), then
// Module._extenions might be undefined. In that case, we just use a plain
// require.
if (Module._extensions === undefined) {
return require(compilerPath);
}

const previousHook = Module._extensions[".js"];

Module._extensions[".js"] = function (
Expand Down

0 comments on commit 42d38ea

Please sign in to comment.