Skip to content

Commit def4667

Browse files
authored
Remove WASM endowment factory (#459)
Node landed `WebAssembly.compileStreaming` and `instantiateStreaming` in nodejs/node#42701 and made it available in Node 18, so we no longer need to exclude these properties from our WebAssembly endowment. This PR therefore removes the WebAssembly endowment factory, which will now be included in whatever form it exists on the execution environment root realm global.
1 parent 31e1556 commit def4667

File tree

5 files changed

+10
-75
lines changed

5 files changed

+10
-75
lines changed

packages/execution-environments/jest.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module.exports = {
77
coverageThreshold: {
88
global: {
99
branches: 34.69,
10-
functions: 38.89,
11-
lines: 34.62,
12-
statements: 34.98,
10+
functions: 35.29,
11+
lines: 32,
12+
statements: 32.41,
1313
},
1414
},
1515
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],

packages/execution-environments/src/common/endowments/index.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ describe('createEndowments', () => {
2727

2828
it('handles factory endowments', () => {
2929
const mockWallet = { foo: Symbol('bar') };
30-
const { endowments } = createEndowments(mockWallet as any, ['WebAssembly']);
30+
const { endowments } = createEndowments(mockWallet as any, ['setTimeout']);
3131

3232
expect(endowments).toStrictEqual({
3333
wallet: mockWallet,
34-
WebAssembly: expect.objectContaining(WebAssembly),
34+
setTimeout: expect.any(Function),
3535
});
36-
expect(endowments.WebAssembly).not.toBe(WebAssembly);
36+
expect(endowments.setTimeout).not.toBe(setTimeout);
3737
});
3838

3939
it('handles some endowments from the same factory', () => {
@@ -80,17 +80,17 @@ describe('createEndowments', () => {
8080
Math,
8181
setTimeout: expect.any(Function),
8282
clearTimeout: expect.any(Function),
83-
WebAssembly: { ...WebAssembly },
83+
WebAssembly,
8484
});
8585

8686
expect(endowments.wallet).toBe(mockWallet);
8787
expect(endowments.Buffer).toBe(Buffer);
88-
expect(endowments.Math).toBe(Math);
8988
expect(endowments.console).toBe(console);
89+
expect(endowments.Math).toBe(Math);
90+
expect(endowments.WebAssembly).toBe(WebAssembly);
9091

9192
expect(endowments.clearTimeout).not.toBe(clearTimeout);
9293
expect(endowments.setTimeout).not.toBe(setTimeout);
93-
expect(endowments.WebAssembly).not.toBe(WebAssembly);
9494
});
9595

9696
it('throws for unknown endowments', () => {

packages/execution-environments/src/common/endowments/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { rootRealmGlobal } from '../globalObject';
33
import buffer from './buffer';
44
import timeout from './timeout';
55
import interval from './interval';
6-
import wasm from './wasm';
76

87
type EndowmentFactoryResult = {
98
teardownFunction?: () => void;
@@ -15,7 +14,7 @@ type EndowmentFactoryResult = {
1514
* the same factory function, but we only call each factory once for each snap.
1615
* See {@link createEndowments} for details.
1716
*/
18-
const endowmentFactories = [buffer, timeout, interval, wasm].reduce(
17+
const endowmentFactories = [buffer, timeout, interval].reduce(
1918
(factories, builder) => {
2019
builder.names.forEach((name) => {
2120
factories.set(name, builder.factory);

packages/execution-environments/src/common/endowments/wasm.test.ts

-30
This file was deleted.

packages/execution-environments/src/common/endowments/wasm.ts

-34
This file was deleted.

0 commit comments

Comments
 (0)