@zohodesk/react-cli 1.1.29-exp.2 → 1.1.29-exp.3
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/README.md +18 -0
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +13 -2
- package/lib/babel/es-plugins-presets.js +14 -3
- package/lib/common/buildEs.js +0 -1
- package/lib/common/getEntries.js +13 -2
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +6 -1
- package/lib/common/runPreProcess.js +15 -6
- package/lib/common/splitChunks.js +21 -2
- package/lib/common/sslcertUpdater.js +18 -7
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +16 -1
- package/lib/configs/jest.config.js +11 -2
- package/lib/configs/libAlias.js +16 -10
- package/lib/configs/resolvers.js +16 -6
- package/lib/configs/webpack.component.umd.config.js +6 -1
- package/lib/configs/webpack.css.umd.config.js +14 -6
- package/lib/configs/webpack.dev.config.js +14 -1
- package/lib/configs/webpack.docs.config.js +9 -1
- package/lib/configs/webpack.impact.config.js +8 -1
- package/lib/configs/webpack.prod.config.js +17 -4
- package/lib/constants.js +18 -9
- package/lib/deprecationLogger.js +7 -0
- package/lib/hooks/docsProptypeHook.js +8 -4
- package/lib/jest/commitedFilesResult.js +46 -4
- package/lib/jest/coverageCollector.js +12 -1
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
- package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
- package/lib/jest/result.js +23 -1
- package/lib/jest/run.js +18 -7
- package/lib/jest/setup.js +60 -8
- package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
- package/lib/loaderUtils/getCSSLoaders.js +22 -10
- package/lib/loaderUtils/getDevJsLoaders.js +13 -4
- package/lib/loaderUtils/index.js +4 -1
- package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
- package/lib/loaderUtils/windowsModification.js +3 -2
- package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
- package/lib/loaders/composeLoader.js +37 -13
- package/lib/loaders/docsLoader.js +12 -1
- package/lib/loaders/docsPropsLoader.js +8 -4
- package/lib/loaders/enhancedReactLiveConverter.js +23 -2
- package/lib/loaders/fileBountryLoader.js +3 -1
- package/lib/loaders/fileLoader.js +23 -12
- package/lib/loaders/markdownLoader.js +19 -14
- package/lib/loaders/reactLiveConvertor.js +15 -5
- package/lib/loaders/scriptInstrumentLoader.js +16 -7
- package/lib/loaders/selectorMappingLoader.js +26 -7
- package/lib/loaders/workerLoader.js +24 -9
- package/lib/logger.js +4 -0
- package/lib/middlewares/HMRMiddleware.js +27 -13
- package/lib/middlewares/SSTMiddleware.js +5 -1
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
- package/lib/pluginUtils/getDevPlugins.js +42 -9
- package/lib/pluginUtils/getDocsPlugins.js +13 -3
- package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
- package/lib/pluginUtils/getLibraryPlugins.js +8 -2
- package/lib/pluginUtils/getProdPlugins.js +47 -8
- package/lib/pluginUtils/getServerPlugins.js +8 -2
- package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
- package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
- package/lib/pluginUtils/index.js +9 -1
- package/lib/plugins/CdnChangePlugin.js +18 -2
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/CssOrderControlPlugin.js +6 -3
- package/lib/plugins/CustomAttributePlugin.js +19 -14
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
- package/lib/plugins/EFCPlugin.js +34 -20
- package/lib/plugins/EFCTemplatePlugin.js +30 -19
- package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
- package/lib/plugins/EventsHandlingPlugin.js +4 -2
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
- package/lib/plugins/I18nSplitPlugin/index.js +24 -13
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +8 -1
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
- package/lib/plugins/ManifestPlugin.js +18 -1
- package/lib/plugins/MinifyPlugin.js +10 -1
- package/lib/plugins/ModuleStatsPlugin.js +24 -1
- package/lib/plugins/OptimizeJSPlugin.js +10 -2
- package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
- package/lib/plugins/PublicPathChangePlugin.js +39 -6
- package/lib/plugins/ReportGeneratePlugin.js +32 -5
- package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
- package/lib/plugins/ResourceHintsPlugin.js +13 -4
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
- package/lib/plugins/SelectorPlugin.js +32 -6
- package/lib/plugins/ServiceWorkerPlugin.js +22 -5
- package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
- package/lib/plugins/SourceMapHookPlugin.js +12 -2
- package/lib/plugins/StatsPlugin.js +14 -0
- package/lib/plugins/TPHashMappingPlugin.js +18 -3
- package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
- package/lib/plugins/VariableConversionCollector.js +42 -15
- package/lib/plugins/index.js +20 -1
- package/lib/plugins/libraryImpactPlugin.js +33 -1
- package/lib/plugins/utils/classHandling.js +6 -0
- package/lib/plugins/utils/fileHandling.js +15 -6
- package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
- package/lib/plugins/variableConvertorUtils.js +29 -14
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/EmptyPlugin.js +4 -3
- package/lib/postcss-plugins/ExcludePlugin.js +5 -1
- package/lib/postcss-plugins/IncludePlugin.js +5 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
- package/lib/postcss-plugins/SelectorReplace.js +16 -1
- package/lib/postcss-plugins/ValueReplacer.js +6 -7
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
- package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
- package/lib/schemas/index.js +10 -3
- package/lib/servers/clusterHubServer.js +11 -1
- package/lib/servers/devBuild.js +26 -14
- package/lib/servers/docsServer.js +3 -1
- package/lib/servers/docsServerCore.js +22 -1
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +6 -1
- package/lib/servers/httpsOptions.js +8 -2
- package/lib/servers/impactServer.js +35 -3
- package/lib/servers/mockserver.js +10 -1
- package/lib/servers/nowatchserver.js +37 -12
- package/lib/servers/requireLocalOrGlobal.js +17 -6
- package/lib/servers/scrServer.js +21 -14
- package/lib/servers/server.js +36 -6
- package/lib/servers/ssServer.js +17 -1
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +13 -7
- package/lib/templates/linterConstant.js +4 -2
- package/lib/utils/babelPresets.js +7 -3
- package/lib/utils/clean.js +9 -3
- package/lib/utils/copy.js +7 -1
- package/lib/utils/copyTimezones.js +9 -1
- package/lib/utils/createEventStream.js +6 -1
- package/lib/utils/cssClassNameGenerate.js +30 -10
- package/lib/utils/cssURLReplacer.js +22 -1
- package/lib/utils/dependencyPostPublish.js +10 -1
- package/lib/utils/deprecationSupport.js +32 -7
- package/lib/utils/fileUtils.js +28 -1
- package/lib/utils/folderIterator.js +13 -2
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +22 -1
- package/lib/utils/getFileType.js +10 -2
- package/lib/utils/getHash.js +8 -1
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +53 -16
- package/lib/utils/getServerURL.js +10 -1
- package/lib/utils/index.js +51 -4
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +30 -7
- package/lib/utils/jsonHelper.js +22 -3
- package/lib/utils/libraryImpactConfig.js +5 -2
- package/lib/utils/lint/addScripts.js +5 -2
- package/lib/utils/lint/checkExistingConfig.js +12 -3
- package/lib/utils/lint/copyConfigs.js +3 -0
- package/lib/utils/lint/index.js +9 -0
- package/lib/utils/lint/lintScripts.js +1 -0
- package/lib/utils/lint/lintSetup.js +4 -3
- package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
- package/lib/utils/lint/question.js +7 -0
- package/lib/utils/lintReporter.js +20 -0
- package/lib/utils/log.js +1 -0
- package/lib/utils/mailSender.js +8 -1
- package/lib/utils/object-manipulation.js +17 -1
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +29 -1
- package/lib/utils/removeAttributes.js +8 -1
- package/lib/utils/repoClone.js +28 -3
- package/lib/utils/request.js +12 -0
- package/lib/utils/rtl.js +17 -5
- package/lib/utils/selectorReplacer.js +16 -10
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +11 -1
- package/lib/utils/switchBranch.js +5 -0
- package/lib/utils/typeCheck.js +1 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/lib/utils/variableConverter.js +31 -22
- package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
- package/package.json +3 -2
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
- package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
@@ -6,25 +6,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.REGEXP_CONTENTHASH = void 0;
|
7
7
|
exports.getShortI18nAssets = getShortI18nAssets;
|
8
8
|
exports.hasContentHash = hasContentHash;
|
9
|
+
|
9
10
|
var _urlConcat = require("../../../utils/urlConcat");
|
11
|
+
|
10
12
|
// export const REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/gi;
|
11
13
|
// export const REGEXP_HASH = /\[hash(?::(\d+))?\]/gi;
|
12
14
|
// export const REGEXP_NAME = /\[name\]/gi;
|
13
15
|
// export const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/gi;
|
14
16
|
// TODO: want to choose file type for i18n load
|
15
|
-
const REGEXP_CONTENTHASH =
|
17
|
+
const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
|
18
|
+
exports.REGEXP_CONTENTHASH = REGEXP_CONTENTHASH;
|
19
|
+
|
16
20
|
function hasContentHash(filenameTemplate) {
|
17
21
|
return REGEXP_CONTENTHASH.test(filenameTemplate);
|
18
22
|
}
|
23
|
+
|
19
24
|
function getShortI18nAssets(chunks, i18nManifest, publicPathPrefix) {
|
20
25
|
const i18nAssets = {};
|
21
26
|
chunks.forEach(chunk => {
|
22
27
|
const i18nFiles = i18nManifest[chunk.id];
|
28
|
+
|
23
29
|
if (i18nFiles) {
|
24
30
|
Object.keys(i18nFiles).forEach(locale => {
|
25
31
|
if (!i18nAssets[locale]) {
|
26
32
|
i18nAssets[locale] = [];
|
27
33
|
}
|
34
|
+
|
28
35
|
i18nAssets[locale].push((0, _urlConcat.urlConcat)(publicPathPrefix, i18nFiles[locale]));
|
29
36
|
});
|
30
37
|
}
|
@@ -3,7 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
|
6
7
|
var _collectI18nKeys = require("./collectI18nKeys");
|
8
|
+
|
7
9
|
Object.keys(_collectI18nKeys).forEach(function (key) {
|
8
10
|
if (key === "default" || key === "__esModule") return;
|
9
11
|
if (key in exports && exports[key] === _collectI18nKeys[key]) return;
|
@@ -14,7 +16,9 @@ Object.keys(_collectI18nKeys).forEach(function (key) {
|
|
14
16
|
}
|
15
17
|
});
|
16
18
|
});
|
19
|
+
|
17
20
|
var _propertiesUtils = require("./propertiesUtils");
|
21
|
+
|
18
22
|
Object.keys(_propertiesUtils).forEach(function (key) {
|
19
23
|
if (key === "default" || key === "__esModule") return;
|
20
24
|
if (key in exports && exports[key] === _propertiesUtils[key]) return;
|
@@ -6,13 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.getAllI18n = getAllI18n;
|
7
7
|
exports.getPropertiesAsJSON = getPropertiesAsJSON;
|
8
8
|
exports.jsonToString = jsonToString;
|
9
|
+
|
9
10
|
var _fs = require("fs");
|
11
|
+
|
10
12
|
var _path = require("path");
|
13
|
+
|
11
14
|
var _logger = require("../../../logger");
|
15
|
+
|
12
16
|
var _unicodeConversion = require("./unicodeConversion");
|
17
|
+
|
13
18
|
function isComment(line) {
|
14
19
|
return line[0] === '#';
|
15
20
|
}
|
21
|
+
|
16
22
|
function getPropertiesAsJSON(filePath) {
|
17
23
|
try {
|
18
24
|
const data = (0, _fs.readFileSync)(filePath);
|
@@ -20,13 +26,16 @@ function getPropertiesAsJSON(filePath) {
|
|
20
26
|
const i18nObj = {};
|
21
27
|
source.split(/\r?\n\r?/).forEach(fline => {
|
22
28
|
const line = fline.trim();
|
29
|
+
|
23
30
|
if (!line || isComment(line)) {
|
24
31
|
return;
|
25
32
|
}
|
33
|
+
|
26
34
|
const ind = line.indexOf('=');
|
27
35
|
const key = line.slice(0, ind).replace(/\\ /g, ' ');
|
28
36
|
let value = line.slice(ind + 1);
|
29
37
|
value = (0, _unicodeConversion.convertUnicode)(value);
|
38
|
+
|
30
39
|
if (key && value) {
|
31
40
|
i18nObj[key] = value;
|
32
41
|
}
|
@@ -36,15 +45,19 @@ function getPropertiesAsJSON(filePath) {
|
|
36
45
|
return {};
|
37
46
|
}
|
38
47
|
}
|
48
|
+
|
39
49
|
function getLang(file) {
|
40
50
|
const underScoreIndex = file.indexOf('_');
|
41
51
|
let language = 'en_US';
|
52
|
+
|
42
53
|
if (underScoreIndex !== -1) {
|
43
54
|
language = file.substring(underScoreIndex + 1);
|
44
55
|
language = language.slice(0, language.indexOf('.'));
|
45
56
|
}
|
57
|
+
|
46
58
|
return language;
|
47
59
|
}
|
60
|
+
|
48
61
|
function getAllI18n({
|
49
62
|
folderPath,
|
50
63
|
disableDefault,
|
@@ -58,9 +71,11 @@ function getAllI18n({
|
|
58
71
|
const context = (0, _path.join)(process.cwd(), folderPath);
|
59
72
|
files.forEach(file => {
|
60
73
|
const filePath = (0, _path.join)(context, file);
|
74
|
+
|
61
75
|
if (exclude.test(filePath) || !include.test(filePath)) {
|
62
76
|
return;
|
63
77
|
}
|
78
|
+
|
64
79
|
const i18n = getPropertiesAsJSON(filePath);
|
65
80
|
allLangI18n[getLang(file)] = disableDefault ? i18n : Object.assign({}, jsResourceI18nKeys, i18n);
|
66
81
|
});
|
@@ -70,22 +85,27 @@ function getAllI18n({
|
|
70
85
|
return {};
|
71
86
|
}
|
72
87
|
}
|
88
|
+
|
73
89
|
function jsonToString(json, keySeperator) {
|
74
90
|
let str = '{';
|
75
91
|
const keys = Object.keys(json);
|
76
92
|
keys.forEach((key, i) => {
|
77
93
|
const value = json[key];
|
94
|
+
|
78
95
|
if (!value) {
|
79
96
|
return;
|
80
97
|
}
|
98
|
+
|
81
99
|
str += `"${keySeperator ? key.replace(/(\.|\\(\s+))/g, keySeperator) : key}":"${value.replace(/.?"/g, match => {
|
82
100
|
if (match[0] === '\\') {
|
83
101
|
return match;
|
84
102
|
} else if (match.length === 2) {
|
85
103
|
return `${match[0]}\\${match[1]}`;
|
86
104
|
}
|
105
|
+
|
87
106
|
return `\\${match}`;
|
88
107
|
}).replace(/(\r\n|\n|\r)/g, '')}"`;
|
108
|
+
|
89
109
|
if (i !== keys.length - 1) {
|
90
110
|
str += ',';
|
91
111
|
}
|
@@ -4,32 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
8
10
|
var _webpackSources = require("webpack-sources");
|
9
|
-
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
10
14
|
let filenameParser = filename => {
|
11
15
|
let filepaths = filename.split('/');
|
12
16
|
let hashedName = filepaths[filepaths.length - 1];
|
17
|
+
|
13
18
|
let {
|
14
19
|
name,
|
15
20
|
ext
|
16
21
|
} = _path.default.parse(hashedName);
|
22
|
+
|
17
23
|
let nameparts = name.split('.');
|
24
|
+
|
18
25
|
if (ext === '.css' && /^(rtl|ltr)$/.test(nameparts[nameparts.length - 1])) {
|
19
26
|
return {
|
20
27
|
name: nameparts.slice(0, nameparts.length - 2).join('.') + ext,
|
21
28
|
hashedName
|
22
29
|
};
|
23
30
|
}
|
31
|
+
|
24
32
|
return {
|
25
33
|
name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
|
26
34
|
hashedName
|
27
35
|
};
|
28
36
|
};
|
37
|
+
|
29
38
|
class ManifestPlugin {
|
30
39
|
constructor(options) {
|
31
40
|
this.options = options;
|
32
41
|
}
|
42
|
+
|
33
43
|
apply(compiler) {
|
34
44
|
compiler.hooks.emit.tap('PublicPathChangePlugin', compilation => {
|
35
45
|
let stats = compilation.getStats().toJson();
|
@@ -38,20 +48,25 @@ class ManifestPlugin {
|
|
38
48
|
name: filename,
|
39
49
|
hashedName
|
40
50
|
} = filenameParser(name);
|
51
|
+
|
41
52
|
if (chunk.canBeInitial()) {
|
42
53
|
if (!files.entryFiles) {
|
43
54
|
files.entryFiles = {};
|
44
55
|
}
|
56
|
+
|
45
57
|
files.entryFiles[filename] = hashedName;
|
46
58
|
}
|
59
|
+
|
47
60
|
files[filename] = hashedName;
|
48
61
|
return files;
|
49
62
|
}, files), {});
|
50
63
|
manifest = stats.assets.reduce((files, asset) => {
|
51
64
|
let isEntryAsset = asset.chunks.length > 0;
|
65
|
+
|
52
66
|
if (isEntryAsset) {
|
53
67
|
return files;
|
54
68
|
}
|
69
|
+
|
55
70
|
let {
|
56
71
|
name: filename
|
57
72
|
} = asset;
|
@@ -65,5 +80,7 @@ class ManifestPlugin {
|
|
65
80
|
compilation.assets[this.options.fileName] = new _webpackSources.RawSource(JSON.stringify(manifest));
|
66
81
|
});
|
67
82
|
}
|
83
|
+
|
68
84
|
}
|
85
|
+
|
69
86
|
exports.default = ManifestPlugin;
|
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _webpackSources = require("webpack-sources");
|
9
|
+
|
8
10
|
var _uglifycss = _interopRequireDefault(require("uglifycss"));
|
9
|
-
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
10
14
|
class MinifierPlugin {
|
11
15
|
apply(compiler) {
|
12
16
|
compiler.hooks.emit.tap('MinifierPlugin', compilation => {
|
@@ -14,10 +18,13 @@ class MinifierPlugin {
|
|
14
18
|
if (/\.css$/.test(filename)) {
|
15
19
|
try {
|
16
20
|
let asset = compilation.assets[filename].source();
|
21
|
+
|
17
22
|
if (typeof asset !== 'string') {
|
18
23
|
asset = asset.toString();
|
19
24
|
}
|
25
|
+
|
20
26
|
const result = _uglifycss.default.processString(asset);
|
27
|
+
|
21
28
|
compilation.assets[filename] = new _webpackSources.RawSource(result);
|
22
29
|
} catch (e) {
|
23
30
|
compilation.errors.push(e);
|
@@ -26,5 +33,7 @@ class MinifierPlugin {
|
|
26
33
|
});
|
27
34
|
});
|
28
35
|
}
|
36
|
+
|
29
37
|
}
|
38
|
+
|
30
39
|
exports.default = MinifierPlugin;
|
@@ -4,29 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
8
10
|
var _webpackSources = require("webpack-sources");
|
9
|
-
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
10
14
|
let isValidModule = name => {
|
11
15
|
if (name.includes('node_modules') && (name.includes(`@zohodesk${_path.default.sep}components`) || name.includes(`@zohodesk${_path.default.sep}dot`) || name.includes(`@zohodesk${_path.default.sep}icons`) || name.includes(`@zohodesk${_path.default.sep}svg`)) && !name.endsWith('docs.js')) {
|
12
16
|
return true;
|
13
17
|
}
|
18
|
+
|
14
19
|
return !name.includes('index.js') && !name.endsWith('.css') && !name.endsWith('.png') && !name.includes('node_modules') && name.includes('src');
|
15
20
|
};
|
21
|
+
|
16
22
|
let getModuleName = modulePath => {
|
17
23
|
let [name] = _path.default.parse(modulePath).name.split('.');
|
24
|
+
|
18
25
|
if (modulePath.includes(`@zohodesk${_path.default.sep}components`)) {
|
19
26
|
name = `@zohodesk/components/${name}`;
|
20
27
|
} else if (modulePath.includes(`@zohodesk${_path.default.sep}dot`)) {
|
21
28
|
name = `@zohodesk/dot/${name}`;
|
22
29
|
}
|
30
|
+
|
23
31
|
return name;
|
24
32
|
};
|
33
|
+
|
25
34
|
class ModuleStatsPlugin {
|
26
35
|
constructor(options = {}) {
|
27
36
|
this.options = options;
|
28
37
|
this.options.filename = options.filename || 'js/moduleStats.js';
|
29
38
|
}
|
39
|
+
|
30
40
|
apply(compiler) {
|
31
41
|
compiler.hooks.emit.tap('ModuleStatsPlugin', compilation => {
|
32
42
|
let stats = compilation.getStats().toJson();
|
@@ -34,11 +44,13 @@ class ModuleStatsPlugin {
|
|
34
44
|
let {
|
35
45
|
modules
|
36
46
|
} = stats;
|
47
|
+
|
37
48
|
for (let module of modules) {
|
38
49
|
let {
|
39
50
|
name,
|
40
51
|
reasons
|
41
52
|
} = module;
|
53
|
+
|
42
54
|
if (isValidModule(name)) {
|
43
55
|
let references = new Set();
|
44
56
|
let referencedby = new Set();
|
@@ -47,6 +59,7 @@ class ModuleStatsPlugin {
|
|
47
59
|
compilation.modules.forEach(module => {
|
48
60
|
module.reasons.forEach(reason => {
|
49
61
|
let exportedValue = reason.dependency;
|
62
|
+
|
50
63
|
if (exportedValue.type === 'harmony export imported specifier') {
|
51
64
|
if (exportedValue.module.userRequest.includes(name.replace('.', ''))) {
|
52
65
|
docsName = exportedValue.name;
|
@@ -55,29 +68,35 @@ class ModuleStatsPlugin {
|
|
55
68
|
});
|
56
69
|
});
|
57
70
|
let currentModuleName = name;
|
71
|
+
|
58
72
|
if (Array.isArray(reasons)) {
|
59
73
|
for (let reason of reasons) {
|
60
74
|
let {
|
61
75
|
moduleName
|
62
76
|
} = reason;
|
77
|
+
|
63
78
|
if (isValidModule(moduleName)) {
|
64
79
|
let reasonedModuleName = moduleName;
|
65
80
|
referencedby.add(reasonedModuleName);
|
66
81
|
}
|
67
82
|
}
|
68
83
|
}
|
84
|
+
|
69
85
|
for (let subModule of modules) {
|
70
86
|
let {
|
71
87
|
name: subModuleName,
|
72
88
|
reasons
|
73
89
|
} = subModule;
|
90
|
+
|
74
91
|
if (isValidModule(subModuleName)) {
|
75
92
|
let currentModuleName = subModuleName;
|
93
|
+
|
76
94
|
if (Array.isArray(reasons)) {
|
77
95
|
for (let reason of reasons) {
|
78
96
|
let {
|
79
97
|
moduleName: reasonedModuleName
|
80
98
|
} = reason;
|
99
|
+
|
81
100
|
if (name === reasonedModuleName) {
|
82
101
|
references.add(currentModuleName);
|
83
102
|
}
|
@@ -85,6 +104,7 @@ class ModuleStatsPlugin {
|
|
85
104
|
}
|
86
105
|
}
|
87
106
|
}
|
107
|
+
|
88
108
|
results[currentModuleName] = {
|
89
109
|
name: currentModuleName,
|
90
110
|
references: Array.from(references),
|
@@ -94,8 +114,11 @@ class ModuleStatsPlugin {
|
|
94
114
|
};
|
95
115
|
}
|
96
116
|
}
|
117
|
+
|
97
118
|
compilation.assets[this.options.filename] = new _webpackSources.RawSource(JSON.stringify(results));
|
98
119
|
});
|
99
120
|
}
|
121
|
+
|
100
122
|
}
|
123
|
+
|
101
124
|
exports.default = ModuleStatsPlugin;
|
@@ -4,13 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _optimizeJs = _interopRequireDefault(require("optimize-js"));
|
9
|
+
|
8
10
|
var _webpackSources = require("webpack-sources");
|
9
|
-
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
10
14
|
class OptimizeJSPlugin {
|
11
15
|
constructor(options = {}) {
|
12
16
|
this.optimize = options.optimize;
|
13
17
|
}
|
18
|
+
|
14
19
|
apply(compiler) {
|
15
20
|
compiler.hooks.compilation.tap('OptimizeJSPlugin', compilation => {
|
16
21
|
compilation.hooks.afterOptimizeChunks.tap('OptimizeJSPlugin', chunks => {
|
@@ -29,5 +34,8 @@ class OptimizeJSPlugin {
|
|
29
34
|
});
|
30
35
|
});
|
31
36
|
}
|
37
|
+
|
32
38
|
}
|
33
|
-
|
39
|
+
|
40
|
+
var _default = OptimizeJSPlugin;
|
41
|
+
exports.default = _default;
|
@@ -5,14 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
const MODULE_TYPE = 'css/mini-extract';
|
8
|
+
|
8
9
|
class PublicPathCallbackPlugin {
|
9
10
|
constructor({
|
10
11
|
callback
|
11
12
|
}) {
|
12
13
|
this.publicPathCallback = callback;
|
13
14
|
}
|
15
|
+
|
14
16
|
getCssChunkObject(mainChunk) {
|
15
17
|
const obj = {};
|
18
|
+
|
16
19
|
for (const chunk of mainChunk.getAllAsyncChunks()) {
|
17
20
|
for (const module of chunk.modulesIterable) {
|
18
21
|
if (module.type === MODULE_TYPE) {
|
@@ -21,20 +24,25 @@ class PublicPathCallbackPlugin {
|
|
21
24
|
}
|
22
25
|
}
|
23
26
|
}
|
27
|
+
|
24
28
|
return obj;
|
25
29
|
}
|
30
|
+
|
26
31
|
needChunkOnDemandLoadingCode(chunk) {
|
27
32
|
for (const chunkGroup of chunk.groupsIterable) {
|
28
33
|
if (chunkGroup.getNumberOfChildren() > 0) {
|
29
34
|
return true;
|
30
35
|
}
|
31
36
|
}
|
37
|
+
|
32
38
|
return false;
|
33
39
|
}
|
40
|
+
|
34
41
|
apply(compiler) {
|
35
42
|
compiler.hooks.thisCompilation.tap('PublicPathCallbackPlugin', compilation => {
|
36
43
|
compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathCallbackPlugin', (source, chunk) => {
|
37
44
|
const chunkMap = this.getCssChunkObject(chunk);
|
45
|
+
|
38
46
|
if (Object.keys(chunkMap).length > 0) {
|
39
47
|
return source.replace('__webpack_require__.p', `${this.publicPathCallback}("css")`);
|
40
48
|
}
|
@@ -48,5 +56,8 @@ class PublicPathCallbackPlugin {
|
|
48
56
|
});
|
49
57
|
});
|
50
58
|
}
|
59
|
+
|
51
60
|
}
|
52
|
-
|
61
|
+
|
62
|
+
var _default = PublicPathCallbackPlugin;
|
63
|
+
exports.default = _default;
|
@@ -4,21 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
8
10
|
var _webpackSources = require("webpack-sources");
|
11
|
+
|
9
12
|
var _utils = require("../utils");
|
10
|
-
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
11
16
|
const MODULE_TYPE = 'css/mini-extract';
|
12
17
|
let {
|
13
18
|
chunkSplitEnable
|
14
19
|
} = (0, _utils.getOptions)().i18n || {};
|
20
|
+
|
15
21
|
let filenameParser = filename => {
|
16
22
|
let filepaths = filename.split('/');
|
17
23
|
let hashedName = filepaths[filepaths.length - 1];
|
24
|
+
|
18
25
|
let {
|
19
26
|
name,
|
20
27
|
ext
|
21
28
|
} = _path.default.parse(hashedName);
|
29
|
+
|
22
30
|
let nameparts = name.split('.');
|
23
31
|
return {
|
24
32
|
name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
|
@@ -26,14 +34,15 @@ let filenameParser = filename => {
|
|
26
34
|
ext
|
27
35
|
};
|
28
36
|
};
|
37
|
+
|
29
38
|
class PublicPathChangePlugin {
|
30
39
|
constructor({
|
31
40
|
publicPaths,
|
32
41
|
resourceHints
|
33
42
|
}) {
|
34
43
|
if (Array.isArray(publicPaths)) {
|
35
|
-
let [js, css, image, font, i18njs] = publicPaths;
|
36
|
-
|
44
|
+
let [js, css, image, font, i18njs] = publicPaths; //eslint-disable-next-line
|
45
|
+
|
37
46
|
publicPaths = {
|
38
47
|
__REACT_CLI_PUBLIC_PATHS__: {
|
39
48
|
js,
|
@@ -44,11 +53,14 @@ class PublicPathChangePlugin {
|
|
44
53
|
}
|
45
54
|
};
|
46
55
|
}
|
56
|
+
|
47
57
|
this.publicPaths = publicPaths;
|
48
58
|
this.resourceHints = resourceHints;
|
49
59
|
}
|
60
|
+
|
50
61
|
getCssChunkObject(mainChunk) {
|
51
62
|
const obj = {};
|
63
|
+
|
52
64
|
for (const chunk of mainChunk.getAllAsyncChunks()) {
|
53
65
|
for (const module of chunk.modulesIterable) {
|
54
66
|
if (module.type === MODULE_TYPE) {
|
@@ -57,34 +69,42 @@ class PublicPathChangePlugin {
|
|
57
69
|
}
|
58
70
|
}
|
59
71
|
}
|
72
|
+
|
60
73
|
return obj;
|
61
74
|
}
|
75
|
+
|
62
76
|
needChunkOnDemandLoadingCode(chunk) {
|
63
77
|
for (const chunkGroup of chunk.groupsIterable) {
|
64
78
|
if (chunkGroup.getNumberOfChildren() > 0) {
|
65
79
|
return true;
|
66
80
|
}
|
67
81
|
}
|
82
|
+
|
68
83
|
return false;
|
69
84
|
}
|
85
|
+
|
70
86
|
getResourceHints(resourceHints, manifest, publicPaths) {
|
71
87
|
let ruleMapping = {};
|
72
88
|
let validFiles = Object.keys(manifest).filter(filename => {
|
73
89
|
let isValidFile = false;
|
90
|
+
|
74
91
|
for (let pattern of resourceHints) {
|
75
92
|
if (typeof pattern === 'string') {
|
76
93
|
isValidFile = new RegExp(pattern).test(filename);
|
77
94
|
} else {
|
78
95
|
isValidFile = new RegExp(pattern.pattern).test(filename);
|
79
96
|
}
|
97
|
+
|
80
98
|
if (isValidFile) {
|
81
99
|
ruleMapping[filename] = typeof pattern !== 'string' ? pattern : {};
|
82
100
|
break;
|
83
101
|
}
|
84
102
|
}
|
103
|
+
|
85
104
|
return isValidFile;
|
86
105
|
});
|
87
106
|
let resourceHintsContent = '';
|
107
|
+
|
88
108
|
for (let file of validFiles) {
|
89
109
|
let {
|
90
110
|
fileType,
|
@@ -93,12 +113,15 @@ class PublicPathChangePlugin {
|
|
93
113
|
let rules = ruleMapping[file];
|
94
114
|
resourceHintsContent += `<link rel=${rules.hint || 'preload'} href='${publicPaths[fileType] + filename}'${rules.hint === 'prefetch' ? '' : `as='${fileType}' crossorigin='${rules.crossorigin || 'false'}'`} />`;
|
95
115
|
}
|
116
|
+
|
96
117
|
return resourceHintsContent;
|
97
118
|
}
|
119
|
+
|
98
120
|
apply(compiler) {
|
99
121
|
compiler.hooks.thisCompilation.tap('PublicPathChangePlugin', compilation => {
|
100
122
|
compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathChangePlugin', (source, chunk) => {
|
101
123
|
const chunkMap = this.getCssChunkObject(chunk);
|
124
|
+
|
102
125
|
if (Object.keys(chunkMap).length > 0) {
|
103
126
|
return source.replace('__webpack_require__.p', '__REACT_CLI_CSS_PUBLIC_PATH__');
|
104
127
|
}
|
@@ -119,6 +142,7 @@ class PublicPathChangePlugin {
|
|
119
142
|
name: filename
|
120
143
|
} = asset;
|
121
144
|
let fileType = (0, _utils.getFileType)(filename);
|
145
|
+
|
122
146
|
if (fileType === 'image' || fileType === 'font') {
|
123
147
|
let {
|
124
148
|
name,
|
@@ -132,12 +156,14 @@ class PublicPathChangePlugin {
|
|
132
156
|
filename
|
133
157
|
};
|
134
158
|
}
|
159
|
+
|
135
160
|
return files;
|
136
161
|
}, {});
|
137
162
|
Object.keys(compilation.assets).forEach(filename => {
|
138
163
|
if (Array.isArray(cdns)) {
|
139
164
|
cdns.forEach(cdn => {
|
140
165
|
let source = compilation.assets[filename].source();
|
166
|
+
|
141
167
|
if (/\.css$/g.test(filename)) {
|
142
168
|
let publicPaths = this.publicPaths[cdn];
|
143
169
|
source = (0, _utils.cssUrlReplacer)(source, publicPaths, manifest, cdn);
|
@@ -148,6 +174,7 @@ class PublicPathChangePlugin {
|
|
148
174
|
image,
|
149
175
|
font
|
150
176
|
} = this.publicPaths[cdn];
|
177
|
+
|
151
178
|
if (typeof source === 'string') {
|
152
179
|
source = source.replace(/__REACT_CLI_JS_PUBLIC_PATH__/g, `"${js}"`);
|
153
180
|
source = source.replace(/__REACT_CLI_CSS_PUBLIC_PATH__/g, `"${css}"`);
|
@@ -163,6 +190,7 @@ class PublicPathChangePlugin {
|
|
163
190
|
source = source.replace(new RegExp('<script defer src="([^"]*)"', 'g'), (match, arg) => match.replace(arg, js + arg));
|
164
191
|
source = source.replace(new RegExp('<link href="([^"]*)"', 'g'), (match, arg) => match.replace(arg, css + arg));
|
165
192
|
let [i18nStr] = source.match(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm);
|
193
|
+
|
166
194
|
if (i18nStr && !chunkSplitEnable) {
|
167
195
|
try {
|
168
196
|
let [i18nObj] = i18nStr.match(/{(.*?)}/gm);
|
@@ -173,21 +201,26 @@ class PublicPathChangePlugin {
|
|
173
201
|
source = source.replace(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm, `<!--I18nInfoToServer${JSON.stringify(i18nObj)}I18nInfoToServer-->`);
|
174
202
|
} catch (e) {
|
175
203
|
// eslint-disable-next-line no-console
|
176
|
-
console.warn('may be I18nInfoToServer inside object was not valid make sure it is parseable by JSON.parse');
|
177
|
-
|
204
|
+
console.warn('may be I18nInfoToServer inside object was not valid make sure it is parseable by JSON.parse'); // eslint-disable-next-line no-console
|
205
|
+
|
178
206
|
console.warn(e);
|
179
207
|
}
|
180
208
|
}
|
209
|
+
|
181
210
|
if (Array.isArray(this.resourceHints) && this.resourceHints.length) {
|
182
211
|
let resourceHintsContent = this.getResourceHints(this.resourceHints, manifest, this.publicPaths[cdn]);
|
183
212
|
source = source.replace(/<\/head>/g, `${resourceHintsContent}</head>`);
|
184
213
|
}
|
185
214
|
}
|
215
|
+
|
186
216
|
compilation.assets[cdn === '__REACT_CLI_PUBLIC_PATHS__' ? filename : `${cdn}/${filename}`] = new _webpackSources.RawSource(source);
|
187
217
|
});
|
188
218
|
}
|
189
219
|
});
|
190
220
|
});
|
191
221
|
}
|
222
|
+
|
192
223
|
}
|
193
|
-
|
224
|
+
|
225
|
+
var _default = PublicPathChangePlugin;
|
226
|
+
exports.default = _default;
|