Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ESM projects #914

Closed
cometkim opened this issue Jan 17, 2023 · 3 comments · Fixed by #920
Closed

Support ESM projects #914

cometkim opened this issue Jan 17, 2023 · 3 comments · Fixed by #920
Assignees

Comments

@cometkim
Copy link

cannot use in SSR + ESM environment

node:internal/process/esm_loader:79
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/tim/Workspace/src/github.com/daangn/council/node_modules/@heroicons/react/24/outline' is not supported resolving ES modules imported from /Users/tim/Workspace/src/github.com/daangn/council/api/dist/server.js
Did you mean to import @heroicons/react/24/outline/index.js?
    at new NodeError (node:internal/errors:399:5)
    at finalizeResolution (node:internal/modules/esm/resolve:224:17)
    at moduleResolve (node:internal/modules/esm/resolve:850:10)
    at defaultResolve (node:internal/modules/esm/resolve:1058:11)
    at nextResolve (node:internal/modules/esm/loader:164:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:419:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36
@wassim
Copy link

wassim commented Jan 18, 2023

Temporary fix:

import { icon } from '@heroicons/react/24/outline/esm/index.js'

@reinink reinink self-assigned this Jan 24, 2023
@reinink
Copy link
Member

reinink commented Jan 24, 2023

Hey! Can you provide a minimal reproduction for this as a Git repo?

This should work, as we do ship an ESM version, which you can see in the package.json file:

https://unpkg.com/browse/@heroicons/[email protected]/24/solid/package.json

You can also see the ESM versions of the icons here:

https://unpkg.com/browse/@heroicons/[email protected]/24/solid/esm/

So I suspect this probably has something to do with your particular project setup, which is why the minimal reproduction is important 👍

Thanks!

@thecrypticace
Copy link
Contributor

Hey! I've merged a change in #920 that should enable this to work. Bare ESM requires the use of extensions unless a package provides an exports field with what amounts to an import map. It will be available in our next tagged release (possibly today but if not it will happen this week).

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 a pull request may close this issue.

4 participants