Skip to content

Vite v8 Incompatibility #191

@david-sh-csiro

Description

@david-sh-csiro

When using the non-beta version of Vite v8 with the example repo https://github.com/geoman-io/maplibre-geoman-examples/tree/master/maplibre-geoman-react, production builds now have a runtime error. This error is not present in vite dev server builds.

Attached screenshot is a prod build with sourcemap enabled for a better trace.
Image

My investigation into why this now occurs with the non-beta version of vite v8 is due to its use of oxc for the Javascript/Typescript transformation/minification as mentioned here: https://vite.dev/guide/migration#javascript-transforms-by-oxc

Altering the vite config with the following resulted in example repo working as expected again. (Note you do need to add esbuild as a dependency now with vite v8 for this to work)

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],

  optimizeDeps: {
    exclude: ["@geoman-io/maplibre-geoman-free"],
  },

  build: { minify: "esbuild" },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions