Skip to content

FAIL TO DEV BUILD: Incorrect dynamic import response during pre-build with esbuild #10403

@ArtemFokin

Description

@ArtemFokin

Describe the bug

Hello
When i started dev server i got some errors like "TypeError: CoinbaseWalletSDK is not a constructor" from packages.
I've looked in package where it's happened and saw that dynamic import provide an unexpected wrapper with default property for it and package don't expect it.
When i build for production it works well, so i think it's something with esbuild.
2022-10-10 12 26 41

For example webpack and rollup build this think without additional wrapper and package expect the same.
2022-10-10 12 26 46

Here piece of code from module with dynamic import

return Promise.resolve(import('@coinbase/wallet-sdk').then(function (m) {
                var _m$default;

                return (_m$default = m == null ? void 0 : m["default"]) != null ? _m$default : m;
  })).then(function (CoinbaseWalletSDK) {....}

Reproduction

https://vitejs-vite-yyulnd--5173.local.webcontainer.io

Steps to reproduce

No response

System Info

System:
    OS: macOS 12.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 450.68 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Browsers:
    Chrome: 106.0.5249.103
    Safari: 15.5
  npmPackages:
    @vitejs/plugin-react: ^2.1.0 => 2.1.0 
    vite: 3 => 3.1.7

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions