From 9cc3dd5551be369d854d5a4c3724b96dc8cc6691 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Fri, 27 Oct 2023 13:57:11 -0700 Subject: [PATCH 1/2] fix(ses): fix types export for newer module resolutions Much like #1803, this adds `types` conditional exports where appropriate. --- packages/ses/package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/ses/package.json b/packages/ses/package.json index 182e1d2211..04797b758a 100644 --- a/packages/ses/package.json +++ b/packages/ses/package.json @@ -36,11 +36,13 @@ "exports": { ".": { "import": "./index.js", - "require": "./dist/ses.cjs" + "require": "./dist/ses.cjs", + "types": "./types.d.ts" }, "./lockdown": { "import": "./index.js", - "require": "./dist/ses.cjs" + "require": "./dist/ses.cjs", + "types": "./types.d.ts" }, "./tools.js": "./tools.js", "./package.json": "./package.json" From fe38c4095c059ed9550aa682a0de5ab958d3522e Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Fri, 27 Oct 2023 14:28:44 -0700 Subject: [PATCH 2/2] fix(ses): fix ThirdPartyStaticModuleInterface type The `proxiedExports` param to the `execute` function cannot be `Object`, which is the literal `Object`. It must be _some_ kind of `Object`, however, a `Record` is suitable. However, the property can be a `PropertyKey` if the exports come from CommonJS and can only be a `string` if the exports come from ESM. Use `string` for now and we can widen the type later. --- packages/ses/package.json.md | 24 ++++++++++++++++-------- packages/ses/types.d.ts | 5 ++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/ses/package.json.md b/packages/ses/package.json.md index 15519a5409..219038f772 100644 --- a/packages/ses/package.json.md +++ b/packages/ses/package.json.md @@ -3,7 +3,7 @@ This is an explainer for the module system configuration of the SES shim package through some properties of `package.json`. -## "type": "module", +## "type": "module" For Node.js, this means that any `.js` file will be interpreted as if it were `.mjs`, meaning a JavaScript module / ESM, as opposed to `.cjs` which is @@ -14,7 +14,7 @@ and translates all `.js` files down from ESM to CommonJS. A patch to `esm` that is in the Agoric SDK repository allows `.js` files in dependencies to break through to the underlying Node.js ESM. -## "main": "./dist/ses.cjs", +## "main": "./dist/ses.cjs" SES provides its own translation from its own ESM sources to CommonJS, emitted by `yarn build`, specifically `scripts/bundle.js`. @@ -35,7 +35,7 @@ The `main` property has been supported by the npm ecosystem since the earliest versions, so every version of Node.js and every tool will look here if nothing else in `package.json` overrides it. -## "module": "./index.js", +## "module": "./index.js" Some tools like WebPack, Parcel and the ESM emulation provided by `node -r esm` use this instead of `main` if it is present. @@ -49,7 +49,7 @@ non-ASCII characters (we use zero-width-joiner to avoid collisions with other names in scope, then censor the use of zero-width-joiner in source). Most tools tolerate this, but WebPack does not. -## "unpkg": "./dist/ses.umd.js", +## "unpkg": "./dist/ses.umd.js" The [Unpkg][] CDN uses this property to direct usage of SES to a precompiled module in "Universal Module Definition" format. @@ -60,7 +60,7 @@ a `