Skip to content

Commit 0b44c06

Browse files
authored
Merge pull request #50 from rylev/import-dependencies
Switch --defined flag for import-dependencies flag
2 parents 09528ec + df14f2f commit 0b44c06

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ wac encode -o output.wasm input.wac
6565

6666
This will encode `input.wac` as a WebAssembly component named `output.wasm`.
6767

68-
By default, `wac` will import dependencies rather than defining (i.e.
69-
embedding) them in the output component; to define dependencies in the output
70-
component, use the `--define` flag:
68+
#### Dependencies
69+
70+
By default, `wac` will create a component that embeds its dependencies (i.e. packages
71+
referenced in a WAC source file) inside of itself rather than importing those dependencies;
72+
to cause dependencies to be imported in the output component, use the
73+
`--import-dependencies` flag:
7174

7275
```
73-
wac encode --define -o output.wasm input.wac
76+
wac encode --import-dependencies -o output.wasm input.wac
7477
```
7578

76-
#### Dependencies
77-
78-
Dependencies (i.e. packages referenced in a WAC source file) may be located
79-
within a `deps` subdirectory, with an expected structure of:
79+
Dependencies may be located within a `deps` subdirectory, with an expected structure of:
8080

8181
```
8282
deps/
8383
├─ <namespace>/
8484
│ ├─ <package>.wasm
8585
``````
86-
If the `wit` build-time feature is enabled, the dependency may be a directory
87-
containing a WIT package:
86+
87+
The dependency may be also be a WIT file or a directory containing a WIT package:
8888
8989
```
9090
deps/
@@ -97,7 +97,7 @@ deps/
9797
The `--deps-dir` CLI option may be used to specify a different directory to
9898
search for dependencies.
9999
100-
Dependencies may also be specified with the `--dep` CLI option:
100+
The location of specific dependencies may also be specified with the `--dep` CLI option:
101101
102102
```
103103
wac encode --dep foo:bar=./baz.wasm -o output.wasm input.wac

src/commands/encode.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ pub struct EncodeCommand {
4545
#[clap(long, short = 't')]
4646
pub wat: bool,
4747

48-
/// Whether to not to define referenced packages.
48+
/// Whether the composed component imports its dependencies.
4949
///
50-
/// If not specified, all referenced packages will be imported.
51-
#[clap(long)]
52-
pub define: bool,
50+
/// If false, all referenced dependent packages will be defined within the component.
51+
///
52+
/// Defaults to false.
53+
#[clap(long, short)]
54+
pub import_dependencies: bool,
5355

5456
/// The path to write the output to.
5557
///
@@ -97,7 +99,7 @@ impl EncodeCommand {
9799
}
98100

99101
let mut bytes = resolved.encode(EncodingOptions {
100-
define_packages: self.define,
102+
define_packages: !self.import_dependencies,
101103
})?;
102104
if !self.no_validate {
103105
Validator::new_with_features(WasmFeatures {

0 commit comments

Comments
 (0)