@ohos-ports/rspack-core 2.2.2-beta.0
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/LICENSE +22 -0
- package/README.md +15 -0
- package/compiled/@rspack/lite-tapable/dist/index.d.ts +176 -0
- package/compiled/@rspack/lite-tapable/license +22 -0
- package/compiled/@rspack/lite-tapable/package.json +1 -0
- package/compiled/@swc/types/index.d.ts +2284 -0
- package/compiled/@swc/types/index.js +19 -0
- package/compiled/@swc/types/license +201 -0
- package/compiled/@swc/types/package.json +1 -0
- package/compiled/connect-next/index.d.ts +57 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +455 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/open/index.d.ts +161 -0
- package/compiled/open/package.json +1 -0
- package/compiled/tinypool/LICENSE +24 -0
- package/compiled/tinypool/README.md +214 -0
- package/compiled/tinypool/dist/common-Bo3KCGim.js +31 -0
- package/compiled/tinypool/dist/entry/process.d.ts +1 -0
- package/compiled/tinypool/dist/entry/process.js +72 -0
- package/compiled/tinypool/dist/entry/utils.d.ts +7 -0
- package/compiled/tinypool/dist/entry/utils.js +3 -0
- package/compiled/tinypool/dist/entry/worker.d.ts +1 -0
- package/compiled/tinypool/dist/entry/worker.js +76 -0
- package/compiled/tinypool/dist/index.d.ts +199 -0
- package/compiled/tinypool/dist/index.js +784 -0
- package/compiled/tinypool/dist/utils-B--2TaWv.js +38 -0
- package/compiled/tinypool/dist/utils-De75vAgL.js +10 -0
- package/compiled/tinypool/package.json +55 -0
- package/compiled/watchpack/index.d.ts +3 -0
- package/compiled/watchpack/index.js +3811 -0
- package/compiled/watchpack/license +20 -0
- package/compiled/watchpack/package.json +8 -0
- package/compiled/watchpack/types/DirectoryWatcher.d.ts +335 -0
- package/compiled/watchpack/types/LinkResolver.d.ts +10 -0
- package/compiled/watchpack/types/getWatcherManager.d.ts +62 -0
- package/compiled/watchpack/types/index.d.ts +269 -0
- package/compiled/watchpack/types/reducePlan.d.ts +34 -0
- package/compiled/watchpack/types/util/globToRegExp.d.ts +2 -0
- package/compiled/watchpack/types/watchEventSource.d.ts +53 -0
- package/compiled/watchpack/types/watchpack.d.ts +2 -0
- package/compiled/webpack-sources/index.js +5835 -0
- package/compiled/webpack-sources/license +21 -0
- package/compiled/webpack-sources/package.json +1 -0
- package/compiled/webpack-sources/types.d.ts +500 -0
- package/dist/612~0.js +32 -0
- package/dist/612~3.js +32 -0
- package/dist/BuildInfo.d.ts +17 -0
- package/dist/Chunk.d.ts +16 -0
- package/dist/ChunkGraph.d.ts +9 -0
- package/dist/Chunks.d.ts +12 -0
- package/dist/CodeGenerationResults.d.ts +1 -0
- package/dist/Compilation.d.ts +448 -0
- package/dist/Compiler.d.ts +229 -0
- package/dist/ConcatenatedModule.d.ts +1 -0
- package/dist/ContextModule.d.ts +1 -0
- package/dist/ContextModuleFactory.d.ts +13 -0
- package/dist/Diagnostics.d.ts +7 -0
- package/dist/Entrypoint.d.ts +2 -0
- package/dist/ErrorHelpers.d.ts +3 -0
- package/dist/ExecuteModulePlugin.d.ts +4 -0
- package/dist/ExportsInfo.d.ts +20 -0
- package/dist/ExternalModule.d.ts +15 -0
- package/dist/FileSystem.d.ts +54 -0
- package/dist/FileSystemInfo.d.ts +5 -0
- package/dist/Module.d.ts +41 -0
- package/dist/ModuleGraph.d.ts +22 -0
- package/dist/ModuleGraphConnection.d.ts +10 -0
- package/dist/ModuleTypeConstants.d.ts +8 -0
- package/dist/MultiCompiler.d.ts +82 -0
- package/dist/MultiStats.d.ts +23 -0
- package/dist/MultiWatching.d.ts +27 -0
- package/dist/NativeWatchFileSystem.d.ts +52 -0
- package/dist/NormalModule.d.ts +14 -0
- package/dist/NormalModuleFactory.d.ts +23 -0
- package/dist/Resolver.d.ts +30 -0
- package/dist/ResolverFactory.d.ts +17 -0
- package/dist/RspackError.d.ts +12 -0
- package/dist/RuleSetCompiler.d.ts +9 -0
- package/dist/RuntimeGlobals.d.ts +360 -0
- package/dist/RuntimeModule.d.ts +34 -0
- package/dist/RuntimeTemplate.d.ts +151 -0
- package/dist/Stats.d.ts +17 -0
- package/dist/Template.d.ts +77 -0
- package/dist/VirtualModulesPlugin.d.ts +12 -0
- package/dist/Watching.d.ts +56 -0
- package/dist/builtin-loader/lightningcss/index.d.ts +114 -0
- package/dist/builtin-loader/lightningcss/target.d.ts +4 -0
- package/dist/builtin-loader/swc/collectTypeScriptInfo.d.ts +21 -0
- package/dist/builtin-loader/swc/index.d.ts +3 -0
- package/dist/builtin-loader/swc/pluginImport.d.ts +33 -0
- package/dist/builtin-loader/swc/types.d.ts +60 -0
- package/dist/builtin-plugin/APIPlugin.d.ts +9 -0
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +9 -0
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/BannerPlugin.d.ts +40 -0
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +14 -0
- package/dist/builtin-plugin/CaseSensitivePlugin.d.ts +9 -0
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +9 -0
- package/dist/builtin-plugin/CircularCheckRspackPlugin.d.ts +33 -0
- package/dist/builtin-plugin/CircularDependencyRspackPlugin.d.ts +60 -0
- package/dist/builtin-plugin/CircularModulesInfoPlugin.d.ts +7 -0
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +9 -0
- package/dist/builtin-plugin/CompactHashedChunkIdsPlugin.d.ts +12 -0
- package/dist/builtin-plugin/CompactHashedModuleIdsPlugin.d.ts +12 -0
- package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +9 -0
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +14 -0
- package/dist/builtin-plugin/CssChunkingPlugin.d.ts +21 -0
- package/dist/builtin-plugin/CssHttpExternalsRspackPlugin.d.ts +9 -0
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/DataUriPlugin.d.ts +9 -0
- package/dist/builtin-plugin/DefinePlugin.d.ts +16 -0
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +7 -0
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +18 -0
- package/dist/builtin-plugin/DllEntryPlugin.d.ts +12 -0
- package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +11 -0
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +12 -0
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +9 -0
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +25 -0
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +11 -0
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +9 -0
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +9 -0
- package/dist/builtin-plugin/EntryPlugin.d.ts +32 -0
- package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +16 -0
- package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +9 -0
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +11 -0
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +10 -0
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +13 -0
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +9 -0
- package/dist/builtin-plugin/FileUriPlugin.d.ts +9 -0
- package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +9 -0
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +9 -0
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +9 -0
- package/dist/builtin-plugin/HashedModuleIdsPlugin.d.ts +10 -0
- package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +7 -0
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +9 -0
- package/dist/builtin-plugin/HttpUriPlugin.d.ts +36 -0
- package/dist/builtin-plugin/IgnorePlugin.d.ts +19 -0
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/InlineExportsPlugin.d.ts +9 -0
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +30 -0
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +10 -0
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/LibManifestPlugin.d.ts +17 -0
- package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +28 -0
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +14 -0
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +9 -0
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +9 -0
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +9 -0
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +7 -0
- package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +9 -0
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +9 -0
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +9 -0
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +7 -0
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +7 -0
- package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +9 -0
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +9 -0
- package/dist/builtin-plugin/NormalModuleReplacementPlugin.d.ts +10 -0
- package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +10 -0
- package/dist/builtin-plugin/ProgressPlugin.d.ts +12 -0
- package/dist/builtin-plugin/ProvidePlugin.d.ts +10 -0
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +20 -0
- package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +9 -0
- package/dist/builtin-plugin/RsdoctorPlugin.d.ts +46 -0
- package/dist/builtin-plugin/RslibPlugin.d.ts +10 -0
- package/dist/builtin-plugin/RstestPlugin.d.ts +10 -0
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +11 -0
- package/dist/builtin-plugin/RuntimePlugin.d.ts +25 -0
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +9 -0
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +19 -0
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +11 -0
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +12 -0
- package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +39 -0
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +216 -0
- package/dist/builtin-plugin/SyncModuleIdsPlugin.d.ts +16 -0
- package/dist/builtin-plugin/URLPlugin.d.ts +9 -0
- package/dist/builtin-plugin/WorkerPlugin.d.ts +14 -0
- package/dist/builtin-plugin/base.d.ts +45 -0
- package/dist/builtin-plugin/css-extract/index.d.ts +24 -0
- package/dist/builtin-plugin/css-extract/loader.d.ts +21 -0
- package/dist/builtin-plugin/css-extract/utils.d.ts +10 -0
- package/dist/builtin-plugin/html-plugin/hooks.d.ts +32 -0
- package/dist/builtin-plugin/html-plugin/index.d.ts +2 -0
- package/dist/builtin-plugin/html-plugin/options.d.ts +77 -0
- package/dist/builtin-plugin/html-plugin/plugin.d.ts +20 -0
- package/dist/builtin-plugin/html-plugin/taps.d.ts +2 -0
- package/dist/builtin-plugin/index.d.ts +92 -0
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +10 -0
- package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +12 -0
- package/dist/builtin-plugin/rsc/Coordinator.d.ts +8 -0
- package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +13 -0
- package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +47 -0
- package/dist/builtin-plugin/rsc/index.d.ts +24 -0
- package/dist/checkNodeVersion.d.ts +1 -0
- package/dist/config/adapter.d.ts +8 -0
- package/dist/config/adapterRuleUse.d.ts +424 -0
- package/dist/config/browserslistTargetHandler.d.ts +15 -0
- package/dist/config/defaults.d.ts +15 -0
- package/dist/config/devServer.d.ts +179 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/normalization.d.ts +156 -0
- package/dist/config/target.d.ts +100 -0
- package/dist/config/types.d.ts +2728 -0
- package/dist/container/ContainerPlugin.d.ts +41 -0
- package/dist/container/ContainerReferencePlugin.d.ts +34 -0
- package/dist/container/ModuleFederationManifestPlugin.d.ts +44 -0
- package/dist/container/ModuleFederationPlugin.d.ts +34 -0
- package/dist/container/ModuleFederationPluginV1.d.ts +22 -0
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +16 -0
- package/dist/container/options.d.ts +3 -0
- package/dist/cssExtractHmr.js +99 -0
- package/dist/cssExtractLoader.js +117 -0
- package/dist/error/ConcurrentCompilationError.d.ts +14 -0
- package/dist/exports.d.ts +192 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +14552 -0
- package/dist/lib/AbstractMethodError.d.ts +23 -0
- package/dist/lib/Cache.d.ts +65 -0
- package/dist/lib/CacheFacade.d.ts +139 -0
- package/dist/lib/DllPlugin.d.ts +42 -0
- package/dist/lib/DllReferencePlugin.d.ts +119 -0
- package/dist/lib/EntryOptionPlugin.d.ts +33 -0
- package/dist/lib/EnvironmentPlugin.d.ts +22 -0
- package/dist/lib/HookWebpackError.d.ts +39 -0
- package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
- package/dist/lib/LoaderOptionsPlugin.d.ts +28 -0
- package/dist/lib/LoaderTargetPlugin.d.ts +24 -0
- package/dist/lib/ModuleFilenameHelpers.d.ts +53 -0
- package/dist/lib/WebpackError.d.ts +21 -0
- package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
- package/dist/lib/cache/getLazyHashedEtag.d.ts +35 -0
- package/dist/lib/cache/mergeEtags.d.ts +16 -0
- package/dist/loader-runner/LoaderLoadingError.d.ts +13 -0
- package/dist/loader-runner/ModuleError.d.ts +13 -0
- package/dist/loader-runner/cache.d.ts +18 -0
- package/dist/loader-runner/dependencies.d.ts +22 -0
- package/dist/loader-runner/index.d.ts +35 -0
- package/dist/loader-runner/loadLoader.d.ts +12 -0
- package/dist/loader-runner/service.d.ts +77 -0
- package/dist/loader-runner/utils.d.ts +7 -0
- package/dist/loader-runner/worker.d.ts +14 -0
- package/dist/logging/Logger.d.ts +61 -0
- package/dist/logging/createConsoleLogger.d.ts +35 -0
- package/dist/logging/truncateArgs.d.ts +16 -0
- package/dist/moduleFederationDefaultRuntime.js +1 -0
- package/dist/node/NodeEnvironmentPlugin.d.ts +10 -0
- package/dist/node/NodeTemplatePlugin.d.ts +18 -0
- package/dist/node/NodeWatchFileSystem.d.ts +30 -0
- package/dist/node/nodeConsole.d.ts +15 -0
- package/dist/rspack.d.ts +24 -0
- package/dist/rspackOptionsApply.d.ts +4 -0
- package/dist/runtime/cssExtractHmr.d.ts +4 -0
- package/dist/runtime/moduleFederationDefaultRuntime.d.ts +1 -0
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
- package/dist/sharing/ConsumeSharedPlugin.d.ts +54 -0
- package/dist/sharing/IndependentSharedPlugin.d.ts +37 -0
- package/dist/sharing/ProvideSharedPlugin.d.ts +54 -0
- package/dist/sharing/SharePlugin.d.ts +89 -0
- package/dist/sharing/ShareRuntimePlugin.d.ts +9 -0
- package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
- package/dist/sharing/TreeShakingSharedPlugin.d.ts +19 -0
- package/dist/sharing/utils.d.ts +2 -0
- package/dist/stats/DefaultStatsFactoryPlugin.d.ts +20 -0
- package/dist/stats/DefaultStatsPresetPlugin.d.ts +4 -0
- package/dist/stats/DefaultStatsPrinterPlugin.d.ts +13 -0
- package/dist/stats/StatsFactory.d.ts +57 -0
- package/dist/stats/StatsPrinter.d.ts +57 -0
- package/dist/stats/statsFactoryUtils.d.ts +338 -0
- package/dist/swc.d.ts +7 -0
- package/dist/taps/compilation.d.ts +8 -0
- package/dist/taps/compiler.d.ts +2 -0
- package/dist/taps/contextModuleFactory.d.ts +2 -0
- package/dist/taps/externalModule.d.ts +2 -0
- package/dist/taps/index.d.ts +7 -0
- package/dist/taps/javascriptModules.d.ts +2 -0
- package/dist/taps/normalModuleFactory.d.ts +2 -0
- package/dist/taps/types.d.ts +11 -0
- package/dist/trace/index.d.ts +47 -0
- package/dist/trace/traceHookPlugin.d.ts +5 -0
- package/dist/util/ArrayQueue.d.ts +45 -0
- package/dist/util/AsyncTask.d.ts +7 -0
- package/dist/util/MergeCaller.d.ts +10 -0
- package/dist/util/SizeFormatHelpers.d.ts +10 -0
- package/dist/util/SplitChunkSize.d.ts +5 -0
- package/dist/util/assertNotNil.d.ts +1 -0
- package/dist/util/assetCondition.d.ts +2 -0
- package/dist/util/asyncLib.d.ts +54 -0
- package/dist/util/bindingVersionCheck.d.ts +5 -0
- package/dist/util/cleverMerge.d.ts +24 -0
- package/dist/util/comparators.d.ts +16 -0
- package/dist/util/createHash.d.ts +16 -0
- package/dist/util/createReadonlyMap.d.ts +1 -0
- package/dist/util/fake.d.ts +11 -0
- package/dist/util/fs.d.ts +376 -0
- package/dist/util/hash/index.d.ts +26 -0
- package/dist/util/hash/md4.d.ts +11 -0
- package/dist/util/hash/wasm-hash.d.ts +51 -0
- package/dist/util/hash/xxhash64.d.ts +11 -0
- package/dist/util/identifier.d.ts +57 -0
- package/dist/util/index.d.ts +9 -0
- package/dist/util/memoize.d.ts +2 -0
- package/dist/util/runtime.d.ts +2 -0
- package/dist/util/smartGrouping.d.ts +21 -0
- package/dist/util/source.d.ts +6 -0
- package/dist/util/supportsColor.d.ts +6 -0
- package/dist/util/targetsVersion.d.ts +2 -0
- package/dist/util/validateConfig.d.ts +5 -0
- package/dist/web/JsonpTemplatePlugin.d.ts +13 -0
- package/dist/webworker/WebWorkerTemplatePlugin.d.ts +13 -0
- package/dist/worker.js +971 -0
- package/hot/dev-server.js +76 -0
- package/hot/emitter.js +23 -0
- package/hot/lazy-compilation-node.js +109 -0
- package/hot/lazy-compilation-web.js +97 -0
- package/hot/log-apply-result.js +52 -0
- package/hot/log.js +87 -0
- package/hot/only-dev-server.js +104 -0
- package/hot/poll.js +41 -0
- package/hot/signal.js +68 -0
- package/module.d.ts +310 -0
- package/package.json +79 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
import { log, formatError } from './log.js';
|
|
6
|
+
import { emitter as hotEmitter } from './emitter.js';
|
|
7
|
+
import { logApplyResult } from './log-apply-result.js';
|
|
8
|
+
|
|
9
|
+
if (import.meta.webpackHot) {
|
|
10
|
+
/** @type {undefined|string} */
|
|
11
|
+
var lastHash;
|
|
12
|
+
var upToDate = function upToDate() {
|
|
13
|
+
return /** @type {string} */ (lastHash).indexOf(__webpack_hash__) >= 0;
|
|
14
|
+
};
|
|
15
|
+
var check = function check() {
|
|
16
|
+
import.meta.webpackHot
|
|
17
|
+
.check(true)
|
|
18
|
+
.then(function (updatedModules) {
|
|
19
|
+
if (!updatedModules) {
|
|
20
|
+
log(
|
|
21
|
+
'warning',
|
|
22
|
+
'[HMR] Cannot find update. ' +
|
|
23
|
+
(typeof window !== 'undefined'
|
|
24
|
+
? 'Need to do a full reload!'
|
|
25
|
+
: 'Please reload manually!'),
|
|
26
|
+
);
|
|
27
|
+
log(
|
|
28
|
+
'warning',
|
|
29
|
+
'[HMR] (Probably because of restarting the rspack-dev-server)',
|
|
30
|
+
);
|
|
31
|
+
if (typeof window !== 'undefined') {
|
|
32
|
+
window.location.reload();
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!upToDate()) {
|
|
38
|
+
check();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
logApplyResult(updatedModules, updatedModules);
|
|
42
|
+
|
|
43
|
+
if (upToDate()) {
|
|
44
|
+
log('info', '[HMR] App is up to date.');
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.catch(function (err) {
|
|
48
|
+
var status = import.meta.webpackHot.status();
|
|
49
|
+
if (['abort', 'fail'].indexOf(status) >= 0) {
|
|
50
|
+
log(
|
|
51
|
+
'warning',
|
|
52
|
+
'[HMR] Cannot apply update. ' +
|
|
53
|
+
(typeof window !== 'undefined'
|
|
54
|
+
? 'Need to do a full reload!'
|
|
55
|
+
: 'Please reload manually!'),
|
|
56
|
+
);
|
|
57
|
+
log('warning', '[HMR] ' + formatError(err));
|
|
58
|
+
if (typeof window !== 'undefined') {
|
|
59
|
+
window.location.reload();
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
log('warning', '[HMR] Update failed: ' + formatError(err));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
hotEmitter.on('webpackHotUpdate', function (currentHash) {
|
|
67
|
+
lastHash = currentHash;
|
|
68
|
+
if (!upToDate() && import.meta.webpackHot.status() === 'idle') {
|
|
69
|
+
log('info', '[HMR] Checking for updates on the server...');
|
|
70
|
+
check();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
log('info', '[HMR] Waiting for update signal from WDS...');
|
|
74
|
+
} else {
|
|
75
|
+
throw new Error('[HMR] Hot Module Replacement is disabled.');
|
|
76
|
+
}
|
package/hot/emitter.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function EventEmitter() {
|
|
2
|
+
this.events = {};
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
EventEmitter.prototype.on = function (eventName, callback) {
|
|
6
|
+
if (!this.events[eventName]) {
|
|
7
|
+
this.events[eventName] = [];
|
|
8
|
+
}
|
|
9
|
+
this.events[eventName].push(callback);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
EventEmitter.prototype.emit = function (eventName) {
|
|
13
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
14
|
+
if (this.events[eventName]) {
|
|
15
|
+
this.events[eventName].forEach(function (callback) {
|
|
16
|
+
callback.apply(null, args);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var emitter = new EventEmitter();
|
|
22
|
+
|
|
23
|
+
export { emitter };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
|
|
3
|
+
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
|
4
|
+
var require = createRequire(import.meta.url);
|
|
5
|
+
var compiling = new Set();
|
|
6
|
+
var errorHandlers = new Set();
|
|
7
|
+
|
|
8
|
+
/** @type {import("http").ClientRequest | undefined} */
|
|
9
|
+
var pendingRequest;
|
|
10
|
+
/** @type {boolean} */
|
|
11
|
+
var hasPendingUpdate = false;
|
|
12
|
+
|
|
13
|
+
function sendRequest() {
|
|
14
|
+
if (compiling.size === 0) {
|
|
15
|
+
hasPendingUpdate = false;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var modules = Array.from(compiling);
|
|
20
|
+
var data = modules.join('\n');
|
|
21
|
+
|
|
22
|
+
var httpModule = urlBase.startsWith('https')
|
|
23
|
+
? require('https')
|
|
24
|
+
: require('http');
|
|
25
|
+
|
|
26
|
+
var request = httpModule.request(
|
|
27
|
+
urlBase,
|
|
28
|
+
{
|
|
29
|
+
method: 'POST',
|
|
30
|
+
agent: false,
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'text/plain',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
function (res) {
|
|
36
|
+
pendingRequest = undefined;
|
|
37
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
38
|
+
var error = new Error(
|
|
39
|
+
'Problem communicating active modules to the server: HTTP ' +
|
|
40
|
+
res.statusCode,
|
|
41
|
+
);
|
|
42
|
+
errorHandlers.forEach(function (onError) {
|
|
43
|
+
onError(error);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Consume response data to free up memory
|
|
47
|
+
res.resume();
|
|
48
|
+
if (hasPendingUpdate) {
|
|
49
|
+
hasPendingUpdate = false;
|
|
50
|
+
sendRequest();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
pendingRequest = request;
|
|
56
|
+
|
|
57
|
+
request.on('error', function (err) {
|
|
58
|
+
pendingRequest = undefined;
|
|
59
|
+
var error = new Error(
|
|
60
|
+
'Problem communicating active modules to the server: ' + err.message,
|
|
61
|
+
);
|
|
62
|
+
errorHandlers.forEach(function (onError) {
|
|
63
|
+
onError(error);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
request.write(data);
|
|
68
|
+
request.end();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function sendActiveRequest() {
|
|
72
|
+
hasPendingUpdate = true;
|
|
73
|
+
|
|
74
|
+
// If no request is pending, start one
|
|
75
|
+
if (!pendingRequest) {
|
|
76
|
+
hasPendingUpdate = false;
|
|
77
|
+
sendRequest();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
|
|
83
|
+
* @returns {() => void} function to destroy response
|
|
84
|
+
*/
|
|
85
|
+
export const activate = function (options) {
|
|
86
|
+
var data = options.data;
|
|
87
|
+
var onError = options.onError;
|
|
88
|
+
var active = options.active;
|
|
89
|
+
var module = options.module;
|
|
90
|
+
|
|
91
|
+
errorHandlers.add(onError);
|
|
92
|
+
|
|
93
|
+
if (!compiling.has(data)) {
|
|
94
|
+
compiling.add(data);
|
|
95
|
+
sendActiveRequest();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!active && !module.hot) {
|
|
99
|
+
console.log(
|
|
100
|
+
'Hot Module Replacement is not enabled. Waiting for process restart...',
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return function () {
|
|
105
|
+
errorHandlers.delete(onError);
|
|
106
|
+
compiling.delete(data);
|
|
107
|
+
sendActiveRequest();
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2
|
+
throw new Error(
|
|
3
|
+
"Environment doesn't support lazy compilation (requires XMLHttpRequest)",
|
|
4
|
+
);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
|
8
|
+
var compiling = new Set();
|
|
9
|
+
var errorHandlers = new Set();
|
|
10
|
+
|
|
11
|
+
/** @type {XMLHttpRequest | undefined} */
|
|
12
|
+
var pendingXhr;
|
|
13
|
+
/** @type {boolean} */
|
|
14
|
+
var hasPendingUpdate = false;
|
|
15
|
+
|
|
16
|
+
var sendRequest = function sendRequest() {
|
|
17
|
+
if (compiling.size === 0) {
|
|
18
|
+
hasPendingUpdate = false;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var modules = Array.from(compiling);
|
|
23
|
+
var data = modules.join('\n');
|
|
24
|
+
|
|
25
|
+
var xhr = new XMLHttpRequest();
|
|
26
|
+
pendingXhr = xhr;
|
|
27
|
+
xhr.open('POST', urlBase, true);
|
|
28
|
+
// text/plain Content-Type is simple request header
|
|
29
|
+
xhr.setRequestHeader('Content-Type', 'text/plain');
|
|
30
|
+
|
|
31
|
+
xhr.onreadystatechange = function () {
|
|
32
|
+
if (xhr.readyState === 4) {
|
|
33
|
+
pendingXhr = undefined;
|
|
34
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
35
|
+
var error = new Error(
|
|
36
|
+
'Problem communicating active modules to the server: HTTP ' +
|
|
37
|
+
xhr.status,
|
|
38
|
+
);
|
|
39
|
+
errorHandlers.forEach(function (onError) {
|
|
40
|
+
onError(error);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (hasPendingUpdate) {
|
|
44
|
+
hasPendingUpdate = false;
|
|
45
|
+
sendRequest();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
xhr.onerror = function () {
|
|
51
|
+
pendingXhr = undefined;
|
|
52
|
+
var error = new Error('Problem communicating active modules to the server');
|
|
53
|
+
errorHandlers.forEach(function (onError) {
|
|
54
|
+
onError(error);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
xhr.send(data);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function sendActiveRequest() {
|
|
62
|
+
hasPendingUpdate = true;
|
|
63
|
+
|
|
64
|
+
// If no request is pending, start one
|
|
65
|
+
if (!pendingXhr) {
|
|
66
|
+
hasPendingUpdate = false;
|
|
67
|
+
sendRequest();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
|
|
73
|
+
* @returns {() => void} function to destroy response
|
|
74
|
+
*/
|
|
75
|
+
export const activate = function (options) {
|
|
76
|
+
var data = options.data;
|
|
77
|
+
var onError = options.onError;
|
|
78
|
+
var active = options.active;
|
|
79
|
+
errorHandlers.add(onError);
|
|
80
|
+
|
|
81
|
+
if (!compiling.has(data)) {
|
|
82
|
+
compiling.add(data);
|
|
83
|
+
sendActiveRequest();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!active && !import.meta.webpackHot) {
|
|
87
|
+
console.log(
|
|
88
|
+
'Hot Module Replacement is not enabled. Waiting for process restart...',
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return function () {
|
|
93
|
+
errorHandlers.delete(onError);
|
|
94
|
+
compiling.delete(data);
|
|
95
|
+
sendActiveRequest();
|
|
96
|
+
};
|
|
97
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { log, groupCollapsed, groupEnd } from './log.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {(string | number)[]} updatedModules updated modules
|
|
10
|
+
* @param {(string | number)[] | null} renewedModules renewed modules
|
|
11
|
+
*/
|
|
12
|
+
function logApplyResult(updatedModules, renewedModules) {
|
|
13
|
+
var unacceptedModules = updatedModules.filter(function (moduleId) {
|
|
14
|
+
return renewedModules && renewedModules.indexOf(moduleId) < 0;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (unacceptedModules.length > 0) {
|
|
18
|
+
log(
|
|
19
|
+
'warning',
|
|
20
|
+
"[HMR] The following modules couldn't be hot updated: (They would need a full reload!)",
|
|
21
|
+
);
|
|
22
|
+
unacceptedModules.forEach(function (moduleId) {
|
|
23
|
+
log('warning', '[HMR] - ' + moduleId);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!renewedModules || renewedModules.length === 0) {
|
|
28
|
+
log('info', '[HMR] Nothing hot updated.');
|
|
29
|
+
} else {
|
|
30
|
+
log('info', '[HMR] Updated modules:');
|
|
31
|
+
renewedModules.forEach(function (moduleId) {
|
|
32
|
+
if (typeof moduleId === 'string' && moduleId.indexOf('!') !== -1) {
|
|
33
|
+
var parts = moduleId.split('!');
|
|
34
|
+
groupCollapsed('info', '[HMR] - ' + parts.pop());
|
|
35
|
+
log('info', '[HMR] - ' + moduleId);
|
|
36
|
+
groupEnd('info');
|
|
37
|
+
} else {
|
|
38
|
+
log('info', '[HMR] - ' + moduleId);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var numberIds = renewedModules.every(function (moduleId) {
|
|
42
|
+
return typeof moduleId === 'number';
|
|
43
|
+
});
|
|
44
|
+
if (numberIds)
|
|
45
|
+
log(
|
|
46
|
+
'info',
|
|
47
|
+
'[HMR] Consider using the optimization.moduleIds: "named" for module names.',
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { logApplyResult };
|
package/hot/log.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** @typedef {"info" | "warning" | "error"} LogLevel */
|
|
2
|
+
|
|
3
|
+
/** @type {LogLevel} */
|
|
4
|
+
var logLevel = 'info';
|
|
5
|
+
|
|
6
|
+
function dummy() {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {LogLevel} level log level
|
|
10
|
+
* @returns {boolean} true, if should log
|
|
11
|
+
*/
|
|
12
|
+
function shouldLog(level) {
|
|
13
|
+
var shouldLog =
|
|
14
|
+
(logLevel === 'info' && level === 'info') ||
|
|
15
|
+
(['info', 'warning'].indexOf(logLevel) >= 0 && level === 'warning') ||
|
|
16
|
+
(['info', 'warning', 'error'].indexOf(logLevel) >= 0 && level === 'error');
|
|
17
|
+
return shouldLog;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {(msg?: string) => void} logFn log function
|
|
22
|
+
* @returns {(level: LogLevel, msg?: string) => void} function that logs when log level is sufficient
|
|
23
|
+
*/
|
|
24
|
+
function logGroup(logFn) {
|
|
25
|
+
return function (level, msg) {
|
|
26
|
+
if (shouldLog(level)) {
|
|
27
|
+
logFn(msg);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {LogLevel} level log level
|
|
34
|
+
* @param {string|Error} msg message
|
|
35
|
+
*/
|
|
36
|
+
function log(level, msg) {
|
|
37
|
+
if (shouldLog(level)) {
|
|
38
|
+
if (level === 'info') {
|
|
39
|
+
console.log(msg);
|
|
40
|
+
} else if (level === 'warning') {
|
|
41
|
+
console.warn(msg);
|
|
42
|
+
} else if (level === 'error') {
|
|
43
|
+
console.error(msg);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var consoleGroup = console.group || dummy;
|
|
49
|
+
var consoleGroupCollapsed = console.groupCollapsed || dummy;
|
|
50
|
+
var consoleGroupEnd = console.groupEnd || dummy;
|
|
51
|
+
|
|
52
|
+
export var group = logGroup(consoleGroup);
|
|
53
|
+
|
|
54
|
+
export var groupCollapsed = logGroup(consoleGroupCollapsed);
|
|
55
|
+
|
|
56
|
+
export var groupEnd = logGroup(consoleGroupEnd);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {LogLevel} level log level
|
|
60
|
+
*/
|
|
61
|
+
export var setLogLevel = function (level) {
|
|
62
|
+
logLevel = level;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {Error} err error
|
|
67
|
+
* @returns {string} formatted error
|
|
68
|
+
*/
|
|
69
|
+
export var formatError = function (err) {
|
|
70
|
+
var message = err.message;
|
|
71
|
+
var stack = err.stack;
|
|
72
|
+
if (!stack) {
|
|
73
|
+
return message;
|
|
74
|
+
} else if (stack.indexOf(message) < 0) {
|
|
75
|
+
return message + '\n' + stack;
|
|
76
|
+
} else {
|
|
77
|
+
return stack;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
log.group = group;
|
|
82
|
+
log.groupCollapsed = groupCollapsed;
|
|
83
|
+
log.groupEnd = groupEnd;
|
|
84
|
+
log.setLogLevel = setLogLevel;
|
|
85
|
+
log.formatError = formatError;
|
|
86
|
+
|
|
87
|
+
export { log };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
import { log, formatError } from './log.js';
|
|
6
|
+
import { emitter as hotEmitter } from './emitter.js';
|
|
7
|
+
import { logApplyResult } from './log-apply-result.js';
|
|
8
|
+
|
|
9
|
+
if (import.meta.webpackHot) {
|
|
10
|
+
/** @type {undefined|string} */
|
|
11
|
+
var lastHash;
|
|
12
|
+
var upToDate = function upToDate() {
|
|
13
|
+
return /** @type {string} */ (lastHash).indexOf(__webpack_hash__) >= 0;
|
|
14
|
+
};
|
|
15
|
+
var check = function check() {
|
|
16
|
+
import.meta.webpackHot
|
|
17
|
+
.check()
|
|
18
|
+
.then(function (updatedModules) {
|
|
19
|
+
if (!updatedModules) {
|
|
20
|
+
log('warning', '[HMR] Cannot find update. Need to do a full reload!');
|
|
21
|
+
log(
|
|
22
|
+
'warning',
|
|
23
|
+
'[HMR] (Probably because of restarting the rspack-dev-server)',
|
|
24
|
+
);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return import.meta.webpackHot
|
|
29
|
+
.apply({
|
|
30
|
+
ignoreUnaccepted: true,
|
|
31
|
+
ignoreDeclined: true,
|
|
32
|
+
ignoreErrored: true,
|
|
33
|
+
onUnaccepted: function (data) {
|
|
34
|
+
log(
|
|
35
|
+
'warning',
|
|
36
|
+
'Ignored an update to unaccepted module ' +
|
|
37
|
+
data.chain.join(' -> '),
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
onDeclined: function (data) {
|
|
41
|
+
log(
|
|
42
|
+
'warning',
|
|
43
|
+
'Ignored an update to declined module ' +
|
|
44
|
+
data.chain.join(' -> '),
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
onErrored: function (data) {
|
|
48
|
+
log('error', data.error);
|
|
49
|
+
log(
|
|
50
|
+
'warning',
|
|
51
|
+
'Ignored an error while updating module ' +
|
|
52
|
+
data.moduleId +
|
|
53
|
+
' (' +
|
|
54
|
+
data.type +
|
|
55
|
+
')',
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
.then(function (renewedModules) {
|
|
60
|
+
if (!upToDate()) {
|
|
61
|
+
check();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
logApplyResult(updatedModules, renewedModules);
|
|
65
|
+
|
|
66
|
+
if (upToDate()) {
|
|
67
|
+
log('info', '[HMR] App is up to date.');
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
})
|
|
71
|
+
.catch(function (err) {
|
|
72
|
+
var status = import.meta.webpackHot.status();
|
|
73
|
+
if (['abort', 'fail'].indexOf(status) >= 0) {
|
|
74
|
+
log(
|
|
75
|
+
'warning',
|
|
76
|
+
'[HMR] Cannot check for update. Need to do a full reload!',
|
|
77
|
+
);
|
|
78
|
+
log('warning', '[HMR] ' + formatError(err));
|
|
79
|
+
} else {
|
|
80
|
+
log('warning', '[HMR] Update check failed: ' + formatError(err));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
hotEmitter.on('webpackHotUpdate', function (currentHash) {
|
|
85
|
+
lastHash = currentHash;
|
|
86
|
+
if (!upToDate()) {
|
|
87
|
+
var status = import.meta.webpackHot.status();
|
|
88
|
+
if (status === 'idle') {
|
|
89
|
+
log('info', '[HMR] Checking for updates on the server...');
|
|
90
|
+
check();
|
|
91
|
+
} else if (['abort', 'fail'].indexOf(status) >= 0) {
|
|
92
|
+
log(
|
|
93
|
+
'warning',
|
|
94
|
+
'[HMR] Cannot apply update as a previous update ' +
|
|
95
|
+
status +
|
|
96
|
+
'ed. Need to do a full reload!',
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
log('info', '[HMR] Waiting for update signal from WDS...');
|
|
102
|
+
} else {
|
|
103
|
+
throw new Error('[HMR] Hot Module Replacement is disabled.');
|
|
104
|
+
}
|
package/hot/poll.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
import { log, formatError } from './log.js';
|
|
6
|
+
import { logApplyResult } from './log-apply-result.js';
|
|
7
|
+
|
|
8
|
+
if (import.meta.webpackHot) {
|
|
9
|
+
var hotPollInterval = +__resourceQuery.slice(1) || 10 * 60 * 1000;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {boolean=} fromUpdate true when called from update
|
|
13
|
+
*/
|
|
14
|
+
var checkForUpdate = function checkForUpdate(fromUpdate) {
|
|
15
|
+
if (import.meta.webpackHot.status() === 'idle') {
|
|
16
|
+
import.meta.webpackHot
|
|
17
|
+
.check(true)
|
|
18
|
+
.then(function (updatedModules) {
|
|
19
|
+
if (!updatedModules) {
|
|
20
|
+
if (fromUpdate) log('info', '[HMR] Update applied.');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
logApplyResult(updatedModules, updatedModules);
|
|
24
|
+
checkForUpdate(true);
|
|
25
|
+
})
|
|
26
|
+
.catch(function (err) {
|
|
27
|
+
var status = import.meta.webpackHot.status();
|
|
28
|
+
if (['abort', 'fail'].indexOf(status) >= 0) {
|
|
29
|
+
log('warning', '[HMR] Cannot apply update.');
|
|
30
|
+
log('warning', '[HMR] ' + formatError(err));
|
|
31
|
+
log('warning', '[HMR] You need to restart the application!');
|
|
32
|
+
} else {
|
|
33
|
+
log('warning', '[HMR] Update failed: ' + formatError(err));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
setInterval(checkForUpdate, hotPollInterval);
|
|
39
|
+
} else {
|
|
40
|
+
throw new Error('[HMR] Hot Module Replacement is disabled.');
|
|
41
|
+
}
|
package/hot/signal.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
import { log, formatError } from './log.js';
|
|
6
|
+
import { logApplyResult } from './log-apply-result.js';
|
|
7
|
+
|
|
8
|
+
if (import.meta.webpackHot) {
|
|
9
|
+
/**
|
|
10
|
+
* @param {boolean=} fromUpdate true when called from update
|
|
11
|
+
*/
|
|
12
|
+
var checkForUpdate = function checkForUpdate(fromUpdate) {
|
|
13
|
+
import.meta.webpackHot
|
|
14
|
+
.check()
|
|
15
|
+
.then(function (updatedModules) {
|
|
16
|
+
if (!updatedModules) {
|
|
17
|
+
if (fromUpdate) log('info', '[HMR] Update applied.');
|
|
18
|
+
else log('warning', '[HMR] Cannot find update.');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return import.meta.webpackHot
|
|
23
|
+
.apply({
|
|
24
|
+
ignoreUnaccepted: true,
|
|
25
|
+
onUnaccepted: function (data) {
|
|
26
|
+
log(
|
|
27
|
+
'warning',
|
|
28
|
+
'Ignored an update to unaccepted module ' +
|
|
29
|
+
data.chain.join(' -> '),
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
.then(function (renewedModules) {
|
|
34
|
+
logApplyResult(updatedModules, renewedModules);
|
|
35
|
+
|
|
36
|
+
checkForUpdate(true);
|
|
37
|
+
return null;
|
|
38
|
+
});
|
|
39
|
+
})
|
|
40
|
+
.catch(function (err) {
|
|
41
|
+
var status = import.meta.webpackHot.status();
|
|
42
|
+
if (['abort', 'fail'].indexOf(status) >= 0) {
|
|
43
|
+
log('warning', '[HMR] Cannot apply update.');
|
|
44
|
+
log('warning', '[HMR] ' + formatError(err));
|
|
45
|
+
log('warning', '[HMR] You need to restart the application!');
|
|
46
|
+
} else {
|
|
47
|
+
log('warning', '[HMR] Update failed: ' + (err.stack || err.message));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
process.on(__resourceQuery.slice(1) || 'SIGUSR2', function () {
|
|
53
|
+
if (import.meta.webpackHot.status() !== 'idle') {
|
|
54
|
+
log(
|
|
55
|
+
'warning',
|
|
56
|
+
'[HMR] Got signal but currently in ' +
|
|
57
|
+
import.meta.webpackHot.status() +
|
|
58
|
+
' state.',
|
|
59
|
+
);
|
|
60
|
+
log('warning', '[HMR] Need to be in idle state to start hot update.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
checkForUpdate();
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error('[HMR] Hot Module Replacement is disabled.');
|
|
68
|
+
}
|