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

./pkg created by default when wasm is located in a different folder #93

Open
carlosouro opened this issue Aug 19, 2020 · 3 comments
Open

Comments

@carlosouro
Copy link

carlosouro commented Aug 19, 2020

If you have a crateDirectory located elsewhere in your filesystem, the plugin will still create an empty ./<outDir> folder locally to the main build process root.

Example:

new WasmPackPlugin({
  crateDirectory: path.resolve(__dirname, "./myRustPlugin")
})

This would create an empty pkg subfolder in ./pkg, and not in ./myRustPlugin/pkg as expected (and according to wasm-pack build).

Note that currently it is possible to workaround this issue by enforcing a full qualified path outDir to the destination pkg location, like so:

new WasmPackPlugin({
  crateDirectory: path.resolve(__dirname, "./myRustPlugin"),
  outDir: path.resolve(__dirname, "./myRustPlugin/pkg")
})

But if you simply use outDir: "build" or leave outDir to the "pkg" default, the problem arises.

The problem appears to be here:

fs.mkdirSync(this.outDir);

@kopotp
Copy link

kopotp commented Oct 15, 2020

same for me

@Directory
Copy link

The issue with this workaround for me at least is that the pkg directory isnt empty. it contains a single empty index.js. when forcing it to use the same pkg directory as where the rust code really is supposed to compile to it overwrites the ledgitamate index.js file with an empty one. and now it cant be imported.

@wleslie
Copy link
Contributor

wleslie commented Sep 15, 2021

This issue may overlap with a few other open issues: #74, #81, #87

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

4 participants