feat(build): multiple build targets per package #732
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey there,
I haven't created an issue for this before submitting this PR, but I think it's a nice addition.
EDIT: I've just seen this PR: #695
It is somewhat similar. Let me know what you think! This PR will also extend the files section of the already existing package.json. Otherwise you would have to do this manually. Maybe the use cases of both PRs differ enough?
Edit2: I've just seen #606.
This PR indeed directly refers to the problem explained there, but we need to discuss whether this should be behind an argument just like I did or whether it should be the default behavior.
What I would propose is that wasm-pack automatically detects whether a package.json exists. If the package.json has been generated with the same --out-name it should be overwritten, otherwise it should extend it. When extending, it should also check whether changes have already been done to extend it so that multiple recompilations of a transitive dependency don't generate a bad package.json.
Here is what I wrote in the docs. Let me know if the use case is clear enough:
Multiple build targets per package
The
build
command accepts an optional--is-child
argument.This command will extend a previously generated package, which makes it possible to have multiple build targets per package.
For example it would be feasible to have an optimized build for web and Node.
Following is an example which will use the wee_alloc feature for web, because size is more crucial whereas Node should be optimized for speed.