Skip to content

Commit 7c8f0a2

Browse files
authored
1 parent b665079 commit 7c8f0a2

File tree

1 file changed

+1
-63
lines changed

1 file changed

+1
-63
lines changed

emsdk.py

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,77 +1260,15 @@ def emscripten_npm_install(tool, directory):
12601260
env = os.environ.copy()
12611261
env["PATH"] = node_path + os.pathsep + env["PATH"]
12621262
print('Running post-install step: npm ci ...')
1263-
# Do a --no-optional install to avoid bloating disk size:
1264-
# https://github.com/emscripten-core/emscripten/issues/12406
12651263
try:
12661264
subprocess.check_output(
1267-
[npm, 'ci', '--production', '--no-optional'],
1265+
[npm, 'ci', '--production'],
12681266
cwd=directory, stderr=subprocess.STDOUT, env=env,
12691267
universal_newlines=True)
12701268
except subprocess.CalledProcessError as e:
12711269
errlog('Error running %s:\n%s' % (e.cmd, e.output))
12721270
return False
12731271

1274-
# Manually install the appropriate native Closure Compiler package
1275-
# This is currently needed because npm ci would install the packages
1276-
# for Closure for all platforms, adding 180MB to the download size
1277-
# There are two problems here:
1278-
# 1. npm ci does not consider the platform of optional dependencies
1279-
# https://github.com/npm/cli/issues/558
1280-
# 2. A bug with the native compiler has bloated the packages from
1281-
# 30MB to almost 300MB
1282-
# https://github.com/google/closure-compiler-npm/issues/186
1283-
# If either of these bugs are fixed then we can remove this exception
1284-
# See also https://github.com/google/closure-compiler/issues/3925
1285-
closure_compiler_native = ''
1286-
if LINUX and ARCH in ('x86', 'x86_64'):
1287-
closure_compiler_native = 'google-closure-compiler-linux'
1288-
if MACOS and ARCH in ('x86', 'x86_64'):
1289-
closure_compiler_native = 'google-closure-compiler-osx'
1290-
if WINDOWS and ARCH == 'x86_64':
1291-
closure_compiler_native = 'google-closure-compiler-windows'
1292-
1293-
if closure_compiler_native:
1294-
# Check which version of native Closure Compiler we want to install via npm.
1295-
# (npm install command has this requirement that we must explicitly tell the pinned version)
1296-
try:
1297-
closure_version = json.load(open(os.path.join(directory, 'package.json')))['dependencies']['google-closure-compiler']
1298-
except KeyError as e:
1299-
# The target version of Emscripten does not (did not) have a package.json that would contain google-closure-compiler. (fastcomp)
1300-
# Skip manual native google-closure-compiler installation there.
1301-
print(str(e))
1302-
print('Emscripten version does not have a npm package.json with google-closure-compiler dependency, skipping native google-closure-compiler install step')
1303-
return True
1304-
1305-
closure_compiler_native += '@' + closure_version
1306-
print('Running post-install step: npm install', closure_compiler_native)
1307-
try:
1308-
subprocess.check_output(
1309-
[npm, 'install', '--production', '--no-optional', closure_compiler_native],
1310-
cwd=directory, stderr=subprocess.STDOUT, env=env,
1311-
universal_newlines=True)
1312-
1313-
# Installation of native Closure compiler was successful, so remove import of Java Closure Compiler module to avoid
1314-
# a Java dependency.
1315-
compiler_filename = os.path.join(directory, 'node_modules', 'google-closure-compiler', 'lib', 'node', 'closure-compiler.js')
1316-
if os.path.isfile(compiler_filename):
1317-
old_js = open(compiler_filename, 'r').read()
1318-
new_js = old_js.replace("require('google-closure-compiler-java')", "''/*require('google-closure-compiler-java') XXX Removed by Emsdk*/")
1319-
if old_js == new_js:
1320-
raise Exception('Failed to patch google-closure-compiler-java dependency away!')
1321-
open(compiler_filename, 'w').write(new_js)
1322-
1323-
# Now that we succeeded to install the native version and patch away the Java dependency, delete the Java version
1324-
# since that takes up ~12.5MB of installation space that is no longer needed.
1325-
# This process is currently a little bit hacky, see https://github.com/google/closure-compiler/issues/3926
1326-
remove_tree(os.path.join(directory, 'node_modules', 'google-closure-compiler-java'))
1327-
print('Removed google-closure-compiler-java dependency.')
1328-
else:
1329-
errlog('Failed to patch away google-closure-compiler Java dependency. ' + compiler_filename + ' does not exist.')
1330-
except subprocess.CalledProcessError as e:
1331-
errlog('Error running %s:\n%s' % (e.cmd, e.output))
1332-
return False
1333-
13341272
print('Done running: npm ci')
13351273

13361274
if os.path.isfile(os.path.join(directory, 'bootstrap.py')):

0 commit comments

Comments
 (0)