Skip to content

Commit

Permalink
pass "-s -w" to go linker, removes 0.1mb (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Feb 19, 2021
1 parent 29500e6 commit e790163
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ exports.buildWasmLib = async (esbuildPath) => {
// Asynchronously start building the WebAssembly module
const npmWasmDir = path.join(repoDir, 'npm', 'esbuild-wasm')
const goBuildPromise = new Promise((resolve, reject) => childProcess.execFile('go',
['build', '-o', path.join(npmWasmDir, 'esbuild.wasm'), path.join(repoDir, 'cmd', 'esbuild')],
[
'build',
'-o', path.join(npmWasmDir, 'esbuild.wasm'),
'-ldflags=-s -w', // This removes ~0.14mb of unnecessary WebAssembly code
path.join(repoDir, 'cmd', 'esbuild'),
],
{ cwd: repoDir, stdio: 'inherit', env: { ...process.env, GOOS: 'js', GOARCH: 'wasm' } },
err => err ? reject(err) : resolve()))

Expand Down

0 comments on commit e790163

Please sign in to comment.