Skip to content

No loader is configured for ".glsl" files when using itk-vtk-viewer in react app with vite #705

@Tinanuaa

Description

@Tinanuaa

Hi, I'm trying to use itk-vtk-viewer in my vite react typescript project, node version is v20.3.1, but I got errors like below:

✘ [ERROR] Could not resolve "../itkConfig.js"

    node_modules/itk-vtk-viewer/src/Rendering/VTKJS/Images/fuseImages.js:1:126:
      1 │ ...ComposeImageWorker from'./ComposeImage.worker.js';import itkConfig from'../itkConfig.js';export const fuseImages=async({imageAtScale,//could be array if Congl...
        ╵                                                                           ~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "../itkConfig.js"

    node_modules/itk-vtk-viewer/src/Rendering/VTKJS/Images/ComposeImage.worker.js:1:625:
      1 │ ...useComponents}from'../../../IO/composeComponents';import itkConfig from'../itkConfig.js';const checkOverlap=(imageA,imageB)=>{const[vtkA,vtkB]=[imageA,imageB]...
        ╵                                                                           ~~~~~~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".glsl" files: node_modules/vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataVS.glsl

    node_modules/vtk.js/Sources/Rendering/OpenGL/ImageMapper/index.js:1:879:
      1 │ .../ImageProperty/Constants';import vtkPolyDataVS from'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataVS.glsl';import vtkPolyDataFS from'vtk.js/Sources/Renderin...
        ╵                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".glsl" files: node_modules/vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl

    node_modules/vtk.js/Sources/Rendering/OpenGL/ImageMapper/index.js:1:962:
      1 │ .../glsl/vtkPolyDataVS.glsl';import vtkPolyDataFS from'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl';import vtkReplacementShaderMapper from'vtk.js/Sou...
        ╵                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".glsl" files: node_modules/vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyData2DFS.glsl

    node_modules/vtk.js/Sources/Rendering/OpenGL/PolyDataMapper2D/index.js:2:282:
      2 │ ...es/Common/Core/Points';import vtkPolyData2DFS from'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyData2DFS.glsl';import vtkPolyData2DVS from'vtk.js/Sources/Rende...
        ╵                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".glsl" files: node_modules/vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyData2DVS.glsl

    node_modules/vtk.js/Sources/Rendering/OpenGL/PolyDataMapper2D/index.js:2:369:
      2 │ .../vtkPolyData2DFS.glsl';import vtkPolyData2DVS from'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyData2DVS.glsl';import vtkReplacementShaderMapper from'vtk.js/So...
        ╵                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".glsl" files: node_modules/vtk.js/Sources/Rendering/OpenGL/glsl/vtkVolumeFS.glsl

    node_modules/vtk.js/Sources/Rendering/OpenGL/VolumeMapper/index.js:2:1060:
      2 │ ...penGL/glsl/vtkVolumeVS.glsl';import vtkVolumeFS from'vtk.js/Sources/Rendering/OpenGL/glsl/vtkVolumeFS.glsl';import{registerOverride}from'vtk.js/Sources/Render...
        ╵                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".glsl" files: node_modules/vtk.js/Sources/Rendering/OpenGL/glsl/vtkVolumeVS.glsl

    node_modules/vtk.js/Sources/Rendering/OpenGL/VolumeMapper/index.js:2:981:
      2 │ ...Core/VolumeMapper/Constants';import vtkVolumeVS from'vtk.js/Sources/Rendering/OpenGL/glsl/vtkVolumeVS.glsl';import vtkVolumeFS from'vtk.js/Sources/Rendering/O...
        ╵                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The steps to reproduce this error is quite simple, I just

npm create vite@latest # project_name as vite-react-app, select react as frameowrk and use typescript
cd vite-react-app
npm install
npm install itk-vtk-viewer
npm run dev

My vite.config.js is like below

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import babel from 'vite-plugin-babel';
import glsl from 'vite-plugin-glsl';
// https://vitejs.dev/config/
export default defineConfig({
  
  plugins: [react(),
    glsl(),
    babel({
      babelConfig: {
        babelrc: false,
        configFile: false,
        compact:true,
        plugins: [
          [
            "@babel/plugin-proposal-decorators",
            { loose: true, version: "2022-03" },
          ],
        ],
      },
    }),],
})

my package.json is like

{
  "name": "vite-react-app",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "@babel/plugin-proposal-decorators": "^7.22.7",
    "itk-vtk-viewer": "^14.43.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "vite-plugin-babel": "^1.1.3",
    "vite-plugin-glsl": "^1.1.2"
  },
  "devDependencies": {
    "@types/react": "^18.2.14",
    "@types/react-dom": "^18.2.6",
    "@typescript-eslint/eslint-plugin": "^5.61.0",
    "@typescript-eslint/parser": "^5.61.0",
    "@vitejs/plugin-react": "^4.0.1",
    "eslint": "^8.44.0",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.1",
    "typescript": "^5.0.2",
    "vite": "^4.4.0"
  }
}

May I know why the itkConfig.js file is not imported correctly in those two files? I notice itkConfig.js is three levels up those two files. I've tried to set up the alias in vite, but it doesn't work. And for the glsl loader, I added glsl plugins in the vite plugins, but still got the errors relating to the glsl files.

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