AMDRequireContextDependency.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const makeSerializable = require("../util/makeSerializable");
  7. const ContextDependency = require("./ContextDependency");
  8. /** @typedef {import("../javascript/JavascriptParser").Range} Range */
  9. /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
  10. /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
  11. class AMDRequireContextDependency extends ContextDependency {
  12. /**
  13. * @param {TODO} options options
  14. * @param {Range} range range
  15. * @param {Range} valueRange value range
  16. */
  17. constructor(options, range, valueRange) {
  18. super(options);
  19. this.range = range;
  20. this.valueRange = valueRange;
  21. }
  22. get type() {
  23. return "amd require context";
  24. }
  25. get category() {
  26. return "amd";
  27. }
  28. /**
  29. * @param {ObjectSerializerContext} context context
  30. */
  31. serialize(context) {
  32. const { write } = context;
  33. write(this.range);
  34. write(this.valueRange);
  35. super.serialize(context);
  36. }
  37. /**
  38. * @param {ObjectDeserializerContext} context context
  39. */
  40. deserialize(context) {
  41. const { read } = context;
  42. this.range = read();
  43. this.valueRange = read();
  44. super.deserialize(context);
  45. }
  46. }
  47. makeSerializable(
  48. AMDRequireContextDependency,
  49. "webpack/lib/dependencies/AMDRequireContextDependency"
  50. );
  51. AMDRequireContextDependency.Template = require("./ContextDependencyTemplateAsRequireCall");
  52. module.exports = AMDRequireContextDependency;