Unverified Commit 02462e5d authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

fix(next/swc): let async wasm binding coerce to sync correctly (#38780)




## Bug

Minor fix to wasm binding to correctlly coerece async interface to return promise, even though it calls sync interface internally.

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
parent bc9a4da4
......@@ -137,23 +137,28 @@ async function loadWasm(importPath = '') {
bindings = await bindings.default()
}
Log.info('Using experimental wasm build of next-swc')
// Note wasm binary does not support async intefaces yet, all async
// interface coereces to sync interfaces.
wasmBindings = {
isWasm: true,
transform(src, options) {
return bindings.transformSync(src.toString(), options)
return Promise.resolve(
bindings.transformSync(src.toString(), options)
)
},
transformSync(src, options) {
return bindings.transformSync(src.toString(), options)
},
minify(src, options) {
return bindings.minifySync(src.toString(), options)
return Promise.resolve(bindings.minifySync(src.toString(), options))
},
minifySync(src, options) {
return bindings.minifySync(src.toString(), options)
},
parse(src, options) {
const astStr = bindings.parseSync(src.toString(), options)
return astStr
return Promise.resolve(astStr)
},
parseSync(src, options) {
const astStr = bindings.parseSync(src.toString(), options)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment