@zohodesk/client_build_tool 0.0.11-exp.15.4 → 0.0.11-exp.16.0
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 +102 -0
- package/README_backup.md +100 -0
- package/docs/DYNAMIC_TEMPLATE_EXAMPLE.md +129 -0
- package/docs/I18N_SINGLE_FILE_MODE.md +126 -0
- package/example-single-file-config.js +59 -0
- package/lib/allCommandsConfigs.js +2 -7
- package/lib/commands/build/commandExecutor.js +1 -5
- package/lib/commands/build/config.js +2 -3
- package/lib/commands/build/optionsProcessor.js +2 -5
- package/lib/commands/build/preProcessor.js +0 -2
- package/lib/commands/buildEs/commandExecutor.js +0 -5
- package/lib/commands/buildEs/config.js +2 -3
- package/lib/commands/buildEs/preProcessor.js +0 -2
- package/lib/commands/buildLib/commandExecutor.js +0 -5
- package/lib/commands/buildLib/config.js +2 -3
- package/lib/commands/buildLib/preProcessor.js +0 -2
- package/lib/commands/mockserver/commandExecutor.js +2 -9
- package/lib/commands/mockserver/config.js +2 -3
- package/lib/commands/pre_process/commandExecutor.js +0 -2
- package/lib/commands/pre_process/config.js +2 -3
- package/lib/commands/start/commandExecutor.js +0 -2
- package/lib/commands/start/config.js +2 -3
- package/lib/commands/start/optionsProcessor.js +2 -4
- package/lib/commands/start/preProcessor.js +0 -2
- package/lib/commands/template/commandExecutor.js +0 -7
- package/lib/commands/template/config.js +2 -3
- package/lib/commands/version/commandExecutor.js +0 -3
- package/lib/commands/version/config.js +2 -3
- package/lib/commandsRouter.js +5 -21
- package/lib/index.js +0 -2
- package/lib/logger.js +0 -5
- package/lib/schemas/applyValuesToSchema/index.js +0 -8
- package/lib/schemas/applyValuesToSchema/isObject.js +0 -1
- package/lib/schemas/applyValuesToSchema/isValid.js +0 -2
- package/lib/schemas/cliArgsToObject.js +2 -6
- package/lib/schemas/defaultConfigValues.js +21 -12
- package/lib/schemas/defaultConfigValuesOnly.js +4 -7
- package/lib/schemas/deprecatedOptionsHandler.js +7 -16
- package/lib/schemas/getNpmVersion.js +0 -5
- package/lib/schemas/giveDefaultValue.js +0 -3
- package/lib/schemas/npmConfigToObject.js +2 -5
- package/lib/schemas/readOptions.js +10 -30
- package/lib/schemas/readOptionsForConfigFile.js +2 -12
- package/lib/shared/babel/addDefaultPlugins.js +0 -2
- package/lib/shared/babel/babelWebConfig.js +1 -10
- package/lib/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -4
- package/lib/shared/babel/getBabelPlugin.js +2 -7
- package/lib/shared/babel/runBabelForJSFile.js +1 -4
- package/lib/shared/babel/runBabelForTsFile.js +1 -5
- package/lib/shared/bundler/webpack/common/decidePublicPath.js +0 -5
- package/lib/shared/bundler/webpack/common/libAlias.js +3 -3
- package/lib/shared/bundler/webpack/common/modeUtils.js +0 -5
- package/lib/shared/bundler/webpack/common/nameTemplates.js +11 -18
- package/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +2 -3
- package/lib/shared/bundler/webpack/configCustomLoaders.js +0 -1
- package/lib/shared/bundler/webpack/cssLoaders.js +0 -2
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +1 -20
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +20 -25
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +4 -9
- package/lib/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +3 -23
- package/lib/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +8 -19
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +2 -6
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +81 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +135 -60
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +20 -26
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +5 -26
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +13 -16
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +19 -53
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +2 -17
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +11 -21
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +4 -14
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +3 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +3 -12
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +2 -7
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +2 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +2 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +8 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -14
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +1 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +5 -25
- package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +3 -10
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -7
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +13 -17
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +6 -15
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +4 -13
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +4 -6
- package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -10
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -3
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +4 -20
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +10 -12
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +2 -3
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +7 -20
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +7 -10
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +1 -16
- package/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +4 -11
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +3 -10
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +27 -62
- package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +3 -15
- package/lib/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +2 -12
- package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +2 -7
- package/lib/shared/bundler/webpack/defaultVendorPatternList.js +2 -6
- package/lib/shared/bundler/webpack/devtoolConfig.js +0 -1
- package/lib/shared/bundler/webpack/entryConfig.js +0 -4
- package/lib/shared/bundler/webpack/externals.js +0 -1
- package/lib/shared/bundler/webpack/getCSSLoaders.js +1 -6
- package/lib/shared/bundler/webpack/getFilenameFromModule.js +1 -5
- package/lib/shared/bundler/webpack/jsLoaders.js +6 -10
- package/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -2
- package/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +2 -3
- package/lib/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +3 -12
- package/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -1
- package/lib/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +2 -10
- package/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -2
- package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -12
- package/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +1 -15
- package/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +1 -4
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +8 -16
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +22 -29
- package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +2 -2
- package/lib/shared/bundler/webpack/loaders/workerLoader.js +8 -19
- package/lib/shared/bundler/webpack/optimizationConfig.js +5 -13
- package/lib/shared/bundler/webpack/outputConfig.js +1 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +5 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +4 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +1 -16
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -16
- package/lib/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +2 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +5 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +19 -25
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +92 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +3 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -7
- package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +3 -7
- package/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +1 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +1 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +1 -6
- package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +1 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +1 -6
- package/lib/shared/bundler/webpack/plugins.js +3 -30
- package/lib/shared/bundler/webpack/resolvers.js +3 -17
- package/lib/shared/bundler/webpack/splitChunksConfig.js +2 -15
- package/lib/shared/bundler/webpack/statsConfig.js +2 -5
- package/lib/shared/bundler/webpack/tsLoaders.js +2 -4
- package/lib/shared/bundler/webpack/utils/index.js +1 -12
- package/lib/shared/bundler/webpack/utils/object-manipulation.js +2 -16
- package/lib/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -7
- package/lib/shared/bundler/webpack/webpackBuild.js +1 -8
- package/lib/shared/bundler/webpack/webpackConfig.js +0 -17
- package/lib/shared/commands-utils/doBasicRequirementCheck.js +0 -3
- package/lib/shared/commands-utils/getCliPath.js +5 -9
- package/lib/shared/commands-utils/index.js +0 -3
- package/lib/shared/commands-utils/log.js +0 -2
- package/lib/shared/commands-utils/readArgsFormCommandLine.js +0 -1
- package/lib/shared/commands-utils/readOptionFormCommandLine.js +0 -1
- package/lib/shared/commands-utils/spawnSyncIO.js +5 -13
- package/lib/shared/constants.js +9 -29
- package/lib/shared/fileUtils/copyFile.js +1 -8
- package/lib/shared/fileUtils/directoryIterator.js +0 -4
- package/lib/shared/fileUtils/watchRun.js +3 -24
- package/lib/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +1 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +2 -3
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +6 -13
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +6 -26
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +6 -9
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -3
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +2 -7
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -2
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +4 -9
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -10
- package/lib/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +16 -29
- package/lib/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -17
- package/lib/shared/postcss/custom_postcss_plugins/ValueReplacer.js +4 -9
- package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +27 -63
- package/lib/shared/postcss/filterPluginsAllowedForSpecficFile.js +5 -13
- package/lib/shared/postcss/getAllowedPostCssPlugins.js +0 -3
- package/lib/shared/postcss/getSpecificPostCssPlugin.js +7 -17
- package/lib/shared/postcss/runPostCssForCssFile.js +1 -9
- package/lib/shared/pre_process/runPreProcess.js +0 -11
- package/lib/shared/server/configWebpackDevMiddleware.js +1 -8
- package/lib/shared/server/corsHandling.js +2 -6
- package/lib/shared/server/getIp.js +1 -7
- package/lib/shared/server/getServerURL.js +0 -6
- package/lib/shared/server/httpsOptions.js +0 -11
- package/lib/shared/server/initExpressApp.js +1 -4
- package/lib/shared/server/initialHTMLHandling.js +7 -16
- package/lib/shared/server/mockApiHandler.js +8 -16
- package/lib/shared/server/mockServer.js +0 -7
- package/lib/shared/server/serveContextFiles.js +1 -5
- package/lib/shared/server/serverBywebpackDevMiddleware.js +4 -9
- package/lib/shared/server/startHttpServer.js +0 -3
- package/lib/shared/server/startHttpsServer.js +1 -9
- package/lib/shared/server/unwanted/addHttp2Server.js +2 -7
- package/lib/shared/server/unwanted/configWebpackDevMiddleware.js +1 -8
- package/lib/shared/server/unwanted/mockApiSupport.js +0 -2
- package/lib/shared/server/unwanted/websocketMockSetup.js +1 -7
- package/lib/shared/server/urlConcat.js +3 -8
- package/lib/shared/utils/requireLocalOrGlobal.js +10 -25
- package/lib/shared/utils/versionPrint.js +1 -6
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/client_build_tool/test-i18n-config.js +22 -0
|
@@ -4,29 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
9
|
-
|
|
10
8
|
var _webpack = require("webpack");
|
|
11
|
-
|
|
12
9
|
var _nameTemplates = require("../../common/nameTemplates");
|
|
13
|
-
|
|
14
10
|
var _modeUtils = require("../../common/modeUtils");
|
|
15
|
-
|
|
16
11
|
var _webpackCustomJsUrlLoader = _interopRequireDefault(require("./webpackCustomJsUrlLoader"));
|
|
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
|
// import { RuntimeGlobals, RuntimeModule } from 'webpack';
|
|
14
|
+
|
|
21
15
|
// eslint-disable-next-line import/extensions
|
|
16
|
+
|
|
22
17
|
// import { Template } from 'webpack';
|
|
23
18
|
// eslint-disable-next-line import/extensions
|
|
24
|
-
|
|
19
|
+
|
|
20
|
+
const pluginName = 'CdnChangePlugin';
|
|
21
|
+
// const MODULE_TYPE = 'css/mini-extract';
|
|
22
|
+
|
|
25
23
|
// class CdnChangeRuntimePlugin extends RuntimeModule {
|
|
26
24
|
// constructor(compiler, { variableName }) {
|
|
27
25
|
// super('cdn loading', 10);
|
|
28
26
|
// this.variableName = variableName;
|
|
29
27
|
// }
|
|
28
|
+
|
|
30
29
|
// generate() {
|
|
31
30
|
// return `${RuntimeGlobals.getChunkCssFilename} = function(chunkId) {
|
|
32
31
|
// const cssCdnUrl = window[${this.variableName}] || chunkId;
|
|
@@ -34,7 +33,6 @@ const pluginName = 'CdnChangePlugin'; // const MODULE_TYPE = 'css/mini-extract';
|
|
|
34
33
|
// }`;
|
|
35
34
|
// }
|
|
36
35
|
// }
|
|
37
|
-
|
|
38
36
|
class CdnChangePlugin {
|
|
39
37
|
constructor(options) {
|
|
40
38
|
this.createSeparateSMap = options.createSeparateSMap;
|
|
@@ -44,7 +42,6 @@ class CdnChangePlugin {
|
|
|
44
42
|
this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
|
|
45
43
|
this.mode = options.mode || 'prod';
|
|
46
44
|
}
|
|
47
|
-
|
|
48
45
|
apply(compiler) {
|
|
49
46
|
// compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
50
47
|
// const enabledChunks = new WeakSet();
|
|
@@ -52,8 +49,11 @@ class CdnChangePlugin {
|
|
|
52
49
|
// if (enabledChunks.has(entryRuntimeChunk)) {
|
|
53
50
|
// return;
|
|
54
51
|
// }
|
|
52
|
+
|
|
55
53
|
// enabledChunks.add(entryRuntimeChunk);
|
|
54
|
+
|
|
56
55
|
// set.add(RuntimeGlobals.getFullHash);
|
|
56
|
+
|
|
57
57
|
// set.add(RuntimeGlobals.getChunkCssFilename);
|
|
58
58
|
// compilation.addRuntimeModule(
|
|
59
59
|
// entryRuntimeChunk,
|
|
@@ -67,14 +67,16 @@ class CdnChangePlugin {
|
|
|
67
67
|
// .for(RuntimeGlobals.ensureChunkHandlers)
|
|
68
68
|
// .tap(pluginName, handler);
|
|
69
69
|
// });
|
|
70
|
+
|
|
70
71
|
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
71
72
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, (data, cb) => {
|
|
72
73
|
const {
|
|
73
74
|
createSeparateSMap,
|
|
74
75
|
mode
|
|
75
|
-
} = this;
|
|
76
|
-
|
|
77
|
-
data.assets = {
|
|
76
|
+
} = this;
|
|
77
|
+
// eslint-disable-next-line no-param-reassign
|
|
78
|
+
data.assets = {
|
|
79
|
+
...data.assets,
|
|
78
80
|
css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
|
|
79
81
|
js: data.assets.js.map(js => {
|
|
80
82
|
if ((0, _modeUtils.isProductionMode)(mode) && createSeparateSMap && !(0, _nameTemplates.isI18nFile)(js)) {
|
|
@@ -84,29 +86,24 @@ class CdnChangePlugin {
|
|
|
84
86
|
js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
|
-
|
|
88
89
|
return `${(0, _nameTemplates.isI18nFile)(js) ? this.i18nTemplate : this.jsTemplate}${js}`;
|
|
89
90
|
})
|
|
90
91
|
};
|
|
91
92
|
cb && cb(null, data);
|
|
92
93
|
});
|
|
93
|
-
|
|
94
94
|
compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.getChunkScriptFilename).tap(pluginName, (chunk, set) => {
|
|
95
95
|
if (typeof compilation.outputOptions.chunkFilename === 'string' && /\[(full)?hash(:\d+)?\]/.test(compilation.outputOptions.chunkFilename)) {
|
|
96
96
|
set.add(_webpack.RuntimeGlobals.getFullHash);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
compilation.addRuntimeModule(chunk,
|
|
99
|
+
// eslint-disable-next-line new-cap
|
|
100
100
|
new _webpackCustomJsUrlLoader.default('javascript', 'javascript', _webpack.RuntimeGlobals.getChunkScriptFilename, chunk => chunk.filenameTemplate || (chunk.canBeInitial() ? compilation.outputOptions.filename : compilation.outputOptions.chunkFilename), false, this.variableName));
|
|
101
101
|
return true;
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
var _default = CdnChangePlugin; // Cdn Change Plugin for runtime chunks???
|
|
109
|
-
|
|
106
|
+
var _default = exports.default = CdnChangePlugin; // Cdn Change Plugin for runtime chunks???
|
|
110
107
|
/**
|
|
111
108
|
* the filename of the script part of the chunk
|
|
112
109
|
*/
|
|
@@ -114,6 +111,4 @@ var _default = CdnChangePlugin; // Cdn Change Plugin for runtime chunks???
|
|
|
114
111
|
// /**
|
|
115
112
|
// * the filename of the css part of the chunk
|
|
116
113
|
// */
|
|
117
|
-
// exports.getChunkCssFilename = "__webpack_require__.k";
|
|
118
|
-
|
|
119
|
-
exports.default = _default;
|
|
114
|
+
// exports.getChunkCssFilename = "__webpack_require__.k";
|
package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js
CHANGED
|
@@ -4,18 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _GetChunkFilenameRuntimeModule = _interopRequireDefault(require("webpack/lib/runtime/GetChunkFilenameRuntimeModule"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
9
|
// import { RuntimeGlobals, RuntimeModule, Template } from 'webpack';
|
|
10
|
+
|
|
13
11
|
// const GetChunkFilenameRuntimeModule = require('webpack/lib/runtime/GetChunkFilenameRuntimeModule');
|
|
14
12
|
// import GetChunkFilenameRuntimeModule from 'webpack/lib/runtime/GetChunkFilenameRuntimeModule';
|
|
15
13
|
// const first = set => {
|
|
16
14
|
// const entry = set.values().next();
|
|
17
15
|
// return entry.done ? undefined : entry.value;
|
|
18
16
|
// };
|
|
17
|
+
|
|
19
18
|
class CustomizedGetChunkFilenameRuntimeModule extends _GetChunkFilenameRuntimeModule.default {
|
|
20
19
|
/**
|
|
21
20
|
* @param {string} contentType the to use the content hash for
|
|
@@ -33,14 +32,10 @@ class CustomizedGetChunkFilenameRuntimeModule extends _GetChunkFilenameRuntimeMo
|
|
|
33
32
|
this.dependentHash = true;
|
|
34
33
|
this.variableName = variableName;
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
generate() {
|
|
38
36
|
const sourceCode = super.generate().toString();
|
|
39
37
|
const replaceCode = sourceCode.replaceAll('"js-chunks/', `${this.variableName} + "js-chunks/`);
|
|
40
38
|
return replaceCode;
|
|
41
39
|
}
|
|
42
|
-
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
var _default = CustomizedGetChunkFilenameRuntimeModule;
|
|
46
|
-
exports.default = _default;
|
|
41
|
+
var _default = exports.default = CustomizedGetChunkFilenameRuntimeModule;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CustomScriptLoadingStrategyPlugin = void 0;
|
|
7
|
-
|
|
8
7
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
9
|
const pluginName = 'CustomScriptLoadingStrategyPlugin';
|
|
13
|
-
|
|
14
10
|
class CustomScriptLoadingStrategyPlugin {
|
|
15
11
|
constructor({
|
|
16
12
|
scriptLoadingStategey
|
|
@@ -18,69 +14,57 @@ class CustomScriptLoadingStrategyPlugin {
|
|
|
18
14
|
this.scriptLoadingStrategy = scriptLoadingStategey;
|
|
19
15
|
this.tagNamesToMatch = ['script'];
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
getFileNameFromTagSrc(src) {
|
|
23
18
|
const fileNameArr = src.split('/');
|
|
24
19
|
return fileNameArr[fileNameArr.length - 1];
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
addAttributestToTag(tag, attributes) {
|
|
28
22
|
tag.attributes = Object.assign({}, tag.attributes, attributes);
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
matchFileName(tag, fileName) {
|
|
32
25
|
return fileName.test(this.getFileNameFromTagSrc(tag.attributes.src));
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
blockingStrategy(tag) {
|
|
36
28
|
delete tag.attributes.defer;
|
|
37
29
|
delete tag.attributes.async;
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
deferStrategy(tag) {
|
|
41
32
|
delete tag.attributes.async;
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
asyncStrategy(tag) {
|
|
45
35
|
delete tag.attributes.defer;
|
|
46
36
|
}
|
|
47
|
-
|
|
48
37
|
moduleStrategy(tag) {
|
|
49
38
|
this.deferStrategy(tag);
|
|
50
39
|
}
|
|
51
|
-
|
|
52
40
|
matchStrategy(scriptLoadingStrategy, tag) {
|
|
53
41
|
if (scriptLoadingStrategy === 'blocking') {
|
|
54
42
|
this.blockingStrategy(tag);
|
|
55
43
|
}
|
|
56
|
-
|
|
57
44
|
if (scriptLoadingStrategy === 'defer') {
|
|
58
45
|
this.deferStrategy(tag);
|
|
59
46
|
}
|
|
60
|
-
|
|
61
47
|
if (scriptLoadingStrategy === 'async') {
|
|
62
48
|
this.asyncStrategy(tag);
|
|
63
49
|
}
|
|
64
|
-
|
|
65
50
|
if (scriptLoadingStrategy === 'module') {
|
|
66
51
|
this.moduleStrategy(tag);
|
|
67
52
|
}
|
|
68
53
|
}
|
|
69
|
-
|
|
70
54
|
matchAndApplyCustomLoadingStrategyToScripts(tags) {
|
|
71
55
|
Object.keys(this.scriptLoadingStrategy).forEach(scriptLoadingStrategy => {
|
|
72
56
|
const filesToMatch = this.scriptLoadingStrategy[scriptLoadingStrategy];
|
|
73
57
|
tags.forEach(tag => {
|
|
74
58
|
if (this.tagNamesToMatch.includes(tag.tagName) && tag.attributes.src) {
|
|
75
59
|
const isFileMatch = filesToMatch.some(fileName => this.matchFileName(tag, fileName));
|
|
76
|
-
|
|
77
60
|
if (isFileMatch) {
|
|
78
61
|
this.matchStrategy(scriptLoadingStrategy, tag);
|
|
79
62
|
this.addAttributestToTag(tag, {
|
|
80
63
|
[scriptLoadingStrategy]: true
|
|
81
64
|
});
|
|
82
65
|
}
|
|
83
|
-
}
|
|
66
|
+
}
|
|
67
|
+
// filesToMatch.forEach(fileName => {
|
|
84
68
|
// if (!this.matchFileName(tag, fileName)) {
|
|
85
69
|
// return;
|
|
86
70
|
// }
|
|
@@ -89,11 +73,9 @@ class CustomScriptLoadingStrategyPlugin {
|
|
|
89
73
|
// [scriptLoadingStrategy]: true
|
|
90
74
|
// });
|
|
91
75
|
// });
|
|
92
|
-
|
|
93
76
|
});
|
|
94
77
|
});
|
|
95
78
|
}
|
|
96
|
-
|
|
97
79
|
apply(compiler) {
|
|
98
80
|
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
99
81
|
_htmlWebpackPlugin.default.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, callback) => {
|
|
@@ -103,7 +85,5 @@ class CustomScriptLoadingStrategyPlugin {
|
|
|
103
85
|
});
|
|
104
86
|
});
|
|
105
87
|
}
|
|
106
|
-
|
|
107
88
|
}
|
|
108
|
-
|
|
109
89
|
exports.CustomScriptLoadingStrategyPlugin = CustomScriptLoadingStrategyPlugin;
|
|
@@ -4,21 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EFCTemplatePlugin = void 0;
|
|
7
|
-
|
|
8
7
|
var _fs = require("fs");
|
|
9
|
-
|
|
10
8
|
var _logger = require("../../../../logger");
|
|
11
|
-
|
|
12
9
|
var _LocaleChunkAssetsStore = require("./I18nSplitPlugin/LocaleChunkAssetsStore");
|
|
13
|
-
|
|
14
10
|
var _constants = require("../../../constants");
|
|
15
|
-
|
|
16
11
|
var _getInitialAssetsFuncTemplate = require("./getInitialAssetsFuncTemplate");
|
|
17
|
-
|
|
18
12
|
const INITIAL_ASSETS_TEMPLATE = '// <--getInitialAssets-->';
|
|
19
13
|
const PUBLIC_PATH_TEMPLATE = '"<--publicPath-->"';
|
|
20
14
|
const pluginName = 'EFCTemplatePlugin';
|
|
21
|
-
|
|
22
15
|
class EFCTemplatePlugin {
|
|
23
16
|
constructor(options = {}) {
|
|
24
17
|
const {
|
|
@@ -32,15 +25,18 @@ class EFCTemplatePlugin {
|
|
|
32
25
|
this.options = options;
|
|
33
26
|
this.templateFilePath = (0, _constants.joinWithAppPath)(templateFilePath);
|
|
34
27
|
this.i18nFileNameTemplate = i18nFileNameTemplate;
|
|
35
|
-
this.publicPath = publicPath;
|
|
28
|
+
this.publicPath = publicPath;
|
|
29
|
+
|
|
30
|
+
// NOTE: this logic may be needed for i18n splitted file name with contenthash cases
|
|
36
31
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
|
37
32
|
// IMPORTANT: here we merging options from package.json and options via constructor
|
|
38
33
|
// So when debugging consider this as well
|
|
39
34
|
// this.options = Object.assign({}, efcOptions, options);
|
|
40
|
-
|
|
41
35
|
this.entryPointName = entryPointName || 'efc';
|
|
42
36
|
this.outputFile = outputFile.replace('[version]', version);
|
|
43
|
-
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// NOTE: this logic may be needed for i18n splitted file name with contenthash cases
|
|
44
40
|
// getI18nManifest(compilation) {
|
|
45
41
|
// const i18nManifestFile =
|
|
46
42
|
// compilation.assets[this.options.i18nManifestFileName];
|
|
@@ -52,12 +48,11 @@ class EFCTemplatePlugin {
|
|
|
52
48
|
// }
|
|
53
49
|
// eslint-disable-next-line class-methods-use-this
|
|
54
50
|
|
|
55
|
-
|
|
56
51
|
templateReplacer(entryPoint, compilation) {
|
|
57
52
|
const {
|
|
58
53
|
enableRTLSplit
|
|
59
|
-
} = this.options;
|
|
60
|
-
|
|
54
|
+
} = this.options;
|
|
55
|
+
// const i18nManifest = this.getI18nManifest(compilation);
|
|
61
56
|
const initialAssetsFuncTemplate = (0, _getInitialAssetsFuncTemplate.getInitialAssetsFuncTemplate)({
|
|
62
57
|
entryPoint,
|
|
63
58
|
compilation,
|
|
@@ -70,7 +65,6 @@ class EFCTemplatePlugin {
|
|
|
70
65
|
const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
|
|
71
66
|
return templateStr.replace(INITIAL_ASSETS_TEMPLATE, initialAssetsFuncTemplate).replace(PUBLIC_PATH_TEMPLATE, this.publicPath);
|
|
72
67
|
}
|
|
73
|
-
|
|
74
68
|
apply(compiler) {
|
|
75
69
|
const {
|
|
76
70
|
RawSource
|
|
@@ -89,16 +83,13 @@ class EFCTemplatePlugin {
|
|
|
89
83
|
outputFile
|
|
90
84
|
} = this;
|
|
91
85
|
const entryPoint = compilation.entrypoints.get(entryPointName);
|
|
92
|
-
|
|
93
86
|
if (!entryPoint) {
|
|
94
87
|
return;
|
|
95
88
|
}
|
|
96
|
-
|
|
97
89
|
if (!(0, _fs.existsSync)(this.templateFilePath)) {
|
|
98
90
|
(0, _logger.errorLogger)(`EFC Template file not exists ${this.templateFilePath}`);
|
|
99
91
|
return;
|
|
100
92
|
}
|
|
101
|
-
|
|
102
93
|
const source = new RawSource(this.templateReplacer(entryPoint, compilation));
|
|
103
94
|
compilation.emitAsset(outputFile, source);
|
|
104
95
|
(0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
|
|
@@ -106,7 +97,5 @@ class EFCTemplatePlugin {
|
|
|
106
97
|
});
|
|
107
98
|
});
|
|
108
99
|
}
|
|
109
|
-
|
|
110
100
|
}
|
|
111
|
-
|
|
112
101
|
exports.EFCTemplatePlugin = EFCTemplatePlugin;
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js
CHANGED
|
@@ -4,22 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.I18nGroupRuntimeModule = void 0;
|
|
7
|
-
|
|
8
7
|
var _webpack = require("webpack");
|
|
9
|
-
|
|
10
8
|
class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
11
9
|
constructor(options) {
|
|
12
10
|
super('i18n-group-loader');
|
|
13
11
|
this.options = options;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
generate() {
|
|
17
14
|
const {
|
|
18
15
|
customGroups,
|
|
19
16
|
localeVarName,
|
|
20
17
|
jsonpFunc
|
|
21
|
-
} = this.options;
|
|
18
|
+
} = this.options;
|
|
22
19
|
|
|
20
|
+
// Build chunk-to-group mapping from config
|
|
23
21
|
const chunkToGroup = {};
|
|
24
22
|
Object.entries(customGroups || {}).forEach(([groupName, config]) => {
|
|
25
23
|
(config.chunks || []).forEach(chunkName => {
|
|
@@ -118,7 +116,5 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
118
116
|
})();
|
|
119
117
|
`;
|
|
120
118
|
}
|
|
121
|
-
|
|
122
119
|
}
|
|
123
|
-
|
|
124
120
|
exports.I18nGroupRuntimeModule = I18nGroupRuntimeModule;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const pluginName = 'I18nNumericIndexHtmlInjectorPlugin';
|
|
6
|
+
class I18nNumericIndexHtmlInjectorPlugin {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
apply(compiler) {
|
|
11
|
+
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
12
|
+
HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tapAsync(pluginName, (hookData, cb) => {
|
|
13
|
+
const {
|
|
14
|
+
assets
|
|
15
|
+
} = hookData;
|
|
16
|
+
const {
|
|
17
|
+
outputFolder,
|
|
18
|
+
numericFilenameTemplate,
|
|
19
|
+
dynamicFilenameTemplate,
|
|
20
|
+
singleFileTemplate,
|
|
21
|
+
htmlTemplateLabel,
|
|
22
|
+
singleFile,
|
|
23
|
+
i18nAssetsPublicPathPrefix = ''
|
|
24
|
+
} = this.options;
|
|
25
|
+
const newI18nAssetUrlsToAdd = [];
|
|
26
|
+
|
|
27
|
+
// Construct full paths using outputFolder
|
|
28
|
+
const constructFullPath = (template, isSingleFile = false) => {
|
|
29
|
+
if (!template) return null;
|
|
30
|
+
|
|
31
|
+
// Replace locale placeholder
|
|
32
|
+
let filePath = template.replace(/\[locale\]/g, htmlTemplateLabel);
|
|
33
|
+
|
|
34
|
+
// Remove [contenthash] placeholder for HTML injection
|
|
35
|
+
// The actual hash will be determined at build time
|
|
36
|
+
filePath = filePath.replace(/\.\[contenthash\]/g, '');
|
|
37
|
+
|
|
38
|
+
// If template already contains outputFolder or starts with a path separator, use as-is
|
|
39
|
+
if (filePath.includes(outputFolder) || filePath.startsWith('/')) {
|
|
40
|
+
return filePath.replace(/\\/g, '/');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// For single-file mode with a simple template like '[locale].js',
|
|
44
|
+
// put it directly in outputFolder without subdirectories
|
|
45
|
+
if (isSingleFile && !filePath.includes('/')) {
|
|
46
|
+
return path.join(outputFolder || 'i18n-chunk', filePath).replace(/\\/g, '/');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// For other cases, preserve subdirectories
|
|
50
|
+
return path.join(outputFolder || 'i18n-chunk', filePath).replace(/\\/g, '/');
|
|
51
|
+
};
|
|
52
|
+
if (singleFile) {
|
|
53
|
+
// In single file mode, use singleFileTemplate
|
|
54
|
+
const singleTemplate = singleFileTemplate || '[locale].js';
|
|
55
|
+
const combinedFilename = constructFullPath(singleTemplate, true);
|
|
56
|
+
if (combinedFilename) {
|
|
57
|
+
newI18nAssetUrlsToAdd.push(combinedFilename);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
// Add both numeric and dynamic files
|
|
61
|
+
const numericFilename = constructFullPath(numericFilenameTemplate);
|
|
62
|
+
if (numericFilename) {
|
|
63
|
+
newI18nAssetUrlsToAdd.push(numericFilename);
|
|
64
|
+
}
|
|
65
|
+
const dynamicFilename = constructFullPath(dynamicFilenameTemplate);
|
|
66
|
+
if (dynamicFilename) {
|
|
67
|
+
newI18nAssetUrlsToAdd.push(dynamicFilename);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (newI18nAssetUrlsToAdd.length > 0) {
|
|
71
|
+
// Add i18n assets to the beginning of JS assets for early loading
|
|
72
|
+
assets.js = [...newI18nAssetUrlsToAdd, ...assets.js];
|
|
73
|
+
}
|
|
74
|
+
cb(null, hookData);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
module.exports = {
|
|
80
|
+
I18nNumericIndexHtmlInjectorPlugin
|
|
81
|
+
};
|