Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite dev fails when using a local commonjs module #7138

Closed
7 tasks done
UltiRequiem opened this issue Mar 1, 2022 · 1 comment
Closed
7 tasks done

vite dev fails when using a local commonjs module #7138

UltiRequiem opened this issue Mar 1, 2022 · 1 comment

Comments

@UltiRequiem
Copy link

UltiRequiem commented Mar 1, 2022

Describe the bug

I have a package.json like

{
  "name": "use-github-react-js",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "use-github": "file:../.."
  },
  "devDependencies": {
    "@vitejs/plugin-react": "^1.0.7",
    "vite": "^2.8.0"
  }
}

The important part is where I import use-github, it's being defined like that because the project is located in an example directory, it's important to mention that this project is not a monorepo!

Reproduction

https://github.com/UltiRequiem/use-github/tree/main/examples/use-github-react-js

System Info

System:
    OS: Linux 5.16 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
    Memory: 12.17 GB / 15.42 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 17.6.0 - /usr/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 8.5.2 - /usr/bin/npm
  Browsers:
    Brave Browser: 98.1.35.103
    Firefox: 97.0.1

Used Package Manager

pnpm

Logs

The problem occurs on the browser, the build is successful

Uncaught ReferenceError: exports is not defined
    at index.js:16:23

index.js

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./user"), exports);
__exportStar(require("./pinned-repos"), exports);

Validations

@bluwy
Copy link
Member

bluwy commented Mar 2, 2022

Duplicate of #5668. There's a documentation update at #7008 but it's not published yet.

@bluwy bluwy closed this as completed Mar 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants