123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- "use strict";
- const Dependency = require("../Dependency");
- const InitFragment = require("../InitFragment");
- const RuntimeGlobals = require("../RuntimeGlobals");
- const makeSerializable = require("../util/makeSerializable");
- const NullDependency = require("./NullDependency");
- class ModuleDecoratorDependency extends NullDependency {
-
- constructor(decorator, allowExportsAccess) {
- super();
- this.decorator = decorator;
- this.allowExportsAccess = allowExportsAccess;
- this._hashUpdate = undefined;
- }
-
- get type() {
- return "module decorator";
- }
- get category() {
- return "self";
- }
-
- getResourceIdentifier() {
- return "self";
- }
-
- getReferencedExports(moduleGraph, runtime) {
- return this.allowExportsAccess
- ? Dependency.EXPORTS_OBJECT_REFERENCED
- : Dependency.NO_EXPORTS_REFERENCED;
- }
-
- updateHash(hash, context) {
- if (this._hashUpdate === undefined) {
- this._hashUpdate = `${this.decorator}${this.allowExportsAccess}`;
- }
- hash.update(this._hashUpdate);
- }
-
- serialize(context) {
- const { write } = context;
- write(this.decorator);
- write(this.allowExportsAccess);
- super.serialize(context);
- }
-
- deserialize(context) {
- const { read } = context;
- this.decorator = read();
- this.allowExportsAccess = read();
- super.deserialize(context);
- }
- }
- makeSerializable(
- ModuleDecoratorDependency,
- "webpack/lib/dependencies/ModuleDecoratorDependency"
- );
- ModuleDecoratorDependency.Template = class ModuleDecoratorDependencyTemplate extends (
- NullDependency.Template
- ) {
-
- apply(
- dependency,
- source,
- { module, chunkGraph, initFragments, runtimeRequirements }
- ) {
- const dep = (dependency);
- runtimeRequirements.add(RuntimeGlobals.moduleLoaded);
- runtimeRequirements.add(RuntimeGlobals.moduleId);
- runtimeRequirements.add(RuntimeGlobals.module);
- runtimeRequirements.add(dep.decorator);
- initFragments.push(
- new InitFragment(
- `/* module decorator */ ${module.moduleArgument} = ${dep.decorator}(${module.moduleArgument});\n`,
- InitFragment.STAGE_PROVIDES,
- 0,
- `module decorator ${chunkGraph.getModuleId(module)}`
- )
- );
- }
- };
- module.exports = ModuleDecoratorDependency;
|