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

Works in dev, but not on a production build #10542

Closed
7 tasks done
FireMasterK opened this issue Oct 19, 2022 · 8 comments
Closed
7 tasks done

Works in dev, but not on a production build #10542

FireMasterK opened this issue Oct 19, 2022 · 8 comments
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@FireMasterK
Copy link

FireMasterK commented Oct 19, 2022

Describe the bug

So, I upgraded my project from Vite v2.9.15 to v3.1.8, after which I started getting build warnings and issues.

Reproduction

https://stackblitz.com/edit/vitejs-vite-retclp?file=main.js

Steps to reproduce

Run:

yarn
yarn build
yarn preview # optional

Open https://piped.kavin.rocks/watch?v=CKo-jOp6twg

System Info

System:
    OS: Linux 6.0 undefined
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 6.16 GB / 13.53 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.16.0 - /usr/bin/node
    Yarn: 1.22.17 - /usr/bin/yarn
    npm: 8.19.2 - /usr/bin/npm
  Browsers:
    Brave Browser: 106.1.44.112
    Chromium: 106.0.5249.119
    Firefox: 106.0

Used Package Manager

yarn

Logs

Browser:

Uncaught (in promise) TypeError: Failed to resolve module specifier "emitter". Relative references must start with either "/", "./", or "../".

Vite build:

node_modules/stream/index.js'emitter' is imported by emitter?commonjs-external, but could not be resolved – treating it as an external dependency

The symptoms are quite similar to #6586

Validations

@sapphi-red
Copy link
Member

Please provide a minimal reproduction, not the complete project.

@github-actions
Copy link

Hello @FireMasterK. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@FireMasterK
Copy link
Author

Hi, I've added a StackBlitz for reproduction.

@sapphi-red sapphi-red added pending triage p3-minor-bug An edge case that only affects very specific usage (priority) and removed needs reproduction labels Oct 20, 2022
@Megrax
Copy link
Contributor

Megrax commented Oct 24, 2022

So, I upgraded my project from Vite v2.9.15 to v3.1.8, after which I started getting build warnings and issues.

I tested on v2.9.15, but it still has warnings on the build.
StackBlitz

@FireMasterK
Copy link
Author

Hmmm, not sure what's going on here! It started appearing on my project when I upgraded to v3.
I did some digging and found something related to emitter: juliangruber/stream#6! Would this still be a vite issue, considering that it only occurs in prod builds?

@barbalex
Copy link

barbalex commented Feb 20, 2023

I have same issue in this project. It is not live yet so only noticed the first time I ran build, then preview.

Seems a bit hard to debug as all the info we get is:

Uncaught TypeError: Failed to resolve module specifier "emitter". Relative references must start with either "/", "./", or "../"

No idea what file caused this.

Edit:

Found this error in the build command but not sure how to deal with it:

transforming (2716) node_modules/@lexical/dragon/LexicalDragon.prod.js"emitter" is imported by "emitter?commonjs-external", but could not be resolved – treating it as an external dependency.

Is this an issue with vite or with LexicalDragon?

@bluwy
Copy link
Member

bluwy commented Mar 2, 2023

This should be a library issue. emitter isn't a module that Vite or anyone provides AFAICT, so some libraries deep down is requiring that and it's incorrect. It works in dev likely because you might not hit that path in runtime, but in Rollup builds it has to analyze and treeshake things, so it'll see it even if you might not used it.

If you want to ignore it, you can set build.rollupOptions.external: ['emitter'], but ideally it should be reported upstream.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2023
@barbalex
Copy link

barbalex commented Mar 3, 2023

Yes, it is caused by a faulty import in stream: juliangruber/stream#5 (comment). I could patch it using patch-package.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

5 participants