vite-bundle-visualizer
                                
                                 vite-bundle-visualizer copied to clipboard
                                
                                    vite-bundle-visualizer copied to clipboard
                            
                            
                            
                        v1.0.0 fails in Yarn projects with Plug'n'Play
Following this commit, Yarn projects with Plug'n'Play no longer works (version 0.11.0 worked so long as the project set  yarn unplug vite-bundle-visualizer).
The error after upgrading to 1.0.0:
❯ yarn vite-bundle-visualizer
file:///...project.../.yarn/cache/import-from-esm-npm-1.3.3-4c64f297d5-4287ff7e7b.zip/node_modules/import-from-esm/index.js:100
		const error = new Error(errorString);
		              ^
Error: Cannot find module 'vite'
    at importFrom (file:///...project.../.yarn/cache/import-from-esm-npm-1.3.3-4c64f297d5-4287ff7e7b.zip/node_modules/import-from-esm/index.js:100:17)
    at async start (file:///...project.../.yarn/cache/vite-bundle-visualizer-npm-1.0.0-aad67201df-9113c78bf4.zip/node_modules/vite-bundle-visualizer/index.js:25:21)
    at async file:///...project.../.yarn/cache/vite-bundle-visualizer-npm-1.0.0-aad67201df-9113c78bf4.zip/node_modules/vite-bundle-visualizer/bin.js:35:1 {
  code: 'MODULE_NOT_FOUND'
}
Node.js v20.11.0
Could you please supply a demo project with Yarn PnP?
Additionally, what Yarn version are you using? Maybe some version of Yarn PnP don't support ESM.
Thanks for looking into it @KusStar!
Here's a project where v0.11.0 works but v1.0.0 fails. It's using the latest stable [email protected].
It seems to be related to these issues: https://github.com/sheerlox/import-from-esm/issues/80 -> https://github.com/wooorm/import-meta-resolve/issues/10
It seems to be related to these issues: sheerlox/import-from-esm#80 -> wooorm/import-meta-resolve#10
Thanks for pointing out the solution, but the [email protected] is unstable, so maybe it was not a good fix now.
> [!CAUTION]
> In this alpha version, we are using the built-in `import.meta.resolve` function. It is still behind an experimental flag until Node v20.6.0, and as of v21.6.0, its `parentURL` parameter is still flagged. Hence, for this version of the library to work correctly, you _must_ run Node with the `--experimental-import-meta-resolve` flag.
Just use [email protected] for now.
It currently only works in a limited way, installing and using it in your project via yarn add -D vite-bundle-visualizer, yarn vite-bundle-visualizer.
Contrary to expectations, yarn dlx vite-bundle-visualizer is not working. However, #18 does resolve the yarn vite-bundle-visualizer issue reported by the original issue reporter.
It only works in a limited way, so we'll need to reopen the issue.