Skip to content

optimize deps with vite breaking #364

@dabreegster

Description

@dabreegster

Hi! I'm trying this out in a Svelte 5 project using Vite 7. I've added @developmentseed/deck.gl-geotiff as a dependency. My usage code is quite simple to start, using https://github.com/dimfeld/svelte-maplibre/, which has a DeckGl integration.

<DeckGlLayer
  type={COGLayer}
  geotiff="private_assets/layers/ni_ortho.cog"
  interleaved
  layout={{
    visibility: showOrthoPhotos ? "visible" : "none",
  }}
/>

When I npm run dev, I get this on the console:

The file does not exist at "/home/dabreegster/route-appraisal/web/node_modules/.vite/deps/worker.js?worker_file&type=module" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to `optimizeDeps.exclude`. (x32)

The browser is trying and failing to get http://localhost:5173/node_modules/.vite/deps/worker.js?worker_file&type=module. There's a source map error:

Source map error: Error: URL constructor:  is not a valid URL.
Stack in the worker:resolveSourceMapURL@resource://devtools/client/shared/source-map-loader/utils/fetchSourceMap.js:56:22
getOriginalURLs@resource://devtools/client/shared/source-map-loader/source-map.js:74:24
workerHandler/</<@resource://devtools/client/shared/worker-utils.js:115:52
workerHandler/<@resource://devtools/client/shared/worker-utils.js:113:13

Resource URL: wasm:http://localhost:5173/node_modules/.vite/deps/@developmentseed_deck__gl-geotiff.js?v=36f12bda%20line%2049954%20%3E%20WebAssembly.Module
Source Map URL: null

I tried adding to my vite.config:

  optimizeDeps: {
    exclude: ["@developmentseed/deck.gl-geotiff"]
  },

But npm run dev can't find files:

Sourcemap for "/home/dabreegster/route-appraisal/web/node_modules/@developmentseed/deck.gl-geotiff/dist/index.js" points to missing source files
Sourcemap for "/home/dabreegster/route-appraisal/web/node_modules/@developmentseed/deck.gl-geotiff/dist/cog-layer.js" points to missing source files
Sourcemap for "/home/dabreegster/route-appraisal/web/node_modules/@developmentseed/deck.gl-geotiff/dist/geotiff/texture.js" points to missing source files
Sourcemap for "/home/dabreegster/route-appraisal/web/node_modules/@developmentseed/deck.gl-geotiff/dist/mosaic-layer/mosaic-layer.js" points to missing source files
Sourcemap for "/home/dabreegster/route-appraisal/web/node_modules/@developmentseed/deck.gl-geotiff/dist/mosaic-layer/mosaic-tileset-2d.js" points to missing source files
... many more

npm run build gives a different error:

[commonjs--resolver] Invalid value "iife" for option "worker.format" - UMD and IIFE output formats are not supported for code-splitting builds.
file: /home/dabreegster/route-appraisal/web/node_modules/@developmentseed/geotiff/dist/pool/pool.js
    at getRollupError (file:///home/dabreegster/route-appraisal/web/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
    at error (file:///home/dabreegster/route-appraisal/web/node_modules/rollup/dist/es/shared/parseAst.js:397:42)
    at validateOptionsForMultiChunkOutput (file:///home/dabreegster/route-appraisal/web/node_modules/rollup/dist/es/shared/node-entry.js:20673:16)

I am woefully unfamiliar with the madness of JS build systems and bundlers. Any advice? Thank you!

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