applyModuleDefaults = (
	module,
	{
		cache,
		syncWebAssembly,
		asyncWebAssembly,
		css,
		futureDefaults,
		isNode,
		uniqueName,
		targetProperties,
		mode
	}
) => {
	if (cache) {
		D(
			module,
			"unsafeCache",
			/**
			 * @param {Module} module module
			 * @returns {boolean} true, if we want to cache the module
			 */
			module => {
				const name = module.nameForCondition();
				if (!name) {
					return false;
				}
				return NODE_MODULES_REGEXP.test(name);
			}
		);
	} else {
		D(module, "unsafeCache", false);
	}

	F(module.parser, ASSET_MODULE_TYPE, () => ({}));
	F(
		/** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
		(module.parser[ASSET_MODULE_TYPE]),
		"dataUrlCondition",
		() => ({})
	);
	if (
		typeof (
			/** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
			(module.parser[ASSET_MODULE_TYPE]).dataUrlCondition
		) === "object"
	) {
		D(
			/** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
			(module.parser[ASSET_MODULE_TYPE]).dataUrlCondition,
			"maxSize",
			8096
		);
	}

	F(module.parser, "javascript", () => ({}));
	F(module.parser, JSON_MODULE_TYPE, () => ({}));
	D(
		/** @type {NonNullable<ParserOptionsByModuleTypeKnown[JSON_MODULE_TYPE]>} */
		(module.parser[JSON_MODULE_TYPE]),
		"exportsDepth",
		mode === "development" ? 1 : Infinity
	);

	applyJavascriptParserOptionsDefaults(
		/** @type {NonNullable<ParserOptionsByModuleTypeKnown["javascript"]>} */
		(module.parser.javascript),
		{
			futureDefaults,
			isNode
		}
	);

	F(module.generator, "json", () => ({}));
	applyJsonGeneratorOptionsDefaults(
		/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown["json"]>} */
		(module.generator.json)
	);

	if (css) {
		F(module.parser, CSS_MODULE_TYPE, () => ({}));

		D(
			/** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
			(module.parser[CSS_MODULE_TYPE]),
			"import",
			true
		);
		D(
			/** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
			(module.parser[CSS_MODULE_TYPE]),
			"url",
			true
		);
		D(
			/** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
			(module.parser[CSS_MODULE_TYPE]),
			"namedExports",
			true
		);

		F(module.generator, CSS_MODULE_TYPE, () => ({}));

		applyCssGeneratorOptionsDefaults(
			/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
			(module.generator[CSS_MODULE_TYPE]),
			{ targetProperties }
		);

		const localIdentName =
			uniqueName.length > 0 ? "[uniqueName]-[id]-[local]" : "[id]-[local]";

		F(module.generator, CSS_MODULE_TYPE_AUTO, () => ({}));
		D(
			/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]>} */
			(module.generator[CSS_MODULE_TYPE_AUTO]),
			"localIdentName",
			localIdentName
		);
		D(
			/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]>} */
			(module.generator[CSS_MODULE_TYPE_AUTO]),
			"exportsConvention",
			"as-is"
		);

		F(module.generator, CSS_MODULE_TYPE_MODULE, () => ({}));
		D(
			/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
			(module.generator[CSS_MODULE_TYPE_MODULE]),
			"localIdentName",
			localIdentName
		);
		D(
			/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
			(module.generator[CSS_MODULE_TYPE_MODULE]),
			"exportsConvention",
			"as-is"
		);

		F(module.generator, CSS_MODULE_TYPE_GLOBAL, () => ({}));
		D(
			/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_GLOBAL]>} */
			(module.generator[CSS_MODULE_TYPE_GLOBAL]),
			"localIdentName",
			localIdentName
		);
		D(
			/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_GLOBAL]>} */
			(module.generator[CSS_MODULE_TYPE_GLOBAL]),
			"exportsConvention",
			"as-is"
		);
	}

	A(module, "defaultRules", () => {
		const esm = {
			type: JAVASCRIPT_MODULE_TYPE_ESM,
			resolve: {
				byDependency: {
					esm: {
						fullySpecified: true
					}
				}
			}
		};
		const commonjs = {
			type: JAVASCRIPT_MODULE_TYPE_DYNAMIC
		};
		/** @type {RuleSetRules} */
		const rules = [
			{
				mimetype: "application/node",
				type: JAVASCRIPT_MODULE_TYPE_AUTO
			},
			{
				test: /\.json$/i,
				type: JSON_MODULE_TYPE
			},
			{
				mimetype: "application/json",
				type: JSON_MODULE_TYPE
			},
			{
				test: /\.mjs$/i,
				...esm
			},
			{
				test: /\.js$/i,
				descriptionData: {
					type: "module"
				},
				...esm
			},
			{
				test: /\.cjs$/i,
				...commonjs
			},
			{
				test: /\.js$/i,
				descriptionData: {
					type: "commonjs"
				},
				...commonjs
			},
			{
				mimetype: {
					or: ["text/javascript", "application/javascript"]
				},
				...esm
			}
		];
		if (asyncWebAssembly) {
			const wasm = {
				type: WEBASSEMBLY_MODULE_TYPE_ASYNC,
				rules: [
					{
						descriptionData: {
							type: "module"
						},
						resolve: {
							fullySpecified: true
						}
					}
				]
			};
			rules.push({
				test: /\.wasm$/i,
				...wasm
			});
			rules.push({
				mimetype: "application/wasm",
				...wasm
			});
		} else if (syncWebAssembly) {
			const wasm = {
				type: WEBASSEMBLY_MODULE_TYPE_SYNC,
				rules: [
					{
						descriptionData: {
							type: "module"
						},
						resolve: {
							fullySpecified: true
						}
					}
				]
			};
			rules.push({
				test: /\.wasm$/i,
				...wasm
			});
			rules.push({
				mimetype: "application/wasm",
				...wasm
			});
		}
		if (css) {
			const resolve = {
				fullySpecified: true,
				preferRelative: true
			};
			rules.push({
				test: /\.css$/i,
				type: CSS_MODULE_TYPE_AUTO,
				resolve
			});
			rules.push({
				mimetype: "text/css+module",
				type: CSS_MODULE_TYPE_MODULE,
				resolve
			});
			rules.push({
				mimetype: "text/css",
				type: CSS_MODULE_TYPE,
				resolve
			});
		}
		rules.push(
			{
				dependency: "url",
				oneOf: [
					{
						scheme: /^data$/,
						type: ASSET_MODULE_TYPE_INLINE
					},
					{
						type: ASSET_MODULE_TYPE_RESOURCE
					}
				]
			},
			{
				assert: { type: JSON_MODULE_TYPE },
				type: JSON_MODULE_TYPE
			},
			{
				with: { type: JSON_MODULE_TYPE },
				type: JSON_MODULE_TYPE
			}
		);
		return rules;
	});
}
@param {ModuleOptions} module options
@param {object} options options
@param {boolean} options.cache is caching enabled
@param {boolean} options.syncWebAssembly is syncWebAssembly enabled
@param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
@param {boolean} options.css is css enabled
@param {boolean} options.futureDefaults is future defaults enabled
@param {string} options.uniqueName the unique name
@param {boolean} options.isNode is node target platform
@param {TargetProperties | false} options.targetProperties target properties
@param {Mode | undefined} options.mode mode
@returns {void}