Skip to content

Commit cd43f21

Browse files
authored
Merge pull request #7036 from NomicFoundation/rename_dependencies_to_compile_and_build_task
Rename dependencies to compile and build task
2 parents c7d3f41 + f24922c commit cd43f21

File tree

9 files changed

+55
-38
lines changed

9 files changed

+55
-38
lines changed

.changeset/cold-oranges-guess.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"hardhat": patch
3+
---
4+
5+
Rename `dependenciesToCompile` to `npmFilesToBuild` in Hardhat config ([#6877](https://github.com/NomicFoundation/hardhat/issues/6877))
6+
Add `build` task that replaces `compile`, but keep the `compile` task as an alias to `build` ([#6877](https://github.com/NomicFoundation/hardhat/issues/6877))

v-next/example-project/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const config: HardhatUserConfig = {
199199
version: "0.8.2",
200200
},
201201
},
202-
dependenciesToCompile: [
202+
npmFilesToBuild: [
203203
"@openzeppelin/contracts/token/ERC20/ERC20.sol",
204204
"forge-std/Test.sol",
205205
],

v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,11 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
111111
)
112112
).flat(1);
113113

114-
const dependenciesToCompile =
115-
this.#options.solidityConfig.dependenciesToCompile.map(
116-
npmModuleToNpmRootPath,
117-
);
114+
const npmFilesToBuild = this.#options.solidityConfig.npmFilesToBuild.map(
115+
npmModuleToNpmRootPath,
116+
);
118117

119-
return [...localFilesToCompile, ...dependenciesToCompile];
118+
return [...localFilesToCompile, ...npmFilesToBuild];
120119
}
121120

122121
public async build(

v-next/hardhat/src/internal/builtin-plugins/solidity/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const multiVersionSolcUserConfigType = z.object({
4747
});
4848

4949
const commonSolidityUserConfigType = z.object({
50-
dependenciesToCompile: z.array(z.string()).optional(),
50+
npmFilesToBuild: z.array(z.string()).optional(),
5151
});
5252

5353
const singleVersionSolidityUserConfigType = singleVersionSolcUserConfigType
@@ -215,7 +215,7 @@ function resolveSolidityConfig(
215215
overrides: {},
216216
},
217217
},
218-
dependenciesToCompile: [],
218+
npmFilesToBuild: [],
219219
};
220220
}
221221

@@ -232,7 +232,7 @@ function resolveSolidityConfig(
232232
overrides: {},
233233
},
234234
},
235-
dependenciesToCompile: solidityConfig.dependenciesToCompile ?? [],
235+
npmFilesToBuild: solidityConfig.npmFilesToBuild ?? [],
236236
};
237237
}
238238

@@ -259,7 +259,7 @@ function resolveSolidityConfig(
259259
),
260260
},
261261
},
262-
dependenciesToCompile: solidityConfig.dependenciesToCompile ?? [],
262+
npmFilesToBuild: solidityConfig.npmFilesToBuild ?? [],
263263
};
264264
}
265265

@@ -311,6 +311,6 @@ function resolveSolidityConfig(
311311

312312
return {
313313
profiles,
314-
dependenciesToCompile: solidityConfig.dependenciesToCompile ?? [],
314+
npmFilesToBuild: solidityConfig.npmFilesToBuild ?? [],
315315
};
316316
}

v-next/hardhat/src/internal/builtin-plugins/solidity/index.ts

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@ import { globalOption, task } from "../../core/config.js";
55

66
import "./type-extensions.js";
77

8+
const buildTask = task("build", "Builds your project")
9+
.addFlag({
10+
name: "force",
11+
description: "Force compilation even if no files have changed",
12+
})
13+
.addFlag({
14+
name: "quiet",
15+
description: "Makes the compilation process less verbose",
16+
})
17+
.addOption({
18+
name: "defaultBuildProfile",
19+
description: "The default build profile to use",
20+
defaultValue: "default",
21+
})
22+
.addVariadicArgument({
23+
name: "files",
24+
description: "An optional list of files to compile",
25+
defaultValue: [],
26+
})
27+
.setAction(import.meta.resolve("./tasks/build.js"))
28+
.build();
29+
830
const hardhatPlugin: HardhatPlugin = {
931
id: "builtin:solidity",
1032
dependencies: [async () => (await import("../artifacts/index.js")).default],
@@ -13,27 +35,16 @@ const hardhatPlugin: HardhatPlugin = {
1335
hre: import.meta.resolve("./hook-handlers/hre.js"),
1436
},
1537
tasks: [
16-
task("compile", "Compiles your project")
17-
.addFlag({
18-
name: "force",
19-
description: "Force compilation even if no files have changed",
20-
})
21-
.addFlag({
22-
name: "quiet",
23-
description: "Makes the compilation process less verbose",
24-
})
25-
.addOption({
26-
name: "defaultBuildProfile",
27-
description: "The default build profile to use",
28-
defaultValue: "default",
29-
})
30-
.addVariadicArgument({
31-
name: "files",
32-
description: "An optional list of files to compile",
33-
defaultValue: [],
34-
})
35-
.setAction(import.meta.resolve("./tasks/compile.js"))
36-
.build(),
38+
{
39+
...buildTask,
40+
id: ["build"],
41+
description: "Builds your project",
42+
},
43+
{
44+
...buildTask,
45+
id: ["compile"],
46+
description: "Builds your project (alias for build)",
47+
},
3748
],
3849
globalOptions: [
3950
globalOption({

v-next/hardhat/src/internal/builtin-plugins/solidity/tasks/compile.ts renamed to v-next/hardhat/src/internal/builtin-plugins/solidity/tasks/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface CompileActionArguments {
1212
defaultBuildProfile: string | undefined;
1313
}
1414

15-
const compileAction: NewTaskActionFunction<CompileActionArguments> = async (
15+
const buildAction: NewTaskActionFunction<CompileActionArguments> = async (
1616
{ force, files, quiet, defaultBuildProfile },
1717
{ solidity, globalOptions },
1818
) => {
@@ -43,4 +43,4 @@ const compileAction: NewTaskActionFunction<CompileActionArguments> = async (
4343
}
4444
};
4545

46-
export default compileAction;
46+
export default buildAction;

v-next/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ declare module "../../../types/config.js" {
2424
}
2525

2626
export interface CommonSolidityUserConfig {
27-
dependenciesToCompile?: string[];
27+
npmFilesToBuild?: string[];
2828
}
2929

3030
export interface SingleVersionSolidityUserConfig
@@ -59,7 +59,7 @@ declare module "../../../types/config.js" {
5959

6060
export interface SolidityConfig {
6161
profiles: Record<string, SolidityBuildProfileConfig>;
62-
dependenciesToCompile: string[];
62+
npmFilesToBuild: string[];
6363
}
6464

6565
export interface HardhatConfig {

v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/build-system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe(
8080
overrides: {},
8181
},
8282
},
83-
dependenciesToCompile: [],
83+
npmFilesToBuild: [],
8484
};
8585

8686
before(async () => {

v-next/hardhat/test/internal/cli/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ Usage: hardhat [GLOBAL OPTIONS] <TASK> [SUBTASK] [TASK OPTIONS] [--] [TASK ARGUM
228228
229229
AVAILABLE TASKS:
230230
231+
build Builds your project
231232
clean Clears the cache and deletes all artifacts
232-
compile Compiles your project
233+
compile Builds your project (alias for build)
233234
console Opens a hardhat console
234235
flatten Flattens and prints contracts and their dependencies
235236
node Starts a JSON-RPC server on top of Hardhat Network

0 commit comments

Comments
 (0)