@efebia/hardhat-compile-monorepo 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/package.json +7 -2
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @efebia/hardhat-compile-monorepo
|
|
2
|
+
|
|
3
|
+
Hardhat plugin that compiles Solidity contracts from multiple monorepo packages in a single `hardhat compile` run.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @efebia/hardhat-compile-monorepo
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Import the plugin in your Hardhat config:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// hardhat.config.ts
|
|
17
|
+
import '@efebia/hardhat-compile-monorepo';
|
|
18
|
+
import { HardhatUserConfig } from 'hardhat/config';
|
|
19
|
+
|
|
20
|
+
const config: HardhatUserConfig = {
|
|
21
|
+
solidity: '0.8.17',
|
|
22
|
+
compileMonorepo: {
|
|
23
|
+
// Packages whose Solidity files should be included in compilation.
|
|
24
|
+
// Each entry must be resolvable via require() from the Hardhat project root.
|
|
25
|
+
paths: ['@my-org/contracts-core', '@my-org/contracts-utils'],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default config;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Running `npx hardhat compile` will:
|
|
33
|
+
1. Resolve each package in `paths` and copy stub `.sol` import files into a temporary directory inside `sources`
|
|
34
|
+
2. Run the standard Hardhat compile task
|
|
35
|
+
3. Clean up the temporary directory (unless `keep: true`)
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
All options go under the `compileMonorepo` key in `hardhat.config`:
|
|
40
|
+
|
|
41
|
+
| Option | Type | Default | Description |
|
|
42
|
+
|--------|------|---------|-------------|
|
|
43
|
+
| `paths` | `string[]` | `[]` | Packages or `.sol` file paths to include. Must be `require()`-resolvable. |
|
|
44
|
+
| `path` | `string` | `'@efebia/hardhat-compile-monorepo'` | Subdirectory inside `sources` used as the temporary output directory. |
|
|
45
|
+
| `keep` | `boolean` | `false` | Keep the temporary directory after compilation (useful for debugging). |
|
|
46
|
+
|
|
47
|
+
## How it works
|
|
48
|
+
|
|
49
|
+
For each entry in `paths`:
|
|
50
|
+
- If the entry has no file extension, it is treated as an npm package. The plugin resolves the package, reads its `files` field from `package.json`, and includes all matching `.sol` files.
|
|
51
|
+
- If the entry has a `.sol` extension, it is treated as a direct file import.
|
|
52
|
+
|
|
53
|
+
Stub `.sol` files are generated with a single `import` statement pointing to the original source, then fed to the Hardhat compiler. The temporary directory is tracked with a hidden marker file so the plugin never accidentally deletes user-owned directories.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@efebia/hardhat-compile-monorepo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"glob": "^8.0.3",
|
|
@@ -16,5 +16,10 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsc"
|
|
18
18
|
},
|
|
19
|
-
"main": "./lib"
|
|
19
|
+
"main": "./lib",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/efebia-com/be-libs.git",
|
|
23
|
+
"directory": "packages/hardhat-compile-monorepo"
|
|
24
|
+
}
|
|
20
25
|
}
|