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

Do not remove the pkg directory #1110

Merged
merged 1 commit into from
Feb 16, 2022
Merged

Conversation

huntc
Copy link
Contributor

@huntc huntc commented Feb 11, 2022

A recent commit (d79e721) ensured that the pkg directory was removed as the first step of attempting to create it. Unfortunately, this causes a problem for webpack when watching the pkg directory. Webpack is unable to recover its watching and so any watch server must be restarted, which is a blocker when using it.

Please note that there was some debate about whether to remove the pkg directory. It is unclear to me what the actual benefits of it are, and whether this PR re-introduces some other problem. However, wasmpack appears to have existed as per the behaviour of this PR for a few years.

This PR reverses the change made in the above commit and fixes #1099.

A recent commit ensured that the pkg directory was removed as the first step of creating it. Unfortunately, this causes a problem for tools such as webpack when watching the pkg directory. In the case of webpack, it is unable to recover its watching and so any watch server must be restarted, consuming the developer's time.
@huntc huntc mentioned this pull request Feb 11, 2022
3 tasks
Copy link
Contributor

@simlay simlay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof. Well, sorry about. Thanks for mentioning the discussion. It's nice to know that it was at least discussed about even if the incorrect choice was made.

@drager Could you merge when you get a chance?

@huntc
Copy link
Contributor Author

huntc commented Feb 12, 2022

Are these test failures mine? I simply removed a line... I couldn't successfully run cargo test for perhaps other reasons as I couldn't afford to invest a great deal of time on this. I will look further in terms of getting a good setup though if required.

@huntc
Copy link
Contributor Author

huntc commented Feb 16, 2022

Are these test failures mine? I simply removed a line... I couldn't successfully run cargo test for perhaps other reasons as I couldn't afford to invest a great deal of time on this. I will look further in terms of getting a good setup though if required.

Would it be possible to follow up on the above as wasmpack is broken for us. Thanks.

@drager
Copy link
Member

drager commented Feb 16, 2022

Are these test failures mine? I simply removed a line... I couldn't successfully run cargo test for perhaps other reasons as I couldn't afford to invest a great deal of time on this. I will look further in terms of getting a good setup though if required.

Would it be possible to follow up on the above as wasmpack is broken for us. Thanks.

I think this wasn't this PRs fault. Will merge and investigate why it fails. Thanks for the PR!

@drager drager merged commit 4ae6306 into rustwasm:master Feb 16, 2022
@huntc
Copy link
Contributor Author

huntc commented Feb 16, 2022

Thank you, and thanks for your efforts here too!

@huntc huntc deleted the no-remove-dir branch February 16, 2022 22:19
@main--
Copy link
Contributor

main-- commented Mar 1, 2022

This change - while necessary to fix interaction with e.g. the webpack dev server - causes a new problem: Now that wasm-pack doesn't clear the output folder, it will pick up the package.json created by a previous run and try to deserialize this as if it was created by wasm-bindgen. This fails and causes wasm-pack to return an error code.

@huntc
Copy link
Contributor Author

huntc commented Mar 1, 2022

This change - while necessary to fix interaction with e.g. the webpack dev server - causes a new problem: Now that wasm-pack doesn't clear the output folder, it will pick up the package.json created by a previous run and try to deserialize this as if it was created by wasm-bindgen. This fails and causes wasm-pack to return an error code.

The change here restores behaviour to what it was, so is the problem you describe really a new issue?

@main--
Copy link
Contributor

main-- commented Mar 1, 2022

Yes. Deleting the output folder was introduced along with the changes that implement the package.json generation, so prior to that, the problem I describe did not exist.

@huntc
Copy link
Contributor Author

huntc commented Mar 1, 2022

Perhaps the solution is to just remove the package.json? I don’t know, but I’m thinking a new issue should be raised. Wdyt?

@main--
Copy link
Contributor

main-- commented Mar 2, 2022

Simply removing package.json is what I'm doing now: main--@13369d2

And it does resolve the problem for me.

@huntc
Copy link
Contributor Author

huntc commented Mar 2, 2022

Do you know if this upsets webpack again though as per #1110 (comment)?

@main--
Copy link
Contributor

main-- commented Mar 2, 2022

At least in my setup, this makes webpack even happier than before. Before, I was (on Windows) just launching an instance of cmd in the pkg directory to prevent it from getting deleted - this still made webpack sad because it would see files getting deleted, rebuild (with an error) and then build again once the files are back. Now that the files are overwritten directly, it only builds once (and also much faster, presumably because caching works better). My webpack doesn't care about the package.json at all.

@huntc
Copy link
Contributor Author

huntc commented Mar 2, 2022

At least in my setup, this makes webpack even happier than before. Before, I was (on Windows) just launching an instance of cmd in the pkg directory to prevent it from getting deleted - this still made webpack sad because it would see files getting deleted, rebuild (with an error) and then build again once the files are back. Now that the files are overwritten directly, it only builds once (and also much faster, presumably because caching works better). My webpack doesn't care about the package.json at all.

Thanks for following up. Fingers crossed then!

@drager
Copy link
Member

drager commented Mar 3, 2022

Not sure I follow correctly but will this PR when released solve your problem @main-- ?

@egfx-notifications
Copy link
Contributor

Just opened an issue (#1118) regarding this and arrived at the same conclusion as @main-- during my investigation.
main--@13369d2 would fix the issue introduced by this PR.
@main-- Could you make a PR with this commit?

Another option would be to rewrite write_package_json() so that it can distinguish between a package.json from wasm-bindgen and a package.json already processed by wasm-pack. I have no idea if and how that would work, though.

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 this pull request may close these issues.

Change in v0.10.2 that causes output directory to first be removed breaks my build
5 participants