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

ReferenceError: location is not defined with vite-plugin-gltf in SSR #9000

Closed
ixxie opened this issue Feb 11, 2023 · 2 comments
Closed

ReferenceError: location is not defined with vite-plugin-gltf in SSR #9000

ixxie opened this issue Feb 11, 2023 · 2 comments

Comments

@ixxie
Copy link

ixxie commented Feb 11, 2023

Describe the bug

It seems SSR in SvelteKit breaks vite-plugin-gltf, yielding an internal ReferenceError relating to an undefined location in a glb file. I'm not entirely sure if this is Vite related or SvelteKit related, but I thought this is a good place to start.

As requested by maintainers at rd-bundler-3d-plugins, a copy of the issue is filed there: nytimes/rd-bundler-3d-plugins#19

Reproduction

Minimal reproduction is available in this repository.

Logs

ReferenceError: location is not defined
    at file:///home/ixxie/repos/sveltekit-gltf/.svelte-kit/output/server/entries/pages/_page.svelte.js:16468:55
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async Module.component (file:///home/ixxie/repos/sveltekit-gltf/.svelte-kit/output/server/nodes/2.js:4:39)
    at async Promise.all (index 1)
    at async render_response (file:///home/ixxie/repos/sveltekit-gltf/.svelte-kit/output/server/index.js:1206:19)
    at async render_page (file:///home/ixxie/repos/sveltekit-gltf/.svelte-kit/output/server/index.js:1752:12)
    at async resolve (file:///home/ixxie/repos/sveltekit-gltf/.svelte-kit/output/server/index.js:2436:22)
    at async respond (file:///home/ixxie/repos/sveltekit-gltf/.svelte-kit/output/server/index.js:2327:22)

System Info

System:
    OS: Linux 5.15 NixOS 23.05 (Stoat) 23.05 (Stoat)
    CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
    Memory: 3.13 GB / 7.62 GB
    Container: Yes
    Shell: 3.5.1 - /run/current-system/sw/bin/fish
  Binaries:
    Node: 18.12.1 - /run/current-system/sw/bin/node
    Yarn: 1.22.19 - /run/current-system/sw/bin/yarn
    npm: 8.19.2 - /run/current-system/sw/bin/npm
  Browsers:
    Chromium: 107.0.5304.121
    Firefox: 107.0
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0 => 1.0.2 
    @sveltejs/kit: ^1.0.0 => 1.3.9 
    svelte: ^3.54.0 => 3.55.1 
    vite: ^4.0.0 => 4.1.1

Severity

annoyance

Additional Information

Relevant discussions:

@Rich-Harris
Copy link
Member

The plugin references location twice:

When the resulting module runs on the server, location is undefined. The asset path needs to be constructed without using URL (which requires location) — this is how Vite itself does it for asset imports: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/asset.ts.

Closing as this is a bug in vite-plugin-gltf, and not something we can fix within SvelteKit.

@Rich-Harris Rich-Harris closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2023
@ixxie
Copy link
Author

ixxie commented Feb 11, 2023

Thanks for the pointer @Rich-Harris, I'm sure the maintainers of the plugin will appreciate the insight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants