Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | const makeSerializable = require("../util/makeSerializable");
|
---|
9 | const NullDependency = require("./NullDependency");
|
---|
10 |
|
---|
11 | /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
---|
12 | /** @typedef {import("../Dependency")} Dependency */
|
---|
13 | /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
---|
14 |
|
---|
15 | class UnsupportedDependency extends NullDependency {
|
---|
16 | constructor(request, range) {
|
---|
17 | super();
|
---|
18 |
|
---|
19 | this.request = request;
|
---|
20 | this.range = range;
|
---|
21 | }
|
---|
22 |
|
---|
23 | serialize(context) {
|
---|
24 | const { write } = context;
|
---|
25 |
|
---|
26 | write(this.request);
|
---|
27 | write(this.range);
|
---|
28 |
|
---|
29 | super.serialize(context);
|
---|
30 | }
|
---|
31 |
|
---|
32 | deserialize(context) {
|
---|
33 | const { read } = context;
|
---|
34 |
|
---|
35 | this.request = read();
|
---|
36 | this.range = read();
|
---|
37 |
|
---|
38 | super.deserialize(context);
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | makeSerializable(
|
---|
43 | UnsupportedDependency,
|
---|
44 | "webpack/lib/dependencies/UnsupportedDependency"
|
---|
45 | );
|
---|
46 |
|
---|
47 | UnsupportedDependency.Template = class UnsupportedDependencyTemplate extends (
|
---|
48 | NullDependency.Template
|
---|
49 | ) {
|
---|
50 | /**
|
---|
51 | * @param {Dependency} dependency the dependency for which the template should be applied
|
---|
52 | * @param {ReplaceSource} source the current replace source which can be modified
|
---|
53 | * @param {DependencyTemplateContext} templateContext the context object
|
---|
54 | * @returns {void}
|
---|
55 | */
|
---|
56 | apply(dependency, source, { runtimeTemplate }) {
|
---|
57 | const dep = /** @type {UnsupportedDependency} */ (dependency);
|
---|
58 |
|
---|
59 | source.replace(
|
---|
60 | dep.range[0],
|
---|
61 | dep.range[1],
|
---|
62 | runtimeTemplate.missingModule({
|
---|
63 | request: dep.request
|
---|
64 | })
|
---|
65 | );
|
---|
66 | }
|
---|
67 | };
|
---|
68 |
|
---|
69 | module.exports = UnsupportedDependency;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.