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.

Add flag to remove new URL(url, import.meta.url)

See original GitHub issue

#15 says that vite now supports new URL(url, import.meta.url), but that is not entirely correct.

If a flag were added that would remove that line from the generated .js file’s init function, then it would be possible to create Sveltekit+Rust projects that work automatically in SSR mode without manually deleting that line. Link to PoC project.

The lines that are commented out should be deleted when the flag is enabled: image

If those lines are not deleted and one tries to run the PoC project in SSR mode then this happens: image

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
lencxcommented, Sep 30, 2021

Thanks for the suggestion,and it will be supported by adding loadType in the next version. https://github.com/lencx/vite-plugin-rsw/issues/22#issuecomment-929752914

0reactions
Septiascommented, Jan 18, 2022

A little late, but here I am. The shown solution with just deleting the new Url(...) didn’t work for me (the page I use wa on doesn’t load and it complains that wasm Init functions doesn’t not get right input) so it seems the path is actually needed. Any ideas how to fix it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

import.meta - JavaScript - MDN Web Docs
meta meta -property exposes context-specific metadata to a JavaScript module. It contains information about the module, such as the module's URL.
Read more >
Transition from __dirname to import.meta.url could be ... - GitHub
Describe the solution you'd like. Add a few lines in the doc on how to transition from __dirname to import.meta.url.
Read more >
Alternative for __dirname in Node.js when using ES6 modules
So with new URL('<path or file>', import.meta.url) it solves and you don't need to be treating strings and creating variables to be concatenated ......
Read more >
import.meta - JavaScript - UDN Web Docs: MDN Backup
The import.meta object exposes context-specific metadata to a JavaScript module. It contains information about the module, like the module's URL.
Read more >
Issue 773713 in chromium: Implement `import.meta.url`
Changing this as Implement `import.meta.url` and closing as fixed. ... [ES6 modules] Enable dynamic import and import.meta by default without feature flags
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