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

Workaround for failed imports? #574

Closed
jelleag opened this issue Nov 1, 2022 · 3 comments
Closed

Workaround for failed imports? #574

jelleag opened this issue Nov 1, 2022 · 3 comments

Comments

@jelleag
Copy link

jelleag commented Nov 1, 2022

I am currently running into a variant of a known issue: ESM imports escape the runfiles tree and the sandbox due to #362.

[vite]: Rollup failed to resolve import "@emotion/cache" from "../../../../../../../../node_modules/.aspect_rules_js/@[email protected]_sogmqz4enknxtkxk3k5s6bqwnq/node_modules/@mantine/styles/esm/index.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

One workaround seems to be running the Vite binary from the root, but this is undesirable as I'm working with a monorepo. Are there currently any other workarounds, or maybe a timeline for the fix?

Many thanks in advance!

@gregmagolan
Copy link
Member

gregmagolan commented Nov 4, 2022

#362 is a tricky one. Its a small change in the node source code that would fix it but the internal .js file that needs the change is compiled into the node binary so it would mean forking node and building it from source.

Your problem above however looks more like a pnpm strict dependency issue to me.

It looks like @mantine/styles doesn't declare a dep on @emotion/cache: https://unpkg.com/@mantine/[email protected]/package.json

You can inject the missing dependency with pnpm packageExtensions however. For example, we inject mocha-multi-reporters as a peer dep of mocha here:

"mocha-multi-reporters": "*"

See https://pnpm.io/package_json#pnpmpackageextensions for more info

@jelleag
Copy link
Author

jelleag commented Nov 4, 2022

@gregmagolan Greg, you are a hero. Have been struggling with this for so long. Your workaround works like a charm!

@jelleag jelleag closed this as completed Nov 4, 2022
@gregmagolan
Copy link
Member

Awesome.

BTW, I tried out the change in Node.js that is needed to fix #362 and verified that it does work as expected. #362 (comment). Next step is to get it landed in node.

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

No branches or pull requests

2 participants