FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 922 forks source link

[BUG] Entrypoint resolver is not compatible with node folder mappings #3438

Open iMagdy opened 3 years ago

iMagdy commented 3 years ago

Bug Report Quick Checklist

Describe the bug

Using any node module that makes use of node's subpath folder mappings (regardless whether the deprecated syntax or the new one) will throw an error:

Package "xxxx" exists but package.json "exports" does not include entry for "./folder_path/file.js"

Example for map (node's deprecated):

"./directives/": {
    "default": "./directives/"
},

Example for map (new):

"./directives/*.js": {
    "default": "./directives/*.js"
},

To solve this issue, this node module must use absolute file path in the imports instead of folder mappings.

To Reproduce

  1. Install an node module like lit (https://lit.dev) which have exports map, then try to import any directive, for example dp import { cssMap } from 'lit/directives/css-map.js'
  2. See the error.
    Package "lit" exists but package.json "exports" does not include entry for "./directives/until.js"

Expected behavior

Should parse folder mappings correctly with both deprecated and new syntax.

cmditch commented 2 years ago

Also hitting this issue with using @snowpack/web-test-runner-plugin and Google's firebase on import 'firebase/compat/firestore'

cmditch commented 2 years ago

@iMagdy have you found a workaround for this by chance? This has been a blocker for me to get web-test-runner working.

Testing in snowpack has proven to be very difficult, haven't had luck w/ jest either.