pulumi/tests/integration/nodejs/esm-ts-default-export
Luke Hoban 1181311c4e
[sdk/nodejs] Support top-level default exports in ESM (#8766)
In #7764 and #8655 we added support for ESM entrypoints.  However, ESM "default exports" were handled just as "normal" in Node.js dynamic import of ESM - as a `default` proeprty in the export object.

This is not a particularly useful behaviour for Pulumi program entry points, and doesn't quite match some of the special logic we apply to non-object exports in CommonJS modules (invoking exported functions, and then awaiting exports promises).

Instead, this change adds support for default exports, treating the default export (if present) as the full returned export value.

It is for now an error to have both a default export and named exports, since it is unclear what this should mean.  In the future, we could potentially relax this and define how these two sets of exports are merged.

This is technically a breaking change from the support added in the recent releases, but only in a narrow case, and in that case the Pulumi stack exports were almost certainly not what the user wanted.

Fixes #8725, which includes a motivating example where this is ~necessary.
2022-01-22 18:33:28 -08:00
..
Pulumi.yaml [sdk/nodejs] Support top-level default exports in ESM (#8766) 2022-01-22 18:33:28 -08:00
index.ts [sdk/nodejs] Support top-level default exports in ESM (#8766) 2022-01-22 18:33:28 -08:00
package.json [sdk/nodejs] Support top-level default exports in ESM (#8766) 2022-01-22 18:33:28 -08:00
tsconfig.json [sdk/nodejs] Support top-level default exports in ESM (#8766) 2022-01-22 18:33:28 -08:00