Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion emsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,13 +1223,41 @@ def emscripten_npm_install(tool, directory):
print('Running post-install step: npm ci ...')
try:
subprocess.check_output(
[npm, 'ci', '--production'],
[npm, 'ci', '--production', '--no-optional'],
cwd=directory, stderr=subprocess.STDOUT, env=env,
universal_newlines=True)
except subprocess.CalledProcessError as e:
print('Error running %s:\n%s' % (e.cmd, e.output))
return False

# Manually install the appropriate native Closure Compiler package
# This is currently needed because npm ci will install the packages
# for Closure for all platforms, adding 180MB to the download size
# There are two problems here:
# 1. npm ci does not consider the platform of optional dependencies
# https://github.com/npm/cli/issues/558
# 2. A bug with the native compiler has bloated the packages from
# 30MB to almost 300MB
# https://github.com/google/closure-compiler-npm/issues/186
# If either of these bugs are fixed then we can remove this exception
closure_compiler_native = ''
if LINUX and ARCH in ('x86', 'x86_64'):
closure_compiler_native = 'google-closure-compiler-linux'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these binaries actually exist and run on x86 as will as x86_64?

You can do .. and ARCH in ('x86' , 'x86_64'): here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked which architectures the npm packages said they supported.

if MACOS and ARCH in ('x86', 'x86_64'):
closure_compiler_native = 'google-closure-compiler-osx'
if WINDOWS and ARCH == 'x86_64':
closure_compiler_native = 'google-closure-compiler-windows'
if closure_compiler_native:
print('Running post-install step: npm install', closure_compiler_native)
try:
subprocess.check_output(
[npm, 'install', closure_compiler_native],
cwd=directory, stderr=subprocess.STDOUT, env=env,
universal_newlines=True)
except subprocess.CalledProcessError as e:
print('Error running %s:\n%s' % (e.cmd, e.output))
return False

print('Done running: npm ci')
return True

Expand Down