Skip to content

Commit 2fd0c0d

Browse files
Add cts,cjs hardhat config file support
1 parent 71bb2b3 commit 2fd0c0d

File tree

14 files changed

+30
-19
lines changed

14 files changed

+30
-19
lines changed

client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ If the Solidity file is not part of a project or the project cannot be determine
191191

192192
### Hardhat
193193

194-
Hardhat projects are detected by looking for a `hardhat.config.{js,ts}` file.
194+
Hardhat projects are detected by looking for a `hardhat.config.{ts,cts,js,cjs}` file.
195195

196196
Inline validation (the display of compiler errors and warnings against the code) is based on your Hardhat configuration file. The version of the `solc` solidity compiler used for validation is set within this file, see the [Hardhat documentation](https://hardhat.org/config/#solidity-configuration) for more details.
197197

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"vscode": "^1.99.0"
4040
},
4141
"activationEvents": [
42-
"workspaceContains:**/hardhat.config.{ts,js}",
42+
"workspaceContains:**/hardhat.config.{ts,cts,js,cjs}",
4343
"workspaceContains:**/foundry.toml",
4444
"workspaceContains:**/truffle-config.js",
4545
"workspaceContains:**/ape-config.yaml"

client/src/setup/indexHardhatProjects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ExtensionState } from "../types";
44

55
export async function indexHardhatProjects(state: ExtensionState) {
66
const hardhatConfigs = await vscode.workspace.findFiles(
7-
"**/hardhat.config.{ts,js}",
7+
"**/hardhat.config.{ts,cts,js,cjs}",
88
"**/node_modules/**"
99
);
1010

client/src/setup/setupLanguageServerHooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const startLanguageServer = async (
5050
],
5151
synchronize: {
5252
fileEvents: [
53-
workspace.createFileSystemWatcher("**/hardhat.config.{ts,js}"),
53+
workspace.createFileSystemWatcher("**/hardhat.config.{ts,cts,js,cjs}"),
5454
workspace.createFileSystemWatcher("**/{truffle-config,truffle}.js"),
5555
workspace.createFileSystemWatcher("**/foundry.toml"),
5656
workspace.createFileSystemWatcher("**/ape-config.yaml"),

coc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ If the Solidity file is not part of a project or the project cannot be determine
171171

172172
### Hardhat
173173

174-
Hardhat projects are detected by looking for a `hardhat.config.{js,ts}` file.
174+
Hardhat projects are detected by looking for a `hardhat.config.{ts,cts,js,cjs}` file.
175175

176176
Inline validation (the display of compiler errors and warnings against the code) is based on your Hardhat configuration file. The version of the `solc` solidity compiler used for validation is set within this file, see the [Hardhat documentation](https://hardhat.org/config/#solidity-configuration) for more details.
177177

coc/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
2323
synchronize: {
2424
configurationSection: "solidity",
2525
fileEvents: [
26-
coc.workspace.createFileSystemWatcher("**/hardhat.config.{ts,js}"),
26+
coc.workspace.createFileSystemWatcher("**/hardhat.config.{ts,cts,js,cjs}"),
2727
coc.workspace.createFileSystemWatcher("**/foundry.toml"),
2828
coc.workspace.createFileSystemWatcher(
2929
"**/{truffle-config,truffle}.js"

docs/codebase.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Source files are associated to projects during the initial indexing phase, and t
156156

157157
As of now, the responsibilities that are put behind the abstraction are the following:
158158

159-
- Scan directories to find projects (look for `hardhat.config.{js,ts}` for instance)
159+
- Scan directories to find projects (look for `hardhat.config.{ts,cts,js,cjs}` for instance)
160160
- Initialize, and perform any setup tasks for the project
161161
- Determine whether a Solidity file belongs to the project
162162
- Resolve the path of a Solidity import statement
@@ -171,7 +171,7 @@ As of now, the responsibilities that are put behind the abstraction are the foll
171171

172172
Hardhat validation is our most sophisticated framework adapter. It leverages the hardhat library local to a project.
173173

174-
The Hardhat adapter identifies Hardhat project by the presence of `hardhat.config.{ts,js}` files. Each found Hardhat project is then initialized by forking into its own child process. This is necessary because we need to load multiple Hardhat libraries (because we support multiple open projects) as node.js modules. If we were to attempt to load them in the same process, they would be cached and we wouldn't be able to reference the per project HRE object.
174+
The Hardhat adapter identifies Hardhat project by the presence of `hardhat.config.{ts,cts,js,cjs}` files. Each found Hardhat project is then initialized by forking into its own child process. This is necessary because we need to load multiple Hardhat libraries (because we support multiple open projects) as node.js modules. If we were to attempt to load them in the same process, they would be cached and we wouldn't be able to reference the per project HRE object.
175175

176176
This model of forking into child processes adds overhead to communication, since we can't just call javascript functions from the parent process to the child process. We need to leverage a protocol using the IPC transport. Each time we need a service that involves using the HRE, we send a message to the child process and wait for a response.
177177

docs/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ If the Solidity file is not part of a project or the project cannot be determine
148148

149149
### Hardhat
150150

151-
Hardhat projects are detected by looking for a `hardhat.config.{js,ts}` file.
151+
Hardhat projects are detected by looking for a `hardhat.config.{ts,cts,js,cjs}` file.
152152

153153
Inline validation (the display of compiler errors and warnings against the code) is based on your Hardhat configuration file. The version of the `solc` solidity compiler used for validation is set within this file, see the [Hardhat documentation](https://hardhat.org/config/#solidity-configuration) for more details.
154154

server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ If the Solidity file is not part of a project or the project cannot be determine
199199
200200
### Hardhat
201201
202-
Hardhat projects are detected by looking for a `hardhat.config.{js,ts}` file.
202+
Hardhat projects are detected by looking for a `hardhat.config.{ts,cts,js,cjs}` file.
203203
204204
Inline validation (the display of compiler errors and warnings against the code) is based on your Hardhat configuration file. The version of the `solc` solidity compiler used for validation is set within this file, see the [Hardhat documentation](https://hardhat.org/config/#solidity-configuration) for more details.
205205

server/src/frameworks/Hardhat/HardhatIndexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class HardhatIndexer extends ProjectIndexer {
1616
// Find all hardhat.config files in the workspace folder
1717
const configFiles = await this.fileRetriever.findFiles(
1818
uri,
19-
"**/hardhat.config.{ts,js}",
19+
"**/hardhat.config.{ts,cts,js,cjs}",
2020
["**/node_modules/**"]
2121
);
2222

0 commit comments

Comments
 (0)