From 148c4be6e61171b6c0059597f049bdb3479b4d3c Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Sun, 12 Jan 2020 22:06:01 +0530 Subject: [PATCH 1/5] get rid of some hacks in declarations file for webpack-4 --- declarations.d.ts | 32 -------------------------------- declarations/WebpackOptions.d.ts | 4 ++-- schemas/WebpackOptions.json | 6 ++---- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/declarations.d.ts b/declarations.d.ts index 83b612e4cad..770212b6768 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -228,36 +228,4 @@ declare module "@webassemblyjs/ast" { export function isFuncImportDescr(n: Node): boolean; } -// This "hack" is needed because typescript doesn't support recursive type definitions -// It's referenced from "ruleSet-conditions" in schemas/WebpackOptions.json -interface RuleSetConditionsRecursive - extends Array {} -interface RuleSetConditionsAbsoluteRecursive - extends Array< - import("./declarations/WebpackOptions").RuleSetConditionAbsolute - > {} - -/** - * Global variable declarations - * @todo Once this issue is resolved, remove these globals and add JSDoc onsite instead - * https://github.com/Microsoft/TypeScript/issues/15626 - */ -declare const $hash$; -declare const $requestTimeout$; -declare const installedModules; -declare const $require$; -declare const hotDownloadManifest; -declare const hotDownloadUpdateChunk; -declare const hotDisposeChunk; -declare const modules; -declare const installedChunks; -declare const hotAddUpdateChunk; -declare const parentHotUpdateCallback; -declare const $hotChunkFilename$; -declare const $hotMainFilename$; -declare namespace WebAssembly {} -declare const importScripts; -declare const $crossOriginLoading$; -declare const chunkId; - type TODO = any; diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 57f9df076c3..a0bdde054d1 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -132,7 +132,7 @@ export type RuleSetCondition = * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "RuleSetConditions". */ -export type RuleSetConditions = RuleSetConditionsRecursive; +export type RuleSetConditions = RuleSetCondition[] /** * One or multiple rule conditions * @@ -181,7 +181,7 @@ export type RuleSetConditionAbsolute = * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "RuleSetConditionsAbsolute". */ -export type RuleSetConditionsAbsolute = RuleSetConditionsAbsoluteRecursive; +export type RuleSetConditionsAbsolute = RuleSetConditionAbsolute[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "RuleSetLoader". diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 310e3388085..1fd61706d84 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -1428,8 +1428,7 @@ "$ref": "#/definitions/RuleSetCondition" } ] - }, - "tsType": "RuleSetConditionsRecursive" + } }, "RuleSetConditionsAbsolute": { "type": "array", @@ -1440,8 +1439,7 @@ "$ref": "#/definitions/RuleSetConditionAbsolute" } ] - }, - "tsType": "RuleSetConditionsAbsoluteRecursive" + } }, "RuleSetLoader": { "type": "string", From 23941366d99553ef4a78f03f6b947bb47f912fd9 Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Tue, 14 Jan 2020 09:55:09 +0530 Subject: [PATCH 2/5] added variable declarations in files where required --- lib/HotModuleReplacement.runtime.js | 6 ++++++ lib/node/NodeMainTemplate.runtime.js | 5 +++++ lib/node/NodeMainTemplateAsync.runtime.js | 7 +++++++ lib/web/JsonpMainTemplate.runtime.js | 8 ++++++++ lib/webworker/WebWorkerMainTemplate.runtime.js | 9 +++++++++ 5 files changed, 35 insertions(+) diff --git a/lib/HotModuleReplacement.runtime.js b/lib/HotModuleReplacement.runtime.js index 5756623e629..3082fcbb055 100644 --- a/lib/HotModuleReplacement.runtime.js +++ b/lib/HotModuleReplacement.runtime.js @@ -3,6 +3,12 @@ Author Tobias Koppers @sokra */ /*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */ + +var $hash$ = undefined; +var $requestTimeout$ = undefined; +var installedModules = undefined; +var $require$ = undefined; + module.exports = function() { var hotApplyOnUpdate = true; // eslint-disable-next-line no-unused-vars diff --git a/lib/node/NodeMainTemplate.runtime.js b/lib/node/NodeMainTemplate.runtime.js index d34388bf76f..2f83631f80c 100644 --- a/lib/node/NodeMainTemplate.runtime.js +++ b/lib/node/NodeMainTemplate.runtime.js @@ -3,6 +3,11 @@ Author Tobias Koppers @sokra */ /*global installedChunks $hotChunkFilename$ hotAddUpdateChunk $hotMainFilename$ */ + +var $hotChunkFilename$ = undefined; +var hotAddUpdateChunk = undefined; +var installedChunks = undefined; + module.exports = function() { // eslint-disable-next-line no-unused-vars function hotDownloadUpdateChunk(chunkId) { diff --git a/lib/node/NodeMainTemplateAsync.runtime.js b/lib/node/NodeMainTemplateAsync.runtime.js index 35eb47b665e..560a3cf597f 100644 --- a/lib/node/NodeMainTemplateAsync.runtime.js +++ b/lib/node/NodeMainTemplateAsync.runtime.js @@ -3,6 +3,13 @@ Author Tobias Koppers @sokra */ /*global installedChunks $hotChunkFilename$ $require$ hotAddUpdateChunk $hotMainFilename$ */ + +var $hotChunkFilename$ = undefined; +var $require$ = undefined; +var hotAddUpdateChunk = undefined; +var $hotMainFilename$ = undefined; +var installedChunks = undefined; + module.exports = function() { // eslint-disable-next-line no-unused-vars function hotDownloadUpdateChunk(chunkId) { diff --git a/lib/web/JsonpMainTemplate.runtime.js b/lib/web/JsonpMainTemplate.runtime.js index 58dcf8312f1..c676dd8b7bc 100644 --- a/lib/web/JsonpMainTemplate.runtime.js +++ b/lib/web/JsonpMainTemplate.runtime.js @@ -3,6 +3,14 @@ Author Tobias Koppers @sokra */ /*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ $crossOriginLoading$ */ + +var hotAddUpdateChunk = undefined; +var parentHotUpdateCallback = undefined; +var $require$ = undefined; +var $hotMainFilename$ = undefined; +var $hotChunkFilename$ = undefined; +var $crossOriginLoading$ = undefined; + module.exports = function() { // eslint-disable-next-line no-unused-vars function webpackHotUpdateCallback(chunkId, moreModules) { diff --git a/lib/webworker/WebWorkerMainTemplate.runtime.js b/lib/webworker/WebWorkerMainTemplate.runtime.js index 8c63f7729e3..891edffd053 100644 --- a/lib/webworker/WebWorkerMainTemplate.runtime.js +++ b/lib/webworker/WebWorkerMainTemplate.runtime.js @@ -3,6 +3,15 @@ Author Tobias Koppers @sokra */ /*globals installedChunks hotAddUpdateChunk parentHotUpdateCallback importScripts XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */ + +var hotAddUpdateChunk = undefined; +var parentHotUpdateCallback = undefined; +var $require$ = undefined; +var $hotChunkFilename$ = undefined; +var $hotMainFilename$ = undefined; +var installedChunks = undefined; +var importScripts = undefined; + module.exports = function() { // eslint-disable-next-line no-unused-vars function webpackHotUpdateCallback(chunkId, moreModules) { From 4bb706fbd6b90e32396ee973180eef89ce43db88 Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Tue, 14 Jan 2020 10:18:17 +0530 Subject: [PATCH 3/5] Fix lint issue --- lib/HotModuleReplacement.runtime.js | 7 +++++-- lib/node/NodeMainTemplate.runtime.js | 4 ++-- lib/node/NodeMainTemplateAsync.runtime.js | 3 +-- lib/web/JsonpMainTemplate.runtime.js | 5 ++--- lib/webworker/WebWorkerMainTemplate.runtime.js | 3 +-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/HotModuleReplacement.runtime.js b/lib/HotModuleReplacement.runtime.js index 3082fcbb055..678a60ddc8d 100644 --- a/lib/HotModuleReplacement.runtime.js +++ b/lib/HotModuleReplacement.runtime.js @@ -2,12 +2,15 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -/*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */ - +// eslint-disable no-unused-vars var $hash$ = undefined; var $requestTimeout$ = undefined; var installedModules = undefined; var $require$ = undefined; +var hotDownloadManifest = undefined; +var hotDownloadUpdateChunk = undefined; +var hotDisposeChunk = undefined; +var modules = undefined; module.exports = function() { var hotApplyOnUpdate = true; diff --git a/lib/node/NodeMainTemplate.runtime.js b/lib/node/NodeMainTemplate.runtime.js index 2f83631f80c..0880124b2d0 100644 --- a/lib/node/NodeMainTemplate.runtime.js +++ b/lib/node/NodeMainTemplate.runtime.js @@ -2,11 +2,11 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -/*global installedChunks $hotChunkFilename$ hotAddUpdateChunk $hotMainFilename$ */ - +// eslint-disable-next-line no-unused-vars var $hotChunkFilename$ = undefined; var hotAddUpdateChunk = undefined; var installedChunks = undefined; +var $hotMainFilename$ = undefined; module.exports = function() { // eslint-disable-next-line no-unused-vars diff --git a/lib/node/NodeMainTemplateAsync.runtime.js b/lib/node/NodeMainTemplateAsync.runtime.js index 560a3cf597f..a021f5a0d4e 100644 --- a/lib/node/NodeMainTemplateAsync.runtime.js +++ b/lib/node/NodeMainTemplateAsync.runtime.js @@ -2,8 +2,7 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -/*global installedChunks $hotChunkFilename$ $require$ hotAddUpdateChunk $hotMainFilename$ */ - +// eslint-disable-next-line no-unused-vars var $hotChunkFilename$ = undefined; var $require$ = undefined; var hotAddUpdateChunk = undefined; diff --git a/lib/web/JsonpMainTemplate.runtime.js b/lib/web/JsonpMainTemplate.runtime.js index c676dd8b7bc..cbaa01ef7aa 100644 --- a/lib/web/JsonpMainTemplate.runtime.js +++ b/lib/web/JsonpMainTemplate.runtime.js @@ -2,11 +2,10 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ $crossOriginLoading$ */ - +// eslint-disable-next-line no-unused-vars var hotAddUpdateChunk = undefined; var parentHotUpdateCallback = undefined; -var $require$ = undefined; +var $require$ = undefined; var $hotMainFilename$ = undefined; var $hotChunkFilename$ = undefined; var $crossOriginLoading$ = undefined; diff --git a/lib/webworker/WebWorkerMainTemplate.runtime.js b/lib/webworker/WebWorkerMainTemplate.runtime.js index 891edffd053..aa240b2246c 100644 --- a/lib/webworker/WebWorkerMainTemplate.runtime.js +++ b/lib/webworker/WebWorkerMainTemplate.runtime.js @@ -2,8 +2,7 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -/*globals installedChunks hotAddUpdateChunk parentHotUpdateCallback importScripts XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */ - +// eslint-disable-next-line no-unused-vars var hotAddUpdateChunk = undefined; var parentHotUpdateCallback = undefined; var $require$ = undefined; From 2101892e3c3ee435d2ef2be7a42482413970ccc8 Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Tue, 14 Jan 2020 10:23:28 +0530 Subject: [PATCH 4/5] add chunkid declaration --- lib/HotModuleReplacement.runtime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/HotModuleReplacement.runtime.js b/lib/HotModuleReplacement.runtime.js index 678a60ddc8d..8427189b30a 100644 --- a/lib/HotModuleReplacement.runtime.js +++ b/lib/HotModuleReplacement.runtime.js @@ -11,6 +11,7 @@ var hotDownloadManifest = undefined; var hotDownloadUpdateChunk = undefined; var hotDisposeChunk = undefined; var modules = undefined; +var chunkId = undefined; module.exports = function() { var hotApplyOnUpdate = true; @@ -213,7 +214,6 @@ module.exports = function() { /*foreachInstalledChunks*/ // eslint-disable-next-line no-lone-blocks { - /*globals chunkId */ hotEnsureUpdateChunk(chunkId); } if ( From ef739915c2a88d6d8f8247f0f3c1fb4ba20908d7 Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Wed, 15 Jan 2020 09:32:15 +0530 Subject: [PATCH 5/5] update webpackOption.d.ts --- declarations/WebpackOptions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index a0bdde054d1..372d2b2f6cd 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -132,7 +132,7 @@ export type RuleSetCondition = * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "RuleSetConditions". */ -export type RuleSetConditions = RuleSetCondition[] +export type RuleSetConditions = RuleSetCondition[]; /** * One or multiple rule conditions *