Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.0 fails in Yarn projects with Plug'n'Play #15

Open
bitjson opened this issue Jan 24, 2024 · 5 comments · Fixed by #18
Open

v1.0.0 fails in Yarn projects with Plug'n'Play #15

bitjson opened this issue Jan 24, 2024 · 5 comments · Fixed by #18

Comments

@bitjson
Copy link

bitjson commented Jan 24, 2024

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
@KusStar
Copy link
Owner

KusStar commented Jan 24, 2024

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.

@bitjson
Copy link
Author

bitjson commented Jan 25, 2024

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 yarn@4.0.2.

@nix6839
Copy link
Contributor

nix6839 commented Jan 29, 2024

It seems to be related to these issues:
sheerlox/import-from-esm#80 -> wooorm/import-meta-resolve#10

@KusStar
Copy link
Owner

KusStar commented Jan 30, 2024

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 import-from-esm@1.4.0-alpha.1 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 vite-bundle-visualizer@0.11.0 for now.

@nix6839
Copy link
Contributor

nix6839 commented Mar 14, 2024

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.

@KusStar KusStar reopened this Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants