FredKSchott / snowpack

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

🐛 BUG: namedExports won't work on version 3.x #3889

Open alcferreira opened 2 years ago

alcferreira commented 2 years ago

Quick checklist

What package manager are you using?

yarn

What operating system are you using?

macOS

Describe the bug

I'm updating snowpack from version 2.18.2 to 3.8.8.

I fixed the breaking changes related to config name changes that we were expecting based on the upgrade guide, but after we keep getting this error message: Module "XXXX" has no exported member "default". Did you mean to use "import default from 'XXXX'" instead?.

On version 2.x this was fixed by using the namedExports option that is documented on the Common error details

I didn't find anything else related to this on the docs, did I miss something? Was there any other change on this behavior that perhaps was not documented?

Steps to reproduce

  1. have a project with namedImports and snowpack@2.x
  2. update snowpack to v3.x and fix the errors related to the config name changes
  3. now the namedImports config won't work anymore

Link to minimal reproducible example (optional)

No response

crapthings commented 2 years ago

I have the same issue

@walletconnect.jsonrpc-utils.v1.0.0.js:3 Uncaught (in promise) SyntaxError: The requested module '/_snowpack/pkg/@walletconnect.environment.v1.0.0.js' does not provide an export named 'formatErrorMessage' (at @walletconnect.jsonrpc-utils.v1.0.0.js:3:10)

image

add namedExports doesn't help

pc-erin commented 2 years ago

@crapthings Is this the same bug? It seems like a bug in snowpack but I'm not sure it's related to the namedExports thing.

If you have a look at the @walletconnect/jsonrpc-utils package snowpack seems to mistakenly be thinking that all it's exports are being re-exported from @walletconnect/environment.

I think this is related to a nested re-export statement.

If you have a look here: https://unpkg.com/@walletconnect/jsonrpc-utils@1.0.0/dist/esm/index.js The first 2 lines work fine. All the exports from ./constants and ./error are re-exported correctly, with parseConnectionError being the last export in the snowpack'ed version. After that ./env uses the line export * from "@walletconnect/environment"; and snowpack seems to convert that to

export { formatErrorMessage, formatJsonRpcError, formatJsonRpcRequest, formatJsonRpcResult, isHttpUrl, isJsonRpcError, isJsonRpcPayload, isJsonRpcRequest, isJsonRpcResponse, isJsonRpcResult, isJsonRpcValidationInvalid, isLocalhostUrl, isValidDefaultRoute, isValidLeadingWildcardRoute, isValidRoute, isValidTrailingWildcardRoute, isValidWildcardRoute, isWsUrl, payloadId } from '@walletconnect/environment';

simply assuming the rest of the exports are coming from @walletconnect/environment.

Not sure if this should be moved to a different issue.