Skip to content

fix: export module as esm - #677

Open
iamdey wants to merge 6 commits into
reshaped-ui:mainfrom
iamdey:fix_esm_build_via_tsc-alias
Open

iamdey wants to merge 6 commits into
reshaped-ui:mainfrom
iamdey:fix_esm_build_via_tsc-alias

Conversation

@iamdey

@iamdey iamdey commented Oct 7, 2026

Copy link
Copy Markdown

Summary

  • change package type for module in every packages
  • apply tsc-alias configuration: resolveFullPaths: true where it's necessary
  • change ts configuration module to esnext instead of nodenext
  • change ts configuration moduleResolution to bundler instead of nodenext

Related Issue

#672

Screenshots / Recordings

Notes for Reviewers

Thanks to this configuration, the source code doesn't need to be strictly esm valid but the emitted code will be.

closes reshaped-ui#672

- change package type for module in every packages
- apply tsc-alias configuration: resolveFullPaths: true where it's necessary
- change ts configuration module to esnext instead of nodenext
- change ts configuration moduleResolution to bundler instead of nodenext

Thanks to this configuration, the code source doesn't need to be strictly esm valid but the emited code will be.
@iamdey iamdey mentioned this pull request Oct 7, 2026
@blvdmitry

Copy link
Copy Markdown
Contributor

Did a few passes with an agent, can you check the following?

  1. The CLI breaks. packages/reshaped/bin/cli.js contains require("@reshaped/theming/cli/run"). Under "type": "module" that file is ESM, so npx reshaped theming crashes. Fix: change it to import "@reshaped/theming/cli/run";, or rename it to cli.cjs and update bin and files.

  2. (we can potentially also look into deprecating these but I would prefer avoiding that in a minor release, even though likely no one uses it anymore)
    The UMD bundle breaks. dist/bundle.js is a UMD build (formats: ["umd"] in vite.config.mjs). Under "type": "module", Node and bundlers load it as ESM, so module/exports don’t exist. It then falls back to browser globals, and React is undefined. Fix: emit it as bundle.cjs with a bundle.d.cts, point the ./bundle export and the size-limit path at it, or add an ES-format build. A plain <script src=…/bundle.js> isn’t affected by "type", but renaming the file changes that URL.

  3. Typo in theming’s dev script: "tsc-watch --onSuccess "tsc-alias" is missing the closing ", so the shell fails with Unterminated quoted string. It should be "tsc-watch --onSuccess "tsc-alias"".

@iamdey

iamdey commented Oct 12, 2026 •

Copy link
Copy Markdown
Author

I did not forget this PR, I'll take a look to those issues this week.

@blvdmitry

Copy link
Copy Markdown
Contributor

No rush at all, I think some of these should be quite straightforward but it's not a blocking issue so would be amazing to get your contribution in rather than me recreating a similar solution locally. Let me know if I can help with anything once you get back to it

@iamdey
iamdey force-pushed the fix_esm_build_via_tsc-alias branch from 33d4499 to 5250e1b Compare October 16, 2026 15:15

This branch has not been deployed

No deployments
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.

2 participants