lit icon indicating copy to clipboard operation
lit copied to clipboard

[labs/ssr] module resolution doesn't support export maps

Open 43081j opened this issue 1 year ago • 2 comments

Which package(s) are affected?

Other/unknown (please mention in description)

Description

Currently trying to get #3266 to pass tests. it will fail at runtime because of this:

The requested module 'entities/lib/decode.js' does not provide an export named 'BinTrieFlags'

the parse5 tokenizer is what loads entities/lib/decode.js (from the entities npm package), here.

the entities package supports ESM but through an export map rather than a module field, here (for the file we want).

im guessing we get the error we get because the resolve module doesn't support export maps? if thats true, are we expected to implement it in the package JSON transform or over in resolve?

might be completely wrong too, its difficult to debug the module loading...

Reproduction

run the ssr unit tests in #3266

Workaround

N/A

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Browser/OS/Node environment

Node 17.x

43081j avatar Sep 05 '22 09:09 43081j

This is definitely a problem with implementing loading and resolution ourselves. Do we know of any libraries that implement up-to-date resolution?

Otherwise this could be motivation to limit loading to global or a worker and remove the VM modules. I'd like to get some benchmark numbers before doing that though.

justinfagnani avatar Sep 05 '22 16:09 justinfagnani

@justinfagnani seems like the maintainer of resolve intends on adding support but that was a year or so ago.

meanwhile it looks like most people have moved to this:

https://github.com/webpack/enhanced-resolve

maybe that one will work for us too?

43081j avatar Sep 25 '22 08:09 43081j