Skip to content

Commit d1d4abb

Browse files
authored
Revert "chore: remove no-simd wasm of llhttp (#2871)" (#2935)
This reverts commit 3b2df8e.
1 parent 6a4c8fc commit d1d4abb

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# The wasm files are stored as base64 strings in the corresponding .js files
77
lib/llhttp/llhttp_simd.wasm
8+
lib/llhttp/llhttp.wasm
89

910
!types/**/*
1011
!index.d.ts

build/wasm.js

+9
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ module.exports = fs.readFileSync(require.resolve('./${basename(path)}'))
7979
`)
8080
}
8181

82+
// Build wasm binary
83+
execSync(`${WASM_CC} ${WASM_CFLAGS} ${WASM_LDFLAGS} \
84+
${join(WASM_SRC, 'src')}/*.c \
85+
-I${join(WASM_SRC, 'include')} \
86+
-o ${join(WASM_OUT, 'llhttp.wasm')} \
87+
${WASM_LDLIBS}`, { stdio: 'inherit' })
88+
89+
writeWasmChunk('llhttp.wasm', 'llhttp-wasm.js')
90+
8291
// Build wasm simd binary
8392
execSync(`${WASM_CC} ${WASM_CFLAGS} -msimd128 ${WASM_LDFLAGS} \
8493
${join(WASM_SRC, 'src')}/*.c \

lib/dispatcher/client-h1.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,20 @@ function removeAllListeners (obj) {
7474
}
7575

7676
async function lazyllhttp () {
77-
const mod = await WebAssembly.compile(require('../llhttp/llhttp_simd-wasm.js'))
77+
const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined
78+
79+
let mod
80+
try {
81+
mod = await WebAssembly.compile(require('../llhttp/llhttp_simd-wasm.js'))
82+
} catch (e) {
83+
/* istanbul ignore next */
84+
85+
// We could check if the error was caused by the simd option not
86+
// being enabled, but the occurring of this other error
87+
// * https://github.com/emscripten-core/emscripten/issues/11495
88+
// got me to remove that check to avoid breaking Node 12.
89+
mod = await WebAssembly.compile(llhttpWasmData || require('../llhttp/llhttp-wasm.js'))
90+
}
7891

7992
return await WebAssembly.instantiate(mod, {
8093
env: {

lib/llhttp/llhttp-wasm.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/llhttp/llhttp.wasm

54.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)