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

feat(build): multiple build targets per package #732

Closed
wants to merge 1 commit into from

Conversation

Tarnadas
Copy link
Contributor

@Tarnadas Tarnadas commented Oct 25, 2019

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.

wasm-pack build examples/js-hello-world --is-child --out-name child

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.

wasm-pack build examples/js-hello-world --out-dir pkg -- --features "wee_alloc"
wasm-pack build examples/js-hello-world --out-dir pkg --out-name js-hello-node --is-child

@Tarnadas Tarnadas changed the title feat(build): is-child argument feat(build): multiple build targets per package Oct 25, 2019
@Tarnadas Tarnadas force-pushed the master branch 2 times, most recently from 73c2cd7 to 85cc5b9 Compare July 31, 2020 11:11
is-child can be passed as argument to wasm-pack build for generating
packages with multiple build targets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants