mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Replaces the webpack+ts-loader based bundler for Electron's 8 internal
init bundles (browser, renderer, worker, sandboxed_renderer,
isolated_renderer, node, utility, preload_realm) with a plain esbuild
driver under build/esbuild/. GN template now lives at
build/esbuild/esbuild.gni and is invoked via a new 'bundle' npm script.
Per-target configs move from build/webpack/webpack.config.<target>.js to
small data-only files under build/esbuild/configs/. ProvidePlugin's
global/Buffer/process/Promise capture moves to inject-shims under
build/esbuild/shims/. The wrapper-webpack-plugin try/catch and
___electron_webpack_init__ wrappers are applied as textual pre/postamble
inside the driver so shell/common/node_util.cc's CompileAndCall error
handling still works.
The old BUILDFLAG DefinePlugin pass is replaced with a small onLoad
regex that rewrites BUILDFLAG(NAME) to (true|false) using the
GN-generated buildflags.h. AccessDependenciesPlugin (used by
gen-filenames.ts to populate filenames.auto.gni) is replaced with
esbuild's built-in metafile via a new '--print-graph' flag.
A few source files needed small fixes to work under esbuild's
stricter CJS/ESM interop:
- lib/browser/api/net.ts and lib/utility/api/net.ts mixed ESM
'export function' with 'exports.x = ...' assignments, which
esbuild treats as an ambiguous module. Switched to a single
'module.exports = {}' with a getter for the dynamic 'online'
property.
- lib/common/timers-shim.ts is untouched; lib/common/init.ts no
longer mutates the imported timers namespace (timers.setImmediate
= wrap(...)). Under webpack the mutation applied to the bundled
shim and was invisible to user apps; the refactor stores the
wrapped values in local consts instead.
Drops webpack, webpack-cli, ts-loader, null-loader, and
wrapper-webpack-plugin from devDependencies. Adds esbuild.
Sequential build time for the 8 bundles drops from ~22s (webpack) to
~480ms (esbuild).
8 lines
168 B
JavaScript
8 lines
168 B
JavaScript
module.exports = {
|
|
target: 'renderer',
|
|
alwaysHasNode: true,
|
|
targetDeletesNodeGlobals: true,
|
|
wrapInitWithProfilingTimeout: true,
|
|
wrapInitWithTryCatch: true
|
|
};
|