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

error when starting dev server on v2.7.11 #6491

Closed
7 tasks done
konstantin24121 opened this issue Jan 13, 2022 · 6 comments
Closed
7 tasks done

error when starting dev server on v2.7.11 #6491

konstantin24121 opened this issue Jan 13, 2022 · 6 comments

Comments

@konstantin24121
Copy link

konstantin24121 commented Jan 13, 2022

Describe the bug

Just upgraded to v2.7.11, on previous 2.7.10 all starts fine

Reproduction

need reproduction

System Info

System:
    OS: macOS 12.0
    CPU: (8) arm64 Apple M1
    Memory: 79.16 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.8.0 - ~/.nvm/versions/node/v16.8.0/bin/node
    Yarn: 3.1.0 - ~/.nvm/versions/node/v16.8.0/bin/yarn
    npm: 7.21.0 - ~/.nvm/versions/node/v16.8.0/bin/npm
    Watchman: 2021.12.20.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 88.0.1
    Safari: 15.0
  npmPackages:
    @vitejs/plugin-react: ^1.1.4 => 1.1.4 
    vite: 2.7.11 => 2.7.11

Used Package Manager

yarn

Logs

error when starting dev server:
TypeError: Cannot read property 'replace' of undefined
    at normalizeId$1 (/node_modules/vite/dist/node/chunks/dep-48c3e8a4.js:3879:34)
    at optimizeDeps (/node_modules/vite/dist/node/chunks/dep-48c3e8a4.js:56534:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOptimize (/vite/dist/node/chunks/dep-48c3e8a4.js:60540:48)
    at async Http2SecureServer.httpServer.listen (/node_modules/vite/dist/node/chunks/dep-48c3e8a4.js:60556:21)

Validations

@github-actions
Copy link

Hello @konstantin24121. 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.

@giorginogreg
Copy link

giorginogreg commented Jan 13, 2022

Same here, i've started an open source project here, simply run npm run dev, that started slidev, a third part dependency that uses vite (latest version, so v2.7.11), and has this error.

System:
OS: macOS 12.1
CPU: (8) arm64 Apple M1
Memory: 8.00 GB
Shell: 5.8 - /bin/zsh
image

Also tried v2.7.10 of vite, same issue.

@patak-dev
Copy link
Member

@giorginogreg please create a new issue with your reproduction. The original said that it worked in 2.7.10 so it seems you are hitting a different regression. Thanks!

@akhilmhdh
Copy link

akhilmhdh commented Jan 13, 2022

Yup. Just bumped into this issue now, was trying out vite for first time. Needed to install commonjs plugin.

And by that example, i needed to add plugin in optimizeDeps.esbuildOptions.plugins. But was getting the error.

error when starting dev server:
TypeError: Cannot read property 'replace' of undefined
    at normalizeId$1 (/Users/akhilmhdh/Akhi/one-platform/packages/feedback-spa/node_modules/vite/dist/node/chunks/dep-48c3e8a4.js:3879:34)
    at optimizeDeps (/Users/akhilmhdh/Akhi/one-platform/packages/feedback-spa/node_modules/vite/dist/node/chunks/dep-48c3e8a4.js:56534:34)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async runOptimize (/Users/akhilmhdh/Akhi/one-platform/packages/feedback-spa/node_modules/vite/dist/node/chunks/dep-48c3e8a4.js:60540:48)
    at async Server.httpServer.listen (/Users/akhilmhdh/Akhi/one-platform/packages/feedback-spa/node_modules/vite/dist/node/chunks/dep-48c3e8a4.js:60556:21)

Then i just applied without any plugin and noticed that, its firing only when plugins is used inside esbuildOptions even as empty array.

Here is my config file

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import legacy from '@vitejs/plugin-legacy';
import { viteCommonjs, esbuildCommonjs } from '@originjs/vite-plugin-commonjs';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    viteCommonjs(),
    legacy({
      targets: ['defaults', 'not IE 11'],
    }),
    react(),
  ],
  optimizeDeps: {
    esbuildOptions: {
      plugins: [esbuildCommonjs(['@patternfly/react-styles'])],
    },
  },
});

Downgraded to v2.7.0, and walla works perfectly. So some issue with v2.7.2 i think so.

To reproduce

  1. Create a react app using vite cli
  2. Just create an empty array inside optimizeDeps.esbuildOptions.plugins

This one created frustration hell in me 😅

@recih
Copy link

recih commented Jan 14, 2022

Has same issue here.
After some investigation, it caused by a bug in mergeConfigRecursively when merging array values, which has been fixed in #6499

Workaround can be used before new version released:

optimizeDeps: {
  ...
  include: []    // add this
}

@Niputi
Copy link
Contributor

Niputi commented Jan 14, 2022

@recih change is in 2.7.12

@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 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

6 participants