Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Vite build bundling error about EISDIR on `new URL('.', import.me…
…ta.url)` (#637) Hi! Vite shows EISDIR error at `new URL('.', import.meta.url)` expression on build. Actually checking import.meta.url is not enough to fix this problem. The problem is when bundler tries to build the code in production build, in compile time it has no idea about how the expression `new URL('.', import.meta.url)` should be resolved in runtime. And it tries to read all the file and bake it inline in base64 form. And in case of `new URL('.', ...)` it tries to read the dir what is impossible and throws compile-time error EISDIR. So I created a workaround code which gives the same output in Vite dev and Node.js environments: ```js const filePathname = new URL(import.meta.url).pathname const folderPathname = filePathname.substring(0, filePathname.lastIndexOf('/')+1) ``` actually does literally the same as ```js new URL('.', import.meta.url) ``` Also closes polkadot-js/extension#1018
- Loading branch information