vitejs / vite

Next generation frontend tooling. It's fast!
http://vitejs.dev
MIT License
66.48k stars 5.96k forks source link

Problem with Dependency Optimization in pnpm #16293

Open paul-vd opened 4 months ago

paul-vd commented 4 months ago

Describe the bug

There seems to be an issue with the optimization of cjs packages inside another package when using pnpm as the package manager, specifically in a polyrepo setup. This problem does not occur when using npm or in a monorepo setup, indicating a potential discrepancy in how dependencies resolved.

Reproduction

https://github.com/front-commerce/vite-pnpm-deps-optimization

Steps to reproduce

  1. Navigate to the polyrepo directory using cd polyrepo.
  2. Execute the command pnpm run dev:pnpm.
  3. Upon opening the landing page, the following error is encountered in the console log:
    Uncaught SyntaxError: The requested module '/node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=41e44650' does not provide an export named 'default' (at hello.tsx:2:8)

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 29.55 GB / 47.01 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v20.9.0/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    pnpm: 8.8.0 - ~/.local/share/pnpm/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 122.0.6261.111

Used Package Manager

pnpm

Logs

dev debug in pnpm ```shell vite:config bundled config file loaded in 16.43ms +0ms vite:config using resolved config: { vite:config plugins: [ vite:config 'vite:optimized-deps', vite:config 'vite:watch-package-data', vite:config 'vite:pre-alias', vite:config 'alias', vite:config 'vite:react-babel', vite:config 'vite:react-refresh', vite:config 'vite:modulepreload-polyfill', vite:config 'vite:resolve', vite:config 'vite:html-inline-proxy', vite:config 'vite:css', vite:config 'vite:esbuild', vite:config 'vite:json', vite:config 'vite:wasm-helper', vite:config 'vite:worker', vite:config 'vite:asset', vite:config 'vite:wasm-fallback', vite:config 'vite:define', vite:config 'vite:css-post', vite:config 'vite:worker-import-meta-url', vite:config 'vite:asset-import-meta-url', vite:config 'vite:dynamic-import-vars', vite:config 'vite:import-glob', vite:config 'vite:client-inject', vite:config 'vite:css-analysis', vite:config 'vite:import-analysis' vite:config ], vite:config optimizeDeps: { vite:config holdUntilCrawlEnd: true, vite:config force: undefined, vite:config esbuildOptions: { preserveSymlinks: false, jsx: 'automatic' }, vite:config include: [ 'react', 'react/jsx-dev-runtime', 'react/jsx-runtime' ] vite:config }, vite:config server: { vite:config preTransformRequests: true, vite:config host: undefined, vite:config sourcemapIgnoreList: [Function: isInNodeModules$1], vite:config middlewareMode: false, vite:config fs: { vite:config strict: true, vite:config allow: [Array], vite:config deny: [Array], vite:config cachedChecks: undefined vite:config } vite:config }, vite:config esbuild: { jsxDev: true, jsx: 'automatic', jsxImportSource: undefined }, vite:config build: { vite:config target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ], vite:config cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ], vite:config outDir: 'dist', vite:config assetsDir: 'assets', vite:config assetsInlineLimit: 4096, vite:config cssCodeSplit: true, vite:config sourcemap: false, vite:config rollupOptions: { onwarn: [Function: onwarn] }, vite:config minify: 'esbuild', vite:config terserOptions: {}, vite:config write: true, vite:config emptyOutDir: null, vite:config copyPublicDir: true, vite:config manifest: false, vite:config lib: false, vite:config ssr: false, vite:config ssrManifest: false, vite:config ssrEmitAssets: false, vite:config reportCompressedSize: true, vite:config chunkSizeWarningLimit: 500, vite:config watch: null, vite:config commonjsOptions: { include: [Array], extensions: [Array] }, vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }, vite:config modulePreload: { polyfill: true }, vite:config cssMinify: true vite:config }, vite:config resolve: { vite:config mainFields: [ 'browser', 'module', 'jsnext:main', 'jsnext' ], vite:config conditions: [], vite:config extensions: [ vite:config '.mjs', '.js', vite:config '.mts', '.ts', vite:config '.jsx', '.tsx', vite:config '.json' vite:config ], vite:config dedupe: [ 'react', 'react-dom' ], vite:config preserveSymlinks: false, vite:config alias: [ [Object], [Object] ] vite:config }, vite:config configFile: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/vite.config.ts', vite:config configFileDependencies: [ vite:config '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/vite.config.ts' vite:config ], vite:config inlineConfig: { vite:config root: undefined, vite:config base: undefined, vite:config mode: undefined, vite:config configFile: undefined, vite:config logLevel: undefined, vite:config clearScreen: undefined, vite:config optimizeDeps: { force: undefined }, vite:config server: { host: undefined } vite:config }, vite:config root: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo', vite:config base: '/', vite:config rawBase: '/', vite:config publicDir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/public', vite:config cacheDir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite', vite:config command: 'serve', vite:config mode: 'development', vite:config ssr: { vite:config target: 'node', vite:config optimizeDeps: { noDiscovery: true, esbuildOptions: [Object] } vite:config }, vite:config isWorker: false, vite:config mainConfig: null, vite:config bundleChain: [], vite:config isProduction: false, vite:config css: { lightningcss: undefined }, vite:config preview: { vite:config port: undefined, vite:config strictPort: undefined, vite:config host: undefined, vite:config https: undefined, vite:config open: undefined, vite:config proxy: undefined, vite:config cors: undefined, vite:config headers: undefined vite:config }, vite:config envDir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo', vite:config env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false }, vite:config assetsInclude: [Function: assetsInclude], vite:config logger: { vite:config hasWarned: false, vite:config info: [Function: info], vite:config warn: [Function: warn], vite:config warnOnce: [Function: warnOnce], vite:config error: [Function: error], vite:config clearScreen: [Function: clearScreen], vite:config hasErrorLogged: [Function: hasErrorLogged] vite:config }, vite:config packageCache: Map(1) { vite:config 'fnpd_/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo' => { vite:config dir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo', vite:config data: [Object], vite:config hasSideEffects: [Function: hasSideEffects], vite:config webResolvedImports: {}, vite:config nodeResolvedImports: {}, vite:config setResolvedCache: [Function: setResolvedCache], vite:config getResolvedCache: [Function: getResolvedCache] vite:config }, vite:config set: [Function (anonymous)] vite:config }, vite:config createResolver: [Function: createResolver], vite:config worker: { format: 'iife', plugins: '() => plugins', rollupOptions: {} }, vite:config appType: 'spa', vite:config experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false }, vite:config getSortedPlugins: [Function: getSortedPlugins], vite:config getSortedPluginHooks: [Function: getSortedPluginHooks] vite:config } +4ms vite:deps removing old cache dir /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps +0ms vite:resolve 1.27ms react -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js +0ms vite:resolve 0.24ms react/jsx-dev-runtime -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-dev-runtime.js +0ms vite:resolve 0.12ms react/jsx-runtime -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js +0ms vite:deps scanning for dependencies... +0ms VITE v5.2.6 ready in 127 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h + enter to show help vite:deps Crawling dependencies using entries: vite:deps /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/index.html +0ms vite:resolve 0.18ms /src/main.tsx -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/src/main.tsx +0ms vite:resolve 0.38ms react -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js +2ms vite:resolve 0.20ms react-dom/client -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/client.js +0ms vite:resolve 0.16ms ./App.tsx -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/src/App.tsx +1ms vite:resolve 0.15ms react/jsx-runtime -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js +1ms vite:resolve 0.26ms @test-pkg/hello-world -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +1ms vite:deps Scan completed in 36.96ms: vite:deps react -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js vite:deps react-dom/client -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/client.js vite:deps react/jsx-runtime -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js +24ms vite:deps creating package.json in /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps_temp_d09844f2 +44ms vite:resolve 0.35ms react-dom -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/index.js +0ms vite:resolve 0.28ms react -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js +4ms vite:resolve 0.48ms scheduler -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/scheduler@0.23.0/node_modules/scheduler/index.js +30ms vite:deps Dependencies bundled in 72.81ms +73ms vite:html-fallback Rewriting GET / to /index.html +0ms vite:time 13.13ms /index.html +0ms vite:resolve 2.03ms /src/main.tsx -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/src/main.tsx +0ms vite:load 1.51ms [fs] /src/main.tsx +0ms vite:resolve 0.31ms /@vite/client -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/client.mjs +155ms vite:load 0.02ms [plugin] /@react-refresh +156ms vite:resolve 0.23ms ./App.tsx -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/src/App.tsx +6ms vite:resolve 0.31ms ./index.css -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/src/index.css +0ms vite:resolve 0.42ms react/jsx-dev-runtime -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee +0ms vite:resolve 0.44ms react -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/react.js?v=2885b0ee +0ms vite:resolve 0.48ms react-dom/client -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 +0ms vite:import-analysis /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee needs interop +0ms vite:import-analysis /node_modules/.vite/deps/react.js?v=2885b0ee needs interop +2ms vite:import-analysis /node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 needs interop +0ms vite:import-analysis 4.59ms [5 imports rewritten] src/main.tsx +1ms vite:transform 163.85ms /src/main.tsx +0ms vite:time 10.01ms /src/main.tsx +168ms vite:load 12.09ms [fs] /@vite/client +10ms vite:import-analysis 0.28ms [0 imports rewritten] /@react-refresh +4ms vite:transform 11.11ms /@react-refresh +2ms vite:time 11.53ms /@react-refresh +2ms vite:load 4.41ms [fs] /src/App.tsx +1ms vite:load 19.37ms [fs] /src/index.css +15ms vite:hmr [self-accepts] src/index.css +0ms vite:import-analysis 0.30ms [0 imports rewritten] src/index.css +16ms vite:transform 0.99ms /src/index.css +16ms vite:resolve 0.54ms ./assets/react.svg -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/src/assets/react.svg +26ms vite:resolve 0.65ms ./App.css -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/src/App.css +0ms vite:cache [memory] /@react-refresh +0ms vite:resolve 0.80ms @test-pkg/hello-world -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +0ms vite:import-analysis /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee needs interop +3ms vite:import-analysis /node_modules/.vite/deps/react.js?v=2885b0ee needs interop +0ms vite:hmr [self-accepts] src/App.tsx +3ms vite:import-analysis 2.28ms [7 imports rewritten] src/App.tsx +0ms vite:transform 19.84ms /src/App.tsx +4ms vite:load 1.06ms [plugin] /src/assets/react.svg +5ms vite:load 1.10ms [plugin] /vite.svg +1ms vite:import-analysis 0.04ms [no imports] src/assets/react.svg +2ms vite:import-analysis 0.02ms [no imports] /vite.svg +0ms vite:transform 0.38ms /src/assets/react.svg +1ms vite:transform 0.38ms /vite.svg +0ms vite:resolve 0.14ms @vite/env -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +4ms vite:import-analysis 0.77ms [1 imports rewritten] node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/client.mjs +1ms vite:transform 1.04ms /@vite/client +2ms vite:time 36.92ms /@vite/client +23ms vite:cache [memory] /src/App.tsx +6ms vite:time 0.15ms /src/App.tsx +1ms vite:cache [304] /src/index.css +0ms vite:time 0.16ms /src/index.css +1ms vite:load 5.55ms [fs] /src/App.css +4ms vite:hmr [self-accepts] src/App.css +6ms vite:import-analysis 0.15ms [0 imports rewritten] src/App.css +3ms vite:transform 0.37ms /src/App.css +2ms vite:load 6.11ms [fs] /node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +1ms vite:cache [memory] /src/main.tsx +2ms vite:time 0.29ms /src/main.tsx +2ms vite:load 4.37ms [fs] /node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +1ms vite:cache [memory] /@react-refresh +1ms vite:time 0.33ms /@react-refresh +0ms vite:resolve 0.98ms object-path -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +7ms vite:resolve 1.06ms ky -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +0ms vite:import-analysis /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee needs interop +4ms vite:import-analysis /node_modules/.vite/deps/react.js?v=2885b0ee needs interop +1ms vite:import-analysis 2.36ms [4 imports rewritten] node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +0ms vite:transform 4.78ms /node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +5ms vite:import-analysis 0.02ms [no imports] node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +1ms vite:transform 0.19ms /node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +1ms vite:load 0.96ms [fs] /node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +4ms vite:import-analysis 0.07ms [no imports] node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +1ms vite:transform 0.21ms /node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +1ms vite:load 1.38ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +1ms vite:resolve 0.83ms ./core/Ky.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +4ms vite:resolve 0.96ms ./core/constants.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +0ms vite:resolve 1.03ms ./utils/merge.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +0ms vite:resolve 1.10ms ./errors/HTTPError.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +0ms vite:resolve 1.18ms ./errors/TimeoutError.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +0ms vite:import-analysis 2.10ms [5 imports rewritten] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +2ms vite:transform 2.26ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +2ms vite:cache [memory] /node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +8ms vite:time 0.35ms /node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +9ms vite:load 1.94ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +4ms vite:load 2.06ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +0ms vite:load 2.15ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +0ms vite:load 2.23ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +0ms vite:load 2.34ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +0ms vite:cache [304] /src/assets/react.svg?import +12ms vite:time 0.07ms /src/assets/react.svg?import +1ms vite:cache [304] /vite.svg?import +0ms vite:time 0.09ms /vite.svg?import +0ms vite:cache [304] /node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +1ms vite:time 0.08ms /node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +1ms vite:cache [304] /src/App.css +0ms vite:time 0.15ms /src/App.css +0ms vite:resolve 0.74ms ../errors/HTTPError.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +7ms vite:resolve 0.82ms ../errors/TimeoutError.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +1ms vite:resolve 0.88ms ../utils/merge.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +0ms vite:resolve 0.94ms ../utils/normalize.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +0ms vite:resolve 0.99ms ../utils/timeout.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +0ms vite:resolve 1.05ms ../utils/delay.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +0ms vite:resolve 1.10ms ../utils/options.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +0ms vite:resolve 1.16ms ./constants.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +0ms vite:import-analysis 2.30ms [8 imports rewritten] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +8ms vite:transform 2.53ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +8ms vite:resolve 0.13ms ./is.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +1ms vite:import-analysis 0.44ms [1 imports rewritten] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +1ms vite:transform 0.59ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +1ms vite:import-analysis 0.02ms [no imports] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +0ms vite:transform 0.13ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +0ms vite:import-analysis 0.01ms [no imports] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +0ms vite:transform 0.11ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +0ms vite:import-analysis 0.03ms [no imports] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +1ms vite:transform 0.13ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +9ms vite:time 3.10ms /node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +9ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +4ms vite:time 0.26ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +1ms vite:load 9.44ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +15ms vite:load 9.57ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +0ms vite:load 9.67ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +0ms vite:load 9.80ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +0ms vite:load 8.90ms [fs] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +0ms vite:resolve 0.22ms ../core/constants.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +13ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +8ms vite:import-analysis 1.17ms [1 imports rewritten] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +12ms vite:transform 1.43ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +12ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +1ms vite:import-analysis 0.66ms [1 imports rewritten] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +1ms vite:transform 0.83ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +1ms vite:import-analysis 0.02ms [no imports] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +0ms vite:transform 0.24ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +0ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +1ms vite:import-analysis 0.46ms [1 imports rewritten] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +1ms vite:transform 0.58ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +1ms vite:import-analysis 0.03ms [no imports] node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +0ms vite:transform 0.28ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +2ms vite:time 0.43ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +12ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +1ms vite:time 0.18ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +0ms vite:time 0.20ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +0ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +4ms vite:time 0.39ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +4ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +1ms vite:time 0.14ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +2ms vite:time 0.20ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +2ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +0ms vite:time 0.15ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +0ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +1ms vite:time 0.15ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +1ms vite:time 0.14ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +0ms vite:time 0.13ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +0ms vite:cache [memory] /@vite/client +27ms vite:time 1.03ms /@vite/client +27ms vite:cache [memory] /src/App.tsx +1ms vite:time 0.41ms /src/App.tsx +2ms vite:cache [memory] /src/index.css +3ms vite:time 0.25ms /src/index.css +2ms vite:cache [memory] /node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +2ms vite:time 0.28ms /node_modules/.pnpm/file+..+monorepo+packages+hello-world_react@18.2.0/node_modules/@test-pkg/hello-world/hello.tsx +2ms vite:cache [memory] /src/assets/react.svg +1ms vite:time 0.56ms /src/assets/react.svg?import +1ms vite:cache [memory] /node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +1ms vite:time 0.18ms /node_modules/.pnpm/vite@5.2.6/node_modules/vite/dist/client/env.mjs +1ms vite:cache [memory] /vite.svg +0ms vite:time 0.18ms /vite.svg?import +0ms vite:cache [memory] /node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +1ms vite:time 1.35ms /node_modules/.pnpm/object-path@0.11.8/node_modules/object-path/index.js?v=c0759e35 +2ms vite:cache [memory] /src/App.css +1ms vite:time 0.12ms /src/App.css +0ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +1ms vite:time 0.25ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/index.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +0ms vite:time 0.21ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/Ky.js?v=c0759e35 +0ms vite:deps ✨ static imports crawl ended +27s vite:deps ✨ using post-scan optimizer result, the scanner found every used dependency +0ms vite:deps creating _metadata.json in /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps_temp_d09844f2 +27s vite:deps renaming /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps_temp_d09844f2 to /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps +1ms vite:optimize-deps load /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/react_jsx-dev-runtime.js +0ms vite:optimize-deps load /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/react.js +0ms vite:optimize-deps load /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/react-dom_client.js +0ms vite:deps ✨ dependencies optimized +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +2ms vite:time 0.18ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/timeout.js?v=c0759e35 +2ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +1ms vite:time 0.21ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/core/constants.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +0ms vite:time 0.13ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/merge.js?v=c0759e35 +0ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +1ms vite:time 0.12ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/HTTPError.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +0ms vite:time 0.16ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/errors/TimeoutError.js?v=c0759e35 +0ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +0ms vite:time 0.14ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/normalize.js?v=c0759e35 +1ms vite:load 117.60ms [plugin] /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee +62ms vite:resolve 0.10ms ./chunk-UFULD5UP.js -> /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/chunk-UFULD5UP.js?v=c0759e35 +59ms vite:optimize-deps load /home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite/deps/chunk-UFULD5UP.js +4ms vite:import-analysis 0.72ms [1 imports rewritten] node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee +56ms vite:transform 0.92ms /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee +55ms vite:time 98.03ms /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee +2ms vite:load 119.04ms [plugin] /node_modules/.vite/deps/react.js?v=2885b0ee +2ms vite:import-analysis 0.18ms [1 imports rewritten] node_modules/.vite/deps/react.js?v=2885b0ee +1ms vite:transform 0.31ms /node_modules/.vite/deps/react.js?v=2885b0ee +1ms vite:time 98.56ms /node_modules/.vite/deps/react.js?v=2885b0ee +0ms vite:load 120.46ms [plugin] /node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 +1ms vite:import-analysis 5.44ms [1 imports rewritten] node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 +9ms vite:transform 8.04ms /node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 +9ms vite:time 104.87ms /node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 +14ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +20ms vite:time 0.32ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/delay.js?v=c0759e35 +4ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +1ms vite:time 0.17ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/options.js?v=c0759e35 +0ms vite:cache [memory] /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +0ms vite:time 0.23ms /node_modules/.pnpm/ky@1.2.3/node_modules/ky/distribution/utils/is.js?v=c0759e35 +1ms vite:load 19.62ms [plugin] /node_modules/.vite/deps/chunk-UFULD5UP.js?v=c0759e35 +18ms vite:import-analysis 0.42ms [no imports] node_modules/.vite/deps/chunk-UFULD5UP.js?v=c0759e35 +11ms vite:transform 0.69ms /node_modules/.vite/deps/chunk-UFULD5UP.js?v=c0759e35 +11ms vite:time 1.05ms /node_modules/.vite/deps/chunk-UFULD5UP.js?v=c0759e35 +1ms vite:cache [memory] /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee +225ms vite:time 0.30ms /node_modules/.vite/deps/react_jsx-dev-runtime.js?v=2885b0ee +223ms vite:cache [memory] /node_modules/.vite/deps/react.js?v=2885b0ee +0ms vite:time 0.10ms /node_modules/.vite/deps/react.js?v=2885b0ee +0ms vite:cache [memory] /node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 +0ms vite:time 0.80ms /node_modules/.vite/deps/react-dom_client.js?v=840ac8d8 +1ms ```
Build debug in pnpm ```shell vite:config bundled config file loaded in 15.31ms +0ms vite:config using resolved config: { vite:config plugins: [ vite:config 'vite:build-metadata', vite:config 'vite:watch-package-data', vite:config 'vite:pre-alias', vite:config 'alias', vite:config 'vite:react-babel', vite:config 'vite:react-refresh', vite:config 'vite:modulepreload-polyfill', vite:config 'vite:resolve', vite:config 'vite:html-inline-proxy', vite:config 'vite:css', vite:config 'vite:esbuild', vite:config 'vite:json', vite:config 'vite:wasm-helper', vite:config 'vite:worker', vite:config 'vite:asset', vite:config 'vite:wasm-fallback', vite:config 'vite:define', vite:config 'vite:css-post', vite:config 'vite:build-html', vite:config 'vite:worker-import-meta-url', vite:config 'vite:asset-import-meta-url', vite:config 'vite:force-systemjs-wrap-complete', vite:config 'commonjs', vite:config 'vite:data-uri', vite:config 'vite:dynamic-import-vars', vite:config 'vite:import-glob', vite:config 'vite:build-import-analysis', vite:config 'vite:esbuild-transpile', vite:config 'vite:terser', vite:config 'vite:reporter', vite:config 'vite:load-fallback' vite:config ], vite:config build: { vite:config target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ], vite:config cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ], vite:config outDir: 'dist', vite:config assetsDir: 'assets', vite:config assetsInlineLimit: 4096, vite:config cssCodeSplit: true, vite:config sourcemap: false, vite:config rollupOptions: { onwarn: [Function: onwarn] }, vite:config minify: 'esbuild', vite:config terserOptions: {}, vite:config write: true, vite:config emptyOutDir: null, vite:config copyPublicDir: true, vite:config manifest: false, vite:config lib: false, vite:config ssr: false, vite:config ssrManifest: false, vite:config ssrEmitAssets: false, vite:config reportCompressedSize: true, vite:config chunkSizeWarningLimit: 500, vite:config watch: null, vite:config commonjsOptions: { include: [Array], extensions: [Array] }, vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }, vite:config modulePreload: { polyfill: true }, vite:config cssMinify: true vite:config }, vite:config esbuild: { jsxDev: false, jsx: 'automatic', jsxImportSource: undefined }, vite:config optimizeDeps: { vite:config holdUntilCrawlEnd: true, vite:config esbuildOptions: { preserveSymlinks: false, jsx: 'automatic' }, vite:config include: [ 'react', 'react/jsx-dev-runtime', 'react/jsx-runtime' ] vite:config }, vite:config resolve: { vite:config mainFields: [ 'browser', 'module', 'jsnext:main', 'jsnext' ], vite:config conditions: [], vite:config extensions: [ vite:config '.mjs', '.js', vite:config '.mts', '.ts', vite:config '.jsx', '.tsx', vite:config '.json' vite:config ], vite:config dedupe: [ 'react', 'react-dom' ], vite:config preserveSymlinks: false, vite:config alias: [ [Object], [Object] ] vite:config }, vite:config configFile: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/vite.config.ts', vite:config configFileDependencies: [ vite:config '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/vite.config.ts' vite:config ], vite:config inlineConfig: { vite:config root: undefined, vite:config base: undefined, vite:config mode: undefined, vite:config configFile: undefined, vite:config logLevel: undefined, vite:config clearScreen: undefined, vite:config build: {} vite:config }, vite:config root: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo', vite:config base: '/', vite:config rawBase: '/', vite:config publicDir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/public', vite:config cacheDir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo/node_modules/.vite', vite:config command: 'build', vite:config mode: 'production', vite:config ssr: { vite:config target: 'node', vite:config optimizeDeps: { noDiscovery: true, esbuildOptions: [Object] } vite:config }, vite:config isWorker: false, vite:config mainConfig: null, vite:config bundleChain: [], vite:config isProduction: true, vite:config css: { lightningcss: undefined }, vite:config server: { vite:config preTransformRequests: true, vite:config sourcemapIgnoreList: [Function: isInNodeModules$1], vite:config middlewareMode: false, vite:config fs: { vite:config strict: true, vite:config allow: [Array], vite:config deny: [Array], vite:config cachedChecks: undefined vite:config } vite:config }, vite:config preview: { vite:config port: undefined, vite:config strictPort: undefined, vite:config host: undefined, vite:config https: undefined, vite:config open: undefined, vite:config proxy: undefined, vite:config cors: undefined, vite:config headers: undefined vite:config }, vite:config envDir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo', vite:config env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true }, vite:config assetsInclude: [Function: assetsInclude], vite:config logger: { vite:config hasWarned: false, vite:config info: [Function: info], vite:config warn: [Function: warn], vite:config warnOnce: [Function: warnOnce], vite:config error: [Function: error], vite:config clearScreen: [Function: clearScreen], vite:config hasErrorLogged: [Function: hasErrorLogged] vite:config }, vite:config packageCache: Map(1) { vite:config 'fnpd_/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo' => { vite:config dir: '/home/paul/Projects/reproduction/vite-pnpm-package-optimization/polyrepo', vite:config data: [Object], vite:config hasSideEffects: [Function: hasSideEffects], vite:config webResolvedImports: {}, vite:config nodeResolvedImports: {}, vite:config setResolvedCache: [Function: setResolvedCache], vite:config getResolvedCache: [Function: getResolvedCache] vite:config }, vite:config set: [Function (anonymous)] vite:config }, vite:config createResolver: [Function: createResolver], vite:config worker: { format: 'iife', plugins: '() => plugins', rollupOptions: {} }, vite:config appType: 'spa', vite:config experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false }, vite:config getSortedPlugins: [Function: getSortedPlugins], vite:config getSortedPluginHooks: [Function: getSortedPluginHooks] vite:config } +13ms vite v5.2.6 building for production... ✓ 48 modules transformed. dist/index.html 0.46 kB │ gzip: 0.30 kB dist/assets/react-CHdo91hT.svg 4.13 kB │ gzip: 2.14 kB dist/assets/index-Svrmm00t.css 1.41 kB │ gzip: 0.73 kB dist/assets/index-_mWGsVeD.js 157.17 kB │ gzip: 50.86 kB ✓ built in 545ms ```

