/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/universal/example.js
17 строк
629 B
Sebastian Beltran
feat(universal): add example for universal target with ESM support (#21244)
23 июн 2026, 10:12
Не верифицирован
23 июн 2026, 10:12
2e43eb4
Код
Авторство
О чём код?
// One source file, one ESM bundle, every runtime. `target: "universal"` tells // webpack to emit only the runtime features that browser, web worker, Node.js, // Electron and NW.js all share, so this entry runs as-is on each one. import { platform } from "./env"; const banner = `Hello from webpack — running on: ${platform()}`; async function main() { // Code-split into its own chunk. The universal chunk loader knows how to // fetch it on either platform (native `import()` in the browser, dynamic // `import()` of the emitted `.mjs` in Node). const { render } = await import("./render"); render(banner); } main();