ConcatenatedModule.js 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Module = require("../Module");
  7. const Template = require("../Template");
  8. const Parser = require("../Parser");
  9. const eslintScope = require("eslint-scope");
  10. const { ConcatSource, ReplaceSource } = require("webpack-sources");
  11. const DependencyReference = require("../dependencies/DependencyReference");
  12. const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
  13. const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency");
  14. const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency");
  15. const HarmonyExportSpecifierDependency = require("../dependencies/HarmonyExportSpecifierDependency");
  16. const HarmonyExportExpressionDependency = require("../dependencies/HarmonyExportExpressionDependency");
  17. const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
  18. const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
  19. const createHash = require("../util/createHash");
  20. /** @typedef {import("../Dependency")} Dependency */
  21. /** @typedef {import("../Compilation")} Compilation */
  22. /** @typedef {import("../util/createHash").Hash} Hash */
  23. /** @typedef {import("../RequestShortener")} RequestShortener */
  24. const joinIterableWithComma = iterable => {
  25. // This is more performant than Array.from().join(", ")
  26. // as it doesn't create an array
  27. let str = "";
  28. let first = true;
  29. for (const item of iterable) {
  30. if (first) {
  31. first = false;
  32. } else {
  33. str += ", ";
  34. }
  35. str += item;
  36. }
  37. return str;
  38. };
  39. /**
  40. * @typedef {Object} ConcatenationEntry
  41. * @property {"concatenated" | "external"} type
  42. * @property {Module} module
  43. */
  44. const ensureNsObjSource = (
  45. info,
  46. moduleToInfoMap,
  47. requestShortener,
  48. strictHarmonyModule
  49. ) => {
  50. if (!info.hasNamespaceObject) {
  51. info.hasNamespaceObject = true;
  52. const name = info.exportMap.get(true);
  53. const nsObj = [`var ${name} = {};`, `__webpack_require__.r(${name});`];
  54. for (const exportName of info.module.buildMeta.providedExports) {
  55. const finalName = getFinalName(
  56. info,
  57. exportName,
  58. moduleToInfoMap,
  59. requestShortener,
  60. false,
  61. strictHarmonyModule
  62. );
  63. nsObj.push(
  64. `__webpack_require__.d(${name}, ${JSON.stringify(
  65. exportName
  66. )}, function() { return ${finalName}; });`
  67. );
  68. }
  69. info.namespaceObjectSource = nsObj.join("\n") + "\n";
  70. }
  71. };
  72. const getExternalImport = (
  73. importedModule,
  74. info,
  75. exportName,
  76. asCall,
  77. strictHarmonyModule
  78. ) => {
  79. const used = importedModule.isUsed(exportName);
  80. if (!used) return "/* unused reexport */undefined";
  81. const comment =
  82. used !== exportName ? ` ${Template.toNormalComment(exportName)}` : "";
  83. switch (importedModule.buildMeta.exportsType) {
  84. case "named":
  85. if (exportName === "default") {
  86. return info.name;
  87. } else if (exportName === true) {
  88. info.interopNamespaceObjectUsed = true;
  89. return info.interopNamespaceObjectName;
  90. } else {
  91. break;
  92. }
  93. case "namespace":
  94. if (exportName === true) {
  95. return info.name;
  96. } else {
  97. break;
  98. }
  99. default:
  100. if (strictHarmonyModule) {
  101. if (exportName === "default") {
  102. return info.name;
  103. } else if (exportName === true) {
  104. info.interopNamespaceObjectUsed = true;
  105. return info.interopNamespaceObjectName;
  106. } else {
  107. return "/* non-default import from non-esm module */undefined";
  108. }
  109. } else {
  110. if (exportName === "default") {
  111. info.interopDefaultAccessUsed = true;
  112. return asCall
  113. ? `${info.interopDefaultAccessName}()`
  114. : `${info.interopDefaultAccessName}.a`;
  115. } else if (exportName === true) {
  116. return info.name;
  117. } else {
  118. break;
  119. }
  120. }
  121. }
  122. const reference = `${info.name}[${JSON.stringify(used)}${comment}]`;
  123. if (asCall) return `Object(${reference})`;
  124. return reference;
  125. };
  126. const getFinalName = (
  127. info,
  128. exportName,
  129. moduleToInfoMap,
  130. requestShortener,
  131. asCall,
  132. strictHarmonyModule,
  133. alreadyVisited = new Set()
  134. ) => {
  135. switch (info.type) {
  136. case "concatenated": {
  137. const directExport = info.exportMap.get(exportName);
  138. if (directExport) {
  139. if (exportName === true) {
  140. ensureNsObjSource(
  141. info,
  142. moduleToInfoMap,
  143. requestShortener,
  144. strictHarmonyModule
  145. );
  146. } else if (!info.module.isUsed(exportName)) {
  147. return "/* unused export */ undefined";
  148. }
  149. if (info.globalExports.has(directExport)) {
  150. return directExport;
  151. }
  152. const name = info.internalNames.get(directExport);
  153. if (!name) {
  154. throw new Error(
  155. `The export "${directExport}" in "${info.module.readableIdentifier(
  156. requestShortener
  157. )}" has no internal name`
  158. );
  159. }
  160. return name;
  161. }
  162. const reexport = info.reexportMap.get(exportName);
  163. if (reexport) {
  164. if (alreadyVisited.has(reexport)) {
  165. throw new Error(
  166. `Circular reexports ${Array.from(
  167. alreadyVisited,
  168. e =>
  169. `"${e.module.readableIdentifier(requestShortener)}".${
  170. e.exportName
  171. }`
  172. ).join(
  173. " --> "
  174. )} -(circular)-> "${reexport.module.readableIdentifier(
  175. requestShortener
  176. )}".${reexport.exportName}`
  177. );
  178. }
  179. alreadyVisited.add(reexport);
  180. const refInfo = moduleToInfoMap.get(reexport.module);
  181. if (refInfo) {
  182. // module is in the concatenation
  183. return getFinalName(
  184. refInfo,
  185. reexport.exportName,
  186. moduleToInfoMap,
  187. requestShortener,
  188. asCall,
  189. strictHarmonyModule,
  190. alreadyVisited
  191. );
  192. }
  193. }
  194. const problem =
  195. `Cannot get final name for export "${exportName}" in "${info.module.readableIdentifier(
  196. requestShortener
  197. )}"` +
  198. ` (known exports: ${Array.from(info.exportMap.keys())
  199. .filter(name => name !== true)
  200. .join(" ")}, ` +
  201. `known reexports: ${Array.from(info.reexportMap.keys()).join(" ")})`;
  202. return `${Template.toNormalComment(problem)} undefined`;
  203. }
  204. case "external": {
  205. const importedModule = info.module;
  206. return getExternalImport(
  207. importedModule,
  208. info,
  209. exportName,
  210. asCall,
  211. strictHarmonyModule
  212. );
  213. }
  214. }
  215. };
  216. const addScopeSymbols1 = (s, nameSet, scopeSet) => {
  217. let scope = s;
  218. while (scope) {
  219. if (scopeSet.has(scope)) break;
  220. scopeSet.add(scope);
  221. for (const variable of scope.variables) {
  222. nameSet.add(variable.name);
  223. }
  224. scope = scope.upper;
  225. }
  226. };
  227. const addScopeSymbols2 = (s, nameSet, scopeSet1, scopeSet2) => {
  228. let scope = s;
  229. while (scope) {
  230. if (scopeSet1.has(scope)) break;
  231. if (scopeSet2.has(scope)) break;
  232. scopeSet1.add(scope);
  233. for (const variable of scope.variables) {
  234. nameSet.add(variable.name);
  235. }
  236. scope = scope.upper;
  237. }
  238. };
  239. const getAllReferences = variable => {
  240. let set = variable.references;
  241. // Look for inner scope variables too (like in class Foo { t() { Foo } })
  242. const identifiers = new Set(variable.identifiers);
  243. for (const scope of variable.scope.childScopes) {
  244. for (const innerVar of scope.variables) {
  245. if (innerVar.identifiers.some(id => identifiers.has(id))) {
  246. set = set.concat(innerVar.references);
  247. break;
  248. }
  249. }
  250. }
  251. return set;
  252. };
  253. const getPathInAst = (ast, node) => {
  254. if (ast === node) {
  255. return [];
  256. }
  257. const nr = node.range;
  258. const enterNode = n => {
  259. if (!n) return undefined;
  260. const r = n.range;
  261. if (r) {
  262. if (r[0] <= nr[0] && r[1] >= nr[1]) {
  263. const path = getPathInAst(n, node);
  264. if (path) {
  265. path.push(n);
  266. return path;
  267. }
  268. }
  269. }
  270. return undefined;
  271. };
  272. var i;
  273. if (Array.isArray(ast)) {
  274. for (i = 0; i < ast.length; i++) {
  275. const enterResult = enterNode(ast[i]);
  276. if (enterResult !== undefined) return enterResult;
  277. }
  278. } else if (ast && typeof ast === "object") {
  279. const keys = Object.keys(ast);
  280. for (i = 0; i < keys.length; i++) {
  281. const value = ast[keys[i]];
  282. if (Array.isArray(value)) {
  283. const pathResult = getPathInAst(value, node);
  284. if (pathResult !== undefined) return pathResult;
  285. } else if (value && typeof value === "object") {
  286. const enterResult = enterNode(value);
  287. if (enterResult !== undefined) return enterResult;
  288. }
  289. }
  290. }
  291. };
  292. const getHarmonyExportImportedSpecifierDependencyExports = dep => {
  293. const importModule = dep._module;
  294. if (!importModule) return [];
  295. if (dep._id) {
  296. // export { named } from "module"
  297. return [
  298. {
  299. name: dep.name,
  300. id: dep._id,
  301. module: importModule
  302. }
  303. ];
  304. }
  305. if (dep.name) {
  306. // export * as abc from "module"
  307. return [
  308. {
  309. name: dep.name,
  310. id: true,
  311. module: importModule
  312. }
  313. ];
  314. }
  315. // export * from "module"
  316. return importModule.buildMeta.providedExports
  317. .filter(exp => exp !== "default" && !dep.activeExports.has(exp))
  318. .map(exp => {
  319. return {
  320. name: exp,
  321. id: exp,
  322. module: importModule
  323. };
  324. });
  325. };
  326. class ConcatenatedModule extends Module {
  327. constructor(rootModule, modules, concatenationList) {
  328. super("javascript/esm", null);
  329. super.setChunks(rootModule._chunks);
  330. // Info from Factory
  331. this.rootModule = rootModule;
  332. this.factoryMeta = rootModule.factoryMeta;
  333. // Info from Compilation
  334. this.index = rootModule.index;
  335. this.index2 = rootModule.index2;
  336. this.depth = rootModule.depth;
  337. // Info from Optimization
  338. this.used = rootModule.used;
  339. this.usedExports = rootModule.usedExports;
  340. // Info from Build
  341. this.buildInfo = {
  342. strict: true,
  343. cacheable: modules.every(m => m.buildInfo.cacheable),
  344. moduleArgument: rootModule.buildInfo.moduleArgument,
  345. exportsArgument: rootModule.buildInfo.exportsArgument,
  346. fileDependencies: new Set(),
  347. contextDependencies: new Set(),
  348. assets: undefined
  349. };
  350. this.built = modules.some(m => m.built);
  351. this.buildMeta = rootModule.buildMeta;
  352. // Caching
  353. this._numberOfConcatenatedModules = modules.length;
  354. // Graph
  355. const modulesSet = new Set(modules);
  356. this.reasons = rootModule.reasons.filter(
  357. reason =>
  358. !(reason.dependency instanceof HarmonyImportDependency) ||
  359. !modulesSet.has(reason.module)
  360. );
  361. this.dependencies = [];
  362. this.blocks = [];
  363. this.warnings = [];
  364. this.errors = [];
  365. this._orderedConcatenationList =
  366. concatenationList ||
  367. ConcatenatedModule.createConcatenationList(rootModule, modulesSet, null);
  368. for (const info of this._orderedConcatenationList) {
  369. if (info.type === "concatenated") {
  370. const m = info.module;
  371. // populate dependencies
  372. for (const d of m.dependencies.filter(
  373. dep =>
  374. !(dep instanceof HarmonyImportDependency) ||
  375. !modulesSet.has(dep._module)
  376. )) {
  377. this.dependencies.push(d);
  378. }
  379. // populate blocks
  380. for (const d of m.blocks) {
  381. this.blocks.push(d);
  382. }
  383. // populate file dependencies
  384. if (m.buildInfo.fileDependencies) {
  385. for (const file of m.buildInfo.fileDependencies) {
  386. this.buildInfo.fileDependencies.add(file);
  387. }
  388. }
  389. // populate context dependencies
  390. if (m.buildInfo.contextDependencies) {
  391. for (const context of m.buildInfo.contextDependencies) {
  392. this.buildInfo.contextDependencies.add(context);
  393. }
  394. }
  395. // populate warnings
  396. for (const warning of m.warnings) {
  397. this.warnings.push(warning);
  398. }
  399. // populate errors
  400. for (const error of m.errors) {
  401. this.errors.push(error);
  402. }
  403. if (m.buildInfo.assets) {
  404. if (this.buildInfo.assets === undefined) {
  405. this.buildInfo.assets = Object.create(null);
  406. }
  407. Object.assign(this.buildInfo.assets, m.buildInfo.assets);
  408. }
  409. if (m.buildInfo.assetsInfo) {
  410. if (this.buildInfo.assetsInfo === undefined) {
  411. this.buildInfo.assetsInfo = new Map();
  412. }
  413. for (const [key, value] of m.buildInfo.assetsInfo) {
  414. this.buildInfo.assetsInfo.set(key, value);
  415. }
  416. }
  417. }
  418. }
  419. this._identifier = this._createIdentifier();
  420. }
  421. get modules() {
  422. return this._orderedConcatenationList
  423. .filter(info => info.type === "concatenated")
  424. .map(info => info.module);
  425. }
  426. identifier() {
  427. return this._identifier;
  428. }
  429. readableIdentifier(requestShortener) {
  430. return (
  431. this.rootModule.readableIdentifier(requestShortener) +
  432. ` + ${this._numberOfConcatenatedModules - 1} modules`
  433. );
  434. }
  435. libIdent(options) {
  436. return this.rootModule.libIdent(options);
  437. }
  438. nameForCondition() {
  439. return this.rootModule.nameForCondition();
  440. }
  441. build(options, compilation, resolver, fs, callback) {
  442. throw new Error("Cannot build this module. It should be already built.");
  443. }
  444. size() {
  445. // Guess size from embedded modules
  446. return this._orderedConcatenationList.reduce((sum, info) => {
  447. switch (info.type) {
  448. case "concatenated":
  449. return sum + info.module.size();
  450. case "external":
  451. return sum + 5;
  452. }
  453. return sum;
  454. }, 0);
  455. }
  456. /**
  457. * @param {Module} rootModule the root of the concatenation
  458. * @param {Set<Module>} modulesSet a set of modules which should be concatenated
  459. * @param {Compilation} compilation the compilation context
  460. * @returns {ConcatenationEntry[]} concatenation list
  461. */
  462. static createConcatenationList(rootModule, modulesSet, compilation) {
  463. const list = [];
  464. const set = new Set();
  465. /**
  466. * @param {Module} module a module
  467. * @returns {(function(): Module)[]} imported modules in order
  468. */
  469. const getConcatenatedImports = module => {
  470. /** @type {WeakMap<DependencyReference, Dependency>} */
  471. const map = new WeakMap();
  472. const references = module.dependencies
  473. .filter(dep => dep instanceof HarmonyImportDependency)
  474. .map(dep => {
  475. const ref = compilation.getDependencyReference(module, dep);
  476. if (ref) map.set(ref, dep);
  477. return ref;
  478. })
  479. .filter(ref => ref);
  480. DependencyReference.sort(references);
  481. // TODO webpack 5: remove this hack, see also DependencyReference
  482. return references.map(ref => {
  483. const dep = map.get(ref);
  484. return () => compilation.getDependencyReference(module, dep).module;
  485. });
  486. };
  487. const enterModule = getModule => {
  488. const module = getModule();
  489. if (!module) return;
  490. if (set.has(module)) return;
  491. set.add(module);
  492. if (modulesSet.has(module)) {
  493. const imports = getConcatenatedImports(module);
  494. imports.forEach(enterModule);
  495. list.push({
  496. type: "concatenated",
  497. module
  498. });
  499. } else {
  500. list.push({
  501. type: "external",
  502. get module() {
  503. // We need to use a getter here, because the module in the dependency
  504. // could be replaced by some other process (i. e. also replaced with a
  505. // concatenated module)
  506. return getModule();
  507. }
  508. });
  509. }
  510. };
  511. enterModule(() => rootModule);
  512. return list;
  513. }
  514. _createIdentifier() {
  515. let orderedConcatenationListIdentifiers = "";
  516. for (let i = 0; i < this._orderedConcatenationList.length; i++) {
  517. if (this._orderedConcatenationList[i].type === "concatenated") {
  518. orderedConcatenationListIdentifiers += this._orderedConcatenationList[
  519. i
  520. ].module.identifier();
  521. orderedConcatenationListIdentifiers += " ";
  522. }
  523. }
  524. const hash = createHash("md4");
  525. hash.update(orderedConcatenationListIdentifiers);
  526. return this.rootModule.identifier() + " " + hash.digest("hex");
  527. }
  528. source(dependencyTemplates, runtimeTemplate) {
  529. const requestShortener = runtimeTemplate.requestShortener;
  530. // Metainfo for each module
  531. const modulesWithInfo = this._orderedConcatenationList.map((info, idx) => {
  532. switch (info.type) {
  533. case "concatenated": {
  534. const exportMap = new Map();
  535. const reexportMap = new Map();
  536. for (const dep of info.module.dependencies) {
  537. if (dep instanceof HarmonyExportSpecifierDependency) {
  538. if (!exportMap.has(dep.name)) {
  539. exportMap.set(dep.name, dep.id);
  540. }
  541. } else if (dep instanceof HarmonyExportExpressionDependency) {
  542. if (!exportMap.has("default")) {
  543. exportMap.set("default", "__WEBPACK_MODULE_DEFAULT_EXPORT__");
  544. }
  545. } else if (
  546. dep instanceof HarmonyExportImportedSpecifierDependency
  547. ) {
  548. const exportName = dep.name;
  549. const importName = dep._id;
  550. const importedModule = dep._module;
  551. if (exportName && importName) {
  552. if (!reexportMap.has(exportName)) {
  553. reexportMap.set(exportName, {
  554. module: importedModule,
  555. exportName: importName,
  556. dependency: dep
  557. });
  558. }
  559. } else if (exportName) {
  560. if (!reexportMap.has(exportName)) {
  561. reexportMap.set(exportName, {
  562. module: importedModule,
  563. exportName: true,
  564. dependency: dep
  565. });
  566. }
  567. } else if (importedModule) {
  568. for (const name of importedModule.buildMeta.providedExports) {
  569. if (dep.activeExports.has(name) || name === "default") {
  570. continue;
  571. }
  572. if (!reexportMap.has(name)) {
  573. reexportMap.set(name, {
  574. module: importedModule,
  575. exportName: name,
  576. dependency: dep
  577. });
  578. }
  579. }
  580. }
  581. }
  582. }
  583. return {
  584. type: "concatenated",
  585. module: info.module,
  586. index: idx,
  587. ast: undefined,
  588. internalSource: undefined,
  589. source: undefined,
  590. globalScope: undefined,
  591. moduleScope: undefined,
  592. internalNames: new Map(),
  593. globalExports: new Set(),
  594. exportMap: exportMap,
  595. reexportMap: reexportMap,
  596. hasNamespaceObject: false,
  597. namespaceObjectSource: null
  598. };
  599. }
  600. case "external":
  601. return {
  602. type: "external",
  603. module: info.module,
  604. index: idx,
  605. name: undefined,
  606. interopNamespaceObjectUsed: false,
  607. interopNamespaceObjectName: undefined,
  608. interopDefaultAccessUsed: false,
  609. interopDefaultAccessName: undefined
  610. };
  611. default:
  612. throw new Error(`Unsupported concatenation entry type ${info.type}`);
  613. }
  614. });
  615. // Create mapping from module to info
  616. const moduleToInfoMap = new Map();
  617. for (const m of modulesWithInfo) {
  618. moduleToInfoMap.set(m.module, m);
  619. }
  620. // Configure template decorators for dependencies
  621. const innerDependencyTemplates = new Map(dependencyTemplates);
  622. innerDependencyTemplates.set(
  623. HarmonyImportSpecifierDependency,
  624. new HarmonyImportSpecifierDependencyConcatenatedTemplate(
  625. dependencyTemplates.get(HarmonyImportSpecifierDependency),
  626. moduleToInfoMap
  627. )
  628. );
  629. innerDependencyTemplates.set(
  630. HarmonyImportSideEffectDependency,
  631. new HarmonyImportSideEffectDependencyConcatenatedTemplate(
  632. dependencyTemplates.get(HarmonyImportSideEffectDependency),
  633. moduleToInfoMap
  634. )
  635. );
  636. innerDependencyTemplates.set(
  637. HarmonyExportSpecifierDependency,
  638. new NullTemplate()
  639. );
  640. innerDependencyTemplates.set(
  641. HarmonyExportExpressionDependency,
  642. new HarmonyExportExpressionDependencyConcatenatedTemplate(
  643. dependencyTemplates.get(HarmonyExportExpressionDependency),
  644. this.rootModule
  645. )
  646. );
  647. innerDependencyTemplates.set(
  648. HarmonyExportImportedSpecifierDependency,
  649. new NullTemplate()
  650. );
  651. innerDependencyTemplates.set(
  652. HarmonyCompatibilityDependency,
  653. new NullTemplate()
  654. );
  655. // Must use full identifier in our cache here to ensure that the source
  656. // is updated should our dependencies list change.
  657. // TODO webpack 5 refactor
  658. innerDependencyTemplates.set(
  659. "hash",
  660. innerDependencyTemplates.get("hash") + this.identifier()
  661. );
  662. // Generate source code and analyse scopes
  663. // Prepare a ReplaceSource for the final source
  664. for (const info of modulesWithInfo) {
  665. if (info.type === "concatenated") {
  666. const m = info.module;
  667. const source = m.source(innerDependencyTemplates, runtimeTemplate);
  668. const code = source.source();
  669. let ast;
  670. try {
  671. ast = Parser.parse(code, {
  672. sourceType: "module"
  673. });
  674. } catch (err) {
  675. if (
  676. err.loc &&
  677. typeof err.loc === "object" &&
  678. typeof err.loc.line === "number"
  679. ) {
  680. const lineNumber = err.loc.line;
  681. const lines = code.split("\n");
  682. err.message +=
  683. "\n| " +
  684. lines
  685. .slice(Math.max(0, lineNumber - 3), lineNumber + 2)
  686. .join("\n| ");
  687. }
  688. throw err;
  689. }
  690. const scopeManager = eslintScope.analyze(ast, {
  691. ecmaVersion: 6,
  692. sourceType: "module",
  693. optimistic: true,
  694. ignoreEval: true,
  695. impliedStrict: true
  696. });
  697. const globalScope = scopeManager.acquire(ast);
  698. const moduleScope = globalScope.childScopes[0];
  699. const resultSource = new ReplaceSource(source);
  700. info.ast = ast;
  701. info.internalSource = source;
  702. info.source = resultSource;
  703. info.globalScope = globalScope;
  704. info.moduleScope = moduleScope;
  705. }
  706. }
  707. // List of all used names to avoid conflicts
  708. const allUsedNames = new Set([
  709. "__WEBPACK_MODULE_DEFAULT_EXPORT__", // avoid using this internal name
  710. "abstract",
  711. "arguments",
  712. "async",
  713. "await",
  714. "boolean",
  715. "break",
  716. "byte",
  717. "case",
  718. "catch",
  719. "char",
  720. "class",
  721. "const",
  722. "continue",
  723. "debugger",
  724. "default",
  725. "delete",
  726. "do",
  727. "double",
  728. "else",
  729. "enum",
  730. "eval",
  731. "export",
  732. "extends",
  733. "false",
  734. "final",
  735. "finally",
  736. "float",
  737. "for",
  738. "function",
  739. "goto",
  740. "if",
  741. "implements",
  742. "import",
  743. "in",
  744. "instanceof",
  745. "int",
  746. "interface",
  747. "let",
  748. "long",
  749. "native",
  750. "new",
  751. "null",
  752. "package",
  753. "private",
  754. "protected",
  755. "public",
  756. "return",
  757. "short",
  758. "static",
  759. "super",
  760. "switch",
  761. "synchronized",
  762. "this",
  763. "throw",
  764. "throws",
  765. "transient",
  766. "true",
  767. "try",
  768. "typeof",
  769. "var",
  770. "void",
  771. "volatile",
  772. "while",
  773. "with",
  774. "yield",
  775. "module",
  776. "__dirname",
  777. "__filename",
  778. "exports",
  779. "Array",
  780. "Date",
  781. "eval",
  782. "function",
  783. "hasOwnProperty",
  784. "Infinity",
  785. "isFinite",
  786. "isNaN",
  787. "isPrototypeOf",
  788. "length",
  789. "Math",
  790. "NaN",
  791. "name",
  792. "Number",
  793. "Object",
  794. "prototype",
  795. "String",
  796. "toString",
  797. "undefined",
  798. "valueOf",
  799. "alert",
  800. "all",
  801. "anchor",
  802. "anchors",
  803. "area",
  804. "assign",
  805. "blur",
  806. "button",
  807. "checkbox",
  808. "clearInterval",
  809. "clearTimeout",
  810. "clientInformation",
  811. "close",
  812. "closed",
  813. "confirm",
  814. "constructor",
  815. "crypto",
  816. "decodeURI",
  817. "decodeURIComponent",
  818. "defaultStatus",
  819. "document",
  820. "element",
  821. "elements",
  822. "embed",
  823. "embeds",
  824. "encodeURI",
  825. "encodeURIComponent",
  826. "escape",
  827. "event",
  828. "fileUpload",
  829. "focus",
  830. "form",
  831. "forms",
  832. "frame",
  833. "innerHeight",
  834. "innerWidth",
  835. "layer",
  836. "layers",
  837. "link",
  838. "location",
  839. "mimeTypes",
  840. "navigate",
  841. "navigator",
  842. "frames",
  843. "frameRate",
  844. "hidden",
  845. "history",
  846. "image",
  847. "images",
  848. "offscreenBuffering",
  849. "open",
  850. "opener",
  851. "option",
  852. "outerHeight",
  853. "outerWidth",
  854. "packages",
  855. "pageXOffset",
  856. "pageYOffset",
  857. "parent",
  858. "parseFloat",
  859. "parseInt",
  860. "password",
  861. "pkcs11",
  862. "plugin",
  863. "prompt",
  864. "propertyIsEnum",
  865. "radio",
  866. "reset",
  867. "screenX",
  868. "screenY",
  869. "scroll",
  870. "secure",
  871. "select",
  872. "self",
  873. "setInterval",
  874. "setTimeout",
  875. "status",
  876. "submit",
  877. "taint",
  878. "text",
  879. "textarea",
  880. "top",
  881. "unescape",
  882. "untaint",
  883. "window",
  884. "onblur",
  885. "onclick",
  886. "onerror",
  887. "onfocus",
  888. "onkeydown",
  889. "onkeypress",
  890. "onkeyup",
  891. "onmouseover",
  892. "onload",
  893. "onmouseup",
  894. "onmousedown",
  895. "onsubmit"
  896. ]);
  897. // Set of already checked scopes
  898. const alreadyCheckedScopes = new Set();
  899. // get all global names
  900. for (const info of modulesWithInfo) {
  901. const superClassExpressions = [];
  902. // ignore symbols from moduleScope
  903. if (info.moduleScope) {
  904. alreadyCheckedScopes.add(info.moduleScope);
  905. // The super class expression in class scopes behaves weird
  906. // We store ranges of all super class expressions to make
  907. // renaming to work correctly
  908. for (const childScope of info.moduleScope.childScopes) {
  909. if (childScope.type !== "class") continue;
  910. if (!childScope.block.superClass) continue;
  911. superClassExpressions.push({
  912. range: childScope.block.superClass.range,
  913. variables: childScope.variables
  914. });
  915. }
  916. }
  917. // add global symbols
  918. if (info.globalScope) {
  919. for (const reference of info.globalScope.through) {
  920. const name = reference.identifier.name;
  921. if (
  922. /^__WEBPACK_MODULE_REFERENCE__\d+_([\da-f]+|ns)(_call)?(_strict)?__$/.test(
  923. name
  924. )
  925. ) {
  926. for (const expr of superClassExpressions) {
  927. if (
  928. expr.range[0] <= reference.identifier.range[0] &&
  929. expr.range[1] >= reference.identifier.range[1]
  930. ) {
  931. for (const variable of expr.variables) {
  932. allUsedNames.add(variable.name);
  933. }
  934. }
  935. }
  936. addScopeSymbols1(
  937. reference.from,
  938. allUsedNames,
  939. alreadyCheckedScopes
  940. );
  941. } else {
  942. allUsedNames.add(name);
  943. }
  944. }
  945. }
  946. // add exported globals
  947. if (info.type === "concatenated") {
  948. const variables = new Set();
  949. for (const variable of info.moduleScope.variables) {
  950. variables.add(variable.name);
  951. }
  952. for (const [, variable] of info.exportMap) {
  953. if (!variables.has(variable)) {
  954. info.globalExports.add(variable);
  955. }
  956. }
  957. }
  958. }
  959. // generate names for symbols
  960. for (const info of modulesWithInfo) {
  961. switch (info.type) {
  962. case "concatenated": {
  963. const namespaceObjectName = this.findNewName(
  964. "namespaceObject",
  965. allUsedNames,
  966. null,
  967. info.module.readableIdentifier(requestShortener)
  968. );
  969. allUsedNames.add(namespaceObjectName);
  970. info.internalNames.set(namespaceObjectName, namespaceObjectName);
  971. info.exportMap.set(true, namespaceObjectName);
  972. for (const variable of info.moduleScope.variables) {
  973. const name = variable.name;
  974. if (allUsedNames.has(name)) {
  975. const references = getAllReferences(variable);
  976. const symbolsInReferences = new Set();
  977. const alreadyCheckedInnerScopes = new Set();
  978. for (const ref of references) {
  979. addScopeSymbols2(
  980. ref.from,
  981. symbolsInReferences,
  982. alreadyCheckedInnerScopes,
  983. alreadyCheckedScopes
  984. );
  985. }
  986. const newName = this.findNewName(
  987. name,
  988. allUsedNames,
  989. symbolsInReferences,
  990. info.module.readableIdentifier(requestShortener)
  991. );
  992. allUsedNames.add(newName);
  993. info.internalNames.set(name, newName);
  994. const source = info.source;
  995. const allIdentifiers = new Set(
  996. references.map(r => r.identifier).concat(variable.identifiers)
  997. );
  998. for (const identifier of allIdentifiers) {
  999. const r = identifier.range;
  1000. const path = getPathInAst(info.ast, identifier);
  1001. if (
  1002. path &&
  1003. path.length > 1 &&
  1004. path[1].type === "Property" &&
  1005. path[1].shorthand
  1006. ) {
  1007. source.insert(r[1], `: ${newName}`);
  1008. } else {
  1009. source.replace(r[0], r[1] - 1, newName);
  1010. }
  1011. }
  1012. } else {
  1013. allUsedNames.add(name);
  1014. info.internalNames.set(name, name);
  1015. }
  1016. }
  1017. break;
  1018. }
  1019. case "external": {
  1020. const externalName = this.findNewName(
  1021. "",
  1022. allUsedNames,
  1023. null,
  1024. info.module.readableIdentifier(requestShortener)
  1025. );
  1026. allUsedNames.add(externalName);
  1027. info.name = externalName;
  1028. if (
  1029. info.module.buildMeta.exportsType === "named" ||
  1030. !info.module.buildMeta.exportsType
  1031. ) {
  1032. const externalNameInterop = this.findNewName(
  1033. "namespaceObject",
  1034. allUsedNames,
  1035. null,
  1036. info.module.readableIdentifier(requestShortener)
  1037. );
  1038. allUsedNames.add(externalNameInterop);
  1039. info.interopNamespaceObjectName = externalNameInterop;
  1040. }
  1041. if (!info.module.buildMeta.exportsType) {
  1042. const externalNameInterop = this.findNewName(
  1043. "default",
  1044. allUsedNames,
  1045. null,
  1046. info.module.readableIdentifier(requestShortener)
  1047. );
  1048. allUsedNames.add(externalNameInterop);
  1049. info.interopDefaultAccessName = externalNameInterop;
  1050. }
  1051. break;
  1052. }
  1053. }
  1054. }
  1055. // Find and replace referenced to modules
  1056. for (const info of modulesWithInfo) {
  1057. if (info.type === "concatenated") {
  1058. for (const reference of info.globalScope.through) {
  1059. const name = reference.identifier.name;
  1060. const match = /^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_strict)?__$/.exec(
  1061. name
  1062. );
  1063. if (match) {
  1064. const referencedModule = modulesWithInfo[+match[1]];
  1065. let exportName;
  1066. if (match[2] === "ns") {
  1067. exportName = true;
  1068. } else {
  1069. const exportData = match[2];
  1070. exportName = Buffer.from(exportData, "hex").toString("utf-8");
  1071. }
  1072. const asCall = !!match[3];
  1073. const strictHarmonyModule = !!match[4];
  1074. const finalName = getFinalName(
  1075. referencedModule,
  1076. exportName,
  1077. moduleToInfoMap,
  1078. requestShortener,
  1079. asCall,
  1080. strictHarmonyModule
  1081. );
  1082. const r = reference.identifier.range;
  1083. const source = info.source;
  1084. source.replace(r[0], r[1] - 1, finalName);
  1085. }
  1086. }
  1087. }
  1088. }
  1089. // Map with all root exposed used exports
  1090. /** @type {Map<string, function(RequestShortener): string>} */
  1091. const exportsMap = new Map();
  1092. // Set with all root exposed unused exports
  1093. /** @type {Set<string>} */
  1094. const unusedExports = new Set();
  1095. for (const dep of this.rootModule.dependencies) {
  1096. if (dep instanceof HarmonyExportSpecifierDependency) {
  1097. const used = this.rootModule.isUsed(dep.name);
  1098. if (used) {
  1099. const info = moduleToInfoMap.get(this.rootModule);
  1100. if (!exportsMap.has(used)) {
  1101. exportsMap.set(
  1102. used,
  1103. () => `/* binding */ ${info.internalNames.get(dep.id)}`
  1104. );
  1105. }
  1106. } else {
  1107. unusedExports.add(dep.name || "namespace");
  1108. }
  1109. } else if (dep instanceof HarmonyExportImportedSpecifierDependency) {
  1110. const exportDefs = getHarmonyExportImportedSpecifierDependencyExports(
  1111. dep
  1112. );
  1113. for (const def of exportDefs) {
  1114. const info = moduleToInfoMap.get(def.module);
  1115. const used = dep.originModule.isUsed(def.name);
  1116. if (used) {
  1117. if (!exportsMap.has(used)) {
  1118. exportsMap.set(used, requestShortener => {
  1119. const finalName = getFinalName(
  1120. info,
  1121. def.id,
  1122. moduleToInfoMap,
  1123. requestShortener,
  1124. false,
  1125. this.rootModule.buildMeta.strictHarmonyModule
  1126. );
  1127. return `/* reexport */ ${finalName}`;
  1128. });
  1129. }
  1130. } else {
  1131. unusedExports.add(def.name);
  1132. }
  1133. }
  1134. }
  1135. }
  1136. const result = new ConcatSource();
  1137. // add harmony compatibility flag (must be first because of possible circular dependencies)
  1138. const usedExports = this.rootModule.usedExports;
  1139. if (usedExports === true || usedExports === null) {
  1140. result.add(`// ESM COMPAT FLAG\n`);
  1141. result.add(
  1142. runtimeTemplate.defineEsModuleFlagStatement({
  1143. exportsArgument: this.exportsArgument
  1144. })
  1145. );
  1146. }
  1147. // define exports
  1148. if (exportsMap.size > 0) {
  1149. result.add(`\n// EXPORTS\n`);
  1150. for (const [key, value] of exportsMap) {
  1151. result.add(
  1152. `__webpack_require__.d(${this.exportsArgument}, ${JSON.stringify(
  1153. key
  1154. )}, function() { return ${value(requestShortener)}; });\n`
  1155. );
  1156. }
  1157. }
  1158. // list unused exports
  1159. if (unusedExports.size > 0) {
  1160. result.add(
  1161. `\n// UNUSED EXPORTS: ${joinIterableWithComma(unusedExports)}\n`
  1162. );
  1163. }
  1164. // define required namespace objects (must be before evaluation modules)
  1165. for (const info of modulesWithInfo) {
  1166. if (info.namespaceObjectSource) {
  1167. result.add(
  1168. `\n// NAMESPACE OBJECT: ${info.module.readableIdentifier(
  1169. requestShortener
  1170. )}\n`
  1171. );
  1172. result.add(info.namespaceObjectSource);
  1173. }
  1174. }
  1175. // evaluate modules in order
  1176. for (const info of modulesWithInfo) {
  1177. switch (info.type) {
  1178. case "concatenated":
  1179. result.add(
  1180. `\n// CONCATENATED MODULE: ${info.module.readableIdentifier(
  1181. requestShortener
  1182. )}\n`
  1183. );
  1184. result.add(info.source);
  1185. break;
  1186. case "external":
  1187. result.add(
  1188. `\n// EXTERNAL MODULE: ${info.module.readableIdentifier(
  1189. requestShortener
  1190. )}\n`
  1191. );
  1192. result.add(
  1193. `var ${info.name} = __webpack_require__(${JSON.stringify(
  1194. info.module.id
  1195. )});\n`
  1196. );
  1197. if (info.interopNamespaceObjectUsed) {
  1198. if (info.module.buildMeta.exportsType === "named") {
  1199. result.add(
  1200. `var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name}, 2);\n`
  1201. );
  1202. } else if (!info.module.buildMeta.exportsType) {
  1203. result.add(
  1204. `var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name});\n`
  1205. );
  1206. }
  1207. }
  1208. if (info.interopDefaultAccessUsed) {
  1209. result.add(
  1210. `var ${info.interopDefaultAccessName} = /*#__PURE__*/__webpack_require__.n(${info.name});\n`
  1211. );
  1212. }
  1213. break;
  1214. default:
  1215. throw new Error(`Unsupported concatenation entry type ${info.type}`);
  1216. }
  1217. }
  1218. return result;
  1219. }
  1220. findNewName(oldName, usedNamed1, usedNamed2, extraInfo) {
  1221. let name = oldName;
  1222. if (name === "__WEBPACK_MODULE_DEFAULT_EXPORT__") name = "";
  1223. // Remove uncool stuff
  1224. extraInfo = extraInfo.replace(
  1225. /\.+\/|(\/index)?\.([a-zA-Z0-9]{1,4})($|\s|\?)|\s*\+\s*\d+\s*modules/g,
  1226. ""
  1227. );
  1228. const splittedInfo = extraInfo.split("/");
  1229. while (splittedInfo.length) {
  1230. name = splittedInfo.pop() + (name ? "_" + name : "");
  1231. const nameIdent = Template.toIdentifier(name);
  1232. if (
  1233. !usedNamed1.has(nameIdent) &&
  1234. (!usedNamed2 || !usedNamed2.has(nameIdent))
  1235. )
  1236. return nameIdent;
  1237. }
  1238. let i = 0;
  1239. let nameWithNumber = Template.toIdentifier(`${name}_${i}`);
  1240. while (
  1241. usedNamed1.has(nameWithNumber) ||
  1242. (usedNamed2 && usedNamed2.has(nameWithNumber))
  1243. ) {
  1244. i++;
  1245. nameWithNumber = Template.toIdentifier(`${name}_${i}`);
  1246. }
  1247. return nameWithNumber;
  1248. }
  1249. /**
  1250. * @param {Hash} hash the hash used to track dependencies
  1251. * @returns {void}
  1252. */
  1253. updateHash(hash) {
  1254. for (const info of this._orderedConcatenationList) {
  1255. switch (info.type) {
  1256. case "concatenated":
  1257. info.module.updateHash(hash);
  1258. break;
  1259. case "external":
  1260. hash.update(`${info.module.id}`);
  1261. break;
  1262. }
  1263. }
  1264. super.updateHash(hash);
  1265. }
  1266. }
  1267. class HarmonyImportSpecifierDependencyConcatenatedTemplate {
  1268. constructor(originalTemplate, modulesMap) {
  1269. this.originalTemplate = originalTemplate;
  1270. this.modulesMap = modulesMap;
  1271. }
  1272. getHarmonyInitOrder(dep) {
  1273. const module = dep._module;
  1274. const info = this.modulesMap.get(module);
  1275. if (!info) {
  1276. return this.originalTemplate.getHarmonyInitOrder(dep);
  1277. }
  1278. return NaN;
  1279. }
  1280. harmonyInit(dep, source, runtimeTemplate, dependencyTemplates) {
  1281. const module = dep._module;
  1282. const info = this.modulesMap.get(module);
  1283. if (!info) {
  1284. this.originalTemplate.harmonyInit(
  1285. dep,
  1286. source,
  1287. runtimeTemplate,
  1288. dependencyTemplates
  1289. );
  1290. return;
  1291. }
  1292. }
  1293. apply(dep, source, runtime, dependencyTemplates) {
  1294. const module = dep._module;
  1295. const info = this.modulesMap.get(module);
  1296. if (!info) {
  1297. this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
  1298. return;
  1299. }
  1300. let content;
  1301. const callFlag = dep.call ? "_call" : "";
  1302. const strictFlag = dep.originModule.buildMeta.strictHarmonyModule
  1303. ? "_strict"
  1304. : "";
  1305. if (dep._id === null) {
  1306. content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
  1307. } else if (dep.namespaceObjectAsContext) {
  1308. content = `__WEBPACK_MODULE_REFERENCE__${
  1309. info.index
  1310. }_ns${strictFlag}__[${JSON.stringify(dep._id)}]`;
  1311. } else {
  1312. const exportData = Buffer.from(dep._id, "utf-8").toString("hex");
  1313. content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${strictFlag}__`;
  1314. }
  1315. if (dep.shorthand) {
  1316. content = dep.name + ": " + content;
  1317. }
  1318. source.replace(dep.range[0], dep.range[1] - 1, content);
  1319. }
  1320. }
  1321. class HarmonyImportSideEffectDependencyConcatenatedTemplate {
  1322. constructor(originalTemplate, modulesMap) {
  1323. this.originalTemplate = originalTemplate;
  1324. this.modulesMap = modulesMap;
  1325. }
  1326. getHarmonyInitOrder(dep) {
  1327. const module = dep._module;
  1328. const info = this.modulesMap.get(module);
  1329. if (!info) {
  1330. return this.originalTemplate.getHarmonyInitOrder(dep);
  1331. }
  1332. return NaN;
  1333. }
  1334. harmonyInit(dep, source, runtime, dependencyTemplates) {
  1335. const module = dep._module;
  1336. const info = this.modulesMap.get(module);
  1337. if (!info) {
  1338. this.originalTemplate.harmonyInit(
  1339. dep,
  1340. source,
  1341. runtime,
  1342. dependencyTemplates
  1343. );
  1344. return;
  1345. }
  1346. }
  1347. apply(dep, source, runtime, dependencyTemplates) {
  1348. const module = dep._module;
  1349. const info = this.modulesMap.get(module);
  1350. if (!info) {
  1351. this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
  1352. return;
  1353. }
  1354. }
  1355. }
  1356. class HarmonyExportExpressionDependencyConcatenatedTemplate {
  1357. constructor(originalTemplate, rootModule) {
  1358. this.originalTemplate = originalTemplate;
  1359. this.rootModule = rootModule;
  1360. }
  1361. apply(dep, source, runtime, dependencyTemplates) {
  1362. let content =
  1363. "/* harmony default export */ var __WEBPACK_MODULE_DEFAULT_EXPORT__ = ";
  1364. if (dep.originModule === this.rootModule) {
  1365. const used = dep.originModule.isUsed("default");
  1366. const exportsName = dep.originModule.exportsArgument;
  1367. if (used) content += `${exportsName}[${JSON.stringify(used)}] = `;
  1368. }
  1369. if (dep.range) {
  1370. source.replace(
  1371. dep.rangeStatement[0],
  1372. dep.range[0] - 1,
  1373. content + "(" + dep.prefix
  1374. );
  1375. source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
  1376. return;
  1377. }
  1378. source.replace(
  1379. dep.rangeStatement[0],
  1380. dep.rangeStatement[1] - 1,
  1381. content + dep.prefix
  1382. );
  1383. }
  1384. }
  1385. class NullTemplate {
  1386. apply() {}
  1387. }
  1388. module.exports = ConcatenatedModule;