Validations

Possible related issues

hi-ogawa commented 4 months ago

This problem does not occur when using npm or in a monorepo setup

You might be experiencing this situation https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude

In pnpm + file:... case (what you call polyrepo), @test-pkg/hello-world becomes "external" package since it's hard-copied into node_modules/@test-pkg/hello-world, so you might need to explicitly add optimizeDeps.include: ["@test-pkg/hello-world > object-path"] to enforce deps optimization for the transitive dependency.

pnpm + workspace:... (and also npm + file:... if I remember correctly) will create a symlink to monorepo/packages/hello-world, so Vite's "out of node_modules" behavior treats @test-pkg/hello-world to be just like your source code (i.e. not "external") and the same issue doesn't happen.

paul-vd commented 4 months ago

@hi-ogawa, thank you for pointing out the possible workaround involving optimizeDeps.include. However, I'd like to emphasize that the issue we're encountering occurs not only with local packages using file:.. in our polyrepo setup but also with published packages.

This is particularly critical for our workflow because, although we develop in a monorepo and distribute our packages by publishing them, we encountered this issue on release day. After publishing, when attempting to consume these packages in a new Vite-based app (polyrepo), the discrepancies between monorepo and polyrepo environments in Vite became apparent.

This inconsistency hampers our ability to safely develop and test packages, given that the behavior in a monorepo vs. a polyrepo setup with Vite differs significantly. As an attempt to mimic how Vite processes our packages in a polyrepo, we even tried renaming the packages folder in our monorepo to packages_node_modules. This approach brought us closer to replicating the polyrepo scenario, yet the results were still inconsistent.

Given this context, I believe it’s reasonable to expect that if we need to explicitly include dependencies using optimizeDeps.include: ["@test-pkg/hello-world > object-path"] in a polyrepo setup, the same requirement should logically apply to a monorepo setup for consistency. This would ensure that our development and testing processes are aligned across different project structures, thus mitigating unexpected behaviors when our packages are consumed in various environments.

hi-ogawa commented 4 months ago

After publishing, when attempting to consume these packages in a new Vite-based app (polyrepo), the discrepancies between monorepo and polyrepo environments in Vite became apparent.

Actually this type of inconsistency might be somewhat common and I experienced this myself a few times already (my framework and also Vitest's browser mode).

Maybe Vite team knows something, but as far as I know this is an unfortunate situation and what I can suggest is to setup some integration tests for fresh package install scenario, which I just happen to do this recently like here https://github.com/hi-ogawa/vite-plugins/blob/992368d0c2f23dbb6c2d8c67a7ce0546d610a671/packages/react-server/misc/test.sh#L16.

real34 commented 4 months ago

I've investigated a bit more and I have a working solution for the minimal repro (see https://github.com/front-commerce/vite-pnpm-deps-optimization/pull/3/files) with an esbuild plugin marking the package as external: false. I thought it would force the initial scan deps discovery to consider the package as a linked package (which it seems to do) and thus resolve it's own dependencies.

But this solution doesn't work on our more complex application (with aliases, ssr excludes, vite ran from JS API etc…), so I'm not sure :confused:

Alternatives I could find all required some changes in the core. Here are ideas:

Does anyone has any thought about these possible solutions?

hi-ogawa commented 4 months ago

I cannot comment much of the implementation, but FYI, recently there was a discussion about how Vite team thinks about current node_modules heuristics

Also just another idea to spot inconsistency between dev/build early, I was thinking you could try optimizeDeps.noDiscovery: true during dev, which will probably force you to explicitly list cjs deps to optimizeDeps.include in your polyrepo app during development.

But I feel this would worsen DX a lot and it might be easier to setup integration tests with file:... protocols.


Btw, also looking at https://github.com/front-commerce/vite-pnpm-deps-optimization/pull/3, is it different from adding optimizeDeps.include: ["@test-pkg/hello-world"] instead of ["@test-pkg/hello-world > object-path"]?

hi-ogawa commented 4 months ago

Trying to understand the idea of https://github.com/front-commerce/vite-pnpm-deps-optimization/pull/3, maybe you're looking for some ideal (hypothetical) syntax like this?

optimizeDeps: {
  exclude: ["@test-pkg/hello-world"],     // `@test-pkg/hello-world` itself needs to be processed by Vite
  include: ["@test-pkg/hello-world > *"], // but any deps from it can be always pre-bundled by esbuild
}

which somewhat reminds me of how Vitest's browser mode struggles with exclude/include. https://github.com/vitest-dev/vitest/blob/e4e939ba2ab48c67ee14b82ec957fc9a8a52756c/packages/browser/src/node/index.ts#L139-L158

vitest itself cannot be pre-bundled, but we wanted transitive cjs deps to be pre-bundled.

frandiox commented 3 months ago

@hi-ogawa I'm having a similar issue with the cookie dependency of @remix-run/server-runtime when running on workerd.

With NPM, ssr.optimizeDeps: {include: ['cookie']} works well. However, with PNPM the cookie package is not present directly in node_modules, so it fails with ReferenceError: exports is not defined.

I've tried with @remix-run/server-runtime > cookie but it doesn't seem to work. Do you know if this syntax is valid in ssr.optimizeDeps.include or only in optimizeDeps.include? 🤔

The current workaround is adding public-hoist-pattern[]=cookie to .npmrc to hoist the package so that Vite can optimize it.

hi-ogawa commented 3 months ago

I've tried with @remix-run/server-runtime > cookie but it doesn't seem to work. Do you know if this syntax is valid in ssr.optimizeDeps.include or only in optimizeDeps.include? 🤔

@frandiox I thought @remix-run/server-runtime > cookie should work for ssr.optimizeDeps.include, but indeed it doesn't look working when I just tested on vite-node-miniflare example.

Though ssr.optimizeDeps is technically still experimental (and some parts of it is reworked in new environment api https://github.com/vitejs/vite/pull/16129), I think this is worth reporting an separate issue.

Regarding @remix-run/server-runtime and cookie, I remember the same error and what I did is to put the entire @remix-run/server-runtime as ssr.optimizeDeps.include (probably I wasn't familiar with ... > ... syntax at that time, so didn't even try it). Do you have some issues with doing this on hydrogen? https://github.com/hi-ogawa/vite-plugins/blob/aa4ce2625b69b1f867554b4372dec5a30b3515b4/packages/vite-node-miniflare/examples/remix/vite.config.ts#L15

frandiox commented 3 months ago

Regarding @remix-run/server-runtime and cookie, I remember the same error and what I did is to put the entire @remix-run/server-runtime as ssr.optimizeDeps.include (probably I wasn't familiar with ... > ... syntax at that time, so didn't even try it). Do you have some issues with doing this on hydrogen?

Yeah that works. I started adding cookie directly because I thought it would be more performant and it worked with NPM. However, I guess it's safer to add the entire server-runtime just in case. Thanks!

yairEO commented 3 months ago

I can confirm an issue with pnpm and a 3rd-party package which imports the following:

import {renderToStaticMarkup} from "react-dom/server"

I've made a highly simplified Vite repo which showcases the problem:

https://github.com/yairEO/vite-pnpm-bug-report-16293

My machine: