jeffreylanters / react-unity-webgl

React Unity WebGL provides a modern solution for embedding Unity WebGL builds in your React Application while providing advanced APIs for two way communication and interaction between Unity and React.
https://react-unity-webgl.dev
Apache License 2.0
1.7k stars 160 forks source link

React-unity-webgl conflicts with vite-plugin-istanbul option (unity stops working) #465

Open dmorenoAN opened 1 year ago

dmorenoAN commented 1 year ago

Please avoid duplicates

Language and Compiler

Other TypeScript compiler

What environment are you using?

Local Development Server

When does your problem occur?

While the Unity App is loading

What does your problem relate to?

I don't know

React-Unity-WebGL Version

9.2.1

React Version

18.2.0

Unity Version

2021.1.16f

What happened?

Hi, i have been in a trouble with the thing mentioned in title. This plugin has conflicts with "vite-plugin-istanbul".

Not working code

export default defineConfig({
  plugins: [react(), svgr(), istanbul({ cypress: true, requireEnv: false })],
  server: {
    port: 8000,
    host: "0.0.0.0",
  },
});

Working code

export default defineConfig({
  plugins: [react(), svgr(), istanbul({ cypress: true, requireEnv: true})],
  server: {
    port: 8000,
    host: "0.0.0.0",
  },
});

I would like to know why is this happening, it seems to have no-relation. The option failing if false is requireEnv.

Thanks.

Reproducible test case

//App.tsx
import React from "react";

import { Unity, useUnityContext } from "react-unity-webgl";

function App() {
  const { unityProvider } = useUnityContext({
    loaderUrl: "xxx",
    dataUrl: "xxx",
    frameworkUrl: "xxx",
    codeUrl: "xxx",
  });

  return (
    <div className="App">
      <Unity unityProvider={unityProvider} />
    </div>
  );
}

export default App;
//vite.config.ts

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

export default defineConfig({
  plugins: [react(), istanbul({ cypress: true, requireEnv: false })],
});

Would you be interested in contributing a fix?