Sha256: b37e59b2231c9b09b2c1ef3e22b35e6df8aee076917f65cc5025d18a17d8fba3

Contents?: true

Size: 1.82 KB

Versions: 29

Compression:

Stored size: 1.82 KB

Contents

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
const CriticalDependencyWarning = require("./CriticalDependencyWarning");

const regExpToString = r => (r ? r + "" : "");

class ContextDependency extends Dependency {
	// options: { request, recursive, regExp, include, exclude, mode, chunkName, groupOptions }
	constructor(options) {
		super();
		this.options = options;
		this.userRequest = this.options.request;
		/** @type {false | string} */
		this.critical = false;
		this.hadGlobalOrStickyRegExp = false;
		if (this.options.regExp.global || this.options.regExp.sticky) {
			this.options.regExp = null;
			this.hadGlobalOrStickyRegExp = true;
		}
	}

	getResourceIdentifier() {
		return (
			`context${this.options.request} ${this.options.recursive} ` +
			`${regExpToString(this.options.regExp)} ${regExpToString(
				this.options.include
			)} ${regExpToString(this.options.exclude)} ` +
			`${this.options.mode} ${this.options.chunkName} ` +
			`${JSON.stringify(this.options.groupOptions)}`
		);
	}

	getWarnings() {
		let warnings = super.getWarnings() || [];
		if (this.critical) {
			warnings.push(new CriticalDependencyWarning(this.critical));
		}
		if (this.hadGlobalOrStickyRegExp) {
			warnings.push(
				new CriticalDependencyWarning(
					"Contexts can't use RegExps with the 'g' or 'y' flags."
				)
			);
		}
		return warnings;
	}
}

// TODO remove in webpack 5
Object.defineProperty(ContextDependency.prototype, "async", {
	configurable: false,
	get() {
		throw new Error(
			"ContextDependency.async was removed. Use ContextDependency.options.mode instead."
		);
	},
	set() {
		throw new Error(
			"ContextDependency.async was removed. Pass options.mode to constructor instead"
		);
	}
});

module.exports = ContextDependency;

Version data entries

29 entries across 28 versions & 10 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.18.0 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.18.2 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.16.1 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.15.2 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.18.4 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.18.1 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.14.0 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
tang-0.2.1 spec/tang_app/node_modules/webpack/lib/dependencies/ContextDependency.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/webpack/lib/dependencies/ContextDependency.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/webpack/lib/dependencies/ContextDependency.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/webpack/lib/dependencies/ContextDependency.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/webpack/lib/dependencies/ContextDependency.js
tang-0.2.0 spec/tang_app/node_modules/webpack/lib/dependencies/ContextDependency.js
tang-0.1.0 spec/tang_app/node_modules/webpack/lib/dependencies/ContextDependency.js
tang-0.0.9 spec/tang_app/node_modules/webpack/lib/dependencies/ContextDependency.js
enju_library-0.3.8 spec/dummy/node_modules/webpack/lib/dependencies/ContextDependency.js
jester-data-8.0.0 node_modules/webpack/lib/dependencies/ContextDependency.js