Skip to content

[WIP] Fix esm build - #674

Closed
iamdey wants to merge 2 commits into
reshaped-ui:mainfrom
iamdey:fix_esm_build
Closed

iamdey wants to merge 2 commits into
reshaped-ui:mainfrom
iamdey:fix_esm_build

Conversation

@iamdey

@iamdey iamdey commented Oct 5, 2026 •

Copy link
Copy Markdown

Summary

Fix esm build

Related Issue

#672

Screenshots / Recordings

Notes for Reviewers

This is a PoC in its current state.

It only changes:

  • package type for module: ts and node sees it as esm package
  • change directory imports by filename (e.g. from "@/components/Alert" become "@/components/Alert/index.js"
  • add file extension to all files to let use raw tsc command without using any other transpilers (babel/swc, …)

More details in this post: https://gist.github.com/slavafomin/cd7a54035eff5dc1c7c2eff096b23b6b

Currently the transitives are suffering of the same issue, so there is still work to do:

node:internal/modules/esm/resolve:229
    throw new ERR_UNSUPPORTED_DIR_IMPORT(path, basePath, String(resolved));
          ^

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import 'reshaped_esm/node_modules/@reshaped/utilities/dist/a11y' is not supported resolving ES modules imported from reshaped_esm/node_modules/@reshaped/utilities/dist/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:229:11)
    at moduleResolve (node:internal/modules/esm/resolve:846:10)
    at defaultResolve (node:internal/modules/esm/resolve:973:11)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:708:20)
    at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:728:38)
    at ModuleLoader.resolveSync (node:internal/modules/esm/loader:766:56)
    at #resolve (node:internal/modules/esm/loader:690:17)
    at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:610:35)
    at ModuleJob.syncLink (node:internal/modules/esm/module_job:277:33)
    at ModuleJob.link (node:internal/modules/esm/module_job:389:17) {
  code: 'ERR_UNSUPPORTED_DIR_IMPORT',
  url: 'file:///reshaped_esm/node_modules/@reshaped/utilities/dist/a11y'
}

Let me know if you want me to finish this PR or if you have any suggestions.

@iamdey

iamdey commented Oct 5, 2026 •

Copy link
Copy Markdown
Author

So far I just noticed that https://www.npmjs.com/package/tsc-alias can inject file extensions automatically:

resolveFullPaths: true

[edit]: but typecheck won't allow missing file extension in import/export instructions by default :(

@iamdey

iamdey commented Oct 7, 2026

Copy link
Copy Markdown
Author

Closing in favor of #677

@iamdey iamdey closed this Oct 7, 2026
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