@zohodesk/client_build_tool 0.0.11-exp.16.0 → 0.0.11-exp.17.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 +102 -0
- package/lib/allCommandsConfigs.js +7 -2
- package/lib/commands/build/commandExecutor.js +5 -1
- package/lib/commands/build/config.js +3 -2
- package/lib/commands/build/optionsProcessor.js +5 -2
- package/lib/commands/build/preProcessor.js +2 -0
- package/lib/commands/buildEs/commandExecutor.js +5 -0
- package/lib/commands/buildEs/config.js +3 -2
- package/lib/commands/buildEs/preProcessor.js +2 -0
- package/lib/commands/buildLib/commandExecutor.js +5 -0
- package/lib/commands/buildLib/config.js +3 -2
- package/lib/commands/buildLib/preProcessor.js +2 -0
- package/lib/commands/mockserver/commandExecutor.js +9 -2
- package/lib/commands/mockserver/config.js +3 -2
- package/lib/commands/pre_process/commandExecutor.js +2 -0
- package/lib/commands/pre_process/config.js +3 -2
- package/lib/commands/start/commandExecutor.js +2 -0
- package/lib/commands/start/config.js +3 -2
- package/lib/commands/start/optionsProcessor.js +4 -2
- package/lib/commands/start/preProcessor.js +2 -0
- package/lib/commands/template/commandExecutor.js +7 -0
- package/lib/commands/template/config.js +3 -2
- package/lib/commands/version/commandExecutor.js +3 -0
- package/lib/commands/version/config.js +3 -2
- package/lib/commandsRouter.js +21 -5
- package/lib/index.js +2 -0
- package/lib/logger.js +5 -0
- package/lib/schemas/applyValuesToSchema/index.js +8 -0
- package/lib/schemas/applyValuesToSchema/isObject.js +1 -0
- package/lib/schemas/applyValuesToSchema/isValid.js +2 -0
- package/lib/schemas/cliArgsToObject.js +6 -2
- package/lib/schemas/defaultConfigValues.js +17 -4
- package/lib/schemas/defaultConfigValuesOnly.js +33 -4
- package/lib/schemas/deprecatedOptionsHandler.js +16 -7
- package/lib/schemas/getNpmVersion.js +5 -0
- package/lib/schemas/giveDefaultValue.js +3 -0
- package/lib/schemas/npmConfigToObject.js +5 -2
- package/lib/schemas/readOptions.js +30 -10
- package/lib/schemas/readOptionsForConfigFile.js +12 -2
- package/lib/shared/babel/addDefaultPlugins.js +2 -0
- package/lib/shared/babel/babelWebConfig.js +10 -1
- package/lib/shared/babel/babel_plugins/removeAttributesPlugin.js +4 -0
- package/lib/shared/babel/getBabelPlugin.js +7 -2
- package/lib/shared/babel/runBabelForJSFile.js +4 -1
- package/lib/shared/babel/runBabelForTsFile.js +5 -1
- package/lib/shared/bundler/webpack/common/decidePublicPath.js +5 -0
- package/lib/shared/bundler/webpack/common/libAlias.js +3 -3
- package/lib/shared/bundler/webpack/common/modeUtils.js +5 -0
- package/lib/shared/bundler/webpack/common/nameTemplates.js +18 -11
- package/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +3 -2
- package/lib/shared/bundler/webpack/configCustomLoaders.js +1 -0
- package/lib/shared/bundler/webpack/cssLoaders.js +2 -0
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +20 -1
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +25 -20
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +9 -4
- package/lib/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +23 -3
- package/lib/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +19 -8
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +61 -37
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +33 -15
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +108 -60
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +26 -20
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +26 -5
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +16 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +53 -19
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +17 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +13 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +21 -11
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +4 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +14 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +13 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +12 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +7 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +2 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +3 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +4 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +13 -8
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +14 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +3 -1
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +25 -5
- package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +10 -3
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +6 -1
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +6 -1
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +6 -0
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +7 -0
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +17 -13
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +15 -6
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +13 -4
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +6 -4
- package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +10 -0
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +3 -0
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +20 -4
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +12 -10
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +3 -2
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +20 -7
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +10 -7
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +6 -1
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +16 -1
- package/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +11 -4
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +10 -3
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +62 -27
- package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +15 -3
- package/lib/shared/bundler/webpack/custom_plugins/emitAsset.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +12 -2
- package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +7 -2
- package/lib/shared/bundler/webpack/defaultVendorPatternList.js +6 -2
- package/lib/shared/bundler/webpack/devtoolConfig.js +1 -0
- package/lib/shared/bundler/webpack/entryConfig.js +4 -0
- package/lib/shared/bundler/webpack/externals.js +1 -0
- package/lib/shared/bundler/webpack/getCSSLoaders.js +6 -1
- package/lib/shared/bundler/webpack/getFilenameFromModule.js +5 -1
- package/lib/shared/bundler/webpack/jsLoaders.js +10 -6
- package/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +2 -0
- package/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +3 -2
- package/lib/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +12 -3
- package/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +1 -0
- package/lib/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +10 -2
- package/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +2 -0
- package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +12 -0
- package/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +15 -1
- package/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +4 -1
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +16 -8
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +29 -22
- package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +2 -2
- package/lib/shared/bundler/webpack/loaders/workerLoader.js +19 -8
- package/lib/shared/bundler/webpack/optimizationConfig.js +13 -5
- package/lib/shared/bundler/webpack/outputConfig.js +9 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +9 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +5 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +9 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +8 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +16 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +4 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +16 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +5 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +5 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +8 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +9 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +25 -19
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +26 -12
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +9 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +2 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +7 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +7 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +5 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +4 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +4 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +8 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +6 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +8 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +4 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +8 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +6 -1
- package/lib/shared/bundler/webpack/plugins.js +24 -1
- package/lib/shared/bundler/webpack/resolvers.js +17 -3
- package/lib/shared/bundler/webpack/splitChunksConfig.js +15 -2
- package/lib/shared/bundler/webpack/statsConfig.js +5 -2
- package/lib/shared/bundler/webpack/tsLoaders.js +4 -2
- package/lib/shared/bundler/webpack/utils/index.js +12 -1
- package/lib/shared/bundler/webpack/utils/object-manipulation.js +16 -2
- package/lib/shared/bundler/webpack/utils/updateArrayWithDefault.js +7 -0
- package/lib/shared/bundler/webpack/webpackBuild.js +8 -1
- package/lib/shared/bundler/webpack/webpackConfig.js +17 -0
- package/lib/shared/commands-utils/doBasicRequirementCheck.js +3 -0
- package/lib/shared/commands-utils/getCliPath.js +9 -5
- package/lib/shared/commands-utils/index.js +3 -0
- package/lib/shared/commands-utils/log.js +2 -0
- package/lib/shared/commands-utils/readArgsFormCommandLine.js +1 -0
- package/lib/shared/commands-utils/readOptionFormCommandLine.js +1 -0
- package/lib/shared/commands-utils/spawnSyncIO.js +13 -5
- package/lib/shared/constants.js +29 -9
- package/lib/shared/fileUtils/copyFile.js +8 -1
- package/lib/shared/fileUtils/directoryIterator.js +4 -0
- package/lib/shared/fileUtils/watchRun.js +24 -3
- package/lib/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +6 -1
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +3 -2
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +13 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +26 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +9 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +3 -0
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +7 -2
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +2 -0
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +9 -4
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +10 -0
- package/lib/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +29 -16
- package/lib/shared/postcss/custom_postcss_plugins/SelectorReplace.js +17 -0
- package/lib/shared/postcss/custom_postcss_plugins/ValueReplacer.js +9 -4
- package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +63 -27
- package/lib/shared/postcss/filterPluginsAllowedForSpecficFile.js +13 -5
- package/lib/shared/postcss/getAllowedPostCssPlugins.js +3 -0
- package/lib/shared/postcss/getSpecificPostCssPlugin.js +17 -7
- package/lib/shared/postcss/runPostCssForCssFile.js +9 -1
- package/lib/shared/pre_process/runPreProcess.js +11 -0
- package/lib/shared/server/configWebpackDevMiddleware.js +8 -1
- package/lib/shared/server/corsHandling.js +6 -2
- package/lib/shared/server/getIp.js +7 -1
- package/lib/shared/server/getServerURL.js +6 -0
- package/lib/shared/server/httpsOptions.js +11 -0
- package/lib/shared/server/initExpressApp.js +4 -1
- package/lib/shared/server/initialHTMLHandling.js +16 -7
- package/lib/shared/server/mockApiHandler.js +16 -8
- package/lib/shared/server/mockServer.js +7 -0
- package/lib/shared/server/serveContextFiles.js +5 -1
- package/lib/shared/server/serverBywebpackDevMiddleware.js +9 -4
- package/lib/shared/server/startHttpServer.js +3 -0
- package/lib/shared/server/startHttpsServer.js +9 -1
- package/lib/shared/server/unwanted/addHttp2Server.js +7 -2
- package/lib/shared/server/unwanted/configWebpackDevMiddleware.js +8 -1
- package/lib/shared/server/unwanted/mockApiSupport.js +2 -0
- package/lib/shared/server/unwanted/websocketMockSetup.js +7 -1
- package/lib/shared/server/urlConcat.js +8 -3
- package/lib/shared/utils/requireLocalOrGlobal.js +25 -10
- package/lib/shared/utils/versionPrint.js +6 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -4,14 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EFCTemplatePlugin = void 0;
|
|
7
|
+
|
|
7
8
|
var _fs = require("fs");
|
|
9
|
+
|
|
8
10
|
var _logger = require("../../../../logger");
|
|
11
|
+
|
|
9
12
|
var _LocaleChunkAssetsStore = require("./I18nSplitPlugin/LocaleChunkAssetsStore");
|
|
13
|
+
|
|
10
14
|
var _constants = require("../../../constants");
|
|
15
|
+
|
|
11
16
|
var _getInitialAssetsFuncTemplate = require("./getInitialAssetsFuncTemplate");
|
|
17
|
+
|
|
12
18
|
const INITIAL_ASSETS_TEMPLATE = '// <--getInitialAssets-->';
|
|
13
19
|
const PUBLIC_PATH_TEMPLATE = '"<--publicPath-->"';
|
|
14
20
|
const pluginName = 'EFCTemplatePlugin';
|
|
21
|
+
|
|
15
22
|
class EFCTemplatePlugin {
|
|
16
23
|
constructor(options = {}) {
|
|
17
24
|
const {
|
|
@@ -25,18 +32,15 @@ class EFCTemplatePlugin {
|
|
|
25
32
|
this.options = options;
|
|
26
33
|
this.templateFilePath = (0, _constants.joinWithAppPath)(templateFilePath);
|
|
27
34
|
this.i18nFileNameTemplate = i18nFileNameTemplate;
|
|
28
|
-
this.publicPath = publicPath;
|
|
29
|
-
|
|
30
|
-
// NOTE: this logic may be needed for i18n splitted file name with contenthash cases
|
|
35
|
+
this.publicPath = publicPath; // NOTE: this logic may be needed for i18n splitted file name with contenthash cases
|
|
31
36
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
|
32
37
|
// IMPORTANT: here we merging options from package.json and options via constructor
|
|
33
38
|
// So when debugging consider this as well
|
|
34
39
|
// this.options = Object.assign({}, efcOptions, options);
|
|
40
|
+
|
|
35
41
|
this.entryPointName = entryPointName || 'efc';
|
|
36
42
|
this.outputFile = outputFile.replace('[version]', version);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// NOTE: this logic may be needed for i18n splitted file name with contenthash cases
|
|
43
|
+
} // NOTE: this logic may be needed for i18n splitted file name with contenthash cases
|
|
40
44
|
// getI18nManifest(compilation) {
|
|
41
45
|
// const i18nManifestFile =
|
|
42
46
|
// compilation.assets[this.options.i18nManifestFileName];
|
|
@@ -48,11 +52,12 @@ class EFCTemplatePlugin {
|
|
|
48
52
|
// }
|
|
49
53
|
// eslint-disable-next-line class-methods-use-this
|
|
50
54
|
|
|
55
|
+
|
|
51
56
|
templateReplacer(entryPoint, compilation) {
|
|
52
57
|
const {
|
|
53
58
|
enableRTLSplit
|
|
54
|
-
} = this.options;
|
|
55
|
-
|
|
59
|
+
} = this.options; // const i18nManifest = this.getI18nManifest(compilation);
|
|
60
|
+
|
|
56
61
|
const initialAssetsFuncTemplate = (0, _getInitialAssetsFuncTemplate.getInitialAssetsFuncTemplate)({
|
|
57
62
|
entryPoint,
|
|
58
63
|
compilation,
|
|
@@ -65,6 +70,7 @@ class EFCTemplatePlugin {
|
|
|
65
70
|
const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
|
|
66
71
|
return templateStr.replace(INITIAL_ASSETS_TEMPLATE, initialAssetsFuncTemplate).replace(PUBLIC_PATH_TEMPLATE, this.publicPath);
|
|
67
72
|
}
|
|
73
|
+
|
|
68
74
|
apply(compiler) {
|
|
69
75
|
const {
|
|
70
76
|
RawSource
|
|
@@ -83,13 +89,16 @@ class EFCTemplatePlugin {
|
|
|
83
89
|
outputFile
|
|
84
90
|
} = this;
|
|
85
91
|
const entryPoint = compilation.entrypoints.get(entryPointName);
|
|
92
|
+
|
|
86
93
|
if (!entryPoint) {
|
|
87
94
|
return;
|
|
88
95
|
}
|
|
96
|
+
|
|
89
97
|
if (!(0, _fs.existsSync)(this.templateFilePath)) {
|
|
90
98
|
(0, _logger.errorLogger)(`EFC Template file not exists ${this.templateFilePath}`);
|
|
91
99
|
return;
|
|
92
100
|
}
|
|
101
|
+
|
|
93
102
|
const source = new RawSource(this.templateReplacer(entryPoint, compilation));
|
|
94
103
|
compilation.emitAsset(outputFile, source);
|
|
95
104
|
(0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
|
|
@@ -97,5 +106,7 @@ class EFCTemplatePlugin {
|
|
|
97
106
|
});
|
|
98
107
|
});
|
|
99
108
|
}
|
|
109
|
+
|
|
100
110
|
}
|
|
111
|
+
|
|
101
112
|
exports.EFCTemplatePlugin = EFCTemplatePlugin;
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js
CHANGED
|
@@ -4,20 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.I18nGroupRuntimeModule = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpack = require("webpack");
|
|
9
|
+
|
|
8
10
|
class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
9
11
|
constructor(options) {
|
|
10
12
|
super('i18n-group-loader');
|
|
11
13
|
this.options = options;
|
|
12
14
|
}
|
|
15
|
+
|
|
13
16
|
generate() {
|
|
14
17
|
const {
|
|
15
18
|
customGroups,
|
|
16
19
|
localeVarName,
|
|
17
20
|
jsonpFunc
|
|
18
|
-
} = this.options;
|
|
21
|
+
} = this.options; // Build chunk-to-group mapping from config
|
|
19
22
|
|
|
20
|
-
// Build chunk-to-group mapping from config
|
|
21
23
|
const chunkToGroup = {};
|
|
22
24
|
Object.entries(customGroups || {}).forEach(([groupName, config]) => {
|
|
23
25
|
(config.chunks || []).forEach(chunkName => {
|
|
@@ -27,53 +29,73 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
27
29
|
return `
|
|
28
30
|
// I18n Group Loading Runtime
|
|
29
31
|
(function() {
|
|
32
|
+
console.log('[I18n Runtime] Initializing i18n group loader with groups:', ${JSON.stringify(chunkToGroup)});
|
|
30
33
|
var loadedGroups = {};
|
|
31
34
|
var chunkToGroup = ${JSON.stringify(chunkToGroup)};
|
|
32
35
|
|
|
36
|
+
// Function to load i18n group
|
|
37
|
+
function loadI18nGroup(groupName) {
|
|
38
|
+
if (loadedGroups[groupName]) {
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var locale = ${localeVarName} || 'en_US';
|
|
43
|
+
var groupConfig = ${JSON.stringify(customGroups)};
|
|
44
|
+
var config = groupConfig[groupName];
|
|
45
|
+
|
|
46
|
+
if (!config) {
|
|
47
|
+
return Promise.resolve();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return new Promise(function(resolve, reject) {
|
|
51
|
+
var i18nUrl = config.filenameTemplate
|
|
52
|
+
.replace('[locale]', locale)
|
|
53
|
+
.replace('i18n-chunk/', __webpack_require__.p + 'i18n-chunk/');
|
|
54
|
+
|
|
55
|
+
console.log('[I18n Runtime] Loading i18n group:', groupName, 'from:', i18nUrl);
|
|
56
|
+
|
|
57
|
+
var script = document.createElement('script');
|
|
58
|
+
script.src = i18nUrl;
|
|
59
|
+
script.async = true;
|
|
60
|
+
|
|
61
|
+
script.onload = function() {
|
|
62
|
+
loadedGroups[groupName] = true;
|
|
63
|
+
console.log('[I18n Runtime] Successfully loaded i18n group:', groupName);
|
|
64
|
+
resolve();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
script.onerror = function() {
|
|
68
|
+
console.error('[I18n Runtime] Failed to load i18n group:', groupName);
|
|
69
|
+
reject(new Error('Failed to load i18n group: ' + groupName));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
document.head.appendChild(script);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
33
76
|
// Store original webpack chunk loading function
|
|
34
77
|
var originalEnsureChunk = __webpack_require__.e;
|
|
35
78
|
|
|
36
|
-
// Override webpack's chunk loading
|
|
37
|
-
|
|
38
|
-
|
|
79
|
+
// Override webpack's chunk loading if it exists
|
|
80
|
+
if (originalEnsureChunk) {
|
|
81
|
+
__webpack_require__.e = function(chunkId) {
|
|
82
|
+
var promise = originalEnsureChunk.apply(this, arguments);
|
|
39
83
|
|
|
40
84
|
// Check if this chunk needs an i18n group
|
|
41
85
|
var groupName = chunkToGroup[chunkId];
|
|
42
86
|
if (groupName && !loadedGroups[groupName]) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.replace('[locale]', locale)
|
|
51
|
-
.replace('i18n-chunk/', __webpack_require__.p + 'i18n-chunk/');
|
|
52
|
-
|
|
53
|
-
// Create script tag to load i18n chunk
|
|
54
|
-
var script = document.createElement('script');
|
|
55
|
-
script.src = i18nUrl;
|
|
56
|
-
script.async = true;
|
|
57
|
-
|
|
58
|
-
// Mark as loaded when script loads
|
|
59
|
-
script.onload = function() {
|
|
60
|
-
loadedGroups[groupName] = true;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
document.head.appendChild(script);
|
|
64
|
-
|
|
65
|
-
// If prefetch is enabled, prefetch other locales
|
|
66
|
-
if (config.prefetch && !config.preload) {
|
|
67
|
-
var link = document.createElement('link');
|
|
68
|
-
link.rel = 'prefetch';
|
|
69
|
-
link.href = i18nUrl;
|
|
70
|
-
document.head.appendChild(link);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
87
|
+
console.log('[I18n Runtime] Chunk', chunkId, 'requires i18n group:', groupName);
|
|
88
|
+
// Load the i18n group before the chunk
|
|
89
|
+
var i18nPromise = loadI18nGroup(groupName);
|
|
90
|
+
// Chain the promises so i18n loads first
|
|
91
|
+
promise = Promise.all([promise, i18nPromise]).then(function(results) {
|
|
92
|
+
return results[0]; // Return the original chunk promise result
|
|
93
|
+
});
|
|
73
94
|
}
|
|
74
95
|
|
|
75
|
-
|
|
76
|
-
|
|
96
|
+
return promise;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
77
99
|
|
|
78
100
|
// Also check for webpackI18nGroup comments in dynamic imports
|
|
79
101
|
if (typeof __webpack_require__.l !== 'undefined') {
|
|
@@ -116,5 +138,7 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
116
138
|
})();
|
|
117
139
|
`;
|
|
118
140
|
}
|
|
141
|
+
|
|
119
142
|
}
|
|
143
|
+
|
|
120
144
|
exports.I18nGroupRuntimeModule = I18nGroupRuntimeModule;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
+
|
|
4
5
|
const path = require('path');
|
|
6
|
+
|
|
5
7
|
const pluginName = 'I18nNumericIndexHtmlInjectorPlugin';
|
|
8
|
+
|
|
6
9
|
class I18nNumericIndexHtmlInjectorPlugin {
|
|
7
10
|
constructor(options) {
|
|
8
|
-
this.options = options
|
|
11
|
+
this.options = { ...options,
|
|
12
|
+
injectI18nUrlInIndex: options.injectI18nUrlInIndex !== undefined ? options.injectI18nUrlInIndex : true // Default to true
|
|
13
|
+
|
|
14
|
+
};
|
|
9
15
|
}
|
|
16
|
+
|
|
10
17
|
apply(compiler) {
|
|
11
18
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
12
19
|
HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tapAsync(pluginName, (hookData, cb) => {
|
|
20
|
+
// Skip HTML injection if injectI18nUrlInIndex is false
|
|
21
|
+
if (!this.options.injectI18nUrlInIndex) {
|
|
22
|
+
console.log('[I18nNumericIndexHtmlInjectorPlugin] Skipping HTML injection (injectI18nUrlInIndex is false)');
|
|
23
|
+
return cb(null, hookData);
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
const {
|
|
14
27
|
assets
|
|
15
28
|
} = hookData;
|
|
@@ -22,60 +35,65 @@ class I18nNumericIndexHtmlInjectorPlugin {
|
|
|
22
35
|
singleFile,
|
|
23
36
|
i18nAssetsPublicPathPrefix = ''
|
|
24
37
|
} = this.options;
|
|
25
|
-
const newI18nAssetUrlsToAdd = [];
|
|
38
|
+
const newI18nAssetUrlsToAdd = []; // Construct full paths using outputFolder
|
|
26
39
|
|
|
27
|
-
// Construct full paths using outputFolder
|
|
28
40
|
const constructFullPath = (template, isSingleFile = false) => {
|
|
29
|
-
if (!template) return null;
|
|
30
|
-
|
|
31
|
-
// Replace locale placeholder
|
|
32
|
-
let filePath = template.replace(/\[locale\]/g, htmlTemplateLabel);
|
|
41
|
+
if (!template) return null; // Replace locale placeholder
|
|
33
42
|
|
|
34
|
-
// Remove [contenthash] placeholder for HTML injection
|
|
43
|
+
let filePath = template.replace(/\[locale\]/g, htmlTemplateLabel); // Remove [contenthash] placeholder for HTML injection
|
|
35
44
|
// The actual hash will be determined at build time
|
|
36
|
-
filePath = filePath.replace(/\.\[contenthash\]/g, '');
|
|
37
45
|
|
|
38
|
-
// If template already contains outputFolder or starts with a path separator, use as-is
|
|
46
|
+
filePath = filePath.replace(/\.\[contenthash\]/g, ''); // If template already contains outputFolder or starts with a path separator, use as-is
|
|
47
|
+
|
|
39
48
|
if (filePath.includes(outputFolder) || filePath.startsWith('/')) {
|
|
40
49
|
return filePath.replace(/\\/g, '/');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// For single-file mode with a simple template like '[locale].js',
|
|
50
|
+
} // For single-file mode with a simple template like '[locale].js',
|
|
44
51
|
// put it directly in outputFolder without subdirectories
|
|
52
|
+
|
|
53
|
+
|
|
45
54
|
if (isSingleFile && !filePath.includes('/')) {
|
|
46
55
|
return path.join(outputFolder || 'i18n-chunk', filePath).replace(/\\/g, '/');
|
|
47
|
-
}
|
|
56
|
+
} // For other cases, preserve subdirectories
|
|
57
|
+
|
|
48
58
|
|
|
49
|
-
// For other cases, preserve subdirectories
|
|
50
59
|
return path.join(outputFolder || 'i18n-chunk', filePath).replace(/\\/g, '/');
|
|
51
60
|
};
|
|
61
|
+
|
|
52
62
|
if (singleFile) {
|
|
53
63
|
// In single file mode, use singleFileTemplate
|
|
54
64
|
const singleTemplate = singleFileTemplate || '[locale].js';
|
|
55
65
|
const combinedFilename = constructFullPath(singleTemplate, true);
|
|
66
|
+
|
|
56
67
|
if (combinedFilename) {
|
|
57
68
|
newI18nAssetUrlsToAdd.push(combinedFilename);
|
|
58
69
|
}
|
|
59
70
|
} else {
|
|
60
71
|
// Add both numeric and dynamic files
|
|
61
72
|
const numericFilename = constructFullPath(numericFilenameTemplate);
|
|
73
|
+
|
|
62
74
|
if (numericFilename) {
|
|
63
75
|
newI18nAssetUrlsToAdd.push(numericFilename);
|
|
64
76
|
}
|
|
77
|
+
|
|
65
78
|
const dynamicFilename = constructFullPath(dynamicFilenameTemplate);
|
|
79
|
+
|
|
66
80
|
if (dynamicFilename) {
|
|
67
81
|
newI18nAssetUrlsToAdd.push(dynamicFilename);
|
|
68
82
|
}
|
|
69
83
|
}
|
|
84
|
+
|
|
70
85
|
if (newI18nAssetUrlsToAdd.length > 0) {
|
|
71
86
|
// Add i18n assets to the beginning of JS assets for early loading
|
|
72
87
|
assets.js = [...newI18nAssetUrlsToAdd, ...assets.js];
|
|
73
88
|
}
|
|
89
|
+
|
|
74
90
|
cb(null, hookData);
|
|
75
91
|
});
|
|
76
92
|
});
|
|
77
93
|
}
|
|
94
|
+
|
|
78
95
|
}
|
|
96
|
+
|
|
79
97
|
module.exports = {
|
|
80
98
|
I18nNumericIndexHtmlInjectorPlugin
|
|
81
99
|
};
|