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

Unified Diff: packagerChrome.py

Issue 29762564: Issue 6625 - Expose webpack's resolve.alias to the packagers (Closed)
Patch Set: Created April 26, 2018, 8:41 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 | « README.md ('k') | tests/README.md » ('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 4b199953b8ea6ba0e56759d42eee395d03091e0d..72f033ec1ce88098ee3514a33fab9f8256fc5e18 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -14,6 +14,8 @@ import sys
import random
import posixpath
+import ConfigParser
Sebastian Noack 2018/04/26 11:30:39 Nit: ConfigParser is a corelib module. So it goes
tlucas 2018/04/26 11:40:58 Done.
+
from packager import (readMetadata, getDefaultFileName, getBuildVersion,
getTemplate, get_extension, Files, get_app_id)
@@ -155,6 +157,23 @@ def create_bundles(params, files, bundle_tests):
'edge': 'edgeInfo.js.tmpl',
'gecko': 'geckoInfo.js.tmpl',
}
+ aliases = {
+ # To use our custom loader for the info module we must first set up an
+ # alias to a file that exists.
+ 'info$': os.path.join(os.path.dirname(__file__), 'info.js'),
+ # Prevent builtin Node.js modules from being used instead of our own
+ # when the names clash. Once relative paths are used this won't be
+ # necessary.
+ 'url$': 'url.js',
+ 'events$': 'events.js',
+ 'punycode$': 'punycode.js',
+ }
+ try:
+ aliases.update(
+ {k: v for k, v in params['metadata'].items('module_alias')},
Sebastian Noack 2018/04/26 11:30:39 Nit: The dict comprehension here is redundant.
tlucas 2018/04/26 11:40:58 Done.
+ )
+ except ConfigParser.NoSectionError:
+ pass
# 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
@@ -174,6 +193,7 @@ def create_bundles(params, files, bundle_tests):
'extension_path': base_extension_path,
'info_module': info_module,
'resolve_paths': resolve_paths,
+ 'aliases': aliases,
}
for item in params['metadata'].items('bundles'):
« no previous file with comments | « README.md ('k') | tests/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld