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

Inconsistent Builds in Module Sets #10506

Closed
7 tasks done
kudla opened this issue Oct 18, 2022 · 7 comments
Closed
7 tasks done

Inconsistent Builds in Module Sets #10506

kudla opened this issue Oct 18, 2022 · 7 comments
Labels
duplicate This issue or pull request already exists

Comments

@kudla
Copy link

kudla commented Oct 18, 2022

Describe the bug

On a same immutable application codebase and environment prerequisites Vite:build produces bundles including different sets of dependent modules.
As a consequence chunk content and hashes can mutate from build to build.

Reproduction

https://github.com/kudla/vite-bug-reproduction

Steps to reproduce

npm i
while true; do npm run build  |  grep 'modules transformed' ; done

System Info

System:
    OS: macOS 12.4
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 182.59 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Browsers:
    Chrome: 106.0.5249.119
    Safari: 15.5
  npmPackages:
    @vitejs/plugin-react: ^2.0.1 => 2.0.1
    vite: ^3.1.8 => 3.1.8

Used Package Manager

npm

Logs

Stats grep example

Click to expand!
✓ 1426 modules transformed.
✓ 1429 modules transformed.
✓ 1430 modules transformed.
✓ 1428 modules transformed.

Clear logs

Click to expand!
vite v3.1.8 building for production...
✓ 1425 modules transformed.
dist/index.html                  0.77 KiB
dist/assets/index.f0e9d730.js    1.40 KiB / gzip: 0.72 KiB
dist/assets/vendor.f2801889.js   33.65 KiB / gzip: 10.86 KiB
dist/assets/react.7dcc98bc.js    8.17 KiB / gzip: 3.40 KiB
dist/assets/utils.5559554b.js    95.03 KiB / gzip: 34.55 KiB
dist/assets/main.6d36f42c.js     124.78 KiB / gzip: 46.36 KiB
dist/assets/mui.e8d37d78.js      192.64 KiB / gzip: 64.77 KiB

 02:57:12  home  vite-bug  ⬡ v16.15.1   master ✘ ✭  28s 
$ npm run build

> [email protected] build
> tsc && vite build `test -n "$VITE_BASE_PATH" && echo "--base=$VITE_BASE_PATH" || true`

vite v3.1.8 building for production...
✓ 1430 modules transformed.
dist/index.html                  0.77 KiB
dist/assets/index.41455140.js    1.40 KiB / gzip: 0.71 KiB
dist/assets/vendor.f2801889.js   33.65 KiB / gzip: 10.86 KiB
dist/assets/react.7dcc98bc.js    8.17 KiB / gzip: 3.40 KiB
dist/assets/utils.5559554b.js    95.03 KiB / gzip: 34.55 KiB
dist/assets/main.56be54e9.js     124.50 KiB / gzip: 46.27 KiB
dist/assets/mui.e8d37d78.js      192.64 KiB / gzip: 64.77 KiB

 02:59:09  home  vite-bug  ⬡ v16.15.1   master ✘ ✭  27s 
$ npm run build

> [email protected] build
> tsc && vite build `test -n "$VITE_BASE_PATH" && echo "--base=$VITE_BASE_PATH" || true`

vite v3.1.8 building for production...
✓ 1426 modules transformed.
dist/index.html                  0.77 KiB
dist/assets/vendor.f2801889.js   33.65 KiB / gzip: 10.86 KiB
dist/assets/react.7dcc98bc.js    8.17 KiB / gzip: 3.40 KiB
dist/assets/index.3ada4ac9.js    1.40 KiB / gzip: 0.71 KiB
dist/assets/utils.5559554b.js    95.03 KiB / gzip: 34.55 KiB
dist/assets/main.85318e29.js     124.71 KiB / gzip: 46.33 KiB
dist/assets/mui.e8d37d78.js      192.64 KiB / gzip: 64.77 KiB

Huck Debug Session

Over here I've added a line kind of

console.log(id)

And based on this I've got some stats on included modules within several different build sessions.
Numbers in filenames stand for resulting modules amount for aa session

Raw Logs

build-test-1424.log
build-test-1429.log
build-test-1430.log

Preaggregated Comparable Module Sets

modules-1430.log
modules-1429.log
modules-1424.log

And the Largest Module Sets Spread Diff

Click to expand!
11963a11964
> /Users/home/vite-bug/node_modules/lodash/_WeakMap.js?commonjs-proxy
12018a12020
> /Users/home/vite-bug/node_modules/lodash/_baseIsNative.js?commonjs-proxy
12075a12078
> /Users/home/vite-bug/node_modules/lodash/_coreJsData.js?commonjs-proxy
12118a12122
> /Users/home/vite-bug/node_modules/lodash/_getNative.js?commonjs-proxy
12128a12133
> /Users/home/vite-bug/node_modules/lodash/_getValue.js?commonjs-proxy
12160a12166
> /Users/home/vite-bug/node_modules/lodash/_isMasked.js?commonjs-proxy

Validations

@kudla kudla changed the title Inconsistent Builds in Modules Set Inconsistent Builds in Module Sets Oct 18, 2022
@kudla
Copy link
Author

kudla commented Oct 18, 2022

I'm not really sure the reproduction example is a minimal. It looks like the difference is alway about a lodash submodules. Yet including only the lodash to a project didn't have any reported defects.
So for now I've added the main deps I had in the original project.
Didn't have a time to bisect a root cause.

@wmassa
Copy link

wmassa commented Dec 23, 2022

I created a minimal repro for this issue based on @kudla's code. Hopefully, this helps to gain traction for this issue.

I created a vanilla Vite project and copy pasted the following lines in main.js:

import flow from 'lodash/flow';
import split from 'lodash/fp/split';

export const confNumbers = flow(split(/[;,\s]+/))('e');

Multiple yarn build give different outputs for me.

git clone https://github.com/wmassa/vite-inconsistency-repro
cd vite-inconsistency-repro
yarn
yarn build
yarn build
yarn build
yarn build
yarn build

It outputs index-58937766.js, index-2df03ccf.js, or index-1939915d.js for me.

@kudla
Copy link
Author

kudla commented Dec 23, 2022

I created a minimal repro for this issue

Cool so that now it is 7/7 validated
Thank you @wmassa

@wmassa
Copy link

wmassa commented Dec 30, 2022

A workaround for me is setting maxParallelFileOps: 1, within the rollup options of the vite.config.js file:

import { defineConfig } from 'vite';

export default defineConfig({
  build: {
    rollupOptions: {
      maxParallelFileOps: 1,
    },
  },
});

@rogatty
Copy link

rogatty commented Apr 25, 2023

maxParallelFileOps: 1 workaround doesn't work for me if I delete node_modules/.vite after each build.

@jmsmtn jmsmtn mentioned this issue Oct 6, 2023
7 tasks
derheld42 added a commit to derheld42/repro-vite-10506 that referenced this issue Oct 6, 2023
vitejs/vite#10506
but it doesn't solve the issue.
@derheld42
Copy link

The workaround in #10506 doesn't seem to work for me. I created a repo to try testing the workaround using the basic out-of-the-box base sveltekit app. Test repo is here https://github.com/derheld42/repro-vite-10506

@sapphi-red
Copy link
Member

This repro (#10506 (comment)) was a duplicate of #13672 as the workaround in #13672 (comment) worked.

#10506 (comment) was because svelte kit was injecting non-deterministic value (sveltejs/kit#12260). See sveltejs/kit#12260 (comment).

Closing as a duplicate.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2024
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Aug 12, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

5 participants