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/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..6ff6e29a20 --- /dev/null +++ b/packages/errors/test/test-ses0_18_3.js @@ -0,0 +1,8 @@ +import test from 'ava'; +import 'ses0_18_3'; + +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); +}); 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(); +}); 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"