@zohodesk/client_build_tool 0.0.11-exp.16 → 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 +0 -204
- package/README_backup.md +0 -204
- package/docs/DYNAMIC_TEMPLATE_EXAMPLE.md +129 -0
- package/docs/I18N_NUMERIC_INDEXING_PLUGIN.md +225 -0
- package/docs/I18N_SINGLE_FILE_MODE.md +126 -0
- package/docs/client_build_tool_source_doc.md +390 -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 +31 -7
- 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 +120 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +81 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +328 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +135 -0
- 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 +20 -22
- 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 +23 -4
- 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 +72 -0
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +113 -0
- 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 +38 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +86 -0
- 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 -24
- 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 +28 -64
- 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,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.templateFileName = templateFileName;
|
|
7
|
-
|
|
8
7
|
var _webpack = require("webpack");
|
|
9
|
-
|
|
10
8
|
var _templateHashHelpers = require("./templateHashHelpers");
|
|
11
|
-
|
|
12
9
|
function templateFileName({
|
|
13
10
|
compilation,
|
|
14
11
|
dynamicFilename,
|
|
@@ -20,8 +17,9 @@ function templateFileName({
|
|
|
20
17
|
const {
|
|
21
18
|
mapExpr,
|
|
22
19
|
mapExprWithLength
|
|
23
|
-
} = (0, _templateHashHelpers.templateHashHelpers)(chunks);
|
|
20
|
+
} = (0, _templateHashHelpers.templateHashHelpers)(chunks);
|
|
24
21
|
|
|
22
|
+
// "i18n-chunk/[locale]/[name].[chunkhash].js"
|
|
25
23
|
const i18nURLPathTemplate = compilation.getPath(JSON.stringify(dynamicFilename).replace(/\[locale\]/gi, '"+ locale +"'), {
|
|
26
24
|
hash: `" + ${_webpack.RuntimeGlobals.getFullHash}() + "`,
|
|
27
25
|
hashWithLength: length => `" + ${_webpack.RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.templateHashHelpers = templateHashHelpers;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* this function will be used for chunk name, chunk hash, contentHash
|
|
10
9
|
* in these, sometime chunk name and chunk id same for some chunkss so below logic has little towek
|
|
11
10
|
* @param {Chunk} chunks
|
|
12
11
|
* @returns { mapExpr, mapExprWithLength }
|
|
13
12
|
*/
|
|
13
|
+
|
|
14
14
|
function templateHashHelpers(chunks) {
|
|
15
15
|
/**
|
|
16
16
|
* @param {function(Chunk): string | number} fn function from chunk to value
|
|
@@ -20,11 +20,10 @@ function templateHashHelpers(chunks) {
|
|
|
20
20
|
const obj = {};
|
|
21
21
|
let useId = false;
|
|
22
22
|
let lastKey;
|
|
23
|
-
let entries = 0;
|
|
24
|
-
|
|
23
|
+
let entries = 0;
|
|
24
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
25
25
|
for (const c of chunks) {
|
|
26
26
|
const value = fn(c);
|
|
27
|
-
|
|
28
27
|
if (value === c.id) {
|
|
29
28
|
useId = true;
|
|
30
29
|
} else {
|
|
@@ -33,38 +32,34 @@ function templateHashHelpers(chunks) {
|
|
|
33
32
|
entries++;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
if (entries === 0) {
|
|
38
36
|
return 'chunkId';
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
if (entries === 1) {
|
|
42
39
|
return useId ? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify(obj[lastKey])} : chunkId)` : JSON.stringify(obj[lastKey]);
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
return useId ? `(${JSON.stringify(obj)}[chunkId] || chunkId)` : `${JSON.stringify(obj)}[chunkId]`;
|
|
46
42
|
};
|
|
43
|
+
|
|
47
44
|
/**
|
|
48
45
|
* @param {function(Chunk): string | number} fn function from chunk to value
|
|
49
46
|
* @returns {string} code with static mapping of results of fn for including in quoted string
|
|
50
47
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
48
|
const mapExpr = fn => `" + ${createMap(fn)} + "`;
|
|
49
|
+
|
|
54
50
|
/**
|
|
55
51
|
* @param {function(Chunk): string | number} fn function from chunk to value
|
|
56
52
|
* @returns {function(number): string} function which generates code with static mapping of results of fn for including in quoted string for specific length
|
|
57
53
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const mapExprWithLength = fn => length => // console.log('called with lentch', length),
|
|
54
|
+
const mapExprWithLength = fn => length =>
|
|
55
|
+
// console.log('called with lentch', length),
|
|
61
56
|
`" + ${createMap(c => `${fn(c)}`.slice(0, length))} + "`;
|
|
62
|
-
|
|
63
57
|
return {
|
|
64
58
|
mapExpr,
|
|
65
59
|
mapExprWithLength
|
|
66
60
|
};
|
|
67
61
|
}
|
|
62
|
+
|
|
68
63
|
/**
|
|
69
64
|
function mapExpr(fn) {
|
|
70
65
|
const obj = {};
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.collectI18nKeysfromAST = collectI18nKeysfromAST;
|
|
7
7
|
exports.collectI18nKeysfromComments = collectI18nKeysfromComments;
|
|
8
|
-
|
|
9
8
|
var _estreeWalker = require("estree-walker");
|
|
10
|
-
|
|
11
9
|
function collectI18nKeysfromAST(ast, allI18n) {
|
|
12
10
|
const i18nKeys = {};
|
|
13
11
|
(0, _estreeWalker.walk)(ast, {
|
|
@@ -18,41 +16,33 @@ function collectI18nKeysfromAST(ast, allI18n) {
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
});
|
|
23
20
|
return Object.keys(i18nKeys);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
const prefixI18nComment = 'I18N';
|
|
27
23
|
const prefixI18nComment1 = 'dynamic-i18n-key';
|
|
28
|
-
|
|
29
24
|
function getI18nKeysFromComment(comment) {
|
|
30
25
|
const commentString = comment.value.trim();
|
|
31
26
|
let i18nKeyStr;
|
|
32
|
-
|
|
33
27
|
if (commentString.startsWith(prefixI18nComment)) {
|
|
34
28
|
i18nKeyStr = commentString.slice(prefixI18nComment.length).trim();
|
|
35
29
|
} else if (commentString.startsWith(prefixI18nComment1)) {
|
|
36
30
|
i18nKeyStr = commentString.slice(prefixI18nComment1.length).trim();
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
if (!i18nKeyStr) {
|
|
40
33
|
return [];
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
const i18nKeys = i18nKeyStr.split(',');
|
|
44
36
|
return i18nKeys;
|
|
45
|
-
}
|
|
46
|
-
|
|
37
|
+
}
|
|
47
38
|
|
|
39
|
+
// export function fromComments(comments, allI18n) {
|
|
48
40
|
function collectI18nKeysfromComments(comments, allI18n) {
|
|
49
41
|
// TODO: need to implement
|
|
50
42
|
const i18nKeys = {};
|
|
51
43
|
/* eslint-disable no-restricted-syntax */
|
|
52
|
-
|
|
53
44
|
for (const comment of comments) {
|
|
54
45
|
const keys = getI18nKeysFromComment(comment);
|
|
55
|
-
|
|
56
46
|
for (const key of keys) {
|
|
57
47
|
if (key && allI18n[key]) {
|
|
58
48
|
i18nKeys[key] = allI18n[key];
|
|
@@ -60,7 +50,5 @@ function collectI18nKeysfromComments(comments, allI18n) {
|
|
|
60
50
|
}
|
|
61
51
|
}
|
|
62
52
|
/* eslint-enable no-restricted-syntax */
|
|
63
|
-
|
|
64
|
-
|
|
65
53
|
return Object.keys(i18nKeys);
|
|
66
54
|
}
|
|
@@ -10,9 +10,7 @@ exports.hasContentHash = hasContentHash;
|
|
|
10
10
|
// export const REGEXP_NAME = /\[name\]/gi;
|
|
11
11
|
// export const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/gi;
|
|
12
12
|
// TODO: want to choose file type for i18n load
|
|
13
|
-
const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
|
|
14
|
-
exports.REGEXP_CONTENTHASH = REGEXP_CONTENTHASH;
|
|
15
|
-
|
|
13
|
+
const REGEXP_CONTENTHASH = exports.REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
|
|
16
14
|
function hasContentHash(filenameTemplate) {
|
|
17
15
|
REGEXP_CONTENTHASH.lastIndex = 0;
|
|
18
16
|
return REGEXP_CONTENTHASH.test(filenameTemplate);
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _collectI18nKeys = require("./collectI18nKeys");
|
|
8
|
-
|
|
9
7
|
Object.keys(_collectI18nKeys).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _collectI18nKeys[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_collectI18nKeys).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _propertiesUtils = require("./propertiesUtils");
|
|
21
|
-
|
|
22
18
|
Object.keys(_propertiesUtils).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _propertiesUtils[key]) return;
|
|
@@ -3,20 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.decodeUnicodeEscapes = decodeUnicodeEscapes;
|
|
6
7
|
exports.getAllI18n = getAllI18n;
|
|
7
8
|
exports.getPropertiesAsJSON = getPropertiesAsJSON;
|
|
8
9
|
exports.jsonToString = jsonToString;
|
|
9
|
-
|
|
10
10
|
var _fs = require("fs");
|
|
11
|
-
|
|
12
11
|
var _path = require("path");
|
|
13
|
-
|
|
14
12
|
var _constants = require("../../../../../constants");
|
|
15
|
-
|
|
16
13
|
function isComment(line) {
|
|
17
14
|
return line[0] === '#';
|
|
18
15
|
}
|
|
19
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Decode Unicode escape sequences in a string
|
|
19
|
+
* Converts \uXXXX to the actual character
|
|
20
|
+
*/
|
|
21
|
+
function decodeUnicodeEscapes(str) {
|
|
22
|
+
if (typeof str !== 'string') {
|
|
23
|
+
return str;
|
|
24
|
+
}
|
|
25
|
+
return str.replace(/\\u([0-9a-fA-F]{4})/g, (match, hex) => {
|
|
26
|
+
return String.fromCharCode(parseInt(hex, 16));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
20
29
|
function getPropertiesAsJSON(filePath) {
|
|
21
30
|
try {
|
|
22
31
|
const data = (0, _fs.readFileSync)(filePath);
|
|
@@ -24,16 +33,15 @@ function getPropertiesAsJSON(filePath) {
|
|
|
24
33
|
const i18nObj = {};
|
|
25
34
|
source.split(/\r?\n\r?/).forEach(fline => {
|
|
26
35
|
const line = fline.trim();
|
|
27
|
-
|
|
28
36
|
if (!line || isComment(line)) {
|
|
29
37
|
return;
|
|
30
38
|
}
|
|
31
|
-
|
|
32
39
|
const ind = line.indexOf('=');
|
|
33
40
|
const key = line.slice(0, ind).replace(/\\ /g, ' ');
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
let value = line.slice(ind + 1);
|
|
36
42
|
if (key && value) {
|
|
43
|
+
// Decode Unicode escapes in the value
|
|
44
|
+
value = decodeUnicodeEscapes(value);
|
|
37
45
|
i18nObj[key] = value;
|
|
38
46
|
}
|
|
39
47
|
}, {});
|
|
@@ -41,21 +49,18 @@ function getPropertiesAsJSON(filePath) {
|
|
|
41
49
|
} catch (err) {
|
|
42
50
|
return {};
|
|
43
51
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
52
|
+
}
|
|
46
53
|
|
|
54
|
+
// TODO: need to make it as custom option and dynamic
|
|
47
55
|
function getLang(file) {
|
|
48
56
|
const underScoreIndex = file.indexOf('_');
|
|
49
57
|
let language = 'en_US';
|
|
50
|
-
|
|
51
58
|
if (underScoreIndex !== -1) {
|
|
52
59
|
language = file.substring(underScoreIndex + 1);
|
|
53
60
|
language = language.slice(0, language.indexOf('.'));
|
|
54
61
|
}
|
|
55
|
-
|
|
56
62
|
return language;
|
|
57
63
|
}
|
|
58
|
-
|
|
59
64
|
function getAllI18n({
|
|
60
65
|
folderPath,
|
|
61
66
|
disableDefault,
|
|
@@ -69,13 +74,12 @@ function getAllI18n({
|
|
|
69
74
|
const context = (0, _constants.joinWithAppPath)(folderPath);
|
|
70
75
|
files.forEach(file => {
|
|
71
76
|
const filePath = (0, _path.join)(context, file);
|
|
72
|
-
|
|
73
77
|
if (exclude.test(filePath) || !include.test(filePath)) {
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
76
|
-
|
|
77
80
|
const i18n = getPropertiesAsJSON(filePath);
|
|
78
|
-
allLangI18n[getLang(file)] = disableDefault ? i18n : {
|
|
81
|
+
allLangI18n[getLang(file)] = disableDefault ? i18n : {
|
|
82
|
+
...jsResourceI18nKeys,
|
|
79
83
|
...i18n
|
|
80
84
|
};
|
|
81
85
|
});
|
|
@@ -85,29 +89,23 @@ function getAllI18n({
|
|
|
85
89
|
return {};
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
|
-
|
|
89
92
|
function jsonToString(json, keySeperator) {
|
|
90
93
|
let str = '{';
|
|
91
94
|
const keys = Object.keys(json);
|
|
92
95
|
keys.forEach((key, i) => {
|
|
93
96
|
const value = json[key];
|
|
94
|
-
|
|
95
97
|
if (!value) {
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
|
-
|
|
99
100
|
str += `"${keySeperator ? key.replace(/(\.|\\(\s+))/g, keySeperator) : key}":"${value.replace(/.?"/g, match => {
|
|
100
101
|
if (match[0] === '\\') {
|
|
101
102
|
return match;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
104
|
if (match.length === 2) {
|
|
105
105
|
return `${match[0]}\\${match[1]}`;
|
|
106
106
|
}
|
|
107
|
-
|
|
108
107
|
return `\\${match}`;
|
|
109
108
|
}).replace(/(\r\n|\n|\r)/g, '')}"`;
|
|
110
|
-
|
|
111
109
|
if (i !== keys.length - 1) {
|
|
112
110
|
str += ',';
|
|
113
111
|
}
|
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.InitialHtmlPlugin = 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 = 'InitialHtmlPlugin';
|
|
13
|
-
|
|
14
10
|
class InitialHtmlPlugin {
|
|
15
11
|
constructor(options) {
|
|
16
12
|
this.options = options;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
apply(compiler) {
|
|
20
15
|
const {
|
|
21
16
|
filename,
|
|
@@ -40,21 +35,19 @@ class InitialHtmlPlugin {
|
|
|
40
35
|
Object.assign(tag.attributes, {
|
|
41
36
|
nonce: '{{--CSP-nonce}}'
|
|
42
37
|
});
|
|
43
|
-
|
|
44
38
|
if (tag.tagName === 'link') {
|
|
45
39
|
headTags.push(tag);
|
|
46
40
|
} else {
|
|
47
41
|
bodyTags.push(tag);
|
|
48
42
|
}
|
|
49
43
|
});
|
|
50
|
-
cb(null, {
|
|
44
|
+
cb(null, {
|
|
45
|
+
...data,
|
|
51
46
|
headTags,
|
|
52
47
|
bodyTags
|
|
53
48
|
});
|
|
54
49
|
});
|
|
55
50
|
});
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
exports.InitialHtmlPlugin = InitialHtmlPlugin;
|
package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.addFilesNamesToManifestJson = addFilesNamesToManifestJson;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _removeHashFromFileName = require("./removeHashFromFileName");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
10
|
function addFilesNamesToManifestJson({
|
|
15
11
|
manifestJson,
|
|
16
12
|
option,
|
|
@@ -20,7 +16,6 @@ function addFilesNamesToManifestJson({
|
|
|
20
16
|
const json = manifestJson;
|
|
21
17
|
Object.keys(assets).forEach(filename => {
|
|
22
18
|
const fileName = _path.default.parse(filename).base;
|
|
23
|
-
|
|
24
19
|
if (option.test(filename)) {
|
|
25
20
|
const filenameNameWithoutHash = (0, _removeHashFromFileName.removeHashFromFileName)(fileName, hashDigestLength);
|
|
26
21
|
json[filenameNameWithoutHash] = fileName;
|
package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js
CHANGED
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createInitialEntriesForManifestJson = createInitialEntriesForManifestJson;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _removeHashFromFileName = require("./removeHashFromFileName");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
10
|
function createInitialEntriesForManifestJson(initialFileNames, hashLength) {
|
|
15
11
|
const initialEntries = {};
|
|
16
12
|
initialFileNames.forEach(filename => {
|
|
17
13
|
const fileName = _path.default.parse(filename).base;
|
|
18
|
-
|
|
19
14
|
const filenameNameWithoutHash = (0, _removeHashFromFileName.removeHashFromFileName)(fileName, hashLength);
|
|
20
15
|
initialEntries[filenameNameWithoutHash] = fileName;
|
|
21
16
|
});
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createManifestJson = createManifestJson;
|
|
7
|
-
|
|
8
7
|
var _findInitialFileNames = require("./findInitialFileNames");
|
|
9
|
-
|
|
10
8
|
var _addFilesNamesToManifestJson = require("./addFilesNamesToManifestJson");
|
|
11
|
-
|
|
12
9
|
var _createInitialEntries = require("./createInitialEntries");
|
|
13
|
-
|
|
14
10
|
function createManifestJson({
|
|
15
11
|
option,
|
|
16
12
|
hashDigestLength,
|
|
@@ -18,13 +14,11 @@ function createManifestJson({
|
|
|
18
14
|
assets
|
|
19
15
|
}) {
|
|
20
16
|
const manifestJson = {};
|
|
21
|
-
|
|
22
17
|
if (option.needInitialEntries) {
|
|
23
18
|
const initialFileNames = (0, _findInitialFileNames.findInitialFileNames)(compilation);
|
|
24
19
|
const initialEntries = (0, _createInitialEntries.createInitialEntriesForManifestJson)(initialFileNames, hashDigestLength);
|
|
25
20
|
manifestJson.entryFiles = initialEntries;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
const outputJson = (0, _addFilesNamesToManifestJson.addFilesNamesToManifestJson)({
|
|
29
23
|
manifestJson,
|
|
30
24
|
option,
|
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AddFileToManifestJson = void 0;
|
|
7
|
-
|
|
8
7
|
var _webpack = require("webpack");
|
|
9
|
-
|
|
10
8
|
var _createManifestJson = require("./createManifestJson");
|
|
11
|
-
|
|
12
9
|
const pluginName = 'AddFileToManifestJson';
|
|
13
|
-
|
|
14
10
|
class AddFileToManifestJson {
|
|
15
11
|
constructor(options) {
|
|
16
12
|
this.options = options;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
apply(compiler) {
|
|
20
15
|
const {
|
|
21
16
|
RawSource
|
|
@@ -40,7 +35,5 @@ class AddFileToManifestJson {
|
|
|
40
35
|
});
|
|
41
36
|
});
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
exports.AddFileToManifestJson = AddFileToManifestJson;
|
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _webpack = require("webpack");
|
|
9
|
-
|
|
10
8
|
const pluginName = 'prefetch-preload-chunk-plugin';
|
|
9
|
+
|
|
11
10
|
/**
|
|
12
11
|
* NOTE: below functions are useable in webpack 5.79.0 as per day 28 Apr 2023
|
|
13
12
|
* Please checkout for future changes
|
|
@@ -32,40 +31,36 @@ class ResourceHintsPlugin {
|
|
|
32
31
|
css: publicPath,
|
|
33
32
|
i18n: publicPath
|
|
34
33
|
};
|
|
35
|
-
}
|
|
36
|
-
|
|
34
|
+
}
|
|
37
35
|
|
|
36
|
+
// eslint-disable-next-line class-methods-use-this
|
|
38
37
|
apply(compiler) {
|
|
39
38
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
40
39
|
const enabledChunks = new WeakSet();
|
|
41
|
-
|
|
42
40
|
const handler = (entryRuntimeChunk, set) => {
|
|
43
41
|
if (enabledChunks.has(entryRuntimeChunk)) {
|
|
44
42
|
return;
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
enabledChunks.add(entryRuntimeChunk);
|
|
48
|
-
set.add(_webpack.RuntimeGlobals.getFullHash);
|
|
45
|
+
set.add(_webpack.RuntimeGlobals.getFullHash);
|
|
49
46
|
|
|
47
|
+
// set.add(RuntimeGlobals.getChunkCssFilename);
|
|
50
48
|
const {
|
|
51
49
|
publicPathsTemplateObj
|
|
52
50
|
} = this;
|
|
53
|
-
compilation.addRuntimeModule(entryRuntimeChunk,
|
|
51
|
+
compilation.addRuntimeModule(entryRuntimeChunk,
|
|
52
|
+
// eslint-disable-next-line no-use-before-define
|
|
54
53
|
new ResourceHintsRuntimePlugin(compiler, {
|
|
55
54
|
chunk: entryRuntimeChunk,
|
|
56
55
|
allowPrefetchingMultipleChunks: this.allowPrefetchingMultipleChunks,
|
|
57
56
|
publicPathsTemplateObj
|
|
58
57
|
}));
|
|
59
58
|
};
|
|
60
|
-
|
|
61
59
|
compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.ensureChunkHandlers).tap(pluginName, handler);
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
|
-
|
|
65
62
|
}
|
|
66
|
-
|
|
67
63
|
exports.default = ResourceHintsPlugin;
|
|
68
|
-
|
|
69
64
|
class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
70
65
|
constructor(compiler, {
|
|
71
66
|
chunk,
|
|
@@ -78,7 +73,6 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
78
73
|
this.allowPrefetchingMultipleChunks = allowPrefetchingMultipleChunks;
|
|
79
74
|
this.chunk = chunk;
|
|
80
75
|
}
|
|
81
|
-
|
|
82
76
|
generate() {
|
|
83
77
|
const {
|
|
84
78
|
chunk
|
|
@@ -89,7 +83,6 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
89
83
|
Object.keys(idNameMap).forEach(key => {
|
|
90
84
|
const value = idNameMap[key];
|
|
91
85
|
nameIdMap[value] = key;
|
|
92
|
-
|
|
93
86
|
if (key !== value) {
|
|
94
87
|
needsMap = true;
|
|
95
88
|
}
|
|
@@ -102,6 +95,7 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
102
95
|
jsPP = jsPP || _webpack.RuntimeGlobals.publicPath;
|
|
103
96
|
cssPP = cssPP || _webpack.RuntimeGlobals.publicPath;
|
|
104
97
|
i18nPP = i18nPP || _webpack.RuntimeGlobals.publicPath;
|
|
98
|
+
|
|
105
99
|
/**
|
|
106
100
|
* naming abbr
|
|
107
101
|
* ntc -> nameToChunkIdMap
|
|
@@ -150,7 +144,8 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
150
144
|
return chunkId;
|
|
151
145
|
}
|
|
152
146
|
${_webpack.RuntimeGlobals.require}.getChunkIds = function getChunkIds(chunkId) {
|
|
153
|
-
${
|
|
147
|
+
${
|
|
148
|
+
// eslint-disable-next-line no-nested-ternary
|
|
154
149
|
this.allowPrefetchingMultipleChunks ? `
|
|
155
150
|
const isRegExAsChunkId = chunkId instanceof RegExp;
|
|
156
151
|
if(isRegExAsChunkId) {
|
|
@@ -173,13 +168,15 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
173
168
|
let idOfAChunk = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)[0];
|
|
174
169
|
lpp(idOfAChunk, "preload");
|
|
175
170
|
}
|
|
176
|
-
`
|
|
171
|
+
`
|
|
172
|
+
// `// Prefetch a chunk (${pluginName})`,
|
|
177
173
|
// `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
|
|
178
174
|
// Template.indent([
|
|
179
175
|
// `chunkId = ${RuntimeGlobals.require}.getChunkId(chunkId)`,
|
|
180
176
|
// `${RuntimeGlobals.require}.e(chunkId);`
|
|
181
177
|
// ]),
|
|
182
178
|
// '};',
|
|
179
|
+
|
|
183
180
|
// `// Preload a chunk (${pluginName})`,
|
|
184
181
|
// `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
|
|
185
182
|
// Template.indent([
|
|
@@ -189,5 +186,4 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
189
186
|
// '};'
|
|
190
187
|
]);
|
|
191
188
|
}
|
|
192
|
-
|
|
193
189
|
}
|
|
@@ -4,18 +4,13 @@ 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 _JavascriptModulesPlugin = _interopRequireDefault(require("webpack/lib/javascript/JavascriptModulesPlugin"));
|
|
11
|
-
|
|
12
9
|
var _replaceCssDirTemplate = require("./replaceCssDirTemplate");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
11
|
// import { JavascriptModulesPlugin } from 'webpack';
|
|
17
|
-
const pluginName = 'OverwriteCssPathForRTL';
|
|
18
12
|
|
|
13
|
+
const pluginName = 'OverwriteCssPathForRTL';
|
|
19
14
|
class OverwriteCssPathForRTL {
|
|
20
15
|
constructor(options = {
|
|
21
16
|
dirVarName: 'document.dir'
|
|
@@ -23,40 +18,36 @@ class OverwriteCssPathForRTL {
|
|
|
23
18
|
this.dirVarName = options.dirVarName || 'document.dir';
|
|
24
19
|
this.templateLabel = options.templateLabel || '{{--dir}}';
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
overwriteCssPathinHTML(compilation) {
|
|
28
22
|
// NOTE: need to reconsider It is not working as expected
|
|
29
23
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, data => {
|
|
30
24
|
const {
|
|
31
25
|
assets
|
|
32
26
|
} = data;
|
|
33
|
-
return {
|
|
34
|
-
|
|
27
|
+
return {
|
|
28
|
+
...data,
|
|
29
|
+
assets: {
|
|
30
|
+
...assets,
|
|
35
31
|
css: assets.css && (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(assets.css, this.templateLabel)
|
|
36
32
|
}
|
|
37
33
|
};
|
|
38
34
|
});
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
overwriteCssPathinRequireEnsure(compilation, compiler) {
|
|
42
37
|
const {
|
|
43
38
|
RawSource
|
|
44
39
|
} = compiler.webpack.sources;
|
|
45
|
-
|
|
46
40
|
_JavascriptModulesPlugin.default.getCompilationHooks(compilation).renderMain.tap(pluginName, source => {
|
|
47
41
|
const templateText = `"+(${this.dirVarName} === "rtl" ? "rtl": "ltr")+"`;
|
|
48
42
|
const replacedStr = source.source().replace(/\[dir\]/g, templateText);
|
|
49
43
|
return new RawSource(replacedStr);
|
|
50
44
|
});
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
apply(compiler) {
|
|
54
47
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
55
48
|
this.overwriteCssPathinHTML(compilation);
|
|
56
49
|
this.overwriteCssPathinRequireEnsure(compilation, compiler);
|
|
57
50
|
});
|
|
58
51
|
}
|
|
59
|
-
|
|
60
52
|
}
|
|
61
|
-
|
|
62
53
|
exports.default = OverwriteCssPathForRTL;
|