question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing `@sveltejs/gl` during dev raises an exception

See original GitHub issue

Describe the bug Importing @sveltejs/gl during dev raises the following exception:

500

Must use import to load ES Module: /home/ushi/repos/sveltexr/node_modules/@sveltejs/gl/index.mjs

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/ushi/repos/sveltexr/node_modules/@sveltejs/gl/index.mjs
    at new NodeError (node:internal/errors:329:5)
    at Module.load (node:internal/modules/cjs/loader:971:11)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at nodeRequire (/home/ushi/repos/sveltexr/node_modules/vite/dist/node/chunks/dep-6e02b235.js:69041:17)
    at ssrImport (/home/ushi/repos/sveltexr/node_modules/vite/dist/node/chunks/dep-6e02b235.js:68999:20)
    at eval (/home/ushi/repos/sveltexr/src/routes/gl.svelte:9:31)
    at instantiateModule (/home/ushi/repos/sveltexr/node_modules/vite/dist/node/chunks/dep-6e02b235.js:69027:166)

This may occur with other ES modules as well.

To Reproduce

npm init svelte@next
npm i -D @sveltejs/gl

Add a gl.svelte route with the following

<script>
	import * as GL from '@sveltejs/gl';
<script>

Start the dev server and navigate to that route, (probably http://localhost:3000/gl).

Expected behavior Should import without exceptions

Information about your SvelteKit Installation:

  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers
  System:
    OS: Linux 4.19 Ubuntu 18.04.4 LTS (Bionic Beaver)
    CPU: (24) x64 AMD Ryzen Threadripper 2920X 12-Core Processor
    Memory: 22.71 GB / 31.30 GB
    Container: Yes
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 15.8.0 - ~/.nvm/versions/node/v15.8.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 7.5.2 - ~/.nvm/versions/node/v15.8.0/bin/npm
  Browsers:
    Firefox: 83.0
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.65 
    svelte: ^3.29.0 => 3.36.0 

Severity Blocking usage of svelte/gl and probably other ES based modules

Additional context Discord thread: https://discord.com/channels/@me/474342761529606144/826909912884969482

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
benmccanncommented, Apr 6, 2021

Thanks for looking into this Rich and for testing all the suggestions @saabi

I’m going to go ahead and close this since it’s working for you now in favor of https://github.com/sveltejs/kit/issues/904 which should be a longer-term solution to the issue

0reactions
saabicommented, Apr 6, 2021

@Rich-Harris That worked for me as well.

I’m completely new to Vitejs. I also had no idea rollup plugins would work out of the box, like for glslify. Good to know, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting status code for exception raised in load() function in ...
You can return an object with a status property, like in this example from the docs. That will automatically show the error page....
Read more >
Errors • Docs • SvelteKit
Errors are an inevitable fact of software development. ... An expected error is one created with the error helper imported from @sveltejs/kit :....
Read more >
Code Splitting in Svelte JS + Routify | by Firthous
The best technique is to split the code at the router level. Routify is a promising file-based router that has been supporting dynamic...
Read more >
Adding Sentry kills Celery worker : r/django - Reddit
I have just tried to implement Sentry in my django app. ... line 1265, in mark_as_worker_lost raise WorkerLostError( billiard.exceptions.
Read more >
Issue 7559: TestLoader.loadTestsFromName swallows import ...
A reason for this might be a misspelt import in that module. ... test that re-raises the *original exception* (with traceback) when run....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found