Feature request: support package.json conditional exports
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- cpp, javascript, wasm
- Ambito
- build-system
Direzione di ricerca
Start by reading how emcc handles multiple target environments and generates JavaScript glue, then review the related issue #21899 and the conditional exports approach described here. The issue does not name specific source files or tests; first determine how variants could share one WebAssembly binary without rebuilding it for each environment. Done means emcc can produce environment-specific glue with conditional exports while sharing the binary.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Currently, when multiple environments are provided to emcc, it generates a JavaScript file similar to this:
async function MyModule(moduleArg = {}) {
var Module = moduleArg;
var ENVIRONMENT_IS_WEB = !!globalThis.window;
var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
var ENVIRONMENT_IS_NODE =
globalThis.process?.versions?.node &&
globalThis.process?.type != "renderer";
// ...
}
The thing is, since this output relies on checking globalThis, it is difficult to treeshake in bundlers. It also ships a little bit of unnecessary code for users.
A solution could be to use package.json conditional exports.
The problem is there seems to be no easy to way to output multiple variants of JS glue code, but only one WebAssembly binary. For example, the wasm-vips library handles this through a custom build script that builds it for both Node and the browser before collapsing the WebAssembly binary into one file. This can be very time consuming, especially if LTO is enabled.
Related: #21899
- Lingua principale
- C++
- Stelle
- 27.8k
- Fork
- 3.6k
- Merge medio
- 1g 6h
- PR unite (30g)
- 181
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di emscripten-core/emscripten
-
`other.test_cmake_cxx_import_std` fails on CMake 3.30–4.0.2 due to missing `CMAKE_EXPERIMENTAL_CXX_IMPORT_STD` UUIDsForse già presa @subhaushsingh l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
emscripten-core/emscripten#28160 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
emscripten-core/emscripten#27994 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
LEGACY_GL_EMULATION: generated fixed-function fragment shaders use mediump — fp16 overflow where mediump is half precisionForse già presa @TheTomBritton l’ha presa 14 giorni fa. ApertaDesktop OpenGL emulation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
emscripten-core/emscripten#27948 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
emscripten-core/emscripten#27906 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
run_python, run_python_compiler could readlink -fForse già presa @kapouer l’ha presa 129 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
emscripten-core/emscripten#27211 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di emscripten-core/emscripten
Issue simili
-
enhancement third-party
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pocoproject/poco#5656 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
documentation enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
QuantStack/git2cpp#203 ·
I maintainer di solito rispondono entro 1 giorno