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:
If those lines are not deleted and one tries to run the PoC project in SSR mode then this happens:
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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-929752914A 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?