Skip to content

[New Docs]: splitVendorChunkPlugin is deprecated in vite.config.ts #4917

@jdegand

Description

@jdegand

Which @ngrx/* package(s) are the source of the bug?

www

Minimal reproduction of the bug/regression with instructions

NA

Expected behavior

/// <reference types="vitest" />
import analog from '@analogjs/platform';
import { defineConfig } from 'vite';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
import ngrxStackblitzPlugin from './src/tools/vite-ngrx-stackblits.plugin';

export default defineConfig(({ mode }) => ({
  root: __dirname,
  cacheDir: '../../node_modules/.vite',

  build: {
    outDir: '../../dist/projects/www/client',
    reportCompressedSize: true,
    target: ['es2020'],
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return 'vendor';
          }
           return undefined;  // this will fix a warning that gets thrown, but is this good enough? 
        },
      },
    },
  },

  server: {
    fs: {
      allow: ['.'],
    },
    headers: {
      'Cross-Origin-Embedder-Policy': 'require-corp',
      'Cross-Origin-Opener-Policy': 'same-origin',
    },
  },

  plugins: [
    analog({
      static: true,
      content: {
        highlighter: 'shiki',
        shikiOptions: {
          highlighter: {
            additionalLangs: ['sh'],
          },
        },
      },
    }),
    nxViteTsPaths(),
    ngrxStackblitzPlugin(),
  ],

  test: {
    globals: true,
    environment: 'jsdom',
    setupFiles: ['src/test-setup.ts'],
    include: ['**/*.spec.ts'],
    reporters: ['default'],
  },

  define: {
    'import.meta.vitest': mode !== 'production',
  },
}));

Using manualChunks causes a problem as Not all code paths return a value.ts(7030). It can be fixed by returning undefined. Is this good enough or should something else be done?

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

NA

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions