From f9e5f480378ba6e216cdfed2227539c262abaaf4 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Tue, 20 Feb 2024 23:18:25 -0800 Subject: [PATCH 1/4] test(errors): Add failing backward compat test --- packages/errors/package.json | 1 + packages/errors/test/test-ses0_18_3.js | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 packages/errors/test/test-ses0_18_3.js diff --git a/packages/errors/package.json b/packages/errors/package.json index d28ddff9e1..24bb39df65 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -43,6 +43,7 @@ "@endo/ses-ava": "^1.1.1", "ava": "^5.3.0", "c8": "^7.14.0", + "ses0_18_3": "npm:ses@0.18.3", "tsd": "^0.28.1" }, "files": [ diff --git a/packages/errors/test/test-ses0_18_3.js b/packages/errors/test/test-ses0_18_3.js new file mode 100644 index 0000000000..c85553a2f4 --- /dev/null +++ b/packages/errors/test/test-ses0_18_3.js @@ -0,0 +1,8 @@ +import test from 'ava'; +import 'ses0_18_3'; + +test.failing('shim bare on ses 0.18.3', async t => { + // SES v0.18.3 predates the `bare` export. + const namespace = await import('../index.js'); + t.is(namespace.bare, namespace.quote); +}); From f83010589d55b6b94f6b7a0ddca1ca197ba78634 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Tue, 20 Feb 2024 23:24:09 -0800 Subject: [PATCH 2/4] chore: Update yarn.lock --- yarn.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yarn.lock b/yarn.lock index 0e33a09b98..885dbf4c06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7125,6 +7125,11 @@ server-destroy@^1.0.1: resolved "https://registry.yarnpkg.com/server-destroy/-/server-destroy-1.0.1.tgz#f13bf928e42b9c3e79383e61cc3998b5d14e6cdd" integrity sha512-rb+9B5YBIEzYcD6x2VKidaa+cqYBJQKnU4oe4E3ANwRRN56yk/ua1YCJT1n21NTS8w6CcOclAKNP3PhdCXKYtQ== +"ses0_18_3@npm:ses@0.18.3": + version "0.18.3" + resolved "https://registry.yarnpkg.com/ses/-/ses-0.18.3.tgz#d21ac8a5eaa53c3bfde2f14fc660f4fbc4fdd6c3" + integrity sha512-deFT7cN12wE8FGDfXrZ/tUDkGofixzNl2bGc/PmF2oTAhh/x+Do6qfNhpmOMSAxnDdqtPinTcBAM94cKHvxjZg== + set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" From ef7b9f041e8e3dc2ba92660b0ea918612d7c5bef Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Tue, 20 Feb 2024 23:18:51 -0800 Subject: [PATCH 3/4] fix(errors): Fix backward-compat for bare export --- packages/errors/index.js | 14 +++++++++++--- packages/errors/test/test-ses0_18_3.js | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/errors/index.js b/packages/errors/index.js index 15320cbe1e..1a15cf0934 100644 --- a/packages/errors/index.js +++ b/packages/errors/index.js @@ -31,7 +31,10 @@ const missing = /** @type {const} */ ([ 'details', 'Fail', 'quote', - 'bare', + // As of 2024-02, the Agoric chain's bootstrap vat runs with a version of SES that + // predates addition of the 'bare' method, so we must tolerate its absence and fall + // back to quote behavior in that environment (see below). + // 'bare', 'makeAssert', ]).filter(name => globalAssert[name] === undefined); if (missing.length > 0) { @@ -61,18 +64,23 @@ const assert = (value, optDetails, optErrorContructor) => globalAssert(value, optDetails, optErrorContructor); Object.assign(assert, assertions); +// As of 2024-02, the Agoric chain's bootstrap vat runs with a version of SES +// that predates the addition of the 'bare' method, so we must fall back to +// quote behavior for that environment. +const bareOrQuote = bare || quote; + export { // assertions assert, // related utilities that aren't assertions - bare, + bareOrQuote as bare, makeError, note, quote, redacted, throwRedacted, // conventional abbreviations and aliases - bare as b, + bareOrQuote as b, quote as q, redacted as X, throwRedacted as Fail, diff --git a/packages/errors/test/test-ses0_18_3.js b/packages/errors/test/test-ses0_18_3.js index c85553a2f4..6ff6e29a20 100644 --- a/packages/errors/test/test-ses0_18_3.js +++ b/packages/errors/test/test-ses0_18_3.js @@ -1,7 +1,7 @@ import test from 'ava'; import 'ses0_18_3'; -test.failing('shim bare on ses 0.18.3', async t => { +test('shim bare on ses 0.18.3', async t => { // SES v0.18.3 predates the `bare` export. const namespace = await import('../index.js'); t.is(namespace.bare, namespace.quote); From c86880f511ccef3bc4d084303109336bb67c7f7b Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Tue, 20 Feb 2024 23:59:42 -0800 Subject: [PATCH 4/4] test(static-module-record): Record pattern that could not be employed to fix bare exports --- .../test/test-static-module-record.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/static-module-record/test/test-static-module-record.js b/packages/static-module-record/test/test-static-module-record.js index 035159786b..21bd72a6fd 100644 --- a/packages/static-module-record/test/test-static-module-record.js +++ b/packages/static-module-record/test/test-static-module-record.js @@ -792,3 +792,12 @@ test('should handle package "immer" source', t => { setUseProxies: ['vn', true], }); }); + +// https://github.com/endojs/endo/issues/2094 +test.failing('should support export of defaulted extraction', t => { + const _ = new StaticModuleRecord(` + const { x, y = x } = globalThis; + export { x, y }; + `); + t.pass(); +});