Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make solcjs compilation work when Hardhat is bundled #3406

Merged
merged 2 commits into from Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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