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 3 - npm package as rollupOptions.input fails when package is unused by other inputs #8750

Closed
7 tasks done
bholmesdev opened this issue Jun 23, 2022 · 0 comments
Closed
7 tasks done
Labels
feat: deps optimizer Esbuild Dependencies Optimization p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@bholmesdev
Copy link
Contributor

Describe the bug

I am running a Vite 3 production build via the JavaScript API, and I'm using an npm package within my build.rollupOptions.input array. This succeeds for npm packages used by other files in the input array. However, if that npm package is unused by other inputs, the build will fail!

Example:

import { build } from 'vite';
(async () => {
  await build({
    build: {
      rollupOptions: {
        input: [
          // Fails when resolving the npm package alone
          'is-odd',
          // ...but succeeds if that npm package is used by another input.
          // Uncomment this line to fix the error 👇
          //'src/test-module.js',
        ],
      },
    },
  });
})();

Interestingly, I was unable to replicate in Stackblitz. See the link below for a step-by-step reproduction when running locally!

Reproduction

https://github.com/bholmesdev/vite-3-bug-build-npm-package

System Info

System:
    OS: macOS 12.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 84.06 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  Browsers:
    Chrome: 102.0.5005.115
    Firefox: 101.0.1
    Safari: 15.3
  npmPackages:
    vite: 3.0.0-beta.1 => 3.0.0-beta.1

Used Package Manager

npm

Logs

vite v3.0.0-beta.1 building for production...
Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(vite:optimized-deps-build) load "/Users/benholmes/Sandbox/vite-server-build-simulaneously/node_modules/.vite/deps_build-dist/is-odd.js"
file:///Users/benholmes/Sandbox/vite-server-build-simulaneously/node_modules/rollup/dist/es/shared/rollup.js:23048
reject(new Error(Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:\n +
^

Error: Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(vite:optimized-deps-build) load "/Users/benholmes/Sandbox/vite-server-build-simulaneously/node_modules/.vite/deps_build-dist/is-odd.js"
at EventEmitter.handleEmptyEventLoop (file:///Users/benholmes/Sandbox/vite-server-build-simulaneously/node_modules/rollup/dist/es/shared/rollup.js:23048:20)
at Object.onceWrapper (node:events:639:28)
at EventEmitter.emit (node:events:520:28)
at process. (file:///Users/benholmes/Sandbox/vite-server-build-simulaneously/node_modules/rollup/dist/es/shared/rollup.js:23042:55)
at process.emit (node:events:520:28)

Validations

@sapphi-red sapphi-red added p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) feat: deps optimizer Esbuild Dependencies Optimization labels Jun 24, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: deps optimizer Esbuild Dependencies Optimization p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants