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

Crate in sub directory causes pkg to be created in the root. #87

Open
GeraldHost opened this issue Mar 25, 2020 · 3 comments
Open

Crate in sub directory causes pkg to be created in the root. #87

GeraldHost opened this issue Mar 25, 2020 · 3 comments

Comments

@GeraldHost
Copy link

This may be intended behaviour and I'm missing something so apologies if that is the case.

When I nest my rust code in a subdirectory and run a build. A pkg directory is created in the root of my project with an empty index.js file in it. Everything else is working as expected, a pkg folder still gets created in my rust subdirectory and I can consume the index.js from there as expected.

Steps to Reproduce

  1. npm init rust-webpack my-app
  2. cd my-app && mkdir rust
  3. mv src tests Cargo.toml rust
  4. Update your webpack WasmPackPlugin crateDirectory to path.resolve(__dirname, 'rust')
  5. npm run build
  6. you will see that a pkg with an empty index.js file has been created in the root.

Expected Behavior

It shouldn't create the pkg folder in the root.

@GeraldHost
Copy link
Author

Should the fallback for outDir look for crateDirectory first and use that otherwise fall all the way back to pkg?

@Cifram
Copy link

Cifram commented May 22, 2020

I'm having the same issue. Just spent like half an hour digging through all my various build configurations trying to figure out where that pkg folder in the root with the empty index.js was coming from.

It's not a matter of finding the right outDir. That works. It creates a pkg where it's supposed to, with all the right files. It just ALSO creates a SECOND pkg folder in the root of the project.

It's hardly a catastrophic bug, but it's definitely causing some confusion. Also, specifying outDir explicitly does cause the bug to go away. That's my workaround for now, I guess.

@GeraldHost
Copy link
Author

#74

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