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

ESM imports not working #9474

Closed
LucasC-S opened this issue Jan 8, 2024 Discussed in #9462 · 3 comments
Closed

ESM imports not working #9474

LucasC-S opened this issue Jan 8, 2024 Discussed in #9462 · 3 comments

Comments

@LucasC-S
Copy link

LucasC-S commented Jan 8, 2024

Discussed in #9462

Originally posted by LucasC-S January 3, 2024
Not sure if this is 100% related to parcel or the packages themselves, but I am trying to use remark-math and rehype-katex with a react app I am using parcel to build. However, when I try and build I get a number of errors where the modules themselves have failed imports. Here is an example:

🚨 Build failed.

@parcel/core: Failed to resolve 'devlop' from './node_modules/hast-util-from-html/lib/index.js'

./node_modules/hast-util-from-html/lib/index.js:60:28
    59 | 
  > 60 | import {ok as assert} from 'devlop'
  >    |                            ^^^^^^^^
    61 | import {fromParse5} from 'hast-util-from-parse5'
    62 | import {parse, parseFragment} from 'parse5'

@parcel/resolver-default: Cannot load file './index' from module 'devlop'

The stuff I have found about this from the unified team all indicates that it is a problem with the resolver (eg. this also happens with jest) and not any unified packages. Any help would be greatly appreciated!!

@mischnic
Copy link
Member

mischnic commented Jan 8, 2024

devlop uses package exports: https://unpkg.com/browse/[email protected]/package.json

You have to opt into them when using Parcel: https://parceljs.org/features/dependency-resolution/#package-exports

@mischnic mischnic closed this as completed Jan 8, 2024
@ttodua
Copy link

ttodua commented Mar 31, 2024

@mischnic but how to ignore the dynamic imports that might exist in some of the dependency modules?
2024-03-31 22 15 05

for example, those dynamic imports are in i.e. if (special_case) { await import(...);} clause, where our application will never have special_case clause to true and thus I will not need to use those dependencies. how to ignore them?

@mischnic
Copy link
Member

mischnic commented Apr 5, 2024

@ttodua
Add

{
	"alias": {
		"http-proxy-agent": false
	}
}

in your project root's package json.

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

No branches or pull requests

3 participants