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

Side by Side Diff: webpack_runner.js

Issue 29762564: Issue 6625 - Expose webpack's resolve.alias to the packagers (Closed)
Patch Set: Created April 26, 2018, 11:40 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« tests/metadata.edge ('K') | « tests/test_packagerWebExt.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 "use strict"; 5 "use strict";
6 6
7 const path = require("path"); 7 const path = require("path");
8 const process = require("process"); 8 const process = require("process");
9 9
10 const MemoryFS = require("memory-fs"); 10 const MemoryFS = require("memory-fs");
11 const webpack = require("webpack"); 11 const webpack = require("webpack");
12 12
13 // We read the configuration from STDIN rather than as an argument to improve 13 // We read the configuration from STDIN rather than as an argument to improve
14 // the output on error. Otherwise the (fairly huge) configuration is printed 14 // the output on error. Otherwise the (fairly huge) configuration is printed
15 // along with the actual error message. 15 // along with the actual error message.
16 let inputChunks = []; 16 let inputChunks = [];
17 process.stdin.setEncoding("utf-8"); 17 process.stdin.setEncoding("utf-8");
18 process.stdin.on("data", chunk => { inputChunks.push(chunk); }); 18 process.stdin.on("data", chunk => { inputChunks.push(chunk); });
19 process.stdin.on("end", () => 19 process.stdin.on("end", () =>
20 { 20 {
21 let {bundles, extension_path, 21 let {bundles, extension_path,
22 info_module, resolve_paths} = JSON.parse(inputChunks.join("")); 22 info_module, resolve_paths, aliases} = JSON.parse(inputChunks.join(""));
23 23
24 // The contents of the info module is passed to us as a string from the Python 24 // The contents of the info module is passed to us as a string from the Python
25 // packager and we pass it through to our custom loader now so it is available 25 // packager and we pass it through to our custom loader now so it is available
26 // at bundle time. 26 // at bundle time.
27 require("./info-loader").setInfoModule(info_module); 27 require("./info-loader").setInfoModule(info_module);
28 28
29 // Since the cost of starting Node.js and loading all the modules is hugely 29 // Since the cost of starting Node.js and loading all the modules is hugely
30 // larger than actually producing bundles we avoid paying it multiple times, 30 // larger than actually producing bundles we avoid paying it multiple times,
31 // instead producing all the bundles in one go. 31 // instead producing all the bundles in one go.
32 let options = []; 32 let options = [];
(...skipping 11 matching lines...) Expand all
44 entry: entry_points, 44 entry: entry_points,
45 output: { 45 output: {
46 path: path.resolve(""), 46 path: path.resolve(""),
47 filename: bundle_name 47 filename: bundle_name
48 }, 48 },
49 node: { 49 node: {
50 global: false 50 global: false
51 }, 51 },
52 resolve: { 52 resolve: {
53 modules: resolve_paths, 53 modules: resolve_paths,
54 alias: { 54 alias: aliases,
55 // To use our custom loader for the info module we must first set up
56 // an alias to a file that exists.
57 info$: path.join(__dirname, "info.js"),
58 // Prevent builtin Node.js modules from being used instead of our own
59 // when the names clash. Once relative paths are used this won't be
60 // necessary.
61 url$: "url.js",
62 events$: "events.js",
63 punycode$: "punycode.js"
64 },
65 plugins: [ 55 plugins: [
66 function() 56 function()
67 { 57 {
68 // Our old module system in packagerChrome.py used to prefix 58 // Our old module system in packagerChrome.py used to prefix
69 // module names with the name of their parent directory and an 59 // module names with the name of their parent directory and an
70 // underscore - but only when that directory wasn't called 60 // underscore - but only when that directory wasn't called
71 // "lib". This plugin is for backwards compatability, but can 61 // "lib". This plugin is for backwards compatability, but can
72 // be removed once use of that deprecated syntax has been 62 // be removed once use of that deprecated syntax has been
73 // replaced. 63 // replaced.
74 this.plugin("described-resolve", (request, callback) => 64 this.plugin("described-resolve", (request, callback) =>
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 included.add(path.relative(extension_path, module.name)); 139 included.add(path.relative(extension_path, module.name));
150 } 140 }
151 } 141 }
152 } 142 }
153 output.included = Array.from(included); 143 output.included = Array.from(included);
154 144
155 console.log(JSON.stringify(output)); 145 console.log(JSON.stringify(output));
156 } 146 }
157 }); 147 });
158 }); 148 });
OLDNEW
« tests/metadata.edge ('K') | « tests/test_packagerWebExt.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld