/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/

"use strict";

const ModuleDependency = require("./ModuleDependency");

/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */

class ImportDependency extends ModuleDependency {
	constructor(request, block) {
		super(request);
		this.block = block;
	}

	get type() {
		return "import()";
	}
}

ImportDependency.Template = class ImportDependencyTemplate extends ModuleDependency.Template {
	/**
	 * @param {Dependency} dependency the dependency for which the template should be applied
	 * @param {ReplaceSource} source the current replace source which can be modified
	 * @param {DependencyTemplateContext} templateContext the context object
	 * @returns {void}
	 */
	apply(
		dependency,
		source,
		{ runtimeTemplate, module, moduleGraph, chunkGraph }
	) {
		const dep = /** @type {ImportDependency} */ (dependency);
		const content = runtimeTemplate.moduleNamespacePromise({
			chunkGraph,
			block: dep.block,
			module: moduleGraph.getModule(dep),
			request: dep.request,
			strict: module.buildMeta.strictHarmonyModule,
			message: "import()"
		});

		source.replace(dep.block.range[0], dep.block.range[1] - 1, content);
	}
};

module.exports = ImportDependency;

@@ -109,16 +109,78 @@
 rict%22;%0A%0A
+const makeSerializable = require(%22../util/makeSerializable%22);%0A
 const Mo
@@ -227,16 +227,16 @@
 ency%22);%0A
-
 %0A/** @ty
@@ -555,16 +555,17 @@
 quest);%0A
+%0A
 %09%09this.b
@@ -620,17 +620,321 @@
 ()%22;%0A%09%7D%0A
-%7D
+%0A%09serialize(context) %7B%0A%09%09const %7B write %7D = context;%0A%0A%09%09write(this.block);%0A%0A%09%09super.serialize(context);%0A%09%7D%0A%0A%09deserialize(context) %7B%0A%09%09const %7B read %7D = context;%0A%0A%09%09this.block = read();%0A%0A%09%09super.deserialize(context);%0A%09%7D%0A%7D%0A%0AmakeSerializable(%0A%09ImportDependency,%0A%09%22webpack/lib/dependencies/ImportDependency %22%0A);
 %0A%0AImport

make serializable