Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite dev doesn't find WebWorker #17400

Closed
7 tasks done
ketourneau opened this issue Jun 5, 2024 · 3 comments
Closed
7 tasks done

Vite dev doesn't find WebWorker #17400

ketourneau opened this issue Jun 5, 2024 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@ketourneau
Copy link

Describe the bug

We try to use iTowns package (which contains WebWorker) with Vite and Vite dev doesn't seem to resolve WebWorker correctly.

He try to search WebWorker at path
http://localhost:5173/itowns-starter/node_modules/.vite/Worker/Potree2Worker.js?worker_file&type=module

WebWorker are declared here :
https://github.com/bloc-in-bloc/itowns/blob/f23332137cf6f662e2790054eb227289ff324086/src/Parser/Potree2BinParser.js#L9

And you can find the complete project Vite + iTowns : https://github.com/bloc-in-bloc/itowns-starter/tree/debug-potree

Reproduction

https://github.com/bloc-in-bloc/itowns-starter/tree/debug-potree

Steps to reproduce

npm install
npm run dev

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 1.35 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.15.0/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
    pnpm: 8.1.1 - ~/.nvm/versions/node/v18.15.0/bin/pnpm
  Browsers:
    Chrome: 125.0.6422.142
    Edge: 125.0.2535.85
    Safari: 17.5
  npmPackages:
    vite: ^5.2.12 => 5.2.12

Used Package Manager

npm

Logs

  vite:html-fallback Rewriting GET /node_modules/.vite/Worker/Potree2Worker.js?worker_file&type=module to /index.html +6ms
  vite:html-fallback Rewriting GET /node_modules/.vite/Worker/Potree2Worker.js?worker_file&type=module to /index.html +1ms
  vite:html-fallback Rewriting GET /node_modules/.vite/Worker/Potree2Worker.js?worker_file&type=module to /index.html +0ms
  vite:html-fallback Rewriting GET /node_modules/.vite/Worker/Potree2Worker.js?worker_file&type=module to /index.html +1ms
  vite:html-fallback Rewriting GET /node_modules/.vite/Worker/Potree2Worker.js?worker_file&type=module to /index.html +0ms

Validations

@sedghi
Copy link

sedghi commented Jun 13, 2024

Following

getting the same error for myself as well

Here is how i create the worker in my library (using comlink and the new URL and import.meta.url)

const instance = new Worker(
    new URL('./shared/decodeImageFrame.js', import.meta.url),
    { type: 'module' }
  );

and here is my tsconfig for publishing with tsc

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": "./",
    "checkJs": false,

    "declaration": true,
    "emitDeclarationOnly": false,
    "isolatedModules": false,

    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "useDefineForClassFields": false,
    "jsx": "react-jsx",
    "lib": ["ES2022", "dom"],

    "noImplicitAny": false,
    "noImplicitThis": false,

    "pretty": true,
    "removeComments": true,
    "skipLibCheck": true,
    "strict": true,
    "strictNullChecks": false,
    "target": "ES2022",
    "downlevelIteration": true,
    "resolveJsonModule": true,

    "module": "esnext", // esnext | commonjs
    "moduleResolution": "node",
    "outDir": "dist",
    "sourceMap": true,

  },
 
}

and here is my vite config in my app for consuming

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

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

I tried various options like

worker: {
    format: "es",
  },

and using vite-comlink plugin

but no success

@sapphi-red
Copy link
Member

Duplicate of #8427

@sapphi-red sapphi-red marked this as a duplicate of #8427 Jun 17, 2024
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Jun 17, 2024
@luvletterldl
Copy link

Same issue, looking forward to you fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants