Description
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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Activity