@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +183 -183
- package/CHANGELOG.md +5 -0
- package/README.md +636 -491
- package/bin/cli.js +372 -367
- package/files/eslintrc.js +57 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +16 -9
- package/lib/babel/es-plugins-presets.js +26 -14
- package/lib/common/getEntries.js +31 -22
- package/lib/common/getPublicPathConfig.js +27 -13
- package/lib/common/index.js +21 -25
- package/lib/common/splitChunks.js +62 -53
- package/lib/common/templateParameters.js +10 -8
- package/lib/configs/jest.config.js +15 -25
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -47
- package/lib/configs/webpack.dev.config.js +70 -52
- package/lib/configs/webpack.docs.config.js +106 -106
- package/lib/configs/webpack.prod.config.js +95 -75
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +103 -74
- package/lib/jest/coverageCollector.js +41 -21
- package/lib/jest/jsonMaker.js +15 -16
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +90 -45
- package/lib/jest/run.js +43 -43
- package/lib/jest/setup.js +102 -95
- package/lib/loaderUtils/getCSSLoaders.js +21 -22
- package/lib/loaderUtils/getDevJsLoaders.js +25 -23
- package/lib/loaderUtils/index.js +11 -13
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileLoader.js +33 -35
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +54 -45
- package/lib/middlewares/SSTMiddleware.js +8 -5
- package/lib/pluginUtils/getDevPlugins.js +114 -52
- package/lib/pluginUtils/getDocsPlugins.js +25 -29
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +163 -74
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
- package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +63 -0
- package/lib/plugins/CleanupStatsPlugin.js +18 -32
- package/lib/plugins/CustomAttributePlugin.js +79 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +185 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +52 -63
- package/lib/plugins/ModuleStatsPlugin.js +83 -173
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
- package/lib/plugins/PublicPathChangePlugin.js +175 -284
- package/lib/plugins/ReportGeneratePlugin.js +150 -151
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +81 -57
- package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
- package/lib/plugins/SourceMapHookPlugin.js +21 -33
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
- package/lib/plugins/index.js +100 -91
- package/lib/plugins/webpackwatchrunplugin.js +18 -30
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
- package/lib/schemas/index.js +336 -81
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +84 -91
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +24 -24
- package/lib/servers/scrServer.js +78 -98
- package/lib/servers/server.js +101 -122
- package/lib/servers/ssServer.js +63 -61
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -46
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +6 -4
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +12 -34
- package/lib/utils/copyTimezones.js +9 -16
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +44 -73
- package/lib/utils/cssURLReplacer.js +60 -54
- package/lib/utils/dependencyPostPublish.js +20 -19
- package/lib/utils/fileUtils.js +66 -54
- package/lib/utils/folderIterator.js +20 -21
- package/lib/utils/getComponents.js +70 -27
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +114 -187
- package/lib/utils/getHash.js +9 -13
- package/lib/utils/getIp.js +9 -9
- package/lib/utils/getOptions.js +26 -29
- package/lib/utils/getServerURL.js +19 -10
- package/lib/utils/index.js +147 -126
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -32
- package/lib/utils/jsonHelper.js +37 -21
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +70 -56
- package/lib/utils/mailSender.js +12 -27
- package/lib/utils/pullOrigin.js +21 -18
- package/lib/utils/reinstallDependencies.js +76 -85
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +47 -45
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +22 -29
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +21 -19
- package/lib/utils/switchBranch.js +21 -20
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +141 -136
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/index.html +1493 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,350 +1,269 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = ShadowDOMSupportPlugin;
|
7
7
|
|
8
|
-
var _Template = require(
|
8
|
+
var _Template = _interopRequireDefault(require("webpack/lib/Template"));
|
9
9
|
|
10
|
-
var
|
10
|
+
var _JsonpMainTemplatePlugin = _interopRequireDefault(require("webpack/lib/web/JsonpMainTemplatePlugin"));
|
11
11
|
|
12
|
-
var
|
13
|
-
|
14
|
-
var _JsonpMainTemplatePlugin2 = _interopRequireDefault(_JsonpMainTemplatePlugin);
|
15
|
-
|
16
|
-
var _tapable = require('tapable');
|
12
|
+
var _tapable = require("tapable");
|
17
13
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
15
|
|
16
|
+
/* eslint-disable no-unused-vars */
|
20
17
|
//eslint-disable-next-line
|
21
|
-
function ShadowDOMSupportPlugin() {}
|
18
|
+
function ShadowDOMSupportPlugin() {}
|
22
19
|
|
23
20
|
ShadowDOMSupportPlugin.prototype.apply = function () {
|
24
21
|
this.patchJsonpMainTemplatePlugin();
|
25
22
|
};
|
26
23
|
|
27
24
|
ShadowDOMSupportPlugin.prototype.patchJsonpMainTemplatePlugin = function () {
|
28
|
-
|
25
|
+
_JsonpMainTemplatePlugin.default.prototype.apply = this._apply;
|
29
26
|
};
|
30
27
|
|
31
28
|
ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
try {
|
38
|
-
for (var _iterator = chunk.groupsIterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
39
|
-
var chunkGroup = _step.value;
|
40
|
-
|
41
|
-
if (chunkGroup.getNumberOfChildren() > 0) {
|
42
|
-
return true;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
} catch (err) {
|
46
|
-
_didIteratorError = true;
|
47
|
-
_iteratorError = err;
|
48
|
-
} finally {
|
49
|
-
try {
|
50
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
51
|
-
_iterator.return();
|
52
|
-
}
|
53
|
-
} finally {
|
54
|
-
if (_didIteratorError) {
|
55
|
-
throw _iteratorError;
|
56
|
-
}
|
29
|
+
const needChunkOnDemandLoadingCode = chunk => {
|
30
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
31
|
+
if (chunkGroup.getNumberOfChildren() > 0) {
|
32
|
+
return true;
|
57
33
|
}
|
58
34
|
}
|
59
35
|
|
60
36
|
return false;
|
61
37
|
};
|
62
|
-
var needChunkLoadingCode = function needChunkLoadingCode(chunk) {
|
63
|
-
var _iteratorNormalCompletion2 = true;
|
64
|
-
var _didIteratorError2 = false;
|
65
|
-
var _iteratorError2 = undefined;
|
66
|
-
|
67
|
-
try {
|
68
|
-
for (var _iterator2 = chunk.groupsIterable[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
69
|
-
var chunkGroup = _step2.value;
|
70
38
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
return true;
|
76
|
-
}
|
39
|
+
const needChunkLoadingCode = chunk => {
|
40
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
41
|
+
if (chunkGroup.chunks.length > 1) {
|
42
|
+
return true;
|
77
43
|
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
} finally {
|
82
|
-
try {
|
83
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
84
|
-
_iterator2.return();
|
85
|
-
}
|
86
|
-
} finally {
|
87
|
-
if (_didIteratorError2) {
|
88
|
-
throw _iteratorError2;
|
89
|
-
}
|
44
|
+
|
45
|
+
if (chunkGroup.getNumberOfChildren() > 0) {
|
46
|
+
return true;
|
90
47
|
}
|
91
48
|
}
|
92
49
|
|
93
50
|
return false;
|
94
51
|
};
|
95
|
-
var needEntryDeferringCode = function needEntryDeferringCode(chunk) {
|
96
|
-
var _iteratorNormalCompletion3 = true;
|
97
|
-
var _didIteratorError3 = false;
|
98
|
-
var _iteratorError3 = undefined;
|
99
52
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
if (chunkGroup.chunks.length > 1) {
|
105
|
-
return true;
|
106
|
-
}
|
107
|
-
}
|
108
|
-
} catch (err) {
|
109
|
-
_didIteratorError3 = true;
|
110
|
-
_iteratorError3 = err;
|
111
|
-
} finally {
|
112
|
-
try {
|
113
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
114
|
-
_iterator3.return();
|
115
|
-
}
|
116
|
-
} finally {
|
117
|
-
if (_didIteratorError3) {
|
118
|
-
throw _iteratorError3;
|
119
|
-
}
|
53
|
+
const needEntryDeferringCode = chunk => {
|
54
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
55
|
+
if (chunkGroup.chunks.length > 1) {
|
56
|
+
return true;
|
120
57
|
}
|
121
58
|
}
|
122
59
|
|
123
60
|
return false;
|
124
61
|
};
|
125
|
-
|
126
|
-
|
62
|
+
|
63
|
+
const needPrefetchingCode = chunk => {
|
64
|
+
const allPrefetchChunks = chunk.getChildIdsByOrdersMap(true).prefetch;
|
127
65
|
return allPrefetchChunks && Object.keys(allPrefetchChunks).length;
|
128
|
-
};
|
66
|
+
}; // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
|
129
67
|
|
130
|
-
|
131
|
-
['jsonpScript', 'linkPreload', 'linkPrefetch'].forEach(
|
68
|
+
|
69
|
+
['jsonpScript', 'linkPreload', 'linkPrefetch'].forEach(hook => {
|
132
70
|
if (!mainTemplate.hooks[hook]) {
|
133
71
|
mainTemplate.hooks[hook] = new _tapable.SyncWaterfallHook(['source', 'chunk', 'hash']);
|
134
72
|
}
|
135
73
|
});
|
136
74
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
75
|
+
const getScriptSrcPath = (hash, chunk, chunkIdExpression) => {
|
76
|
+
const {
|
77
|
+
chunkFilename
|
78
|
+
} = mainTemplate.outputOptions;
|
79
|
+
const chunkMaps = chunk.getChunkMaps();
|
141
80
|
return mainTemplate.getAssetPath(JSON.stringify(chunkFilename), {
|
142
|
-
hash:
|
143
|
-
hashWithLength:
|
144
|
-
return '" + ' + mainTemplate.renderCurrentHashCode(hash, length) + ' + "';
|
145
|
-
},
|
81
|
+
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
82
|
+
hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
146
83
|
chunk: {
|
147
|
-
id:
|
148
|
-
hash:
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
for (var _iterator4 = Object.keys(chunkMaps.hash)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
157
|
-
var chunkId = _step4.value;
|
158
|
-
|
159
|
-
if (typeof chunkMaps.hash[chunkId] === 'string') {
|
160
|
-
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
161
|
-
}
|
162
|
-
}
|
163
|
-
} catch (err) {
|
164
|
-
_didIteratorError4 = true;
|
165
|
-
_iteratorError4 = err;
|
166
|
-
} finally {
|
167
|
-
try {
|
168
|
-
if (!_iteratorNormalCompletion4 && _iterator4.return) {
|
169
|
-
_iterator4.return();
|
170
|
-
}
|
171
|
-
} finally {
|
172
|
-
if (_didIteratorError4) {
|
173
|
-
throw _iteratorError4;
|
174
|
-
}
|
84
|
+
id: `" + ${chunkIdExpression} + "`,
|
85
|
+
hash: `" + ${JSON.stringify(chunkMaps.hash)}[${chunkIdExpression}] + "`,
|
86
|
+
|
87
|
+
hashWithLength(length) {
|
88
|
+
const shortChunkHashMap = Object.create(null);
|
89
|
+
|
90
|
+
for (const chunkId of Object.keys(chunkMaps.hash)) {
|
91
|
+
if (typeof chunkMaps.hash[chunkId] === 'string') {
|
92
|
+
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
175
93
|
}
|
176
94
|
}
|
177
95
|
|
178
|
-
return
|
96
|
+
return `" + ${JSON.stringify(shortChunkHashMap)}[${chunkIdExpression}] + "`;
|
179
97
|
},
|
180
98
|
|
181
|
-
name:
|
99
|
+
name: `" + (${JSON.stringify(chunkMaps.name)}[${chunkIdExpression}]||${chunkIdExpression}) + "`,
|
182
100
|
contentHash: {
|
183
|
-
javascript:
|
101
|
+
javascript: `" + ${JSON.stringify(chunkMaps.contentHash.javascript)}[${chunkIdExpression}] + "`
|
184
102
|
},
|
185
103
|
contentHashWithLength: {
|
186
|
-
javascript:
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
try {
|
194
|
-
for (var _iterator5 = Object.keys(contentHash)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
195
|
-
var chunkId = _step5.value;
|
196
|
-
|
197
|
-
if (typeof contentHash[chunkId] === 'string') {
|
198
|
-
shortContentHashMap[chunkId] = contentHash[chunkId].substr(0, length);
|
199
|
-
}
|
200
|
-
}
|
201
|
-
} catch (err) {
|
202
|
-
_didIteratorError5 = true;
|
203
|
-
_iteratorError5 = err;
|
204
|
-
} finally {
|
205
|
-
try {
|
206
|
-
if (!_iteratorNormalCompletion5 && _iterator5.return) {
|
207
|
-
_iterator5.return();
|
208
|
-
}
|
209
|
-
} finally {
|
210
|
-
if (_didIteratorError5) {
|
211
|
-
throw _iteratorError5;
|
212
|
-
}
|
104
|
+
javascript: length => {
|
105
|
+
const shortContentHashMap = {};
|
106
|
+
const contentHash = chunkMaps.contentHash.javascript;
|
107
|
+
|
108
|
+
for (const chunkId of Object.keys(contentHash)) {
|
109
|
+
if (typeof contentHash[chunkId] === 'string') {
|
110
|
+
shortContentHashMap[chunkId] = contentHash[chunkId].substr(0, length);
|
213
111
|
}
|
214
112
|
}
|
215
113
|
|
216
|
-
return
|
114
|
+
return `" + ${JSON.stringify(shortContentHashMap)}[${chunkIdExpression}] + "`;
|
217
115
|
}
|
218
116
|
}
|
219
117
|
},
|
220
118
|
contentHashType: 'javascript'
|
221
119
|
});
|
222
120
|
};
|
223
|
-
|
224
|
-
|
121
|
+
|
122
|
+
mainTemplate.hooks.localVars.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
123
|
+
const extraCode = [];
|
124
|
+
|
225
125
|
if (needChunkLoadingCode(chunk)) {
|
226
|
-
extraCode.push('', '// object to store loaded and loading chunks', '// undefined = chunk not loaded, null = chunk preloaded/prefetched', '// Promise = chunk loading, 0 = chunk loaded', 'var installedChunks = {',
|
227
|
-
return JSON.stringify(id) + ': 0';
|
228
|
-
}).join(',\n')), '};', '', needEntryDeferringCode(chunk) ? 'var deferredModules = [];' : '');
|
126
|
+
extraCode.push('', '// object to store loaded and loading chunks', '// undefined = chunk not loaded, null = chunk preloaded/prefetched', '// Promise = chunk loading, 0 = chunk loaded', 'var installedChunks = {', _Template.default.indent(chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};', '', needEntryDeferringCode(chunk) ? 'var deferredModules = [];' : '');
|
229
127
|
}
|
128
|
+
|
230
129
|
if (needChunkOnDemandLoadingCode(chunk)) {
|
231
|
-
extraCode.push('', '// script path function', 'function jsonpScriptSrc(chunkId) {',
|
130
|
+
extraCode.push('', '// script path function', 'function jsonpScriptSrc(chunkId) {', _Template.default.indent([`return ${mainTemplate.requireFn}.p + ${getScriptSrcPath(hash, chunk, 'chunkId')}`]), '}');
|
232
131
|
}
|
132
|
+
|
233
133
|
if (extraCode.length === 0) {
|
234
134
|
return source;
|
235
135
|
}
|
236
|
-
return _Template2.default.asString([source].concat(extraCode));
|
237
|
-
});
|
238
|
-
|
239
|
-
mainTemplate.hooks.jsonpScript.tap('JsonpMainTemplatePlugin', function (_, chunk, hash) {
|
240
|
-
var crossOriginLoading = mainTemplate.outputOptions.crossOriginLoading;
|
241
|
-
var chunkLoadTimeout = mainTemplate.outputOptions.chunkLoadTimeout;
|
242
|
-
var jsonpScriptType = mainTemplate.outputOptions.jsonpScriptType;
|
243
|
-
|
244
136
|
|
245
|
-
return
|
137
|
+
return _Template.default.asString([source, ...extraCode]);
|
246
138
|
});
|
247
|
-
mainTemplate.hooks.
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
139
|
+
mainTemplate.hooks.jsonpScript.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
|
140
|
+
const {
|
141
|
+
crossOriginLoading
|
142
|
+
} = mainTemplate.outputOptions;
|
143
|
+
const {
|
144
|
+
chunkLoadTimeout
|
145
|
+
} = mainTemplate.outputOptions;
|
146
|
+
const {
|
147
|
+
jsonpScriptType
|
148
|
+
} = mainTemplate.outputOptions;
|
149
|
+
return _Template.default.asString(['var script = document.createElement(\'script\');', 'var onScriptComplete;', jsonpScriptType ? `script.type = ${JSON.stringify(jsonpScriptType)};` : '', 'script.charset = \'utf-8\';', `script.timeout = ${chunkLoadTimeout / 1000};`, `if (${mainTemplate.requireFn}.nc) {`, _Template.default.indent(`script.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`), '}', 'script.src = jsonpScriptSrc(chunkId);', crossOriginLoading ? _Template.default.asString(['if (script.src.indexOf(window.location.origin + \'/\') !== 0) {', _Template.default.indent(`script.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', 'onScriptComplete = function (event) {', _Template.default.indent(['// avoid mem leaks in IE.', 'script.onerror = script.onload = null;', 'clearTimeout(timeout);', 'var chunk = installedChunks[chunkId];', 'if(chunk !== 0) {', _Template.default.indent(['if(chunk) {', _Template.default.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src;', 'var error = new Error(\'Loading chunk \' + chunkId + \' failed.\\n(\' + errorType + \': \' + realSrc + \')\');', 'error.type = errorType;', 'error.request = realSrc;', 'chunk[1](error);']), '}', 'installedChunks[chunkId] = undefined;']), '}']), '};', 'var timeout = setTimeout(function(){', _Template.default.indent(['onScriptComplete({ type: \'timeout\', target: script });']), `}, ${chunkLoadTimeout});`, 'script.onerror = script.onload = onScriptComplete;']);
|
253
150
|
});
|
254
|
-
mainTemplate.hooks.
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
151
|
+
mainTemplate.hooks.linkPreload.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
|
152
|
+
const {
|
153
|
+
crossOriginLoading
|
154
|
+
} = mainTemplate.outputOptions;
|
155
|
+
const {
|
156
|
+
jsonpScriptType
|
157
|
+
} = mainTemplate.outputOptions;
|
158
|
+
return _Template.default.asString(['var link = document.createElement(\'link\');', jsonpScriptType ? `link.type = ${JSON.stringify(jsonpScriptType)};` : '', 'link.charset = \'utf-8\';', `if (${mainTemplate.requireFn}.nc) {`, _Template.default.indent(`link.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`), '}', 'link.rel = "preload";', 'link.as = "script";', 'link.href = jsonpScriptSrc(chunkId);', crossOriginLoading ? _Template.default.asString(['if (link.href.indexOf(window.location.origin + \'/\') !== 0) {', _Template.default.indent(`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '']);
|
259
159
|
});
|
260
|
-
mainTemplate.hooks.
|
261
|
-
|
160
|
+
mainTemplate.hooks.linkPrefetch.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
|
161
|
+
const {
|
162
|
+
crossOriginLoading
|
163
|
+
} = mainTemplate.outputOptions;
|
164
|
+
return _Template.default.asString(['var link = document.createElement(\'link\');', crossOriginLoading ? `link.crossOrigin = ${JSON.stringify(crossOriginLoading)};` : '', `if (${mainTemplate.requireFn}.nc) {`, _Template.default.indent(`link.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`), '}', 'link.rel = "prefetch";', 'link.as = "script";', 'link.href = jsonpScriptSrc(chunkId);']);
|
262
165
|
});
|
166
|
+
mainTemplate.hooks.requireEnsure.tap('JsonpMainTemplatePlugin load', (source, chunk, hash) => _Template.default.asString([source, '', '// JSONP chunk loading for javascript', '', 'var installedChunkData = installedChunks[chunkId];', 'if(installedChunkData !== 0) { // 0 means "already installed".', _Template.default.indent(['', '// a Promise means "currently loading".', 'if(installedChunkData) {', _Template.default.indent(['promises.push(installedChunkData[2]);']), '} else {', _Template.default.indent(['// setup Promise in chunk cache', 'var promise = new Promise(function(resolve, reject) {', _Template.default.indent(['installedChunkData = installedChunks[chunkId] = [resolve, reject];']), '});', 'promises.push(installedChunkData[2] = promise);', '', '// start chunk loading', mainTemplate.hooks.jsonpScript.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(script);']), '}']), '}']));
|
263
167
|
mainTemplate.hooks.requireEnsure.tap({
|
264
168
|
name: 'JsonpMainTemplatePlugin preload',
|
265
169
|
stage: 10
|
266
|
-
},
|
267
|
-
|
170
|
+
}, (source, chunk, hash) => {
|
171
|
+
const chunkMap = chunk.getChildIdsByOrdersMap().preload;
|
172
|
+
|
268
173
|
if (!chunkMap || Object.keys(chunkMap).length === 0) {
|
269
174
|
return source;
|
270
175
|
}
|
271
|
-
|
176
|
+
|
177
|
+
return _Template.default.asString([source, '', '// chunk preloadng for javascript', '', `var chunkPreloadMap = ${JSON.stringify(chunkMap, null, '\t')};`, '', 'var chunkPreloadData = chunkPreloadMap[chunkId];', 'if(chunkPreloadData) {', _Template.default.indent(['chunkPreloadData.forEach(function(chunkId) {', _Template.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']), '}']);
|
272
178
|
});
|
273
|
-
mainTemplate.hooks.requireExtensions.tap('JsonpMainTemplatePlugin',
|
179
|
+
mainTemplate.hooks.requireExtensions.tap('JsonpMainTemplatePlugin', (source, chunk) => {
|
274
180
|
if (!needChunkOnDemandLoadingCode(chunk)) {
|
275
181
|
return source;
|
276
182
|
}
|
277
183
|
|
278
|
-
return
|
184
|
+
return _Template.default.asString([source, '', '// on error function for async loading', `${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };`]);
|
279
185
|
});
|
280
|
-
mainTemplate.hooks.bootstrap.tap('JsonpMainTemplatePlugin',
|
186
|
+
mainTemplate.hooks.bootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
281
187
|
if (needChunkLoadingCode(chunk)) {
|
282
|
-
|
283
|
-
|
284
|
-
return
|
188
|
+
const withDefer = needEntryDeferringCode(chunk);
|
189
|
+
const withPrefetch = needPrefetchingCode(chunk);
|
190
|
+
return _Template.default.asString([source, '', '// install a JSONP callback for chunk loading', 'function webpackJsonpCallback(data) {', _Template.default.indent(['var chunkIds = data[0];', 'var moreModules = data[1];', withDefer ? 'var executeModules = data[2];' : '', withPrefetch ? 'var prefetchChunks = data[3] || [];' : '', '// add "moreModules" to the modules object,', '// then flag all "chunkIds" as loaded and fire callback', 'var moduleId, chunkId, i = 0, resolves = [];', 'for(;i < chunkIds.length; i++) {', _Template.default.indent(['chunkId = chunkIds[i];', 'if(installedChunks[chunkId]) {', _Template.default.indent('resolves.push(installedChunks[chunkId][0]);'), '}', 'installedChunks[chunkId] = 0;']), '}', 'for(moduleId in moreModules) {', _Template.default.indent(['if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {', _Template.default.indent(mainTemplate.renderAddModule(hash, chunk, 'moduleId', 'moreModules[moduleId]')), '}']), '}', 'if(parentJsonpFunction) parentJsonpFunction(data);', withPrefetch ? _Template.default.asString(['// chunk prefetching for javascript', 'prefetchChunks.forEach(function(chunkId) {', _Template.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPrefetch.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']) : '', 'while(resolves.length) {', _Template.default.indent('resolves.shift()();'), '}', withDefer ? _Template.default.asString(['', '// add entry modules from loaded chunk to deferred list', 'deferredModules.push.apply(deferredModules, executeModules || []);', '', '// run deferred modules when all chunks ready', 'return checkDeferredModules();']) : '']), '};', withDefer ? _Template.default.asString(['function checkDeferredModules() {', _Template.default.indent(['var result;', 'for(var i = 0; i < deferredModules.length; i++) {', _Template.default.indent(['var deferredModule = deferredModules[i];', 'var fulfilled = true;', 'for(var j = 1; j < deferredModule.length; j++) {', _Template.default.indent(['var depId = deferredModule[j];', 'if(installedChunks[depId] !== 0) fulfilled = false;']), '}', 'if(fulfilled) {', _Template.default.indent(['deferredModules.splice(i--, 1);', `result = ${mainTemplate.requireFn}(${mainTemplate.requireFn}.s = deferredModule[0]);`]), '}']), '}', 'return result;']), '}']) : '']);
|
285
191
|
}
|
192
|
+
|
286
193
|
return source;
|
287
194
|
});
|
288
|
-
mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin',
|
195
|
+
mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
289
196
|
if (needChunkLoadingCode(chunk)) {
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
197
|
+
let {
|
198
|
+
jsonpFunction
|
199
|
+
} = mainTemplate.outputOptions;
|
200
|
+
let {
|
201
|
+
globalObject
|
202
|
+
} = mainTemplate.outputOptions;
|
203
|
+
return _Template.default.asString([`var jsonpArray = ${globalObject}[${JSON.stringify(jsonpFunction)}] = ${globalObject}[${JSON.stringify(jsonpFunction)}] || [];`, 'var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);', 'jsonpArray.push = webpackJsonpCallback;', 'jsonpArray = jsonpArray.slice();', 'for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);', 'var parentJsonpFunction = oldJsonpFunction;', '', source]);
|
294
204
|
}
|
205
|
+
|
295
206
|
return source;
|
296
207
|
});
|
297
|
-
mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin',
|
298
|
-
|
208
|
+
mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
209
|
+
const prefetchChunks = chunk.getChildIdsByOrders().prefetch;
|
210
|
+
|
299
211
|
if (needChunkLoadingCode(chunk) && prefetchChunks && prefetchChunks.length) {
|
300
|
-
return
|
212
|
+
return _Template.default.asString([source, `webpackJsonpCallback([[], {}, 0, ${JSON.stringify(prefetchChunks)}]);`]);
|
301
213
|
}
|
214
|
+
|
302
215
|
return source;
|
303
216
|
});
|
304
|
-
mainTemplate.hooks.startup.tap('JsonpMainTemplatePlugin',
|
217
|
+
mainTemplate.hooks.startup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
305
218
|
if (needEntryDeferringCode(chunk)) {
|
306
219
|
if (chunk.hasEntryModule()) {
|
307
|
-
|
308
|
-
|
309
|
-
return c !== chunk;
|
310
|
-
}).map(function (c) {
|
311
|
-
return c.id;
|
312
|
-
}));
|
313
|
-
});
|
314
|
-
return _Template2.default.asString(['// add entry module to deferred list', 'deferredModules.push(' + entries.map(function (e) {
|
315
|
-
return JSON.stringify(e);
|
316
|
-
}).join(', ') + ');', '// run deferred modules when ready', 'return checkDeferredModules();']);
|
220
|
+
const entries = [chunk.entryModule].filter(Boolean).map(m => [m.id].concat(Array.from(chunk.groupsIterable)[0].chunks.filter(c => c !== chunk).map(c => c.id)));
|
221
|
+
return _Template.default.asString(['// add entry module to deferred list', `deferredModules.push(${entries.map(e => JSON.stringify(e)).join(', ')});`, '// run deferred modules when ready', 'return checkDeferredModules();']);
|
317
222
|
}
|
318
|
-
|
223
|
+
|
224
|
+
return _Template.default.asString(['// run deferred modules from other chunks', 'checkDeferredModules();']);
|
319
225
|
}
|
226
|
+
|
320
227
|
return source;
|
321
228
|
});
|
322
|
-
mainTemplate.hooks.hotBootstrap.tap('JsonpMainTemplatePlugin',
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
229
|
+
mainTemplate.hooks.hotBootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
230
|
+
const {
|
231
|
+
globalObject
|
232
|
+
} = mainTemplate.outputOptions;
|
233
|
+
const {
|
234
|
+
hotUpdateChunkFilename
|
235
|
+
} = mainTemplate.outputOptions;
|
236
|
+
const {
|
237
|
+
hotUpdateMainFilename
|
238
|
+
} = mainTemplate.outputOptions;
|
239
|
+
const {
|
240
|
+
crossOriginLoading
|
241
|
+
} = mainTemplate.outputOptions;
|
242
|
+
const {
|
243
|
+
hotUpdateFunction
|
244
|
+
} = mainTemplate.outputOptions;
|
245
|
+
const currentHotUpdateChunkFilename = mainTemplate.getAssetPath(JSON.stringify(hotUpdateChunkFilename), {
|
246
|
+
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
247
|
+
hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
334
248
|
chunk: {
|
335
249
|
id: '" + chunkId + "'
|
336
250
|
}
|
337
251
|
});
|
338
|
-
|
339
|
-
hash:
|
340
|
-
hashWithLength:
|
341
|
-
return '" + ' + mainTemplate.renderCurrentHashCode(hash, length) + ' + "';
|
342
|
-
}
|
252
|
+
const currentHotUpdateMainFilename = mainTemplate.getAssetPath(JSON.stringify(hotUpdateMainFilename), {
|
253
|
+
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
254
|
+
hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
|
343
255
|
});
|
344
|
-
|
345
|
-
|
256
|
+
|
257
|
+
const runtimeSource = _Template.default.getFunctionContent(require('./JsonpMainTemplate.runtime')).replace(/\/\/\$semicolon/g, ';').replace(/\$require\$/g, mainTemplate.requireFn).replace(/\$crossOriginLoading\$/g, crossOriginLoading ? JSON.stringify(crossOriginLoading) : 'null').replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename).replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename).replace(/\$hash\$/g, JSON.stringify(hash));
|
258
|
+
|
259
|
+
return `${source}
|
260
|
+
function hotDisposeChunk(chunkId) {
|
261
|
+
delete installedChunks[chunkId];
|
262
|
+
}
|
263
|
+
var parentHotUpdateCallback = ${globalObject}[${JSON.stringify(hotUpdateFunction)}];
|
264
|
+
${globalObject}[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
|
346
265
|
});
|
347
|
-
mainTemplate.hooks.hash.tap('JsonpMainTemplatePlugin',
|
266
|
+
mainTemplate.hooks.hash.tap('JsonpMainTemplatePlugin', hash => {
|
348
267
|
hash.update('jsonp');
|
349
268
|
hash.update('6');
|
350
269
|
});
|
@@ -1,47 +1,35 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _path2 = _interopRequireDefault(_path);
|
12
|
-
|
13
|
-
var _webpackSources = require('webpack-sources');
|
10
|
+
var _webpackSources = require("webpack-sources");
|
14
11
|
|
15
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
class SourceMapHookPlugin {
|
15
|
+
apply(compiler) {
|
16
|
+
compiler.hooks.emit.tap('SourceMapHookPlugin', compilation => {
|
17
|
+
Object.keys(compilation.assets).forEach(filename => {
|
18
|
+
if (/\.js$/g.test(filename)) {
|
19
|
+
let source = compilation.assets[filename].source();
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
compiler.hooks.emit.tap('SourceMapHookPlugin', function (compilation) {
|
28
|
-
Object.keys(compilation.assets).forEach(function (filename) {
|
29
|
-
if (/\.js$/g.test(filename)) {
|
30
|
-
var source = compilation.assets[filename].source();
|
21
|
+
let {
|
22
|
+
name
|
23
|
+
} = _path.default.parse(filename);
|
31
24
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
var src = source + '\n//# sourceMappingURL=../smap/' + name + '.map';
|
36
|
-
|
37
|
-
compilation.assets[filename.replace(/js\//g, 'js-sm/')] = new _webpackSources.RawSource(src);
|
38
|
-
}
|
39
|
-
});
|
25
|
+
let src = `${source}\n//# sourceMappingURL=../smap/${name}.map`;
|
26
|
+
compilation.assets[filename.replace(/js\//g, 'js-sm/')] = new _webpackSources.RawSource(src);
|
27
|
+
}
|
40
28
|
});
|
41
|
-
}
|
42
|
-
}
|
29
|
+
});
|
30
|
+
}
|
43
31
|
|
44
|
-
|
45
|
-
}();
|
32
|
+
}
|
46
33
|
|
47
|
-
|
34
|
+
var _default = SourceMapHookPlugin;
|
35
|
+
exports.default = _default;
|