LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 { | 125 { |
126 let reason = err.stack || err; | 126 let reason = err.stack || err; |
127 if (err.details) | 127 if (err.details) |
128 reason += "\n" + err.details; | 128 reason += "\n" + err.details; |
129 throw new Error(reason); | 129 throw new Error(reason); |
130 } | 130 } |
131 else if (stats.hasErrors()) | 131 else if (stats.hasErrors()) |
132 throw new Error(stats.toJson().errors.join("\n")); | 132 throw new Error(stats.toJson().errors.join("\n")); |
133 else | 133 else |
134 { | 134 { |
135 let files = {}; | 135 let output = {}; |
| 136 let files = output.files = {}; |
136 | 137 |
137 for (let config of options) | 138 for (let config of options) |
138 { | 139 { |
139 let filepath = path.join(config.output.path, config.output.filename); | 140 let filepath = path.join(config.output.path, config.output.filename); |
140 let relativeFilepath = path.relative("/", filepath); | 141 let relativeFilepath = path.relative("/", filepath); |
141 files[relativeFilepath] = memoryFS.readFileSync(filepath, "utf-8"); | 142 files[relativeFilepath] = memoryFS.readFileSync(filepath, "utf-8"); |
142 files[relativeFilepath + ".map"] = memoryFS.readFileSync( | 143 files[relativeFilepath + ".map"] = memoryFS.readFileSync( |
143 filepath + ".map", "utf-8" | 144 filepath + ".map", "utf-8" |
144 ); | 145 ); |
145 } | 146 } |
146 | 147 |
147 console.log(JSON.stringify(files)); | 148 // We provide a list of all the bundled files, so the packager can avoid |
| 149 // including them again outside of a bundle. Otherwise we end up including |
| 150 // duplicate copies in our builds. |
| 151 let included = new Set(); |
| 152 for (let bundle of stats.toJson().children) |
| 153 { |
| 154 for (let chunk of bundle.chunks) |
| 155 { |
| 156 for (let module of chunk.modules) |
| 157 { |
| 158 if (!module.name.startsWith("multi ")) |
| 159 included.add(path.relative(extension_path, module.name)); |
| 160 } |
| 161 } |
| 162 } |
| 163 output.included = Array.from(included); |
| 164 |
| 165 console.log(JSON.stringify(output)); |
148 } | 166 } |
149 }); | 167 }); |
150 }); | 168 }); |
LEFT | RIGHT |