Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: packagerChrome.py

Issue 29549786: Issue 5535 - Replace our module system with webpack (Closed)
Patch Set: Improve output on error Created Oct. 4, 2017, 10:28 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « package.json ('k') | webpack.config.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packagerChrome.py
diff --git a/packagerChrome.py b/packagerChrome.py
index bf28457acf544c84b276cab5f71fb089bfc4ba5d..b67216b243242b3d94c3c90e37faa978e6db7632 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -7,12 +7,10 @@ import io
import json
import os
import re
-import shutil
from StringIO import StringIO
import struct
import subprocess
import sys
-import tempfile
from ensure_dependencies import read_deps
from packager import (readMetadata, getDefaultFileName, getBuildVersion,
@@ -149,7 +147,6 @@ def create_bundles(params, files):
'edge': 'edgeInfo.js.tmpl',
'gecko-webext': 'geckoInfo.js.tmpl'
}
- info_module = None
# Historically we didn't use relative paths when requiring modules, so in
# order for webpack to know where to find them we need to pass in a list of
@@ -160,44 +157,32 @@ def create_bundles(params, files):
for dir in ['', 'adblockpluscore', 'adblockplusui']]
)
- temp_dir = tempfile.mkdtemp()
- try:
- info_module = os.path.join(temp_dir, 'info.js')
- template = getTemplate(info_templates[params['type']])
- with open(info_module, 'w') as info_file:
- info_file.write(
- template.render(
- basename=params['metadata'].get('general', 'basename'),
- version=params['metadata'].get('general', 'version')
- ).encode('utf-8')
- )
+ template = getTemplate(info_templates[params['type']])
+ info_module = template.render(
+ basename=params['metadata'].get('general', 'basename'),
+ version=params['metadata'].get('general', 'version')
+ ).encode('utf-8')
- for item in params['metadata'].items('bundles'):
- name, value = item
- base_item_path = os.path.dirname(item.source)
-
- bundle_file = os.path.relpath(os.path.join(base_item_path, name),
- base_extension_path)
- entry_files = [os.path.join(base_item_path, module_path)
- for module_path in value.split()]
- subprocess.check_call(
- ['npm', 'run-script', 'webpack', '--silent'],
- cwd=os.path.dirname(__file__),
- env={
- 'EXTENSION_PATH': base_extension_path,
- 'ENTRY_POINTS': ' '.join(entry_files),
- 'OUTPUT_PATH': temp_dir,
- 'BUNDLE_NAME': bundle_file,
- 'RESOLVE_PATHS': resolve_paths,
- 'INFO_PATH': info_module,
- 'PATH': os.environ['PATH']
- }
- )
- for file_name in [bundle_file, bundle_file + '.map']:
- with open(os.path.join(temp_dir, file_name), 'r') as f:
- files[file_name] = f.read()
- finally:
- shutil.rmtree(temp_dir)
+ for item in params['metadata'].items('bundles'):
+ name, value = item
+ base_item_path = os.path.dirname(item.source)
+
+ bundle_file = os.path.relpath(os.path.join(base_item_path, name),
+ base_extension_path)
+ entry_files = [os.path.join(base_item_path, module_path)
+ for module_path in value.split()]
+ files[bundle_file] = subprocess.check_output(
+ ['node', 'webpack_runner.js'],
+ cwd=os.path.dirname(__file__),
+ env={
+ 'EXTENSION_PATH': base_extension_path,
+ 'ENTRY_POINTS': ' '.join(entry_files),
+ 'BUNDLE_NAME': bundle_file,
+ 'RESOLVE_PATHS': resolve_paths,
+ 'INFO_MODULE': info_module,
+ 'PATH': os.environ['PATH']
+ }
+ )
def toJson(data):
« no previous file with comments | « package.json ('k') | webpack.config.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld