Skip to content

Commit 38769d3

Browse files
authored
Merge pull request #1798 from polywrap/origin-0.10-dev
Origin 0.10.6 | /workflows/release-pr
2 parents 1bca63a + c8ce7d7 commit 38769d3

10 files changed

Lines changed: 418 additions & 59 deletions

File tree

.github/workflows/ci-wrap-test-harness.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
- name: Install Rust
8989
uses: actions-rs/toolchain@v1
9090
with:
91-
toolchain: nightly
91+
toolchain: nightly-2023-06-15
9292
override: true
9393

9494
- uses: actions/cache@v2

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v17.9.1
1+
v18.15.0

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Polywrap Origin (0.10.6)
2+
## Bugs
3+
**`polywrap` CLI:**
4+
* [PR-1796](https://github.com/polywrap/cli/pull/1796) **`wrap/rust` Builds Now Properly Remove wasm-bindgen Imports**
5+
* The `wasm-bindgen` CLI was emitting an unneeded `__wbindgen_throw` import, so we use `wasm-snip` to remove it.
6+
17
# Polywrap Origin (0.10.5)
28
## Bugs
39
**`@polywrap/schema-bind`:**

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.5
1+
0.10.6

packages/cli/src/commands/infra.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { InfraManifest } from "@polywrap/polywrap-manifest-types-js";
1313
import path from "path";
1414
import { Argument } from "commander";
1515
import chalk from "chalk";
16-
import yaml from "yaml";
1716
import { readdirSync } from "fs";
1817

1918
export enum InfraActions {
@@ -179,7 +178,8 @@ async function run(
179178
logger.info(JSON.stringify(await infra.getVars(), null, 2));
180179
break;
181180
case InfraActions.CONFIG:
182-
logger.info(yaml.stringify((await infra.config()).data.config, null, 2));
181+
// Calling "docker-compose config" will log to console, so we don't have to
182+
await infra.config();
183183
break;
184184
default:
185185
throw Error(intlMsg.commands_infra_error_never());

packages/cli/src/lib/defaults/build-strategies/wasm/rust/vm/vm-script.mustache

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,32 @@ mv ./{{dir}}/Cargo-local.toml ./{{dir}}/Cargo.toml
2727
cargo build --manifest-path ./{{dir}}/Cargo.toml \
2828
--target wasm32-unknown-unknown --release
2929

30-
# Make the build directory
30+
# Make the build & build-staging directory
3131
rm -rf ./build
3232
mkdir ./build
33+
rm -rf ./build-staging
34+
mkdir ./build-staging
3335

34-
# Run wasm-bindgen over the module, replacing all placeholder __wbindgen_... imports
35-
wasm-bindgen ./{{dir}}/target/wasm32-unknown-unknown/release/module.wasm --out-dir ./build --out-name bg_module.wasm
36+
# Move the rust module into the staging directory
37+
mv ./{{dir}}/target/wasm32-unknown-unknown/release/module.wasm ./build-staging/module.wasm
3638

37-
# Run wasm-tools strip to remove the wasm-interface-types custom section
38-
wasm-tools strip ./build/bg_module.wasm -d wasm-interface-types -o ./build/strip_module.wasm
39-
rm -rf ./build/bg_module.wasm
39+
# Wasm Post-processing
4040

41-
# Run wasm-snip to trip down the size of the binary, removing any dead code
42-
wasm-snip ./build/strip_module.wasm -o ./build/snipped_module.wasm
43-
rm -rf ./build/strip_module.wasm
41+
# 1. Run `wasm-bindgen` over the module, replacing all placeholder __wbindgen_... imports
42+
wasm-bindgen ./build-staging/module.wasm --out-dir ./build-staging --out-name module_bg.wasm
4443

45-
# Use wasm-opt to perform the "asyncify" post-processing step over all modules
44+
# 2. If wasm-bindgen isn't being used, the only import that will be remaining will be __wbindgen_throw.
45+
# So, let's remove this, and if more extraneous imports exist an error will be raised post-compilation
46+
wasm-snip ./build-staging/module_bg.wasm -o ./build-staging/module_bg_snip.wasm -p .*__wbindgen_throw
47+
48+
# 3. Run `wasm-tools strip` to remove the wasm-interface-types custom section (sometimes get injected)
49+
wasm-tools strip ./build-staging/module_bg_snip.wasm -d wasm-interface-types -o ./build-staging/module_bg_snip_strip.wasm
50+
51+
# 4. Use wasm-opt to perform the "asyncify" post-processing step over all modules
4652
export ASYNCIFY_STACK_SIZE=24576
47-
wasm-opt --asyncify -Os ./build/snipped_module.wasm -o ./build/wrap.wasm
48-
rm -rf ./build/snipped_module.wasm
53+
wasm-opt --asyncify -Os ./build-staging/module_bg_snip_strip.wasm -o ./build-staging/module_bg_snip_strip_opt.wasm
54+
55+
# Finish - Move the result
56+
mv ./build-staging/module_bg_snip_strip_opt.wasm ./build/wrap.wasm
57+
4958
{{/polywrap_module}}

packages/cli/src/lib/infra/Infra.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import path from "path";
1313
import fs, { lstatSync, readdirSync } from "fs";
1414
import YAML from "yaml";
1515
import { copySync } from "fs-extra";
16+
import { IDockerComposeOptions } from "docker-compose";
1617

1718
export interface InfraConfig {
1819
rootDir: string;
@@ -105,11 +106,11 @@ export class Infra {
105106
ReturnType<DockerCompose["commands"]["config"]>
106107
> {
107108
const modulesWithPaths = await this._fetchModules();
108-
109-
return await this._dockerCompose.commands.config({
109+
const configOptions: Partial<IDockerComposeOptions> = {
110110
...this._defaultDockerOptions,
111111
config: modulesWithPaths.map((m) => m.path),
112-
});
112+
};
113+
return await this._dockerCompose.commands.config(configOptions);
113114
}
114115

115116
public async getVars(): Promise<string[]> {

packages/js/manifests/polywrap/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"@polywrap/logging-js": "0.10.5",
1919
"@polywrap/polywrap-manifest-schemas": "0.10.5",
2020
"jsonschema": "1.4.0",
21-
"semver": "7.5.0",
21+
"semver": "7.5.3",
2222
"yaml": "2.2.2"
2323
},
2424
"devDependencies": {
2525
"@polywrap/os-js": "0.10.5",
2626
"@types/jest": "26.0.8",
2727
"@types/mustache": "4.0.1",
2828
"@types/prettier": "2.6.0",
29-
"@types/semver": "7.3.11",
29+
"@types/semver": "7.5.0",
3030
"jest": "26.6.3",
3131
"json-schema-to-typescript": "11.0.2",
3232
"mustache": "4.0.1",

0 commit comments

Comments
 (0)