Skip to content

UXP Environment Cannot Resolve Rollup Code-Split Chunks #43

@kernelKun886

Description

@kernelKun886

Issue: UXP Environment Cannot Resolve Rollup Code-Split Chunks

Problem Description

When building a UXP plugin with Vite and Rollup code splitting, the generated chunks cannot be resolved properly in the UXP environment. The error occurs when the main entry file tries to import the vendor chunk:
uxp://uxp-internal/domjs_scripts.js:2 Uncaught Error: Module not found: "./vendor.js". Parent module folder was: "./"

Environment

  • Build Tool: Vite
  • UXP Plugin: vite-uxp-plugin
  • Framework: Vue 3
  • Code Splitting: Rollup manualChunks

Configuration

// vite.config.js
export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        manualChunks: (id) => {
          if (id.includes('node_modules')) {
            return 'vendor';
          }
        },
        format: 'cjs',
        chunkFileNames: 'assets/[name].js',
        entryFileNames: 'assets/[name].js',
        assetFileNames: 'assets/[name][extname]'
      }
    }
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions