@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.170
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/.eslintignore +1 -0
- package/.eslintrc.js +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +855 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +98 -84
- package/lib/configs/webpack.docs.config.js +64 -57
- package/lib/configs/webpack.impact.config.js +108 -0
- package/lib/configs/webpack.prod.config.js +146 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- 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 +95 -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 +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +365 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +534 -66
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +136 -0
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- 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 +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- 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 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
- package/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
@@ -0,0 +1,181 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
var _redis = _interopRequireDefault(require("redis"));
|
13
|
+
|
14
|
+
var _utils = require("../utils");
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
18
|
+
let options = (0, _utils.getOptions)();
|
19
|
+
let {
|
20
|
+
app: {
|
21
|
+
branch,
|
22
|
+
redisHost,
|
23
|
+
redisPort
|
24
|
+
}
|
25
|
+
} = options;
|
26
|
+
|
27
|
+
class reportGeneratePlugin {
|
28
|
+
apply(compiler) {
|
29
|
+
compiler.hooks.emit.tapAsync('reportGeneratePlugin', (compilation, callback) => {
|
30
|
+
function formatBytes(bytes) {
|
31
|
+
if (bytes) {
|
32
|
+
let isNegative;
|
33
|
+
|
34
|
+
if (bytes < 0) {
|
35
|
+
bytes = bytes * -1; //eslint-disable-line
|
36
|
+
|
37
|
+
isNegative = true;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (bytes < 1024) {
|
41
|
+
if (isNegative) {
|
42
|
+
return `- ${bytes} Bytes`;
|
43
|
+
}
|
44
|
+
|
45
|
+
return `${bytes} Bytes`;
|
46
|
+
} else if (bytes < 1048576) {
|
47
|
+
if (isNegative) {
|
48
|
+
return `- ${(bytes / 1024).toFixed(3)} KB`;
|
49
|
+
}
|
50
|
+
|
51
|
+
return `${(bytes / 1024).toFixed(3)} KB`;
|
52
|
+
} else if (bytes < 1073741824) {
|
53
|
+
if (isNegative) {
|
54
|
+
return `- ${(bytes / 1048576).toFixed(3)} MB`;
|
55
|
+
}
|
56
|
+
|
57
|
+
return `${(bytes / 1048576).toFixed(3)} MB`;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (isNegative) {
|
61
|
+
return `- ${(bytes / 1073741824).toFixed(3)} GB`;
|
62
|
+
}
|
63
|
+
|
64
|
+
return `${(bytes / 1073741824).toFixed(3)} GB`;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
let client = _redis.default.createClient(redisPort, redisHost);
|
69
|
+
|
70
|
+
client.on('connect', () => {
|
71
|
+
(0, _utils.log)('Redis client connected');
|
72
|
+
});
|
73
|
+
client.on('error', err => {
|
74
|
+
(0, _utils.log)(`Something went wrong ${err}`);
|
75
|
+
});
|
76
|
+
|
77
|
+
if (_fs.default.existsSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'))) {
|
78
|
+
let statsJSON = _fs.default.readFileSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'), 'utf8');
|
79
|
+
|
80
|
+
statsJSON = JSON.parse(statsJSON);
|
81
|
+
let finalObj = {};
|
82
|
+
let branchName = branch ? branch : (0, _utils.getCurrentBranch)();
|
83
|
+
(0, _utils.log)(branchName);
|
84
|
+
statsJSON.assets.forEach(assetObj => {
|
85
|
+
let nameSplitList = assetObj.name.split('/')[assetObj.name.split('/').length - 1].split('.'); // eslint-disable-line
|
86
|
+
|
87
|
+
let [, hash] = nameSplitList;
|
88
|
+
let name = `${nameSplitList[0]}.${nameSplitList[2]}`;
|
89
|
+
let {
|
90
|
+
size
|
91
|
+
} = assetObj;
|
92
|
+
let tempObject = {
|
93
|
+
name,
|
94
|
+
hash,
|
95
|
+
size
|
96
|
+
}; // eslint-disable-next-line
|
97
|
+
|
98
|
+
if (!finalObj.hasOwnProperty(name)) {
|
99
|
+
finalObj[name] = tempObject;
|
100
|
+
}
|
101
|
+
});
|
102
|
+
client.exists(branchName, (err, bool) => {
|
103
|
+
if (!bool) {
|
104
|
+
client.set(branchName, JSON.stringify(finalObj), _redis.default.print);
|
105
|
+
client.quit();
|
106
|
+
} else {
|
107
|
+
let reportObj = {
|
108
|
+
increased: [],
|
109
|
+
hashChanged: [],
|
110
|
+
branchName
|
111
|
+
};
|
112
|
+
client.get(branchName, (err, reply) => {
|
113
|
+
if (err) {
|
114
|
+
(0, _utils.log)(err);
|
115
|
+
} else {
|
116
|
+
reply = JSON.parse(reply); // eslint-disable-line
|
117
|
+
|
118
|
+
Object.keys(reply).forEach(fileName => {
|
119
|
+
// eslint-disable-next-line
|
120
|
+
if (finalObj.hasOwnProperty(fileName)) {
|
121
|
+
if (parseInt(reply[fileName].size) < parseInt(finalObj[fileName].size)) {
|
122
|
+
reportObj.increased.push({
|
123
|
+
name: fileName,
|
124
|
+
size: {
|
125
|
+
old: formatBytes(reply[fileName].size),
|
126
|
+
new: formatBytes(finalObj[fileName].size),
|
127
|
+
diff: formatBytes(parseInt(finalObj[fileName].size) - parseInt(reply[fileName].size))
|
128
|
+
}
|
129
|
+
});
|
130
|
+
}
|
131
|
+
|
132
|
+
if (reply[fileName].hash !== finalObj[fileName].hash) {
|
133
|
+
reportObj.hashChanged.push({
|
134
|
+
name: fileName,
|
135
|
+
hash: {
|
136
|
+
old: reply[fileName].hash,
|
137
|
+
new: finalObj[fileName].hash
|
138
|
+
}
|
139
|
+
});
|
140
|
+
}
|
141
|
+
}
|
142
|
+
});
|
143
|
+
let json = JSON.stringify(reportObj);
|
144
|
+
|
145
|
+
_fs.default.writeFile(_path.default.resolve(process.cwd(), 'build', 'buildtrack.js'), `let statsJson=${json}`, err => {
|
146
|
+
if (err) {
|
147
|
+
throw err;
|
148
|
+
}
|
149
|
+
|
150
|
+
(0, _utils.log)('Stats Json generated!');
|
151
|
+
});
|
152
|
+
}
|
153
|
+
});
|
154
|
+
client.set(branchName, JSON.stringify(finalObj), _redis.default.print); // fs.copyFileSync(
|
155
|
+
// path.resolve(
|
156
|
+
// process.cwd(),
|
157
|
+
// 'node_modules',
|
158
|
+
// '@zohodesk',
|
159
|
+
// 'react-cli',
|
160
|
+
// 'lib',
|
161
|
+
// 'utils',
|
162
|
+
// 'buildstats.html'
|
163
|
+
// ),
|
164
|
+
// path.resolve(process.cwd(), 'build', 'buildstats.html')
|
165
|
+
// );
|
166
|
+
|
167
|
+
client.quit();
|
168
|
+
callback && callback();
|
169
|
+
}
|
170
|
+
|
171
|
+
if (err) {
|
172
|
+
(0, _utils.log)(err);
|
173
|
+
}
|
174
|
+
});
|
175
|
+
}
|
176
|
+
});
|
177
|
+
}
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
exports.default = reportGeneratePlugin;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
const {
|
9
|
+
Template
|
10
|
+
} = require('webpack');
|
11
|
+
|
12
|
+
const pluginName = 'RequireVariablePublicPlugin';
|
13
|
+
|
14
|
+
class RequireVariablePublicPlugin {
|
15
|
+
constructor(options) {
|
16
|
+
this.requireFuncName = options.requireFuncName;
|
17
|
+
}
|
18
|
+
|
19
|
+
apply(compiler) {
|
20
|
+
compiler.hooks.thisCompilation.tap(pluginName, ({
|
21
|
+
mainTemplate
|
22
|
+
}) => {
|
23
|
+
mainTemplate.hooks.requireExtensions.tap(pluginName, source => Template.asString([source, '', `window[${JSON.stringify(this.requireFuncName)}] = ${mainTemplate.requireFn};`]));
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
var _default = RequireVariablePublicPlugin;
|
30
|
+
exports.default = _default;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
const {
|
9
|
+
Template
|
10
|
+
} = require('webpack');
|
11
|
+
|
12
|
+
const pluginName = 'prefetch-preload-chunk-plugin';
|
13
|
+
|
14
|
+
class ResourceHintsPlugin {
|
15
|
+
apply(compiler) {
|
16
|
+
compiler.hooks.thisCompilation.tap(pluginName, ({
|
17
|
+
mainTemplate
|
18
|
+
}) => {
|
19
|
+
mainTemplate.hooks.requireExtensions.tap(pluginName, (source, chunk, hash) => {
|
20
|
+
const idNameMap = chunk.getChunkMaps().name;
|
21
|
+
const nameIdMap = {};
|
22
|
+
let needsMap = false;
|
23
|
+
|
24
|
+
for (const key in idNameMap) {
|
25
|
+
if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
|
26
|
+
const value = idNameMap[key];
|
27
|
+
nameIdMap[value] = key;
|
28
|
+
|
29
|
+
if (key !== value) {
|
30
|
+
needsMap = true;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
return Template.asString([source, '', `${mainTemplate.requireFn}.getChunkId = function getChunkId(chunkId) {`, Template.indent((needsMap ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`] : []).concat(['return chunkId;'])), '}', `// Prefetch a chunk (${pluginName})`, `${mainTemplate.requireFn}.pfc = function prefetchChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, `${mainTemplate.requireFn}.e(chunkId);`]), '};',
|
36
|
+
/*
|
37
|
+
(needsMap
|
38
|
+
? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
|
39
|
+
: []
|
40
|
+
).concat([
|
41
|
+
'var promises = [];',
|
42
|
+
'if(installedChunks[chunkId] === undefined) {',
|
43
|
+
Template.indent([
|
44
|
+
'installedChunks[chunkId] = null;',
|
45
|
+
/* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
|
46
|
+
'document.head.appendChild(link);', */
|
47
|
+
|
48
|
+
/*
|
49
|
+
mainTemplate.hooks.requireEnsure.call('', chunk, hash)
|
50
|
+
]),
|
51
|
+
'}'
|
52
|
+
])
|
53
|
+
),
|
54
|
+
'}',
|
55
|
+
*/
|
56
|
+
`// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, 'if(installedChunks[chunkId] === undefined) {', Template.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'document.head.appendChild(link);', `${mainTemplate.requireFn}.e(chunkId);` // 'var head = document.getElementsByTagName(\'head\')[0];',
|
57
|
+
// mainTemplate.hooks.jsonpScript.call('', chunk, hash),
|
58
|
+
// 'head.appendChild(script);'
|
59
|
+
]), '}']), '};']);
|
60
|
+
});
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
var _default = ResourceHintsPlugin;
|
67
|
+
exports.default = _default;
|
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
9
|
+
|
10
|
+
var _replaceCssDirTemplate = require("./replaceCssDirTemplate");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
// const HtmlWebpackPlugin = require('html-webpack-plugin');
|
15
|
+
const pluginName = 'OverwriteCssPathForRTL'; // const pluginName = 'rtl-css-transform-webpack-plugin';
|
16
|
+
// if we choose file name as style.ltr.css and style.rtl.css it will be easy for html template
|
17
|
+
// this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
|
18
|
+
|
19
|
+
class OverwriteCssPathForRTL {
|
20
|
+
constructor(options = {
|
21
|
+
dirVarName: 'document.dir'
|
22
|
+
}) {
|
23
|
+
this.dirVarName = options.dirVarName || 'document.dir';
|
24
|
+
this.templateLabel = options.templateLabel || '{{--dir}}';
|
25
|
+
}
|
26
|
+
|
27
|
+
overwriteCssPathinHTML(compilation) {
|
28
|
+
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync(pluginName, (data, cb) => {
|
29
|
+
let {
|
30
|
+
assets
|
31
|
+
} = data;
|
32
|
+
cb(null, Object.assign({}, data, {
|
33
|
+
assets: Object.assign({}, assets, {
|
34
|
+
css: assets.css && (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(assets.css, this.templateLabel)
|
35
|
+
})
|
36
|
+
}));
|
37
|
+
});
|
38
|
+
}
|
39
|
+
|
40
|
+
overwriteCssPathinRequireEnsure(compilation) {
|
41
|
+
// NOTE: if you goig to change an thing here you may check with EFCPlugin, ServiceWorkerPlugin
|
42
|
+
const {
|
43
|
+
mainTemplate
|
44
|
+
} = compilation; // TODO: must verify when we move to webpack5 ay be we need to change this
|
45
|
+
// TODO it's may not be perfect solution, but it will work
|
46
|
+
// mainTemplate.hooks.assetPath.tap(pluginName, (path, data) => {
|
47
|
+
|
48
|
+
mainTemplate.hooks.assetPath.tap(pluginName, filePath => {
|
49
|
+
if (!filePath.endsWith('.css"')) {
|
50
|
+
return filePath;
|
51
|
+
}
|
52
|
+
|
53
|
+
const ENDS = '.ltr.css"'; // if we need total differend temlate for file name it will be too hard
|
54
|
+
|
55
|
+
const templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": ".ltr")+".css"`; // const templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": "")+".css"`;
|
56
|
+
// NOTE:
|
57
|
+
// we don't use rtlFilename as full replace because it may increace runtime chunk file size
|
58
|
+
// they replace [chunkhash] with object full chunk hash so it may dub
|
59
|
+
// const templateText = `(${this.dirVarName} === "rtl" ? ${JSON.stringify(this.rtlFilename)}: ${filePath})`;
|
60
|
+
// const templateText = '."+(document.dir === "rtl" ? ".rtl": "")+".css"';
|
61
|
+
// File path going to be like below
|
62
|
+
// '"style.css"' ==>> `"style."+document.dir+".css"`
|
63
|
+
// '"style.css"' ==>> `"style."+(document.dir === "rtl" ? ".rtl": "")+".css"`
|
64
|
+
// replace like this
|
65
|
+
// '.ltr.css"' ==>> `."+(document.dir === "rtl" ? ".rtl": ".ltr")+".css"`
|
66
|
+
|
67
|
+
return filePath.replace(ENDS, templateText);
|
68
|
+
});
|
69
|
+
}
|
70
|
+
|
71
|
+
apply(compiler) {
|
72
|
+
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
73
|
+
this.overwriteCssPathinHTML(compilation);
|
74
|
+
this.overwriteCssPathinRequireEnsure(compilation);
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
}
|
79
|
+
|
80
|
+
exports.default = OverwriteCssPathForRTL;
|
@@ -0,0 +1,82 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.RtlCssPlugin = void 0;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _webpackSources = require("webpack-sources");
|
11
|
+
|
12
|
+
var _OverwriteCssPathForRTL = _interopRequireDefault(require("./OverwriteCssPathForRTL"));
|
13
|
+
|
14
|
+
var _RTLSplitPlugin = require("../../postcss-plugins/RTLSplitPlugin");
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
18
|
+
// import HtmlWebpackPlugin from 'html-webpack-plugin';
|
19
|
+
// import rtlcss from 'rtlcss';
|
20
|
+
const pluginName = 'RtlCssPlugin'; // const pluginName = 'rtl-css-transform-webpack-plugin';
|
21
|
+
|
22
|
+
const isCss = filename => _path.default.extname(filename) === '.css'; // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
|
23
|
+
|
24
|
+
|
25
|
+
class RtlCssPlugin {
|
26
|
+
constructor(options = {}) {
|
27
|
+
/**
|
28
|
+
* @typedef {Object} Options
|
29
|
+
* @property {String} filename [not used]
|
30
|
+
* @property {String} dirVarName
|
31
|
+
* @property {Boolean} sourcemap
|
32
|
+
* @property {Object} config
|
33
|
+
*/
|
34
|
+
this.options = {
|
35
|
+
filename: options.filename || '[name].rtl.css',
|
36
|
+
// dirVarName: options.dirVarName || 'document.dir',
|
37
|
+
sourcemap: options.sourcemap,
|
38
|
+
config: options.config
|
39
|
+
};
|
40
|
+
this.templateLabel = options.templateLabel || '{{--dir}}';
|
41
|
+
this.dirVarName = options.dirVarName || 'document.dir';
|
42
|
+
this.rtlSplitOptions = {
|
43
|
+
disableMiniFiySelector: options.disableMiniFiySelector
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
apply(compiler) {
|
48
|
+
new _OverwriteCssPathForRTL.default({
|
49
|
+
templateLabel: this.templateLabel,
|
50
|
+
dirVarName: this.dirVarName
|
51
|
+
}).apply(compiler); // const { filename, sourcemap, config } = this.options;
|
52
|
+
// const { devtool } = compiler.options;
|
53
|
+
// const postcssOptions = {
|
54
|
+
// map: (sourcemap === undefined && !!devtool) || !!sourcemap
|
55
|
+
// };
|
56
|
+
|
57
|
+
compiler.hooks.compilation.tap(pluginName, compilation => {
|
58
|
+
compilation.hooks.optimizeChunkAssets.tapAsync(pluginName, (chunks, callback) => {
|
59
|
+
chunks.forEach(chunk => {
|
60
|
+
chunk.files.filter(isCss).forEach(chunkFilename => {
|
61
|
+
const asset = compilation.assets[chunkFilename];
|
62
|
+
const sourceStr = asset.source();
|
63
|
+
const {
|
64
|
+
ltr,
|
65
|
+
rtl
|
66
|
+
} = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions); // const result = rtlcss
|
67
|
+
// .configure(config)
|
68
|
+
// .process(asset.source(), postcssOptions);
|
69
|
+
|
70
|
+
const assetFilename = chunkFilename.replace('.ltr.', '.rtl.');
|
71
|
+
compilation.assets[chunkFilename] = new _webpackSources.RawSource(ltr);
|
72
|
+
compilation.assets[assetFilename] = new _webpackSources.RawSource(rtl);
|
73
|
+
});
|
74
|
+
});
|
75
|
+
callback();
|
76
|
+
});
|
77
|
+
});
|
78
|
+
}
|
79
|
+
|
80
|
+
}
|
81
|
+
|
82
|
+
exports.RtlCssPlugin = RtlCssPlugin;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# RTL Split
|
2
|
+
|
3
|
+
we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
|
4
|
+
It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
|
5
|
+
Here is problem mostly no one need rtl and ltr related css at the same time in browser,
|
6
|
+
we are try to split them by [dir] and load which type of css is needed.
|
7
|
+
For this purpose we created RTL Split Plugin
|
8
|
+
|
9
|
+
|
10
|
+
# To Try it out rtl-ltr split
|
11
|
+
### how to use this feature?
|
12
|
+
|
13
|
+
to use this feature use have give the below oprtions
|
14
|
+
`package.json`
|
15
|
+
```json
|
16
|
+
{
|
17
|
+
/// ...some things
|
18
|
+
"react-cli": {
|
19
|
+
// ...some things
|
20
|
+
"css": {
|
21
|
+
"enableRTLSplit": true,
|
22
|
+
"templateLabel": "{{--dir}}",// this is for html template css file path dir template
|
23
|
+
"disableMiniFiySelector": false,
|
24
|
+
"dirVarName": "document.dir" // this will be used for download css based on dir
|
25
|
+
},
|
26
|
+
// ...some things
|
27
|
+
}
|
28
|
+
}
|
29
|
+
```
|
30
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.replaceCssDirTemplate = replaceCssDirTemplate;
|
7
|
+
exports.replaceCssDirTemplateMapper = replaceCssDirTemplateMapper;
|
8
|
+
exports.strFunctionTempalteToReplaceCssDir = void 0;
|
9
|
+
|
10
|
+
function replaceCssDirTemplate(filePath, cssDirTemplate) {
|
11
|
+
return filePath.endsWith('.ltr.css') ? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
|
12
|
+
filePath.replace('.ltr.css', `.${cssDirTemplate}.css`) : filePath;
|
13
|
+
}
|
14
|
+
|
15
|
+
function replaceCssDirTemplateMapper(assets, cssDirTemplate) {
|
16
|
+
return assets.map(filePath => replaceCssDirTemplate(filePath, cssDirTemplate));
|
17
|
+
}
|
18
|
+
|
19
|
+
const strFunctionTempalteToReplaceCssDir = cssDirTemplate => `function replaceCssDirTemplate(filePath, cssDirTemplate) {
|
20
|
+
return filePath.endsWith(".ltr.css")
|
21
|
+
? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
|
22
|
+
filePath.replace(".ltr.css", ".${cssDirTemplate}.css")
|
23
|
+
: filePath;
|
24
|
+
}`;
|
25
|
+
|
26
|
+
exports.strFunctionTempalteToReplaceCssDir = strFunctionTempalteToReplaceCssDir;
|
@@ -1,51 +1,36 @@
|
|
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 _fs = _interopRequireDefault(require("fs"));
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _fs2 = _interopRequireDefault(_fs);
|
12
|
-
|
13
|
-
var _path = require('path');
|
14
|
-
|
15
|
-
var _path2 = _interopRequireDefault(_path);
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
16
11
|
|
17
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
chunk.files.forEach(function (filename) {
|
34
|
-
if (filename === 'vendor.js') {
|
35
|
-
compilation.assets[filename].children.forEach(function (child) {
|
36
|
-
if (child._value) {
|
37
|
-
child._value = coverageScript + child._value;
|
38
|
-
}
|
39
|
-
});
|
40
|
-
}
|
41
|
-
});
|
14
|
+
let coverageScript = _fs.default.readFileSync(_path.default.resolve(__dirname, '..', 'templates', 'CoverageScriptTemplate.js')).toString();
|
15
|
+
|
16
|
+
class ScriptInstrumentPlugin {
|
17
|
+
apply(compiler) {
|
18
|
+
compiler.hooks.emit.tapAsync('ScriptInstrumentPlugin', (compilation, callback) => {
|
19
|
+
compilation.chunks.forEach(chunk => {
|
20
|
+
chunk.files.forEach(filename => {
|
21
|
+
if (filename === 'vendor.js') {
|
22
|
+
compilation.assets[filename].children.forEach(child => {
|
23
|
+
if (child._value) {
|
24
|
+
child._value = coverageScript + child._value;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
42
28
|
});
|
43
|
-
callback();
|
44
29
|
});
|
45
|
-
|
46
|
-
|
30
|
+
callback();
|
31
|
+
});
|
32
|
+
}
|
47
33
|
|
48
|
-
|
49
|
-
}();
|
34
|
+
}
|
50
35
|
|
51
36
|
exports.default = ScriptInstrumentPlugin;
|
@@ -0,0 +1,107 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
13
|
+
|
14
|
+
var _utils = require("../utils");
|
15
|
+
|
16
|
+
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
|
17
|
+
|
18
|
+
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
19
|
+
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
+
|
22
|
+
const {
|
23
|
+
css: {
|
24
|
+
enableRTLSplit
|
25
|
+
},
|
26
|
+
i18n: {
|
27
|
+
chunkSplitEnable
|
28
|
+
}
|
29
|
+
} = (0, _utils.getOptions)();
|
30
|
+
|
31
|
+
class ServiceWorkerPlugin {
|
32
|
+
constructor(options) {
|
33
|
+
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
34
|
+
this.fileName = options.fileName;
|
35
|
+
this.serviceWorkerPath = options.filePath;
|
36
|
+
this.writePath = options.exitPath;
|
37
|
+
this.replaceText = options.replaceText; // this.publicPaths = options.publicPaths;
|
38
|
+
}
|
39
|
+
|
40
|
+
isInitialChunk(chunk) {
|
41
|
+
if ('canBeInitial' in chunk) {
|
42
|
+
return chunk.canBeInitial();
|
43
|
+
}
|
44
|
+
|
45
|
+
return chunk.isInitial();
|
46
|
+
}
|
47
|
+
|
48
|
+
apply(compiler) {
|
49
|
+
compiler.hooks.emit.tap('ServiceWorkerPlugin', compilation => {
|
50
|
+
_fs.default.readFile(this.serviceWorkerPath, 'utf-8', (err, data) => {
|
51
|
+
if (err) {
|
52
|
+
throw new Error(err);
|
53
|
+
} else {
|
54
|
+
/* const extractedChunks = compilation.chunks.filter(chunk => {
|
55
|
+
if ('canBeInitial' in chunk) {
|
56
|
+
return chunk.canBeInitial();
|
57
|
+
}
|
58
|
+
return chunk.isInitial();
|
59
|
+
}); */
|
60
|
+
// let [js, css, , , i18nPublicPath] = this.publicPaths;
|
61
|
+
// let initialChunkUrls = [];
|
62
|
+
let allChunkUrls = [];
|
63
|
+
let allI18nAssets = [];
|
64
|
+
let entrypoint = compilation.entrypoints.get('main');
|
65
|
+
let initialChunkUrls = entrypoint.getFiles();
|
66
|
+
const cssDirTemplate = '@dir@';
|
67
|
+
/**
|
68
|
+
* NOTE:
|
69
|
+
* if chunkSplitEnable is false means,
|
70
|
+
* serviceWorker will get i18n files path for html
|
71
|
+
*/
|
72
|
+
|
73
|
+
let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
|
74
|
+
chunkSplitEnable && compilation.chunks.filter(c => !this.isInitialChunk(c)).filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).forEach(chunk => {
|
75
|
+
// let isInitial = this.isInitialChunk(chunk);
|
76
|
+
allChunkUrls = allChunkUrls.concat(chunk.files);
|
77
|
+
allI18nAssets.push((0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
78
|
+
});
|
79
|
+
/** Removing source map files from getting added */
|
80
|
+
|
81
|
+
initialChunkUrls = initialChunkUrls.filter(fileName => !fileName.endsWith('.map'));
|
82
|
+
allChunkUrls = allChunkUrls.filter(fileName => !fileName.endsWith('.map'));
|
83
|
+
|
84
|
+
if (enableRTLSplit) {
|
85
|
+
initialChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(initialChunkUrls, cssDirTemplate);
|
86
|
+
allChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(allChunkUrls, cssDirTemplate);
|
87
|
+
}
|
88
|
+
|
89
|
+
let mod = data.replace(this.replaceText, `
|
90
|
+
self.assets = ${JSON.stringify(initialChunkUrls.concat(initalI18nAssets))};
|
91
|
+
self.allChunks = ${JSON.stringify(allChunkUrls.concat(allI18nAssets))};`);
|
92
|
+
|
93
|
+
if (!_fs.default.existsSync(this.writePath)) {
|
94
|
+
_fs.default.mkdirSync(this.writePath, {
|
95
|
+
recursive: true
|
96
|
+
});
|
97
|
+
}
|
98
|
+
|
99
|
+
_fs.default.writeFileSync(_path.default.join(this.writePath, this.fileName), mod);
|
100
|
+
}
|
101
|
+
});
|
102
|
+
});
|
103
|
+
}
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
exports.default = ServiceWorkerPlugin;
|