Skip to content

feat(@angular/build): support WASM/ES Module integration proposal #27973

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

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

clydin
Copy link
Member

@clydin clydin commented Jul 2, 2024

Application builds will now support the direct import of WASM files. The behavior follows the WebAssembly/ES module integration proposal. The usage of this feature requires the ability to use native async/await and top-level await. Due to this requirement, applications must be zoneless to use this new feature. Applications that use Zone.js are currently incompatible and an error will be generated if the feature is used in a Zone.js application. Manual setup of a WASM file is, however, possible in a Zone.js application if WASM usage is required. Further details for manual setup can be found here: https://developer.mozilla.org/en-US/docs/WebAssembly/Loading_and_running

The following is a brief example of using a WASM file in the new feature with the integration proposal behavior:

import { multiply } from './example.wasm';

console.log(multiply(4, 5));

NOTE: TypeScript will not automatically understand the types for WASM files. Type definition files will need to be created for each WASM file to allow for an error-free build. These type definition files are specific to each individual WASM file and will either need to be manually created or provided by library authors.

The feature relies on an active proposal which may change as it progresses through the standardization process. This may result in behavioral differences between versions.
Proposal Details: https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration

For more information regarding zoneless applications, you can visit https://angular.dev/guide/experimental/zoneless

@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Jul 2, 2024
@clydin clydin force-pushed the application/wasm-imports-esm branch 2 times, most recently from cdef2df to 8f7a7f6 Compare July 2, 2024 16:40
@clydin clydin marked this pull request as ready for review July 2, 2024 17:30
@clydin clydin force-pushed the application/wasm-imports-esm branch from 8f7a7f6 to d9b2c04 Compare July 2, 2024 20:20
@clydin clydin requested a review from alan-agius4 July 2, 2024 20:20
@clydin clydin added action: review The PR is still awaiting reviews from at least one requested reviewer target: rc This PR is targeted for the next release-candidate labels Jul 2, 2024
@clydin clydin force-pushed the application/wasm-imports-esm branch 2 times, most recently from 1ac5e6f to fa9fc57 Compare July 2, 2024 21:17
Application builds will now support the direct import of WASM files.
The behavior follows the WebAssembly/ES module integration proposal. The usage
of this feature requires the ability to use native async/await and top-level
await. Due to this requirement, applications must be zoneless to use this new
feature. Applications that use Zone.js are currently incompatible and an error
will be generated if the feature is used in a Zone.js application. Manual
setup of a WASM file is, however, possible in a Zone.js application if WASM
usage is required. Further details for manual setup can be found here:
https://developer.mozilla.org/en-US/docs/WebAssembly/Loading_and_running

The following is a brief example of using a WASM file in the new feature
with the integration proposal behavior:
```
import { multiply } from './example.wasm';

console.log(multiply(4, 5));
```

NOTE: TypeScript will not automatically understand the types for WASM files.
Type definition files will need to be created for each WASM file to allow
for an error-free build. These type definition files are specific to each
individual WASM file and will either need to be manually created or provided
by library authors.

The feature relies on an active proposal which may change as it progresses
through the standardization process. This may result in behavioral differences
between versions.
Proposal Details: https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration

For more information regarding zoneless applications, you can visit https://angular.dev/guide/experimental/zoneless
@clydin clydin force-pushed the application/wasm-imports-esm branch from fa9fc57 to 5440b4c Compare July 3, 2024 13:09
@clydin clydin added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 3, 2024
@clydin clydin merged commit 2cb1fb3 into angular:main Jul 3, 2024
31 checks passed
@clydin
Copy link
Member Author

clydin commented Jul 3, 2024

The changes were merged into the following branches: main, 18.1.x

@clydin clydin deleted the application/wasm-imports-esm branch July 3, 2024 13:26
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker detected: feature PR contains a feature commit target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants