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

v2.1.3 seems to break @vitest/web-worker path in NX Monorepos #6921

Open
6 tasks done
K3TH3R opened this issue Nov 18, 2024 · 2 comments
Open
6 tasks done

v2.1.3 seems to break @vitest/web-worker path in NX Monorepos #6921

K3TH3R opened this issue Nov 18, 2024 · 2 comments

Comments

@K3TH3R
Copy link

K3TH3R commented Nov 18, 2024

Describe the bug

I've been upgrading our dependencies to the most recent versions lately and I've started receiving the following error in our NX Monorepo related to @vitest/web-worker that is breaking all of our unit tests:

Error: Failed to load url /Users/kether/frontend/node_modules/@vitest/web-worker/dist/index.js (resolved id: /Users/kether/frontend/node_modules/@vitest/web-worker/dist/index.js). Does the file exist?

What's particularly weird is that the file is there as expected:
Screenshot 2024-11-18 at 4 35 31 pm

The unit tests run fine up to and including 2.1.2. But as soon as I upgrade to 2.1.3 or above, I start getting the error which breaks our test suites. If I leave [email protected], I can continue to upgrade @vitest/web-worker up to 2.2.0-beta.1 with the unit tests continuing to run as expected.

Config:

{
  root: '/Users/kether/frontend/apps/cloud/app',
  cacheDir: '../../../node_modules/.vite/./apps/cloud/app',
  plugins: [
    {
      name: 'nx-vite-ts-paths',
      enforce: 'pre',
      configResolved: [AsyncFunction: configResolved],
      resolveId: [Function: resolveId],
      writeBundle: [AsyncFunction: writeBundle]
    },
    {
      name: 'unplugin-vue-router',
      enforce: 'pre',
      resolveId: [Function: resolveId],
      buildStart: [Function: buildStart],
      buildEnd: [Function: buildEnd],
      transformInclude: [Function: transformInclude],
      transform: [Function (anonymous)],
      loadInclude: [Function: loadInclude],
      load: [Function (anonymous)],
      vite: {
        configureServer: [Function: configureServer],
        handleHotUpdate: { order: 'post', handler: [Function: handler] }
      },
      configureServer: [Function: configureServer],
      handleHotUpdate: { order: 'post', handler: [Function: handler] }
    },
    {
      name: 'unplugin-vue-i18n:resource',
      enforce: 'pre',
      vite: {
        config: [Function: config],
        configResolved: [Function: configResolved],
        handleHotUpdate: [AsyncFunction: handleHotUpdate]
      },
      webpack: [Function: webpack],
      resolveId: [Function: resolveId],
      load: [AsyncFunction: load],
      transformInclude: [Function: transformInclude],
      transform: [Function (anonymous)],
      config: [Function: config],
      configResolved: [Function: configResolved],
      handleHotUpdate: [AsyncFunction: handleHotUpdate]
    },
    {
      name: 'vite:vue',
      api: { options: [Getter/Setter], version: '5.2.0' },
      handleHotUpdate: [Function: handleHotUpdate],
      config: [Function: config],
      configResolved: [Function: configResolved],
      configureServer: [Function: configureServer],
      buildStart: [Function: buildStart],
      resolveId: [AsyncFunction: resolveId],
      load: [Function: load],
      transform: [Function: transform]
    },
    { name: 'svg-loader', enforce: 'pre', load: [AsyncFunction: load] }
  ],
  build: {
    target: 'esnext',
    outDir: '../../../dist/apps/cloud/app',
    reportCompressedSize: true,
    commonjsOptions: { transformMixedEsModules: true },
    assetsDir: 'd/frontend',
    rollupOptions: {
      input: {
        app: '/Users/kether/frontend/apps/cloud/app/index.html'
      },
      output: {
        manualChunks: [Function: manualChunks],
        assetFileNames: [Function: assetFileNames]
      }
    }
  },
  test: {
    globals: true,
    mockReset: true,
    environment: 'happy-dom',
    passWithNoTests: true,
    globalSetup: '../../../libs/configs/src/lib/vitest.global-setup.ts',
    setupFiles: [
      '../../../libs/configs/src/lib/vitest.setup-time-globals.ts',
      '@vitest/web-worker',
      '../../../libs/configs/src/lib/vitest.setup-dom-matchers.ts'
    ],
    include: [ 'src/**/*.{test,spec}.{js,ts}' ],
    reporters: [ 'default' ],
    watch: false,
    pool: 'threads',
    poolOptions: { threads: { singleThread: true } },
    coverage: {
      provider: 'v8',
      reporter: [ 'json', 'html' ],
      reportsDirectory: '../../../coverage/./apps/cloud/app',
      include: [ 'src/**' ],
      exclude: [
        '**/*.spec.js',
        '**/*.spec.ts',
        '**/*.spec.data.ts',
        '**/*.stories.ts',
        '**/*.mdx',
        '**/*.json',
        '**/*.types.ts',
        '**/*.typegen.ts',
        '**/*.bus.ts',
        '**/index.ts',
      ]
    }
  },
  server: { fs: { allow: [ '../../../libs/configs/src/lib' ] } },
  define: {
    __VUE_OPTIONS_API__: 'false',
    __VUE_PROD_DEVTOOLS__: 'false',
    __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
  },
  optimizeDeps: { exclude: [ 'vue-i18n' ] }
}

Reproduction

  1. git clone [email protected]:K3TH3R/ts-issue-starter-template.git vitest-path-issue
  2. cd vitest-path-issue && git checkout vitest-2.1.2 && yarn install
  3. yarn app1:test -> everything runs as expected
  4. git checkout vitest-2.1.3 && rm -rf node_modules && yarn install
  5. yarn app1:test -> fails with the @vitest/web-worker error

The only thing that has changed between these two branches is the Vitest dependency versions.

System Info

System:
    OS: macOS 15.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 121.14 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.9.0 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.8.3 - /opt/homebrew/bin/npm
  Browsers:
    Brave Browser: 131.1.73.89
    Chrome: 131.0.6778.70
    Edge: 131.0.2903.51
    Safari: 18.1
  npmPackages:
    @vitejs/plugin-vue: 5.2.0 => 5.2.0 
    @vitest/coverage-v8: 2.1.5 => 2.1.5 
    @vitest/ui: 2.1.5 => 2.1.5 
    @vitest/web-worker: 2.1.3 => 2.1.3 
    vite: 5.4.11 => 5.4.11 
    vitest: 2.1.3 => 2.1.3

Used Package Manager

yarn

Validations

Copy link

Hello @K3TH3R. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@K3TH3R
Copy link
Author

K3TH3R commented Nov 19, 2024

@AriPerkkio Okay, I've added a reproduction with the instructions in the original message above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants