Skip to content

Production build generates the exported default as the module itself #6112

@Newbie012

Description

@Newbie012

Describe the bug

When importing the package react-mapbox-wrapper, it behaves differently when used in development and production.

Given the following code:

import * as M from "react-mapbox-wrapper";
console.log(`M`, M);

running vite outputs:

image

running vite build && vite preview outputs:

image

Reproduction

  1. clone https://github.com/Newbie012/vite-bug-1
  2. npm install
  3. npm run dev
  4. see that the console.log that mentioned above exports accordingly
  5. npm run build
  6. npm run preview
  7. see that the console.log logs a module which its default module is itself

System Info

System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 14.32 GB / 24.99 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.22.6 - ~/.nvm/versions/node/v12.22.6/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v12.22.6/bin/npm
  npmPackages:
    @vitejs/plugin-legacy: 1.6.4 => 1.6.4 
    @vitejs/plugin-react: 1.1.3 => 1.1.3 
    vite: 2.7.2 => 2.7.2

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    inconsistencyInconsistency between dev & buildp2-edge-caseBug, but has workaround or limited in scope (priority)pending triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions