Skip to content

fix(typescript): make the built package loadable as ESM - #30

Merged
ExtraToast merged 1 commit into
mainfrom
fix/esm-specifiers
Sep 2, 2026
Merged

fix(typescript): make the built package loadable as ESM#30
ExtraToast merged 1 commit into
mainfrom
fix/esm-specifiers

Conversation

@ExtraToast

Copy link
Copy Markdown
Contributor

The published package cannot be imported by Node:

ERR_UNSUPPORTED_DIR_IMPORT: Directory import '.../dist/generated/client'
is not supported resolving ES modules

The generated sources import with extensionless, sometimes directory-shaped specifiers — export * from './generated/client'. TypeScript's bundler resolution accepts those and emits them unchanged: correct for a bundler, invalid for Node. Vite resolved it happily; vitest in ESA-Blueshell/website did not, and 39 test files failed to import.

The emitted output is now rewritten after compilation — ./x./x.js, or ./x/index.js for a directory. 47 specifiers per package.

Why it shipped

Every test in this repository ran against the TypeScript sources; nothing ever imported the build. CI now loads dist/index.js the way Node does and asserts the sdk came with it. Verified failing against an unfixed build before being committed.

The published package could not be imported by Node:

  ERR_UNSUPPORTED_DIR_IMPORT: Directory import '.../dist/generated/client'
  is not supported resolving ES modules

The generated sources import with extensionless, sometimes directory-shaped
specifiers -- `export * from './generated/client'`. TypeScript's `bundler`
module resolution accepts those and emits them unchanged, which is correct for
a bundler and invalid for Node. Vite resolved it happily; vitest in
ESA-Blueshell/website did not, and 39 of its test files failed to import.

The emitted output is now rewritten after compilation: `./x` becomes `./x.js`,
or `./x/index.js` where the target is a directory. 47 specifiers per package.

The reason this shipped is worth recording: every test here ran against the
TypeScript sources, and nothing ever imported the build. CI now loads
dist/index.js the way Node does and asserts the sdk came with it. Verified
failing against an unfixed build before being committed.
@ExtraToast
ExtraToast merged commit 93f05aa into main Sep 2, 2026
6 checks passed
@ExtraToast
ExtraToast deleted the fix/esm-specifiers branch September 2, 2026 23:03
@github-actions github-actions Bot mentioned this pull request Sep 2, 2026
github-actions Bot added a commit that referenced this pull request Sep 2, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>1.0.2</summary>

##
[1.0.2](v1.0.1...v1.0.2)
(2026-09-02)


### Bug Fixes

* **typescript:** make the built package loadable as ESM
([#30](#30))
([93f05aa](93f05aa))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant