@rspack/core 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
- package/dist/config/types.d.ts +309 -0
- package/dist/config/zod.d.ts +22 -534
- package/dist/cssExtractHmr.js +224 -0
- package/dist/cssExtractLoader.js +277 -0
- package/dist/index.js +23347 -31
- package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
- package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
- package/dist/stats/statsFactoryUtils.d.ts +1 -0
- package/package.json +8 -5
- package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
- package/compiled/json-parse-even-better-errors/index.js +0 -193
- package/compiled/json-parse-even-better-errors/package.json +0 -1
- package/compiled/neo-async/index.d.ts +0 -685
- package/compiled/neo-async/index.js +0 -9207
- package/compiled/neo-async/license +0 -22
- package/compiled/neo-async/package.json +0 -1
- package/compiled/zod-validation-error/index.d.ts +0 -41
- package/compiled/zod-validation-error/index.js +0 -335
- package/compiled/zod-validation-error/license +0 -9
- package/compiled/zod-validation-error/package.json +0 -1
- package/dist/Chunk.js +0 -118
- package/dist/ChunkGraph.js +0 -27
- package/dist/ChunkGroup.js +0 -76
- package/dist/Compilation.js +0 -854
- package/dist/Compiler.js +0 -925
- package/dist/ContextModuleFactory.js +0 -36
- package/dist/DependenciesBlock.js +0 -30
- package/dist/Dependency.js +0 -43
- package/dist/Entrypoint.js +0 -21
- package/dist/ErrorHelpers.js +0 -62
- package/dist/ExecuteModulePlugin.js +0 -46
- package/dist/FileSystem.js +0 -34
- package/dist/FileSystemInfo.js +0 -2
- package/dist/Module.js +0 -226
- package/dist/ModuleTypeConstants.js +0 -92
- package/dist/MultiCompiler.js +0 -440
- package/dist/MultiStats.js +0 -161
- package/dist/MultiWatching.js +0 -62
- package/dist/NormalModule.js +0 -97
- package/dist/NormalModuleFactory.js +0 -43
- package/dist/Resolver.js +0 -39
- package/dist/ResolverFactory.js +0 -61
- package/dist/RspackError.js +0 -21
- package/dist/RuleSetCompiler.js +0 -10
- package/dist/RuntimeGlobals.js +0 -357
- package/dist/RuntimeModule.js +0 -58
- package/dist/Stats.js +0 -161
- package/dist/Template.js +0 -206
- package/dist/Watching.js +0 -290
- package/dist/builtin-loader/index.js +0 -17
- package/dist/builtin-loader/lightningcss/index.js +0 -175
- package/dist/builtin-loader/swc/index.js +0 -5
- package/dist/builtin-loader/swc/pluginImport.js +0 -35
- package/dist/builtin-loader/swc/react.js +0 -7
- package/dist/builtin-loader/swc/types.js +0 -2
- package/dist/builtin-plugin/APIPlugin.js +0 -6
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
- package/dist/builtin-plugin/BannerPlugin.js +0 -22
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
- package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
- package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
- package/dist/builtin-plugin/DataUriPlugin.js +0 -6
- package/dist/builtin-plugin/DefinePlugin.js +0 -44
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
- package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
- package/dist/builtin-plugin/EntryPlugin.js +0 -34
- package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
- package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
- package/dist/builtin-plugin/FileUriPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
- package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
- package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
- package/dist/builtin-plugin/IgnorePlugin.js +0 -20
- package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
- package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
- package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
- package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
- package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
- package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
- package/dist/builtin-plugin/ProgressPlugin.js +0 -15
- package/dist/builtin-plugin/ProvidePlugin.js +0 -14
- package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimePlugin.js +0 -6
- package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
- package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
- package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
- package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
- package/dist/builtin-plugin/WorkerPlugin.js +0 -31
- package/dist/builtin-plugin/base.js +0 -58
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
- package/dist/builtin-plugin/css-extract/index.js +0 -105
- package/dist/builtin-plugin/css-extract/loader.js +0 -204
- package/dist/builtin-plugin/css-extract/utils.js +0 -51
- package/dist/builtin-plugin/index.js +0 -84
- package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
- package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
- package/dist/config/adapter.js +0 -691
- package/dist/config/adapterRuleUse.js +0 -107
- package/dist/config/browserslistTargetHandler.js +0 -345
- package/dist/config/defaults.js +0 -876
- package/dist/config/index.js +0 -20
- package/dist/config/normalization.js +0 -299
- package/dist/config/target.js +0 -318
- package/dist/config/types.js +0 -3
- package/dist/config/zod.js +0 -1030
- package/dist/container/ContainerPlugin.js +0 -50
- package/dist/container/ContainerReferencePlugin.js +0 -49
- package/dist/container/ModuleFederationPlugin.js +0 -137
- package/dist/container/ModuleFederationPluginV1.js +0 -63
- package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
- package/dist/container/options.js +0 -48
- package/dist/error/ConcurrentCompilationError.js +0 -20
- package/dist/exports.js +0 -183
- package/dist/lib/AbstractMethodError.js +0 -51
- package/dist/lib/Cache.js +0 -111
- package/dist/lib/CacheFacade.js +0 -321
- package/dist/lib/Dependency.js +0 -11
- package/dist/lib/EntryOptionPlugin.js +0 -89
- package/dist/lib/EnvironmentPlugin.js +0 -57
- package/dist/lib/HookWebpackError.js +0 -83
- package/dist/lib/IgnoreWarningsPlugin.js +0 -35
- package/dist/lib/LoaderOptionsPlugin.js +0 -74
- package/dist/lib/LoaderTargetPlugin.js +0 -37
- package/dist/lib/ModuleFilenameHelpers.js +0 -83
- package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
- package/dist/lib/WebpackError.js +0 -20
- package/dist/lib/cache/MemoryCachePlugin.js +0 -40
- package/dist/lib/cache/getLazyHashedEtag.js +0 -73
- package/dist/lib/cache/mergeEtags.js +0 -74
- package/dist/lib/formatLocation.js +0 -64
- package/dist/loader-runner/LoaderLoadingError.js +0 -19
- package/dist/loader-runner/index.js +0 -735
- package/dist/loader-runner/loadLoader.js +0 -64
- package/dist/logging/Logger.js +0 -143
- package/dist/logging/createConsoleLogger.js +0 -176
- package/dist/logging/runtime.js +0 -37
- package/dist/logging/truncateArgs.js +0 -81
- package/dist/node/NodeEnvironmentPlugin.js +0 -50
- package/dist/node/NodeTemplatePlugin.js +0 -26
- package/dist/node/NodeWatchFileSystem.js +0 -144
- package/dist/node/nodeConsole.js +0 -146
- package/dist/rspack.js +0 -123
- package/dist/rspackOptionsApply.js +0 -274
- package/dist/sharing/ConsumeSharedPlugin.js +0 -69
- package/dist/sharing/ProvideSharedPlugin.js +0 -50
- package/dist/sharing/SharePlugin.js +0 -66
- package/dist/sharing/ShareRuntimePlugin.js +0 -26
- package/dist/sharing/utils.js +0 -8
- package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
- package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
- package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
- package/dist/stats/StatsFactory.js +0 -167
- package/dist/stats/StatsPrinter.js +0 -142
- package/dist/stats/statsFactoryUtils.js +0 -341
- package/dist/util/ArrayQueue.js +0 -108
- package/dist/util/AssetInfo.js +0 -39
- package/dist/util/IterableHelpers.js +0 -35
- package/dist/util/MergeCaller.js +0 -24
- package/dist/util/SizeFormatHelpers.js +0 -24
- package/dist/util/SplitChunkSize.js +0 -18
- package/dist/util/assertNotNil.js +0 -9
- package/dist/util/assetCondition.js +0 -2
- package/dist/util/bindingVersionCheck.js +0 -124
- package/dist/util/cleverMerge.js +0 -504
- package/dist/util/comparators.js +0 -108
- package/dist/util/createHash.js +0 -161
- package/dist/util/createReadonlyMap.js +0 -29
- package/dist/util/fake.js +0 -28
- package/dist/util/fs.js +0 -120
- package/dist/util/hash/BatchedHash.js +0 -69
- package/dist/util/hash/index.js +0 -39
- package/dist/util/hash/md4.js +0 -27
- package/dist/util/hash/wasm-hash.js +0 -167
- package/dist/util/hash/xxhash64.js +0 -27
- package/dist/util/identifier.js +0 -330
- package/dist/util/index.js +0 -123
- package/dist/util/memoize.js +0 -61
- package/dist/util/scheme.js +0 -57
- package/dist/util/smartGrouping.js +0 -148
- package/dist/util/source.js +0 -42
- package/dist/util/validate.js +0 -77
- package/dist/util/webpack.js +0 -27
- /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
package/dist/Stats.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _Stats_instances, _Stats_inner, _Stats_innerMap, _Stats_getInnerByCompilation;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.normalizeStatsPreset = exports.Stats = void 0;
|
|
16
|
-
class Stats {
|
|
17
|
-
constructor(compilation) {
|
|
18
|
-
_Stats_instances.add(this);
|
|
19
|
-
_Stats_inner.set(this, void 0);
|
|
20
|
-
_Stats_innerMap.set(this, void 0);
|
|
21
|
-
__classPrivateFieldSet(this, _Stats_inner, compilation.__internal_getInner().getStats(), "f");
|
|
22
|
-
this.compilation = compilation;
|
|
23
|
-
__classPrivateFieldSet(this, _Stats_innerMap, new WeakMap([[this.compilation, __classPrivateFieldGet(this, _Stats_inner, "f")]]), "f");
|
|
24
|
-
}
|
|
25
|
-
get hash() {
|
|
26
|
-
return this.compilation.hash;
|
|
27
|
-
}
|
|
28
|
-
get startTime() {
|
|
29
|
-
return this.compilation.startTime;
|
|
30
|
-
}
|
|
31
|
-
get endTime() {
|
|
32
|
-
return this.compilation.endTime;
|
|
33
|
-
}
|
|
34
|
-
hasErrors() {
|
|
35
|
-
return __classPrivateFieldGet(this, _Stats_inner, "f").hasErrors();
|
|
36
|
-
}
|
|
37
|
-
hasWarnings() {
|
|
38
|
-
return __classPrivateFieldGet(this, _Stats_inner, "f").hasWarnings();
|
|
39
|
-
}
|
|
40
|
-
toJson(opts, forToString) {
|
|
41
|
-
const options = this.compilation.createStatsOptions(opts, {
|
|
42
|
-
forToString
|
|
43
|
-
});
|
|
44
|
-
const statsFactory = this.compilation.createStatsFactory(options);
|
|
45
|
-
const statsCompilationMap = new Map();
|
|
46
|
-
// FIXME: This is a really ugly workaround for avoid panic for accessing previous compilation.
|
|
47
|
-
// Modern.js dev server will detect whether the returned stats is available.
|
|
48
|
-
// So this does not do harm to these frameworks.
|
|
49
|
-
// Modern.js: https://github.com/web-infra-dev/modern.js/blob/63f916f882f7d16096949e264e119218c0ab8d7d/packages/server/server/src/dev-tools/dev-middleware/socketServer.ts#L172
|
|
50
|
-
let stats = null;
|
|
51
|
-
try {
|
|
52
|
-
stats = statsFactory.create("compilation", this.compilation, {
|
|
53
|
-
compilation: this.compilation,
|
|
54
|
-
getStatsCompilation: (compilation) => {
|
|
55
|
-
if (statsCompilationMap.has(compilation)) {
|
|
56
|
-
return statsCompilationMap.get(compilation);
|
|
57
|
-
}
|
|
58
|
-
const innerStats = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).call(this, compilation);
|
|
59
|
-
const innerStatsCompilation = innerStats.toJson(options);
|
|
60
|
-
statsCompilationMap.set(compilation, innerStatsCompilation);
|
|
61
|
-
return innerStatsCompilation;
|
|
62
|
-
},
|
|
63
|
-
getInner: __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).bind(this)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
console.warn("Failed to get stats. " +
|
|
68
|
-
"Are you trying to access the stats from the previous compilation?");
|
|
69
|
-
}
|
|
70
|
-
return stats;
|
|
71
|
-
}
|
|
72
|
-
toString(opts) {
|
|
73
|
-
const options = this.compilation.createStatsOptions(opts, {
|
|
74
|
-
forToString: true
|
|
75
|
-
});
|
|
76
|
-
const statsFactory = this.compilation.createStatsFactory(options);
|
|
77
|
-
const statsPrinter = this.compilation.createStatsPrinter(options);
|
|
78
|
-
const statsCompilationMap = new Map();
|
|
79
|
-
// FIXME: This is a really ugly workaround for avoid panic for accessing previous compilation.
|
|
80
|
-
// Modern.js dev server will detect whether the returned stats is available.
|
|
81
|
-
// So this does not do harm to these frameworks.
|
|
82
|
-
// Modern.js: https://github.com/web-infra-dev/modern.js/blob/63f916f882f7d16096949e264e119218c0ab8d7d/packages/server/server/src/dev-tools/dev-middleware/socketServer.ts#L172
|
|
83
|
-
let stats = null;
|
|
84
|
-
try {
|
|
85
|
-
stats = statsFactory.create("compilation", this.compilation, {
|
|
86
|
-
compilation: this.compilation,
|
|
87
|
-
getStatsCompilation: (compilation) => {
|
|
88
|
-
if (statsCompilationMap.has(compilation)) {
|
|
89
|
-
return statsCompilationMap.get(compilation);
|
|
90
|
-
}
|
|
91
|
-
const innerStats = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).call(this, compilation);
|
|
92
|
-
const innerStatsCompilation = innerStats.toJson(options);
|
|
93
|
-
statsCompilationMap.set(compilation, innerStatsCompilation);
|
|
94
|
-
return innerStatsCompilation;
|
|
95
|
-
},
|
|
96
|
-
getInner: __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).bind(this)
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
console.warn("Failed to get stats. " +
|
|
101
|
-
"Are you trying to access the stats from the previous compilation?");
|
|
102
|
-
}
|
|
103
|
-
if (!stats) {
|
|
104
|
-
return "";
|
|
105
|
-
}
|
|
106
|
-
const result = statsPrinter.print("compilation", stats);
|
|
107
|
-
return result === undefined ? "" : result;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.Stats = Stats;
|
|
111
|
-
_Stats_inner = new WeakMap(), _Stats_innerMap = new WeakMap(), _Stats_instances = new WeakSet(), _Stats_getInnerByCompilation = function _Stats_getInnerByCompilation(compilation) {
|
|
112
|
-
if (__classPrivateFieldGet(this, _Stats_innerMap, "f").has(compilation)) {
|
|
113
|
-
return __classPrivateFieldGet(this, _Stats_innerMap, "f").get(compilation);
|
|
114
|
-
}
|
|
115
|
-
const inner = compilation.__internal_getInner().getStats();
|
|
116
|
-
__classPrivateFieldGet(this, _Stats_innerMap, "f").set(compilation, inner);
|
|
117
|
-
return inner;
|
|
118
|
-
};
|
|
119
|
-
function normalizeStatsPreset(options) {
|
|
120
|
-
if (typeof options === "boolean" || typeof options === "string")
|
|
121
|
-
return presetToOptions(options);
|
|
122
|
-
if (!options)
|
|
123
|
-
return {};
|
|
124
|
-
const obj = { ...presetToOptions(options.preset), ...options };
|
|
125
|
-
delete obj.preset;
|
|
126
|
-
return obj;
|
|
127
|
-
}
|
|
128
|
-
exports.normalizeStatsPreset = normalizeStatsPreset;
|
|
129
|
-
function presetToOptions(name) {
|
|
130
|
-
const preset = (typeof name === "string" && name.toLowerCase()) || name;
|
|
131
|
-
switch (preset) {
|
|
132
|
-
case "none":
|
|
133
|
-
return {
|
|
134
|
-
all: false
|
|
135
|
-
};
|
|
136
|
-
case "verbose":
|
|
137
|
-
return {
|
|
138
|
-
all: true,
|
|
139
|
-
modulesSpace: Number.POSITIVE_INFINITY
|
|
140
|
-
};
|
|
141
|
-
case "errors-only":
|
|
142
|
-
return {
|
|
143
|
-
all: false,
|
|
144
|
-
errors: true,
|
|
145
|
-
errorsCount: true,
|
|
146
|
-
logging: "error",
|
|
147
|
-
moduleTrace: true
|
|
148
|
-
};
|
|
149
|
-
case "errors-warnings":
|
|
150
|
-
return {
|
|
151
|
-
all: false,
|
|
152
|
-
errors: true,
|
|
153
|
-
errorsCount: true,
|
|
154
|
-
warnings: true,
|
|
155
|
-
warningsCount: true,
|
|
156
|
-
logging: "warn"
|
|
157
|
-
};
|
|
158
|
-
default:
|
|
159
|
-
return {};
|
|
160
|
-
}
|
|
161
|
-
}
|
package/dist/Template.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/Template.js
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Tobias Koppers @sokra
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Template = void 0;
|
|
13
|
-
const START_LOWERCASE_ALPHABET_CODE = "a".charCodeAt(0);
|
|
14
|
-
const START_UPPERCASE_ALPHABET_CODE = "A".charCodeAt(0);
|
|
15
|
-
const DELTA_A_TO_Z = "z".charCodeAt(0) - START_LOWERCASE_ALPHABET_CODE + 1;
|
|
16
|
-
const NUMBER_OF_IDENTIFIER_START_CHARS = DELTA_A_TO_Z * 2 + 2; // a-z A-Z _ $
|
|
17
|
-
const NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS = NUMBER_OF_IDENTIFIER_START_CHARS + 10; // a-z A-Z _ $ 0-9
|
|
18
|
-
const FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g;
|
|
19
|
-
const INDENT_MULTILINE_REGEX = /^\t/gm;
|
|
20
|
-
const LINE_SEPARATOR_REGEX = /\r?\n/g;
|
|
21
|
-
const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/;
|
|
22
|
-
const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g;
|
|
23
|
-
const COMMENT_END_REGEX = /\*\//g;
|
|
24
|
-
const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
|
|
25
|
-
const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|
26
|
-
class Template {
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param fn a runtime function (.runtime.js) "template"
|
|
30
|
-
* @returns the updated and normalized function string
|
|
31
|
-
*/
|
|
32
|
-
static getFunctionContent(fn) {
|
|
33
|
-
return fn
|
|
34
|
-
.toString()
|
|
35
|
-
.replace(FUNCTION_CONTENT_REGEX, "")
|
|
36
|
-
.replace(INDENT_MULTILINE_REGEX, "")
|
|
37
|
-
.replace(LINE_SEPARATOR_REGEX, "\n");
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @param str the string converted to identifier
|
|
41
|
-
* @returns created identifier
|
|
42
|
-
*/
|
|
43
|
-
static toIdentifier(str) {
|
|
44
|
-
if (typeof str !== "string")
|
|
45
|
-
return "";
|
|
46
|
-
return str
|
|
47
|
-
.replace(IDENTIFIER_NAME_REPLACE_REGEX, "_$1")
|
|
48
|
-
.replace(IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX, "_");
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param str string to be converted to commented in bundle code
|
|
53
|
-
* @returns returns a commented version of string
|
|
54
|
-
*/
|
|
55
|
-
static toComment(str) {
|
|
56
|
-
if (!str)
|
|
57
|
-
return "";
|
|
58
|
-
return `/*! ${str.replace(COMMENT_END_REGEX, "* /")} */`;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* @param str string to be converted to "normal comment"
|
|
63
|
-
* @returns returns a commented version of string
|
|
64
|
-
*/
|
|
65
|
-
static toNormalComment(str) {
|
|
66
|
-
if (!str)
|
|
67
|
-
return "";
|
|
68
|
-
return `/* ${str.replace(COMMENT_END_REGEX, "* /")} */`;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @param str string path to be normalized
|
|
72
|
-
* @returns normalized bundle-safe path
|
|
73
|
-
*/
|
|
74
|
-
static toPath(str) {
|
|
75
|
-
if (typeof str !== "string")
|
|
76
|
-
return "";
|
|
77
|
-
return str
|
|
78
|
-
.replace(PATH_NAME_NORMALIZE_REPLACE_REGEX, "-")
|
|
79
|
-
.replace(MATCH_PADDED_HYPHENS_REPLACE_REGEX, "");
|
|
80
|
-
}
|
|
81
|
-
// map number to a single character a-z, A-Z or multiple characters if number is too big
|
|
82
|
-
/**
|
|
83
|
-
* @param num number to convert to ident
|
|
84
|
-
* @returns returns single character ident
|
|
85
|
-
*/
|
|
86
|
-
static numberToIdentifier(num) {
|
|
87
|
-
let n = num;
|
|
88
|
-
if (n >= NUMBER_OF_IDENTIFIER_START_CHARS) {
|
|
89
|
-
// use multiple letters
|
|
90
|
-
return (Template.numberToIdentifier(n % NUMBER_OF_IDENTIFIER_START_CHARS) +
|
|
91
|
-
Template.numberToIdentifierContinuation(Math.floor(n / NUMBER_OF_IDENTIFIER_START_CHARS)));
|
|
92
|
-
}
|
|
93
|
-
// lower case
|
|
94
|
-
if (n < DELTA_A_TO_Z) {
|
|
95
|
-
return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
|
|
96
|
-
}
|
|
97
|
-
n -= DELTA_A_TO_Z;
|
|
98
|
-
// upper case
|
|
99
|
-
if (n < DELTA_A_TO_Z) {
|
|
100
|
-
return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
|
|
101
|
-
}
|
|
102
|
-
if (n === DELTA_A_TO_Z)
|
|
103
|
-
return "_";
|
|
104
|
-
return "$";
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @param num number to convert to ident
|
|
108
|
-
* @returns returns single character ident
|
|
109
|
-
*/
|
|
110
|
-
static numberToIdentifierContinuation(num) {
|
|
111
|
-
let n = num;
|
|
112
|
-
if (n >= NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS) {
|
|
113
|
-
// use multiple letters
|
|
114
|
-
return (Template.numberToIdentifierContinuation(n % NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS) +
|
|
115
|
-
Template.numberToIdentifierContinuation(Math.floor(n / NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS)));
|
|
116
|
-
}
|
|
117
|
-
// lower case
|
|
118
|
-
if (n < DELTA_A_TO_Z) {
|
|
119
|
-
return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
|
|
120
|
-
}
|
|
121
|
-
n -= DELTA_A_TO_Z;
|
|
122
|
-
// upper case
|
|
123
|
-
if (n < DELTA_A_TO_Z) {
|
|
124
|
-
return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
|
|
125
|
-
}
|
|
126
|
-
n -= DELTA_A_TO_Z;
|
|
127
|
-
// numbers
|
|
128
|
-
if (n < 10) {
|
|
129
|
-
return `${n}`;
|
|
130
|
-
}
|
|
131
|
-
if (n === 10)
|
|
132
|
-
return "_";
|
|
133
|
-
return "$";
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
* @param s string to convert to identity
|
|
138
|
-
* @returns converted identity
|
|
139
|
-
*/
|
|
140
|
-
static indent(s) {
|
|
141
|
-
if (Array.isArray(s)) {
|
|
142
|
-
return s.map(Template.indent).join("\n");
|
|
143
|
-
}
|
|
144
|
-
const str = s.trimEnd();
|
|
145
|
-
if (!str)
|
|
146
|
-
return "";
|
|
147
|
-
const ind = str[0] === "\n" ? "" : "\t";
|
|
148
|
-
return ind + str.replace(/\n([^\n])/g, "\n\t$1");
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
*
|
|
152
|
-
* @param s string to create prefix for
|
|
153
|
-
* @param prefix prefix to compose
|
|
154
|
-
* @returns returns new prefix string
|
|
155
|
-
*/
|
|
156
|
-
static prefix(s, prefix) {
|
|
157
|
-
const str = Template.asString(s).trim();
|
|
158
|
-
if (!str)
|
|
159
|
-
return "";
|
|
160
|
-
const ind = str[0] === "\n" ? "" : prefix;
|
|
161
|
-
return ind + str.replace(/\n([^\n])/g, `\n${prefix}$1`);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
*
|
|
165
|
-
* @param str string or string collection
|
|
166
|
-
* @returns returns a single string from array
|
|
167
|
-
*/
|
|
168
|
-
static asString(str) {
|
|
169
|
-
if (Array.isArray(str)) {
|
|
170
|
-
return str.join("\n");
|
|
171
|
-
}
|
|
172
|
-
return str;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* @param modules a collection of modules to get array bounds for
|
|
176
|
-
* @returns returns the upper and lower array bounds
|
|
177
|
-
* or false if not every module has a number based id
|
|
178
|
-
*/
|
|
179
|
-
static getModulesArrayBounds(modules) {
|
|
180
|
-
let maxId = Number.NEGATIVE_INFINITY;
|
|
181
|
-
let minId = Number.POSITIVE_INFINITY;
|
|
182
|
-
for (const module of modules) {
|
|
183
|
-
const moduleId = module.id;
|
|
184
|
-
if (typeof moduleId !== "number")
|
|
185
|
-
return false;
|
|
186
|
-
if (maxId < moduleId)
|
|
187
|
-
maxId = moduleId;
|
|
188
|
-
if (minId > moduleId)
|
|
189
|
-
minId = moduleId;
|
|
190
|
-
}
|
|
191
|
-
if (minId < 16 + `${minId}`.length) {
|
|
192
|
-
// add minId x ',' instead of 'Array(minId).concat(…)'
|
|
193
|
-
minId = 0;
|
|
194
|
-
}
|
|
195
|
-
// start with -1 because the first module needs no comma
|
|
196
|
-
let objectOverhead = -1;
|
|
197
|
-
for (const module of modules) {
|
|
198
|
-
// module id + colon + comma
|
|
199
|
-
objectOverhead += `${module.id}`.length + 2;
|
|
200
|
-
}
|
|
201
|
-
// number of commas, or when starting non-zero the length of Array(minId).concat()
|
|
202
|
-
const arrayOverhead = minId === 0 ? maxId : 16 + `${minId}`.length + maxId;
|
|
203
|
-
return arrayOverhead < objectOverhead ? [minId, maxId] : false;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
exports.Template = Template;
|
package/dist/Watching.js
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
var _Watching_instances, _Watching_invalidReported, _Watching_closeCallbacks, _Watching_initial, _Watching_closed, _Watching_collectedChangedFiles, _Watching_collectedRemovedFiles, _Watching_invalidate, _Watching_go, _Watching_mergeWithCollected;
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.Watching = void 0;
|
|
19
|
-
/**
|
|
20
|
-
* The following code is modified based on
|
|
21
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/Watching.js
|
|
22
|
-
*
|
|
23
|
-
* MIT Licensed
|
|
24
|
-
* Author Tobias Koppers @sokra
|
|
25
|
-
* Copyright (c) JS Foundation and other contributors
|
|
26
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
27
|
-
*/
|
|
28
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
29
|
-
const _1 = require(".");
|
|
30
|
-
class Watching {
|
|
31
|
-
constructor(compiler, watchOptions, handler) {
|
|
32
|
-
_Watching_instances.add(this);
|
|
33
|
-
_Watching_invalidReported.set(this, void 0);
|
|
34
|
-
_Watching_closeCallbacks.set(this, void 0);
|
|
35
|
-
_Watching_initial.set(this, void 0);
|
|
36
|
-
_Watching_closed.set(this, void 0);
|
|
37
|
-
_Watching_collectedChangedFiles.set(this, void 0);
|
|
38
|
-
_Watching_collectedRemovedFiles.set(this, void 0);
|
|
39
|
-
this.callbacks = [];
|
|
40
|
-
this.invalid = false;
|
|
41
|
-
__classPrivateFieldSet(this, _Watching_invalidReported, true, "f");
|
|
42
|
-
this.blocked = false;
|
|
43
|
-
this.isBlocked = () => false;
|
|
44
|
-
this.onChange = () => { };
|
|
45
|
-
this.onInvalid = () => { };
|
|
46
|
-
this.compiler = compiler;
|
|
47
|
-
this.running = false;
|
|
48
|
-
__classPrivateFieldSet(this, _Watching_initial, true, "f");
|
|
49
|
-
__classPrivateFieldSet(this, _Watching_closed, false, "f");
|
|
50
|
-
this.watchOptions = watchOptions;
|
|
51
|
-
this.handler = handler;
|
|
52
|
-
this.suspended = false;
|
|
53
|
-
// The default aggregateTimeout of WatchPack is 200ms,
|
|
54
|
-
// using smaller values can improve hmr performance
|
|
55
|
-
if (typeof this.watchOptions.aggregateTimeout !== "number") {
|
|
56
|
-
this.watchOptions.aggregateTimeout = 5;
|
|
57
|
-
}
|
|
58
|
-
process.nextTick(() => {
|
|
59
|
-
if (__classPrivateFieldGet(this, _Watching_initial, "f"))
|
|
60
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
watch(files, dirs, missing) {
|
|
64
|
-
this.pausedWatcher = undefined;
|
|
65
|
-
// SAFETY: `watchFileSystem` is expected to be initialized.
|
|
66
|
-
this.watcher = this.compiler.watchFileSystem.watch(files, dirs, missing, this.lastWatcherStartTime, this.watchOptions, (err, fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles) => {
|
|
67
|
-
if (err) {
|
|
68
|
-
this.compiler.fileTimestamps = undefined;
|
|
69
|
-
this.compiler.contextTimestamps = undefined;
|
|
70
|
-
this.compiler.modifiedFiles = undefined;
|
|
71
|
-
this.compiler.removedFiles = undefined;
|
|
72
|
-
return this.handler(err);
|
|
73
|
-
}
|
|
74
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this, fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles);
|
|
75
|
-
this.onChange();
|
|
76
|
-
}, (fileName, changeTime) => {
|
|
77
|
-
if (!__classPrivateFieldGet(this, _Watching_invalidReported, "f")) {
|
|
78
|
-
__classPrivateFieldSet(this, _Watching_invalidReported, true, "f");
|
|
79
|
-
this.compiler.hooks.invalid.call(fileName, changeTime);
|
|
80
|
-
}
|
|
81
|
-
this.onInvalid();
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
close(callback) {
|
|
85
|
-
if (__classPrivateFieldGet(this, _Watching_closeCallbacks, "f")) {
|
|
86
|
-
if (callback) {
|
|
87
|
-
__classPrivateFieldGet(this, _Watching_closeCallbacks, "f").push(callback);
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const finalCallback = (err) => {
|
|
92
|
-
this.running = false;
|
|
93
|
-
this.compiler.running = false;
|
|
94
|
-
this.compiler.watching = undefined;
|
|
95
|
-
this.compiler.watchMode = false;
|
|
96
|
-
this.compiler.modifiedFiles = undefined;
|
|
97
|
-
this.compiler.removedFiles = undefined;
|
|
98
|
-
this.compiler.fileTimestamps = undefined;
|
|
99
|
-
this.compiler.contextTimestamps = undefined;
|
|
100
|
-
// this.compiler.fsStartTime = undefined;
|
|
101
|
-
const shutdown = (err) => {
|
|
102
|
-
this.compiler.hooks.watchClose.call();
|
|
103
|
-
const closeCallbacks = __classPrivateFieldGet(this, _Watching_closeCallbacks, "f");
|
|
104
|
-
__classPrivateFieldSet(this, _Watching_closeCallbacks, undefined, "f");
|
|
105
|
-
for (const cb of closeCallbacks)
|
|
106
|
-
cb(err);
|
|
107
|
-
};
|
|
108
|
-
// TODO: compilation parameter support
|
|
109
|
-
// if (compilation) {
|
|
110
|
-
// const logger = compilation.getLogger("webpack.Watching");
|
|
111
|
-
// logger.time("storeBuildDependencies");
|
|
112
|
-
// this.compiler.cache.storeBuildDependencies(
|
|
113
|
-
// compilation.buildDependencies,
|
|
114
|
-
// err2 => {
|
|
115
|
-
// logger.timeEnd("storeBuildDependencies");
|
|
116
|
-
// shutdown(err || err2);
|
|
117
|
-
// }
|
|
118
|
-
// );
|
|
119
|
-
// } else {
|
|
120
|
-
// shutdown(err);
|
|
121
|
-
// }
|
|
122
|
-
shutdown(err);
|
|
123
|
-
};
|
|
124
|
-
__classPrivateFieldSet(this, _Watching_closed, true, "f");
|
|
125
|
-
if (this.watcher) {
|
|
126
|
-
this.watcher.close();
|
|
127
|
-
this.watcher = undefined;
|
|
128
|
-
}
|
|
129
|
-
if (this.pausedWatcher) {
|
|
130
|
-
this.pausedWatcher.close();
|
|
131
|
-
this.pausedWatcher = undefined;
|
|
132
|
-
}
|
|
133
|
-
this.compiler.watching = undefined;
|
|
134
|
-
this.compiler.watchMode = false;
|
|
135
|
-
__classPrivateFieldSet(this, _Watching_closeCallbacks, [], "f");
|
|
136
|
-
if (callback) {
|
|
137
|
-
__classPrivateFieldGet(this, _Watching_closeCallbacks, "f").push(callback);
|
|
138
|
-
}
|
|
139
|
-
if (this.running) {
|
|
140
|
-
this.invalid = true;
|
|
141
|
-
this._done = finalCallback;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
finalCallback(null);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
invalidate(callback) {
|
|
148
|
-
if (callback) {
|
|
149
|
-
this.callbacks.push(callback);
|
|
150
|
-
}
|
|
151
|
-
if (!__classPrivateFieldGet(this, _Watching_invalidReported, "f")) {
|
|
152
|
-
__classPrivateFieldSet(this, _Watching_invalidReported, true, "f");
|
|
153
|
-
this.compiler.hooks.invalid.call(null, Date.now());
|
|
154
|
-
}
|
|
155
|
-
this.onChange();
|
|
156
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this);
|
|
157
|
-
}
|
|
158
|
-
lazyCompilationInvalidate(files) {
|
|
159
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this, new Map(), new Map(), files, new Set());
|
|
160
|
-
}
|
|
161
|
-
_done(error, compilation) {
|
|
162
|
-
this.running = false;
|
|
163
|
-
let stats = undefined;
|
|
164
|
-
const handleError = (err, cbs) => {
|
|
165
|
-
this.compiler.hooks.failed.call(err);
|
|
166
|
-
// this.compiler.cache.beginIdle();
|
|
167
|
-
// this.compiler.idle = true;
|
|
168
|
-
this.handler(err, stats);
|
|
169
|
-
const callbacksToExecute = cbs || this.callbacks.splice(0);
|
|
170
|
-
for (const cb of callbacksToExecute) {
|
|
171
|
-
cb(err);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
const cbs = this.callbacks;
|
|
175
|
-
this.callbacks = [];
|
|
176
|
-
const startTime = this.startTime; // store last startTime for compilation
|
|
177
|
-
// reset startTime for next compilation, before throwing error
|
|
178
|
-
this.startTime = undefined;
|
|
179
|
-
if (error) {
|
|
180
|
-
return handleError(error);
|
|
181
|
-
}
|
|
182
|
-
(0, node_assert_1.default)(compilation);
|
|
183
|
-
compilation.startTime = startTime;
|
|
184
|
-
compilation.endTime = Date.now();
|
|
185
|
-
stats = new _1.Stats(compilation);
|
|
186
|
-
this.compiler.hooks.done.callAsync(stats, err => {
|
|
187
|
-
if (err)
|
|
188
|
-
return handleError(err, cbs);
|
|
189
|
-
this.handler(null, stats);
|
|
190
|
-
process.nextTick(() => {
|
|
191
|
-
if (!__classPrivateFieldGet(this, _Watching_closed, "f")) {
|
|
192
|
-
this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
for (const cb of cbs)
|
|
196
|
-
cb(null);
|
|
197
|
-
this.compiler.hooks.afterDone.call(stats);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
suspend() {
|
|
201
|
-
this.suspended = true;
|
|
202
|
-
}
|
|
203
|
-
resume() {
|
|
204
|
-
if (this.suspended) {
|
|
205
|
-
this.suspended = false;
|
|
206
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
exports.Watching = Watching;
|
|
211
|
-
_Watching_invalidReported = new WeakMap(), _Watching_closeCallbacks = new WeakMap(), _Watching_initial = new WeakMap(), _Watching_closed = new WeakMap(), _Watching_collectedChangedFiles = new WeakMap(), _Watching_collectedRemovedFiles = new WeakMap(), _Watching_instances = new WeakSet(), _Watching_invalidate = function _Watching_invalidate(fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles) {
|
|
212
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_mergeWithCollected).call(this, changedFiles, removedFiles);
|
|
213
|
-
if (this.suspended || (this.isBlocked() && (this.blocked = true))) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
if (this.running) {
|
|
217
|
-
this.invalid = true;
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_go).call(this, fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles);
|
|
221
|
-
}, _Watching_go = function _Watching_go(fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles) {
|
|
222
|
-
if (this.startTime === undefined)
|
|
223
|
-
this.startTime = Date.now();
|
|
224
|
-
this.running = true;
|
|
225
|
-
if (this.watcher) {
|
|
226
|
-
this.pausedWatcher = this.watcher;
|
|
227
|
-
this.lastWatcherStartTime = Date.now();
|
|
228
|
-
this.watcher.pause();
|
|
229
|
-
this.watcher = undefined;
|
|
230
|
-
}
|
|
231
|
-
else if (!this.lastWatcherStartTime) {
|
|
232
|
-
this.lastWatcherStartTime = Date.now();
|
|
233
|
-
}
|
|
234
|
-
if (fileTimeInfoEntries &&
|
|
235
|
-
contextTimeInfoEntries &&
|
|
236
|
-
changedFiles &&
|
|
237
|
-
removedFiles) {
|
|
238
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_mergeWithCollected).call(this, changedFiles, removedFiles);
|
|
239
|
-
this.compiler.fileTimestamps = fileTimeInfoEntries;
|
|
240
|
-
this.compiler.contextTimestamps = contextTimeInfoEntries;
|
|
241
|
-
}
|
|
242
|
-
else if (this.pausedWatcher) {
|
|
243
|
-
const { changes, removals, fileTimeInfoEntries, contextTimeInfoEntries } = this.pausedWatcher.getInfo();
|
|
244
|
-
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_mergeWithCollected).call(this, changes, removals);
|
|
245
|
-
this.compiler.fileTimestamps = fileTimeInfoEntries;
|
|
246
|
-
this.compiler.contextTimestamps = contextTimeInfoEntries;
|
|
247
|
-
}
|
|
248
|
-
const modifiedFiles = (this.compiler.modifiedFiles =
|
|
249
|
-
__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f"));
|
|
250
|
-
const deleteFiles = (this.compiler.removedFiles =
|
|
251
|
-
__classPrivateFieldGet(this, _Watching_collectedRemovedFiles, "f"));
|
|
252
|
-
__classPrivateFieldSet(this, _Watching_collectedChangedFiles, undefined, "f");
|
|
253
|
-
__classPrivateFieldSet(this, _Watching_collectedRemovedFiles, undefined, "f");
|
|
254
|
-
this.invalid = false;
|
|
255
|
-
__classPrivateFieldSet(this, _Watching_invalidReported, false, "f");
|
|
256
|
-
this.compiler.hooks.watchRun.callAsync(this.compiler, err => {
|
|
257
|
-
if (err)
|
|
258
|
-
return this._done(err, null);
|
|
259
|
-
const canRebuild = !__classPrivateFieldGet(this, _Watching_initial, "f") && (modifiedFiles?.size || deleteFiles?.size);
|
|
260
|
-
const onCompile = (err) => {
|
|
261
|
-
if (err)
|
|
262
|
-
return this._done(err, null);
|
|
263
|
-
// if (this.invalid) return this._done(null);
|
|
264
|
-
this._done(null, this.compiler._lastCompilation);
|
|
265
|
-
};
|
|
266
|
-
this.compiler.compile(onCompile);
|
|
267
|
-
if (!canRebuild) {
|
|
268
|
-
__classPrivateFieldSet(this, _Watching_initial, false, "f");
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}, _Watching_mergeWithCollected = function _Watching_mergeWithCollected(changedFiles, removedFiles) {
|
|
272
|
-
if (!changedFiles)
|
|
273
|
-
return;
|
|
274
|
-
if (!removedFiles)
|
|
275
|
-
return;
|
|
276
|
-
if (!__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f") || !__classPrivateFieldGet(this, _Watching_collectedRemovedFiles, "f")) {
|
|
277
|
-
__classPrivateFieldSet(this, _Watching_collectedChangedFiles, new Set(changedFiles), "f");
|
|
278
|
-
__classPrivateFieldSet(this, _Watching_collectedRemovedFiles, new Set(removedFiles), "f");
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
for (const file of changedFiles) {
|
|
282
|
-
__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f").add(file);
|
|
283
|
-
__classPrivateFieldGet(this, _Watching_collectedRemovedFiles, "f").delete(file);
|
|
284
|
-
}
|
|
285
|
-
for (const file of removedFiles) {
|
|
286
|
-
__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f").delete(file);
|
|
287
|
-
__classPrivateFieldGet(this, _Watching_collectedRemovedFiles, "f").add(file);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./swc"), exports);
|