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