@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.2
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/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
- package/lib/babel/cmjs-plugins-presets.js +1 -8
- package/lib/babel/es-plugins-presets.js +1 -8
- package/lib/common/buildEs.js +1 -0
- package/lib/common/getEntries.js +2 -13
- package/lib/common/getPublicPathConfig.js +0 -6
- package/lib/common/index.js +1 -6
- package/lib/common/runPreProcess.js +6 -15
- package/lib/common/splitChunks.js +2 -21
- package/lib/common/sslcertUpdater.js +7 -18
- package/lib/common/templateParameters.js +0 -2
- package/lib/common/testPattern.js +10 -21
- package/lib/common/valueReplacer.js +1 -16
- package/lib/configs/jest.config.js +1 -10
- package/lib/configs/libAlias.js +8 -14
- package/lib/configs/resolvers.js +4 -14
- package/lib/configs/webpack.component.umd.config.js +1 -6
- package/lib/configs/webpack.css.umd.config.js +6 -14
- package/lib/configs/webpack.dev.config.js +1 -14
- package/lib/configs/webpack.docs.config.js +1 -9
- package/lib/configs/webpack.impact.config.js +1 -8
- package/lib/configs/webpack.prod.config.js +4 -17
- package/lib/constants.js +9 -18
- package/lib/deprecationLogger.js +0 -7
- package/lib/hooks/docsProptypeHook.js +4 -8
- package/lib/jest/commitedFilesResult.js +4 -46
- package/lib/jest/coverageCollector.js +1 -12
- package/lib/jest/jsonMaker.js +0 -6
- package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
- package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
- package/lib/jest/result.js +1 -23
- package/lib/jest/run.js +7 -18
- package/lib/jest/setup.js +8 -60
- package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
- package/lib/loaderUtils/getCSSLoaders.js +10 -22
- package/lib/loaderUtils/getDevJsLoaders.js +4 -13
- package/lib/loaderUtils/index.js +1 -4
- package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
- package/lib/loaderUtils/windowsModification.js +2 -3
- package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
- package/lib/loaders/composeLoader.js +13 -37
- package/lib/loaders/docsLoader.js +1 -12
- package/lib/loaders/docsPropsLoader.js +4 -8
- package/lib/loaders/enhancedReactLiveConverter.js +2 -23
- package/lib/loaders/fileBountryLoader.js +1 -3
- package/lib/loaders/fileLoader.js +12 -23
- package/lib/loaders/markdownLoader.js +14 -19
- package/lib/loaders/reactLiveConvertor.js +5 -15
- package/lib/loaders/scriptInstrumentLoader.js +7 -16
- package/lib/loaders/selectorMappingLoader.js +7 -26
- package/lib/loaders/workerLoader.js +9 -24
- package/lib/logger.js +0 -4
- package/lib/middlewares/HMRMiddleware.js +13 -27
- package/lib/middlewares/SSTMiddleware.js +1 -5
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
- package/lib/pluginUtils/getDevPlugins.js +9 -42
- package/lib/pluginUtils/getDocsPlugins.js +3 -13
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
- package/lib/pluginUtils/getLibraryPlugins.js +2 -8
- package/lib/pluginUtils/getProdPlugins.js +8 -47
- package/lib/pluginUtils/getServerPlugins.js +2 -8
- package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
- package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
- package/lib/pluginUtils/index.js +1 -9
- package/lib/plugins/CdnChangePlugin.js +2 -18
- package/lib/plugins/CleanupStatsPlugin.js +0 -5
- package/lib/plugins/CssOrderControlPlugin.js +3 -6
- package/lib/plugins/CustomAttributePlugin.js +14 -19
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
- package/lib/plugins/EFCPlugin.js +20 -34
- package/lib/plugins/EFCTemplatePlugin.js +19 -30
- package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
- package/lib/plugins/EventsHandlingPlugin.js +2 -4
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
- package/lib/plugins/I18nSplitPlugin/index.js +13 -24
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
- package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
- package/lib/plugins/ManifestPlugin.js +1 -18
- package/lib/plugins/MinifyPlugin.js +1 -10
- package/lib/plugins/ModuleStatsPlugin.js +1 -24
- package/lib/plugins/OptimizeJSPlugin.js +2 -10
- package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
- package/lib/plugins/PublicPathChangePlugin.js +6 -39
- package/lib/plugins/ReportGeneratePlugin.js +5 -32
- package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
- package/lib/plugins/ResourceHintsPlugin.js +4 -13
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
- package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
- package/lib/plugins/SelectorPlugin.js +6 -32
- package/lib/plugins/ServiceWorkerPlugin.js +5 -22
- package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
- package/lib/plugins/SourceMapHookPlugin.js +2 -12
- package/lib/plugins/StatsPlugin.js +0 -14
- package/lib/plugins/TPHashMappingPlugin.js +3 -18
- package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
- package/lib/plugins/VariableConversionCollector.js +15 -42
- package/lib/plugins/index.js +1 -20
- package/lib/plugins/libraryImpactPlugin.js +1 -33
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
- package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
- package/lib/plugins/utils/classHandling.js +0 -6
- package/lib/plugins/utils/fileHandling.js +6 -15
- package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
- package/lib/plugins/variableConvertorUtils.js +14 -29
- package/lib/plugins/webpackwatchrunplugin.js +0 -5
- package/lib/postcss-plugins/EmptyPlugin.js +3 -4
- package/lib/postcss-plugins/ExcludePlugin.js +1 -5
- package/lib/postcss-plugins/IncludePlugin.js +1 -5
- package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
- package/lib/postcss-plugins/SelectorReplace.js +1 -16
- package/lib/postcss-plugins/ValueReplacer.js +7 -6
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
- package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
- package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
- package/lib/schemas/index.js +3 -9
- package/lib/servers/clusterHubServer.js +1 -11
- package/lib/servers/devBuild.js +14 -26
- package/lib/servers/docsServer.js +1 -3
- package/lib/servers/docsServerCore.js +1 -22
- package/lib/servers/getCliPath.js +0 -9
- package/lib/servers/helpServer.js +1 -6
- package/lib/servers/httpsOptions.js +2 -8
- package/lib/servers/impactServer.js +3 -35
- package/lib/servers/mockserver.js +1 -10
- package/lib/servers/nowatchserver.js +12 -37
- package/lib/servers/requireLocalOrGlobal.js +6 -17
- package/lib/servers/scrServer.js +14 -21
- package/lib/servers/server.js +6 -36
- package/lib/servers/ssServer.js +1 -17
- package/lib/templates/CoverageScriptTemplate.js +0 -14
- package/lib/templates/WMSTemplate.js +7 -13
- package/lib/templates/linterConstant.js +2 -4
- package/lib/utils/babelPresets.js +3 -7
- package/lib/utils/clean.js +3 -9
- package/lib/utils/copy.js +1 -7
- package/lib/utils/copyTimezones.js +1 -9
- package/lib/utils/createEventStream.js +1 -6
- package/lib/utils/cssClassNameGenerate.js +10 -30
- package/lib/utils/cssURLReplacer.js +1 -22
- package/lib/utils/dependencyPostPublish.js +1 -10
- package/lib/utils/deprecationSupport.js +7 -32
- package/lib/utils/fileUtils.js +1 -28
- package/lib/utils/folderIterator.js +2 -13
- package/lib/utils/getComponents.js +0 -21
- package/lib/utils/getCurrentBranch.js +0 -5
- package/lib/utils/getDependenciesImpactList.js +1 -22
- package/lib/utils/getFileType.js +2 -10
- package/lib/utils/getHash.js +1 -8
- package/lib/utils/getIp.js +0 -2
- package/lib/utils/getOptions.js +16 -53
- package/lib/utils/getServerURL.js +1 -10
- package/lib/utils/index.js +4 -51
- package/lib/utils/init.js +0 -1
- package/lib/utils/initPreCommitHook.js +7 -30
- package/lib/utils/jsonHelper.js +3 -22
- package/lib/utils/libraryImpactConfig.js +2 -5
- package/lib/utils/lint/addScripts.js +2 -5
- package/lib/utils/lint/checkExistingConfig.js +3 -12
- package/lib/utils/lint/copyConfigs.js +0 -3
- package/lib/utils/lint/index.js +0 -9
- package/lib/utils/lint/lintScripts.js +0 -1
- package/lib/utils/lint/lintSetup.js +3 -4
- package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
- package/lib/utils/lint/question.js +0 -7
- package/lib/utils/lintReporter.js +0 -20
- package/lib/utils/log.js +0 -1
- package/lib/utils/mailSender.js +1 -8
- package/lib/utils/object-manipulation.js +1 -17
- package/lib/utils/pullOrigin.js +0 -4
- package/lib/utils/reinstallDependencies.js +1 -29
- package/lib/utils/removeAttributes.js +1 -8
- package/lib/utils/repoClone.js +3 -28
- package/lib/utils/request.js +0 -12
- package/lib/utils/rtl.js +5 -17
- package/lib/utils/selectorReplacer.js +10 -16
- package/lib/utils/setEnvVariables.js +0 -2
- package/lib/utils/ssTestHack.js +1 -11
- package/lib/utils/switchBranch.js +0 -5
- package/lib/utils/typeCheck.js +0 -1
- package/lib/utils/urlConcat.js +0 -4
- package/lib/utils/useExitCleanup.js +9 -10
- package/lib/utils/variableConverter.js +22 -31
- package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
- package/package.json +1 -1
@@ -4,62 +4,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _postcss = _interopRequireDefault(require("postcss"));
|
9
|
-
|
10
8
|
var _fs = _interopRequireDefault(require("fs"));
|
11
|
-
|
12
9
|
var _classHandling = require("./utils/classHandling");
|
13
|
-
|
14
10
|
var _fileHandling = require("./utils/fileHandling");
|
15
|
-
|
16
11
|
var _windowsModification = require("../loaderUtils/windowsModification");
|
17
|
-
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
-
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
20
13
|
function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
|
21
14
|
rootOriginal.walkRules((rule, index) => {
|
22
15
|
const prevNode = rootOriginal.nodes[index - 1] || null;
|
23
|
-
|
24
16
|
if ((0, _classHandling.hasPrevNodeIgnore)(index, prevNode, 'updateselector:ignore')) {
|
25
17
|
return;
|
26
|
-
}
|
27
|
-
|
28
|
-
|
18
|
+
}
|
19
|
+
// console.log(rule.selector.split(','));
|
29
20
|
const selectorArr = rule.selector.split(',');
|
30
21
|
selectorArr.forEach((singleSelectorStr, index) => {
|
31
22
|
if (excludeStrings.includes(singleSelectorStr.trim())) {
|
32
23
|
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
|
24
|
+
}
|
25
|
+
// NOTE: below logic for attrbute related
|
36
26
|
if (singleSelectorStr.includes(']')) {
|
37
27
|
// console.log(singleSelectorStr);
|
38
28
|
const prefixPart = singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim();
|
39
29
|
const selectorPart = singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 1).trim();
|
40
|
-
|
41
30
|
if (excludeStrings.includes(selectorPart.trim())) {
|
42
31
|
return;
|
43
32
|
}
|
44
|
-
|
45
33
|
if (/^:/gi.test(selectorPart)) {
|
46
34
|
return;
|
47
35
|
}
|
48
|
-
|
49
36
|
if (selectorPart !== '') {
|
50
37
|
selectorArr[index] = `${prefixPart} ${selector}${selectorPart}`;
|
51
38
|
}
|
52
|
-
|
53
39
|
return;
|
54
40
|
}
|
55
|
-
|
56
41
|
selectorArr[index] = `${selector}${singleSelectorStr}`;
|
57
42
|
});
|
58
43
|
rule.selector = selectorArr.join(',\n');
|
59
44
|
});
|
60
45
|
return rootOriginal;
|
61
46
|
}
|
62
|
-
|
63
47
|
class SelectorPlugin {
|
64
48
|
constructor(options = {}) {
|
65
49
|
this.optimize = options.optimize;
|
@@ -67,16 +51,13 @@ class SelectorPlugin {
|
|
67
51
|
this.exclude = options.exclude;
|
68
52
|
this.patterns = options.patterns;
|
69
53
|
}
|
70
|
-
|
71
54
|
apply(compiler) {
|
72
55
|
const {
|
73
56
|
defaultSelector,
|
74
57
|
customFileDetails,
|
75
58
|
excludeStrings
|
76
59
|
} = this.selectorWeightConfig;
|
77
|
-
|
78
60
|
const rawdata = _fs.default.readFileSync(customFileDetails);
|
79
|
-
|
80
61
|
const data = JSON.parse(rawdata);
|
81
62
|
this.exclude = (0, _windowsModification.windowsModification)(this.exclude);
|
82
63
|
compiler.hooks.compilation.tap('selector-weight-rewrite', compilation => {
|
@@ -84,7 +65,6 @@ class SelectorPlugin {
|
|
84
65
|
const mods = modules.filter(x => x.type.includes('css'));
|
85
66
|
mods.forEach(module => {
|
86
67
|
const rootOriginal = _postcss.default.parse(module.content);
|
87
|
-
|
88
68
|
const filename = module.issuer.resource;
|
89
69
|
/*
|
90
70
|
input :
|
@@ -101,7 +81,6 @@ class SelectorPlugin {
|
|
101
81
|
output :
|
102
82
|
true or false
|
103
83
|
*/
|
104
|
-
|
105
84
|
if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
|
106
85
|
filename,
|
107
86
|
filterArr: this.patterns.selectorWeight
|
@@ -123,15 +102,10 @@ class SelectorPlugin {
|
|
123
102
|
case filename is different ?
|
124
103
|
defaultSelector = '.zoho_desk_ui'
|
125
104
|
*/
|
126
|
-
|
127
|
-
|
128
105
|
module.content = selectorWeightPrefixAdder(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
|
129
106
|
});
|
130
107
|
});
|
131
108
|
});
|
132
109
|
}
|
133
|
-
|
134
110
|
}
|
135
|
-
|
136
|
-
var _default = SelectorPlugin;
|
137
|
-
exports.default = _default;
|
111
|
+
var _default = exports.default = SelectorPlugin;
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _fs = _interopRequireDefault(require("fs"));
|
9
|
-
|
10
8
|
var _path = _interopRequireDefault(require("path"));
|
11
|
-
|
12
9
|
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
13
|
-
|
14
10
|
var _utils = require("../utils");
|
15
|
-
|
16
11
|
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
|
17
|
-
|
18
12
|
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
19
|
-
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
-
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
22
14
|
const {
|
23
15
|
css: {
|
24
16
|
enableRTLSplit
|
@@ -27,24 +19,21 @@ const {
|
|
27
19
|
chunkSplitEnable
|
28
20
|
}
|
29
21
|
} = (0, _utils.getOptions)();
|
30
|
-
|
31
22
|
class ServiceWorkerPlugin {
|
32
23
|
constructor(options) {
|
33
24
|
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
34
25
|
this.fileName = options.fileName;
|
35
26
|
this.serviceWorkerPath = options.filePath;
|
36
27
|
this.writePath = options.exitPath;
|
37
|
-
this.replaceText = options.replaceText;
|
28
|
+
this.replaceText = options.replaceText;
|
29
|
+
// this.publicPaths = options.publicPaths;
|
38
30
|
}
|
39
|
-
|
40
31
|
isInitialChunk(chunk) {
|
41
32
|
if ('canBeInitial' in chunk) {
|
42
33
|
return chunk.canBeInitial();
|
43
34
|
}
|
44
|
-
|
45
35
|
return chunk.isInitial();
|
46
36
|
}
|
47
|
-
|
48
37
|
apply(compiler) {
|
49
38
|
compiler.hooks.emit.tap('ServiceWorkerPlugin', compilation => {
|
50
39
|
_fs.default.readFile(this.serviceWorkerPath, 'utf-8', (err, data) => {
|
@@ -57,6 +46,7 @@ class ServiceWorkerPlugin {
|
|
57
46
|
}
|
58
47
|
return chunk.isInitial();
|
59
48
|
}); */
|
49
|
+
|
60
50
|
// let [js, css, , , i18nPublicPath] = this.publicPaths;
|
61
51
|
// let initialChunkUrls = [];
|
62
52
|
let allChunkUrls = [];
|
@@ -69,39 +59,32 @@ class ServiceWorkerPlugin {
|
|
69
59
|
* if chunkSplitEnable is false means,
|
70
60
|
* serviceWorker will get i18n files path for html
|
71
61
|
*/
|
72
|
-
|
73
62
|
let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
|
74
63
|
chunkSplitEnable && compilation.chunks.filter(c => !this.isInitialChunk(c)).filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).forEach(chunk => {
|
75
64
|
// let isInitial = this.isInitialChunk(chunk);
|
76
65
|
allChunkUrls = allChunkUrls.concat(chunk.files);
|
77
66
|
allI18nAssets.push((0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
78
67
|
});
|
79
|
-
/** Removing source map files from getting added */
|
80
68
|
|
69
|
+
/** Removing source map files from getting added */
|
81
70
|
initialChunkUrls = initialChunkUrls.filter(fileName => !fileName.endsWith('.map'));
|
82
71
|
allChunkUrls = allChunkUrls.filter(fileName => !fileName.endsWith('.map'));
|
83
|
-
|
84
72
|
if (enableRTLSplit) {
|
85
73
|
initialChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(initialChunkUrls, cssDirTemplate);
|
86
74
|
allChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(allChunkUrls, cssDirTemplate);
|
87
75
|
}
|
88
|
-
|
89
76
|
let mod = data.replace(this.replaceText, `
|
90
77
|
self.assets = ${JSON.stringify(initialChunkUrls.concat(initalI18nAssets))};
|
91
78
|
self.allChunks = ${JSON.stringify(allChunkUrls.concat(allI18nAssets))};`);
|
92
|
-
|
93
79
|
if (!_fs.default.existsSync(this.writePath)) {
|
94
80
|
_fs.default.mkdirSync(this.writePath, {
|
95
81
|
recursive: true
|
96
82
|
});
|
97
83
|
}
|
98
|
-
|
99
84
|
_fs.default.writeFileSync(_path.default.join(this.writePath, this.fileName), mod);
|
100
85
|
}
|
101
86
|
});
|
102
87
|
});
|
103
88
|
}
|
104
|
-
|
105
89
|
}
|
106
|
-
|
107
90
|
exports.default = ServiceWorkerPlugin;
|
@@ -4,27 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = ShadowDOMSupportPlugin;
|
7
|
-
|
8
7
|
var _Template = _interopRequireDefault(require("webpack/lib/Template"));
|
9
|
-
|
10
8
|
var _JsonpMainTemplatePlugin = _interopRequireDefault(require("webpack/lib/web/JsonpMainTemplatePlugin"));
|
11
|
-
|
12
9
|
var _tapable = require("tapable");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
16
11
|
/* eslint-disable no-unused-vars */
|
12
|
+
|
17
13
|
//eslint-disable-next-line
|
18
14
|
function ShadowDOMSupportPlugin() {}
|
19
|
-
|
20
15
|
ShadowDOMSupportPlugin.prototype.apply = function () {
|
21
16
|
this.patchJsonpMainTemplatePlugin();
|
22
17
|
};
|
23
|
-
|
24
18
|
ShadowDOMSupportPlugin.prototype.patchJsonpMainTemplatePlugin = function () {
|
25
19
|
_JsonpMainTemplatePlugin.default.prototype.apply = this._apply;
|
26
20
|
};
|
27
|
-
|
28
21
|
ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
29
22
|
const needChunkOnDemandLoadingCode = chunk => {
|
30
23
|
for (const chunkGroup of chunk.groupsIterable) {
|
@@ -32,46 +25,38 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
32
25
|
return true;
|
33
26
|
}
|
34
27
|
}
|
35
|
-
|
36
28
|
return false;
|
37
29
|
};
|
38
|
-
|
39
30
|
const needChunkLoadingCode = chunk => {
|
40
31
|
for (const chunkGroup of chunk.groupsIterable) {
|
41
32
|
if (chunkGroup.chunks.length > 1) {
|
42
33
|
return true;
|
43
34
|
}
|
44
|
-
|
45
35
|
if (chunkGroup.getNumberOfChildren() > 0) {
|
46
36
|
return true;
|
47
37
|
}
|
48
38
|
}
|
49
|
-
|
50
39
|
return false;
|
51
40
|
};
|
52
|
-
|
53
41
|
const needEntryDeferringCode = chunk => {
|
54
42
|
for (const chunkGroup of chunk.groupsIterable) {
|
55
43
|
if (chunkGroup.chunks.length > 1) {
|
56
44
|
return true;
|
57
45
|
}
|
58
46
|
}
|
59
|
-
|
60
47
|
return false;
|
61
48
|
};
|
62
|
-
|
63
49
|
const needPrefetchingCode = chunk => {
|
64
50
|
const allPrefetchChunks = chunk.getChildIdsByOrdersMap(true).prefetch;
|
65
51
|
return allPrefetchChunks && Object.keys(allPrefetchChunks).length;
|
66
|
-
};
|
67
|
-
|
52
|
+
};
|
68
53
|
|
54
|
+
// TODO webpack 5, no adding to .hooks, use WeakMap and static methods
|
69
55
|
['jsonpScript', 'linkPreload', 'linkPrefetch'].forEach(hook => {
|
70
56
|
if (!mainTemplate.hooks[hook]) {
|
71
57
|
mainTemplate.hooks[hook] = new _tapable.SyncWaterfallHook(['source', 'chunk', 'hash']);
|
72
58
|
}
|
73
59
|
});
|
74
|
-
|
75
60
|
const getScriptSrcPath = (hash, chunk, chunkIdExpression) => {
|
76
61
|
const {
|
77
62
|
chunkFilename
|
@@ -83,19 +68,15 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
83
68
|
chunk: {
|
84
69
|
id: `" + ${chunkIdExpression} + "`,
|
85
70
|
hash: `" + ${JSON.stringify(chunkMaps.hash)}[${chunkIdExpression}] + "`,
|
86
|
-
|
87
71
|
hashWithLength(length) {
|
88
72
|
const shortChunkHashMap = Object.create(null);
|
89
|
-
|
90
73
|
for (const chunkId of Object.keys(chunkMaps.hash)) {
|
91
74
|
if (typeof chunkMaps.hash[chunkId] === 'string') {
|
92
75
|
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
93
76
|
}
|
94
77
|
}
|
95
|
-
|
96
78
|
return `" + ${JSON.stringify(shortChunkHashMap)}[${chunkIdExpression}] + "`;
|
97
79
|
},
|
98
|
-
|
99
80
|
name: `" + (${JSON.stringify(chunkMaps.name)}[${chunkIdExpression}]||${chunkIdExpression}) + "`,
|
100
81
|
contentHash: {
|
101
82
|
javascript: `" + ${JSON.stringify(chunkMaps.contentHash.javascript)}[${chunkIdExpression}] + "`
|
@@ -104,13 +85,11 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
104
85
|
javascript: length => {
|
105
86
|
const shortContentHashMap = {};
|
106
87
|
const contentHash = chunkMaps.contentHash.javascript;
|
107
|
-
|
108
88
|
for (const chunkId of Object.keys(contentHash)) {
|
109
89
|
if (typeof contentHash[chunkId] === 'string') {
|
110
90
|
shortContentHashMap[chunkId] = contentHash[chunkId].substr(0, length);
|
111
91
|
}
|
112
92
|
}
|
113
|
-
|
114
93
|
return `" + ${JSON.stringify(shortContentHashMap)}[${chunkIdExpression}] + "`;
|
115
94
|
}
|
116
95
|
}
|
@@ -118,22 +97,17 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
118
97
|
contentHashType: 'javascript'
|
119
98
|
});
|
120
99
|
};
|
121
|
-
|
122
100
|
mainTemplate.hooks.localVars.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
123
101
|
const extraCode = [];
|
124
|
-
|
125
102
|
if (needChunkLoadingCode(chunk)) {
|
126
103
|
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 = [];' : '');
|
127
104
|
}
|
128
|
-
|
129
105
|
if (needChunkOnDemandLoadingCode(chunk)) {
|
130
106
|
extraCode.push('', '// script path function', 'function jsonpScriptSrc(chunkId) {', _Template.default.indent([`return ${mainTemplate.requireFn}.p + ${getScriptSrcPath(hash, chunk, 'chunkId')}`]), '}');
|
131
107
|
}
|
132
|
-
|
133
108
|
if (extraCode.length === 0) {
|
134
109
|
return source;
|
135
110
|
}
|
136
|
-
|
137
111
|
return _Template.default.asString([source, ...extraCode]);
|
138
112
|
});
|
139
113
|
mainTemplate.hooks.jsonpScript.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
|
@@ -169,18 +143,15 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
169
143
|
stage: 10
|
170
144
|
}, (source, chunk, hash) => {
|
171
145
|
const chunkMap = chunk.getChildIdsByOrdersMap().preload;
|
172
|
-
|
173
146
|
if (!chunkMap || Object.keys(chunkMap).length === 0) {
|
174
147
|
return source;
|
175
148
|
}
|
176
|
-
|
177
149
|
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);']), '}']), '});']), '}']);
|
178
150
|
});
|
179
151
|
mainTemplate.hooks.requireExtensions.tap('JsonpMainTemplatePlugin', (source, chunk) => {
|
180
152
|
if (!needChunkOnDemandLoadingCode(chunk)) {
|
181
153
|
return source;
|
182
154
|
}
|
183
|
-
|
184
155
|
return _Template.default.asString([source, '', '// on error function for async loading', `${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };`]);
|
185
156
|
});
|
186
157
|
mainTemplate.hooks.bootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
@@ -189,7 +160,6 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
189
160
|
const withPrefetch = needPrefetchingCode(chunk);
|
190
161
|
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;']), '}']) : '']);
|
191
162
|
}
|
192
|
-
|
193
163
|
return source;
|
194
164
|
});
|
195
165
|
mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
@@ -202,16 +172,13 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
202
172
|
} = mainTemplate.outputOptions;
|
203
173
|
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]);
|
204
174
|
}
|
205
|
-
|
206
175
|
return source;
|
207
176
|
});
|
208
177
|
mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
209
178
|
const prefetchChunks = chunk.getChildIdsByOrders().prefetch;
|
210
|
-
|
211
179
|
if (needChunkLoadingCode(chunk) && prefetchChunks && prefetchChunks.length) {
|
212
180
|
return _Template.default.asString([source, `webpackJsonpCallback([[], {}, 0, ${JSON.stringify(prefetchChunks)}]);`]);
|
213
181
|
}
|
214
|
-
|
215
182
|
return source;
|
216
183
|
});
|
217
184
|
mainTemplate.hooks.startup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
@@ -220,10 +187,8 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
220
187
|
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
188
|
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();']);
|
222
189
|
}
|
223
|
-
|
224
190
|
return _Template.default.asString(['// run deferred modules from other chunks', 'checkDeferredModules();']);
|
225
191
|
}
|
226
|
-
|
227
192
|
return source;
|
228
193
|
});
|
229
194
|
mainTemplate.hooks.hotBootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
|
@@ -253,9 +218,7 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
|
|
253
218
|
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
254
219
|
hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
|
255
220
|
});
|
256
|
-
|
257
221
|
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
222
|
return `${source}
|
260
223
|
function hotDisposeChunk(chunkId) {
|
261
224
|
delete installedChunks[chunkId];
|
@@ -4,26 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
8
|
var _webpackSources = require("webpack-sources");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
class SourceMapHookPlugin {
|
15
11
|
apply(compiler) {
|
16
12
|
compiler.hooks.emit.tap('SourceMapHookPlugin', compilation => {
|
17
13
|
Object.keys(compilation.assets).forEach(filename => {
|
18
14
|
if (/\.js$/g.test(filename) && !/(\.map.|tp\/)/g.test(filename)) {
|
19
15
|
let source = compilation.assets[filename].source();
|
20
|
-
|
21
16
|
let {
|
22
17
|
name
|
23
18
|
} = _path.default.parse(filename);
|
24
|
-
|
25
19
|
let src = source;
|
26
|
-
|
27
20
|
if (!/(i18n-chunk\/)/g.test(filename)) {
|
28
21
|
src = `${source}\n//# sourceMappingURL=../../js/${name}.js.map`;
|
29
22
|
compilation.assets[filename.replace(/js\//g, 'smap/js/')] = new _webpackSources.RawSource(src);
|
@@ -34,8 +27,5 @@ class SourceMapHookPlugin {
|
|
34
27
|
});
|
35
28
|
});
|
36
29
|
}
|
37
|
-
|
38
30
|
}
|
39
|
-
|
40
|
-
var _default = SourceMapHookPlugin;
|
41
|
-
exports.default = _default;
|
31
|
+
var _default = exports.default = SourceMapHookPlugin;
|
@@ -1,23 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const fs = require('fs');
|
4
|
-
|
5
4
|
const path = require('path');
|
6
|
-
|
7
5
|
const {
|
8
6
|
Readable
|
9
7
|
} = require('stream');
|
10
|
-
|
11
8
|
const {
|
12
9
|
removeKeysFromObject,
|
13
10
|
convertObjectToStringGen
|
14
11
|
} = require('../utils/object-manipulation');
|
15
|
-
|
16
12
|
const pluginName = 'stats-plugin';
|
17
13
|
const statsSchema = {
|
18
14
|
all: true
|
19
15
|
};
|
20
|
-
|
21
16
|
class StatsPlugin {
|
22
17
|
constructor({
|
23
18
|
statsOptions,
|
@@ -28,7 +23,6 @@ class StatsPlugin {
|
|
28
23
|
this.statsFileName = statsFileName || 'bundle-report-integrity.json';
|
29
24
|
this.statsOptions = Object.assign({}, statsSchema, statsOptions || {});
|
30
25
|
}
|
31
|
-
|
32
26
|
apply(compiler) {
|
33
27
|
compiler.hooks.done.tapAsync(pluginName, (stats, callback) => {
|
34
28
|
const statsJson = removeKeysFromObject(stats.toJson(this.statsOptions), this.excludeKeysInStat);
|
@@ -39,7 +33,6 @@ class StatsPlugin {
|
|
39
33
|
});
|
40
34
|
});
|
41
35
|
}
|
42
|
-
|
43
36
|
writeStatsFileInAStream(statsObj) {
|
44
37
|
const {
|
45
38
|
outputPath
|
@@ -47,20 +40,17 @@ class StatsPlugin {
|
|
47
40
|
const ouputFileName = path.join(outputPath, this.statsFileName);
|
48
41
|
return this.createReadStream(statsObj).pipe(fs.createWriteStream(ouputFileName));
|
49
42
|
}
|
50
|
-
|
51
43
|
createReadStream(statsObj) {
|
52
44
|
const excludeKeys = this.excludeKeysInStat;
|
53
45
|
return new Readable({
|
54
46
|
read() {
|
55
47
|
let isDone = false;
|
56
48
|
const objToStringGen = convertObjectToStringGen(statsObj, excludeKeys);
|
57
|
-
|
58
49
|
while (!isDone) {
|
59
50
|
const {
|
60
51
|
done,
|
61
52
|
value
|
62
53
|
} = objToStringGen.next();
|
63
|
-
|
64
54
|
if (done) {
|
65
55
|
isDone = true;
|
66
56
|
this.push(null);
|
@@ -69,14 +59,10 @@ class StatsPlugin {
|
|
69
59
|
}
|
70
60
|
}
|
71
61
|
}
|
72
|
-
|
73
62
|
});
|
74
63
|
}
|
75
|
-
|
76
64
|
emitStats(statsJson) {
|
77
65
|
return this.writeStatsFileInAStream(statsJson);
|
78
66
|
}
|
79
|
-
|
80
67
|
}
|
81
|
-
|
82
68
|
module.exports = StatsPlugin;
|
@@ -4,55 +4,43 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _webpack = require("webpack");
|
9
|
-
|
10
8
|
var _fs = _interopRequireDefault(require("fs"));
|
11
|
-
|
12
9
|
var _path = _interopRequireDefault(require("path"));
|
13
|
-
|
14
10
|
var _crypto = _interopRequireDefault(require("crypto"));
|
15
|
-
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
18
12
|
/**
|
19
13
|
* Plugin that generates hash for the provided list of third party files
|
20
14
|
* Map the provided key with the file hash and add it to the list of exisiting global constants.
|
21
15
|
* Plugin in turn uses the defineplugin to generate global constants.
|
22
16
|
*/
|
17
|
+
|
23
18
|
class TPHashMappingPlugin {
|
24
19
|
constructor(options) {
|
25
20
|
this.fileMappings = options.fileMappings;
|
26
21
|
this.tpFolder = options.tpFolder;
|
27
22
|
return new _webpack.DefinePlugin(this.getFiles());
|
28
23
|
}
|
29
|
-
|
30
24
|
getHash(content) {
|
31
25
|
let hash = _crypto.default.createHash('md5');
|
32
|
-
|
33
26
|
let data = hash.update(content, 'utf-8');
|
34
27
|
let gen_hash = data.digest('hex');
|
35
28
|
return gen_hash;
|
36
29
|
}
|
37
|
-
|
38
30
|
getFiles() {
|
39
31
|
let hashMapping = {};
|
40
32
|
this.fileMappings.forEach(fileInfo => {
|
41
33
|
let filePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, fileInfo.fileName)}`;
|
42
|
-
|
43
34
|
if (_fs.default.existsSync(filePath)) {
|
44
35
|
let fileContent = _fs.default.readFileSync(filePath, {
|
45
36
|
encoding: 'utf-8'
|
46
37
|
});
|
47
|
-
|
48
38
|
let generatedHash = this.getHash(fileContent);
|
49
39
|
let outputFileSplit = fileInfo.fileName.split('.');
|
50
40
|
outputFileSplit.splice(outputFileSplit.length - 1, 0, generatedHash);
|
51
41
|
let outputFileName = outputFileSplit.join('.');
|
52
42
|
let outputFilePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, outputFileName)}`;
|
53
|
-
|
54
43
|
_fs.default.writeFileSync(outputFilePath, fileContent);
|
55
|
-
|
56
44
|
hashMapping[fileInfo.key] = JSON.stringify(generatedHash);
|
57
45
|
} else {
|
58
46
|
throw new Error(`Third party file ${fileInfo.fileName} does not exist`);
|
@@ -60,8 +48,5 @@ class TPHashMappingPlugin {
|
|
60
48
|
});
|
61
49
|
return hashMapping;
|
62
50
|
}
|
63
|
-
|
64
51
|
}
|
65
|
-
|
66
|
-
var _default = TPHashMappingPlugin;
|
67
|
-
exports.default = _default;
|
52
|
+
var _default = exports.default = TPHashMappingPlugin;
|