@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,28 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getBabelPlugin = getBabelPlugin;
|
|
7
|
+
|
|
7
8
|
var _modeUtils = require("../bundler/webpack/common/modeUtils");
|
|
9
|
+
|
|
8
10
|
var _addDefaultPlugins = require("./addDefaultPlugins");
|
|
11
|
+
|
|
9
12
|
const babelPluginMapping = {
|
|
10
13
|
removeAttribute: './babel_plugins/removeAttributesPlugin',
|
|
11
14
|
removePropTypes: 'babel-plugin-transform-react-remove-prop-types',
|
|
12
15
|
devConsoleExclude: 'babel-plugin-transform-remove-console'
|
|
13
16
|
};
|
|
14
17
|
const babelPluginOrder = ['removeAttribute', 'removePropTypes', 'devConsoleExclude'];
|
|
18
|
+
|
|
15
19
|
function getBabelPlugin(options) {
|
|
16
20
|
const {
|
|
17
21
|
mode
|
|
18
|
-
} = options;
|
|
22
|
+
} = options; // let customPlugins = [];
|
|
19
23
|
|
|
20
|
-
// let customPlugins = [];
|
|
21
24
|
let customPlugins = [];
|
|
22
25
|
const {
|
|
23
26
|
babelCustomizations
|
|
24
27
|
} = options;
|
|
28
|
+
|
|
25
29
|
if ((0, _modeUtils.isProductionMode)(mode)) {
|
|
26
30
|
const configCreator = _addDefaultPlugins.addDefaultPlugins;
|
|
27
31
|
const plugins = babelPluginOrder.map(p => configCreator(babelCustomizations[p], babelPluginMapping[p]));
|
|
28
32
|
customPlugins = plugins;
|
|
29
33
|
}
|
|
34
|
+
|
|
30
35
|
return customPlugins.filter(Boolean);
|
|
31
36
|
}
|
|
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.runBabelForJSFile = runBabelForJSFile;
|
|
7
|
+
|
|
7
8
|
var _core = require("@babel/core");
|
|
9
|
+
|
|
8
10
|
var _babelWebConfig = require("./babelWebConfig");
|
|
11
|
+
|
|
9
12
|
var _copyFile = require("../fileUtils/copyFile");
|
|
13
|
+
|
|
10
14
|
function runBabelForJSFile({
|
|
11
15
|
filename,
|
|
12
16
|
outputFile,
|
|
@@ -14,7 +18,6 @@ function runBabelForJSFile({
|
|
|
14
18
|
mode = 'es'
|
|
15
19
|
}) {
|
|
16
20
|
// const jsSourceCode = readFileSync(filename).toString();
|
|
17
|
-
|
|
18
21
|
const babelConfig = (0, _babelWebConfig.babelWebConfig)(options, mode);
|
|
19
22
|
const result = (0, _core.transformFileSync)(filename, babelConfig);
|
|
20
23
|
(0, _copyFile.writeFile)(outputFile, result.code);
|
|
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.runBabelForTSFile = runBabelForTSFile;
|
|
7
|
+
|
|
7
8
|
var _core = require("@babel/core");
|
|
9
|
+
|
|
8
10
|
var _babelWebConfig = require("./babelWebConfig");
|
|
11
|
+
|
|
9
12
|
var _copyFile = require("../fileUtils/copyFile");
|
|
13
|
+
|
|
10
14
|
function runBabelForTSFile({
|
|
11
15
|
filename,
|
|
12
16
|
outputFile,
|
|
@@ -16,9 +20,9 @@ function runBabelForTSFile({
|
|
|
16
20
|
const {
|
|
17
21
|
enable
|
|
18
22
|
} = options.typeScript;
|
|
23
|
+
|
|
19
24
|
if (enable) {
|
|
20
25
|
// const jsSourceCode = readFileSync(filename).toString();
|
|
21
|
-
|
|
22
26
|
const babelConfig = (0, _babelWebConfig.babelWebConfig)(options, mode);
|
|
23
27
|
const result = (0, _core.transformFileSync)(filename, babelConfig);
|
|
24
28
|
(0, _copyFile.writeFile)(outputFile.replace('.tsx', '.js').replace('.ts', '.js'), result.code);
|
|
@@ -5,12 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.decidePublicPath = decidePublicPath;
|
|
7
7
|
exports.modifiedServerOptions = modifiedServerOptions;
|
|
8
|
+
|
|
8
9
|
var _getServerURL = require("../../../server/getServerURL");
|
|
10
|
+
|
|
9
11
|
var _httpsOptions = require("../../../server/httpsOptions");
|
|
12
|
+
|
|
10
13
|
var _urlConcat = require("../../../server/urlConcat");
|
|
14
|
+
|
|
11
15
|
function decidePublicPath(serverExtras) {
|
|
12
16
|
return serverExtras.isHttps ? serverExtras.httpsUrl : serverExtras.httpUrl;
|
|
13
17
|
}
|
|
18
|
+
|
|
14
19
|
function modifiedServerOptions(options) {
|
|
15
20
|
const {
|
|
16
21
|
server,
|
|
@@ -9,8 +9,7 @@ exports.libAlias = void 0;
|
|
|
9
9
|
// FIXME: But there is a posiblity when these package does not have lib,
|
|
10
10
|
// app will work because of alias, But may be jest won't work because of not alais
|
|
11
11
|
// So need to think about use alais in jest
|
|
12
|
-
|
|
13
|
-
const libAlias = exports.libAlias = {
|
|
12
|
+
const libAlias = {
|
|
14
13
|
'@zohodesk/components/lib': '@zohodesk/components/es',
|
|
15
14
|
// '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
|
|
16
15
|
'@zohodesk/dot/lib': '@zohodesk/dot/es',
|
|
@@ -28,4 +27,5 @@ const libAlias = exports.libAlias = {
|
|
|
28
27
|
'@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
|
|
29
28
|
'@zohodesk/variables/lib': '@zohodesk/variables/es',
|
|
30
29
|
'@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
|
|
31
|
-
};
|
|
30
|
+
};
|
|
31
|
+
exports.libAlias = libAlias;
|
|
@@ -8,24 +8,29 @@ exports.getWebpackMode = getWebpackMode;
|
|
|
8
8
|
exports.isDevelopmentMode = isDevelopmentMode;
|
|
9
9
|
exports.isNotProduction = isNotProduction;
|
|
10
10
|
exports.isProductionMode = isProductionMode;
|
|
11
|
+
|
|
11
12
|
function isProductionMode(mode) {
|
|
12
13
|
return mode === 'prod' || mode === 'production';
|
|
13
14
|
}
|
|
15
|
+
|
|
14
16
|
function isDevelopmentMode(mode) {
|
|
15
17
|
return mode === 'dev' || mode === 'development';
|
|
16
18
|
}
|
|
19
|
+
|
|
17
20
|
function getWebpackMode(options) {
|
|
18
21
|
const {
|
|
19
22
|
mode
|
|
20
23
|
} = options;
|
|
21
24
|
return isProductionMode(mode) ? 'production' : 'development';
|
|
22
25
|
}
|
|
26
|
+
|
|
23
27
|
function getGlobalCacheStorageName(options) {
|
|
24
28
|
const {
|
|
25
29
|
context
|
|
26
30
|
} = options;
|
|
27
31
|
return `${context}Jsonp`;
|
|
28
32
|
}
|
|
33
|
+
|
|
29
34
|
function isNotProduction(options) {
|
|
30
35
|
const {
|
|
31
36
|
mode
|
|
@@ -5,24 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isI18nFile = void 0;
|
|
7
7
|
exports.nameTemplates = nameTemplates;
|
|
8
|
+
|
|
8
9
|
var _modeUtils = require("./modeUtils");
|
|
10
|
+
|
|
9
11
|
// nameTemplate.js
|
|
10
12
|
// NOTE: these below code can be done in js,
|
|
11
|
-
|
|
12
13
|
// we did copy paste in order to avoid unnecessary confusion
|
|
13
14
|
// NOTE: array[0] is dev mode file templates and array[1] is prod mode file templates
|
|
14
|
-
|
|
15
15
|
const defaultTemplates = {
|
|
16
16
|
html: ['index.html', 'index.[contenthash].html'],
|
|
17
17
|
js: ['js/[name].js', 'js/[name].[contenthash]_.js'],
|
|
18
18
|
chunkjs: ['js-chunk/[name].js', 'js-chunks/[name].[contenthash]_.js'],
|
|
19
19
|
i18njs: ['i18n-chunk/[locale]/[name].i18n.js', 'i18n-chunk/[locale]/[name].[chunkhash:20]_.i18n.js'],
|
|
20
|
-
i18nchunkjs: ['i18n-chunk/[locale]/[name].i18n.js',
|
|
21
|
-
// 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js'
|
|
20
|
+
i18nchunkjs: ['i18n-chunk/[locale]/[name].i18n.js', // 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js'
|
|
22
21
|
'i18n-chunk/[locale]/[name].[contenthash]_.i18n.js'],
|
|
23
22
|
i18nmanifest: ['i18n-manifest.json', 'i18n-manifest.json'],
|
|
24
23
|
workerjs: ['js/[name].js', 'js/[name].[contenthash].js'],
|
|
25
24
|
css: ['css/[name].css', 'css/[name].[contenthash]_.css'],
|
|
25
|
+
|
|
26
26
|
/**
|
|
27
27
|
* NOTE: when you change (cssdir) this line it will have affect on Below files will be affected
|
|
28
28
|
* custom_plugins/RtlSplitPlugin/*
|
|
@@ -36,10 +36,12 @@ const defaultTemplates = {
|
|
|
36
36
|
audio: ['fonts/[name][ext]', 'fonts/[name].[contenthash][ext]'],
|
|
37
37
|
video: ['videos/[name][ext]', 'videos/[name].[contenthash][ext]']
|
|
38
38
|
};
|
|
39
|
+
|
|
39
40
|
function createNameTemplate(name, useHash) {
|
|
40
41
|
// const ext = `${useHash ? '.[hash:20]' : ''}[ext]`;
|
|
41
42
|
return useHash ? name[1] : name[0];
|
|
42
43
|
}
|
|
44
|
+
|
|
43
45
|
const defaultDevModeContentHashAllowedTypes = {
|
|
44
46
|
image: true,
|
|
45
47
|
font: true,
|
|
@@ -47,6 +49,7 @@ const defaultDevModeContentHashAllowedTypes = {
|
|
|
47
49
|
audio: true,
|
|
48
50
|
video: true
|
|
49
51
|
};
|
|
52
|
+
|
|
50
53
|
function nameTemplates(type, options) {
|
|
51
54
|
const {
|
|
52
55
|
enableFileNameHashing,
|
|
@@ -58,15 +61,16 @@ function nameTemplates(type, options) {
|
|
|
58
61
|
devModeContentHashAllowedTypes
|
|
59
62
|
} = options;
|
|
60
63
|
devModeContentHashAllowedTypes = devModeContentHashAllowedTypes || defaultDevModeContentHashAllowedTypes;
|
|
61
|
-
const templates = {
|
|
62
|
-
...defaultTemplates,
|
|
64
|
+
const templates = { ...defaultTemplates,
|
|
63
65
|
...nameTemplateCustomization
|
|
64
66
|
};
|
|
65
67
|
const templateName = templates[type];
|
|
68
|
+
|
|
66
69
|
if (!templateName) {
|
|
67
70
|
throw Error(`specified type not valid Type: ${type}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
71
|
+
} // eslint-disable-next-line no-use-before-define
|
|
72
|
+
|
|
73
|
+
|
|
70
74
|
const useHash = checkCanWeAllowHash({
|
|
71
75
|
enableFileNameHashing,
|
|
72
76
|
devLikeHash: devLikeHash || (0, _modeUtils.isDevelopmentMode)(mode),
|
|
@@ -75,6 +79,7 @@ function nameTemplates(type, options) {
|
|
|
75
79
|
});
|
|
76
80
|
return createNameTemplate(templateName, useHash);
|
|
77
81
|
}
|
|
82
|
+
|
|
78
83
|
function checkCanWeAllowHash({
|
|
79
84
|
enableFileNameHashing,
|
|
80
85
|
devLikeHash,
|
|
@@ -84,15 +89,17 @@ function checkCanWeAllowHash({
|
|
|
84
89
|
if (!enableFileNameHashing) {
|
|
85
90
|
return false;
|
|
86
91
|
}
|
|
92
|
+
|
|
87
93
|
if (devLikeHash) {
|
|
88
94
|
return devModeContentHashAllowedTypes[type];
|
|
89
95
|
}
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
96
|
|
|
93
|
-
|
|
97
|
+
return true;
|
|
98
|
+
} // export function cssDirNameTemplate(dir, options) {
|
|
94
99
|
// return nameTemplates('cssdir', options).replace(/\[dir\]/g, dir);
|
|
95
100
|
// }
|
|
96
101
|
|
|
102
|
+
|
|
97
103
|
const isI18nFile = url => url.endsWith('.i18n.js');
|
|
104
|
+
|
|
98
105
|
exports.isI18nFile = isI18nFile;
|
|
@@ -5,16 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.publicPathAsExpression = publicPathAsExpression;
|
|
7
7
|
exports.resourceBasedPublicPath = resourceBasedPublicPath;
|
|
8
|
-
// const publicPaths = {
|
|
9
8
|
|
|
9
|
+
// const publicPaths = {
|
|
10
10
|
// };
|
|
11
|
-
|
|
12
11
|
function resourceBasedPublicPath(resoruceType, options) {
|
|
13
12
|
return options.publicPath;
|
|
14
13
|
}
|
|
14
|
+
|
|
15
15
|
function publicPathAsExpression(resoruceType, options) {
|
|
16
16
|
if (resoruceType === 'i18n') {
|
|
17
17
|
return options.i18nChunkSplit.localeVarName;
|
|
18
18
|
}
|
|
19
|
+
|
|
19
20
|
return JSON.stringify(options.publicPath);
|
|
20
21
|
}
|
|
@@ -4,12 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BundleIntegrityReport = void 0;
|
|
7
|
+
|
|
7
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
|
|
8
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
|
|
9
12
|
var _stream = require("stream");
|
|
13
|
+
|
|
10
14
|
var _objectManipulation = require("../../utils/object-manipulation");
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
12
18
|
const pluginName = 'BundleIntegrityReportPlugin';
|
|
19
|
+
|
|
13
20
|
class BundleIntegrityReport {
|
|
14
21
|
constructor({
|
|
15
22
|
options,
|
|
@@ -20,6 +27,7 @@ class BundleIntegrityReport {
|
|
|
20
27
|
this.statsFileName = fileName;
|
|
21
28
|
this.statsOptions = options;
|
|
22
29
|
}
|
|
30
|
+
|
|
23
31
|
apply(compiler) {
|
|
24
32
|
compiler.hooks.done.tapAsync(pluginName, (stats, callback) => {
|
|
25
33
|
if (stats.hasErrors()) {
|
|
@@ -31,6 +39,7 @@ class BundleIntegrityReport {
|
|
|
31
39
|
}));
|
|
32
40
|
return callback(new Error('Build failed due to compilation errors.'));
|
|
33
41
|
}
|
|
42
|
+
|
|
34
43
|
const statsJson = (0, _objectManipulation.removeKeysFromObject)(stats.toJson(this.statsOptions), this.excludeKeysInStat);
|
|
35
44
|
this.emitStats(statsJson).on('end', () => {
|
|
36
45
|
callback();
|
|
@@ -39,24 +48,30 @@ class BundleIntegrityReport {
|
|
|
39
48
|
});
|
|
40
49
|
});
|
|
41
50
|
}
|
|
51
|
+
|
|
42
52
|
writeStatsFileInAStream(statsObj) {
|
|
43
53
|
const {
|
|
44
54
|
outputPath
|
|
45
55
|
} = statsObj;
|
|
56
|
+
|
|
46
57
|
const ouputFileName = _path.default.join(outputPath, this.statsFileName);
|
|
58
|
+
|
|
47
59
|
return this.createReadStream(statsObj).pipe(_fs.default.createWriteStream(ouputFileName));
|
|
48
60
|
}
|
|
61
|
+
|
|
49
62
|
createReadStream(statsObj) {
|
|
50
63
|
const excludeKeys = this.excludeKeysInStat;
|
|
51
64
|
return new _stream.Readable({
|
|
52
65
|
read() {
|
|
53
66
|
let isDone = false;
|
|
54
67
|
const objToStringGen = (0, _objectManipulation.convertObjectToStringGen)(statsObj, excludeKeys);
|
|
68
|
+
|
|
55
69
|
while (!isDone) {
|
|
56
70
|
const {
|
|
57
71
|
done,
|
|
58
72
|
value
|
|
59
73
|
} = objToStringGen.next();
|
|
74
|
+
|
|
60
75
|
if (done) {
|
|
61
76
|
isDone = true;
|
|
62
77
|
this.push(null);
|
|
@@ -65,10 +80,14 @@ class BundleIntegrityReport {
|
|
|
65
80
|
}
|
|
66
81
|
}
|
|
67
82
|
}
|
|
83
|
+
|
|
68
84
|
});
|
|
69
85
|
}
|
|
86
|
+
|
|
70
87
|
emitStats(statsJson) {
|
|
71
88
|
return this.writeStatsFileInAStream(statsJson);
|
|
72
89
|
}
|
|
90
|
+
|
|
73
91
|
}
|
|
92
|
+
|
|
74
93
|
exports.BundleIntegrityReport = BundleIntegrityReport;
|
|
@@ -4,28 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
9
|
+
|
|
8
10
|
var _webpack = require("webpack");
|
|
11
|
+
|
|
9
12
|
var _nameTemplates = require("../../common/nameTemplates");
|
|
13
|
+
|
|
10
14
|
var _modeUtils = require("../../common/modeUtils");
|
|
15
|
+
|
|
11
16
|
var _webpackCustomJsUrlLoader = _interopRequireDefault(require("./webpackCustomJsUrlLoader"));
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
// import { RuntimeGlobals, RuntimeModule } from 'webpack';
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
19
|
|
|
20
|
+
// import { RuntimeGlobals, RuntimeModule } from 'webpack';
|
|
21
|
+
// eslint-disable-next-line import/extensions
|
|
17
22
|
// import { Template } from 'webpack';
|
|
18
23
|
// eslint-disable-next-line import/extensions
|
|
19
|
-
|
|
20
|
-
const pluginName = 'CdnChangePlugin';
|
|
21
|
-
// const MODULE_TYPE = 'css/mini-extract';
|
|
22
|
-
|
|
24
|
+
const pluginName = 'CdnChangePlugin'; // const MODULE_TYPE = 'css/mini-extract';
|
|
23
25
|
// class CdnChangeRuntimePlugin extends RuntimeModule {
|
|
24
26
|
// constructor(compiler, { variableName }) {
|
|
25
27
|
// super('cdn loading', 10);
|
|
26
28
|
// this.variableName = variableName;
|
|
27
29
|
// }
|
|
28
|
-
|
|
29
30
|
// generate() {
|
|
30
31
|
// return `${RuntimeGlobals.getChunkCssFilename} = function(chunkId) {
|
|
31
32
|
// const cssCdnUrl = window[${this.variableName}] || chunkId;
|
|
@@ -33,6 +34,7 @@ const pluginName = 'CdnChangePlugin';
|
|
|
33
34
|
// }`;
|
|
34
35
|
// }
|
|
35
36
|
// }
|
|
37
|
+
|
|
36
38
|
class CdnChangePlugin {
|
|
37
39
|
constructor(options) {
|
|
38
40
|
this.createSeparateSMap = options.createSeparateSMap;
|
|
@@ -42,6 +44,7 @@ class CdnChangePlugin {
|
|
|
42
44
|
this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
|
|
43
45
|
this.mode = options.mode || 'prod';
|
|
44
46
|
}
|
|
47
|
+
|
|
45
48
|
apply(compiler) {
|
|
46
49
|
// compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
47
50
|
// const enabledChunks = new WeakSet();
|
|
@@ -49,11 +52,8 @@ class CdnChangePlugin {
|
|
|
49
52
|
// if (enabledChunks.has(entryRuntimeChunk)) {
|
|
50
53
|
// return;
|
|
51
54
|
// }
|
|
52
|
-
|
|
53
55
|
// enabledChunks.add(entryRuntimeChunk);
|
|
54
|
-
|
|
55
56
|
// set.add(RuntimeGlobals.getFullHash);
|
|
56
|
-
|
|
57
57
|
// set.add(RuntimeGlobals.getChunkCssFilename);
|
|
58
58
|
// compilation.addRuntimeModule(
|
|
59
59
|
// entryRuntimeChunk,
|
|
@@ -67,16 +67,14 @@ class CdnChangePlugin {
|
|
|
67
67
|
// .for(RuntimeGlobals.ensureChunkHandlers)
|
|
68
68
|
// .tap(pluginName, handler);
|
|
69
69
|
// });
|
|
70
|
-
|
|
71
70
|
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
72
71
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, (data, cb) => {
|
|
73
72
|
const {
|
|
74
73
|
createSeparateSMap,
|
|
75
74
|
mode
|
|
76
|
-
} = this;
|
|
77
|
-
|
|
78
|
-
data.assets = {
|
|
79
|
-
...data.assets,
|
|
75
|
+
} = this; // eslint-disable-next-line no-param-reassign
|
|
76
|
+
|
|
77
|
+
data.assets = { ...data.assets,
|
|
80
78
|
css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
|
|
81
79
|
js: data.assets.js.map(js => {
|
|
82
80
|
if ((0, _modeUtils.isProductionMode)(mode) && createSeparateSMap && !(0, _nameTemplates.isI18nFile)(js)) {
|
|
@@ -86,24 +84,29 @@ class CdnChangePlugin {
|
|
|
86
84
|
js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
|
|
87
85
|
}
|
|
88
86
|
}
|
|
87
|
+
|
|
89
88
|
return `${(0, _nameTemplates.isI18nFile)(js) ? this.i18nTemplate : this.jsTemplate}${js}`;
|
|
90
89
|
})
|
|
91
90
|
};
|
|
92
91
|
cb && cb(null, data);
|
|
93
92
|
});
|
|
93
|
+
|
|
94
94
|
compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.getChunkScriptFilename).tap(pluginName, (chunk, set) => {
|
|
95
95
|
if (typeof compilation.outputOptions.chunkFilename === 'string' && /\[(full)?hash(:\d+)?\]/.test(compilation.outputOptions.chunkFilename)) {
|
|
96
96
|
set.add(_webpack.RuntimeGlobals.getFullHash);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
// eslint-disable-next-line new-cap
|
|
98
|
+
|
|
99
|
+
compilation.addRuntimeModule(chunk, // eslint-disable-next-line new-cap
|
|
100
100
|
new _webpackCustomJsUrlLoader.default('javascript', 'javascript', _webpack.RuntimeGlobals.getChunkScriptFilename, chunk => chunk.filenameTemplate || (chunk.canBeInitial() ? compilation.outputOptions.filename : compilation.outputOptions.chunkFilename), false, this.variableName));
|
|
101
101
|
return true;
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
+
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
+
|
|
108
|
+
var _default = CdnChangePlugin; // Cdn Change Plugin for runtime chunks???
|
|
109
|
+
|
|
107
110
|
/**
|
|
108
111
|
* the filename of the script part of the chunk
|
|
109
112
|
*/
|
|
@@ -111,4 +114,6 @@ var _default = exports.default = CdnChangePlugin; // Cdn Change Plugin for runti
|
|
|
111
114
|
// /**
|
|
112
115
|
// * the filename of the css part of the chunk
|
|
113
116
|
// */
|
|
114
|
-
// exports.getChunkCssFilename = "__webpack_require__.k";
|
|
117
|
+
// exports.getChunkCssFilename = "__webpack_require__.k";
|
|
118
|
+
|
|
119
|
+
exports.default = _default;
|
package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js
CHANGED
|
@@ -4,17 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _GetChunkFilenameRuntimeModule = _interopRequireDefault(require("webpack/lib/runtime/GetChunkFilenameRuntimeModule"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
// import { RuntimeGlobals, RuntimeModule, Template } from 'webpack';
|
|
10
9
|
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
// import { RuntimeGlobals, RuntimeModule, Template } from 'webpack';
|
|
11
13
|
// const GetChunkFilenameRuntimeModule = require('webpack/lib/runtime/GetChunkFilenameRuntimeModule');
|
|
12
14
|
// import GetChunkFilenameRuntimeModule from 'webpack/lib/runtime/GetChunkFilenameRuntimeModule';
|
|
13
15
|
// const first = set => {
|
|
14
16
|
// const entry = set.values().next();
|
|
15
17
|
// return entry.done ? undefined : entry.value;
|
|
16
18
|
// };
|
|
17
|
-
|
|
18
19
|
class CustomizedGetChunkFilenameRuntimeModule extends _GetChunkFilenameRuntimeModule.default {
|
|
19
20
|
/**
|
|
20
21
|
* @param {string} contentType the to use the content hash for
|
|
@@ -32,10 +33,14 @@ class CustomizedGetChunkFilenameRuntimeModule extends _GetChunkFilenameRuntimeMo
|
|
|
32
33
|
this.dependentHash = true;
|
|
33
34
|
this.variableName = variableName;
|
|
34
35
|
}
|
|
36
|
+
|
|
35
37
|
generate() {
|
|
36
38
|
const sourceCode = super.generate().toString();
|
|
37
39
|
const replaceCode = sourceCode.replaceAll('"js-chunks/', `${this.variableName} + "js-chunks/`);
|
|
38
40
|
return replaceCode;
|
|
39
41
|
}
|
|
42
|
+
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
|
|
45
|
+
var _default = CustomizedGetChunkFilenameRuntimeModule;
|
|
46
|
+
exports.default = _default;
|
|
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CustomScriptLoadingStrategyPlugin = 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 = 'CustomScriptLoadingStrategyPlugin';
|
|
13
|
+
|
|
10
14
|
class CustomScriptLoadingStrategyPlugin {
|
|
11
15
|
constructor({
|
|
12
16
|
scriptLoadingStategey
|
|
@@ -14,57 +18,69 @@ class CustomScriptLoadingStrategyPlugin {
|
|
|
14
18
|
this.scriptLoadingStrategy = scriptLoadingStategey;
|
|
15
19
|
this.tagNamesToMatch = ['script'];
|
|
16
20
|
}
|
|
21
|
+
|
|
17
22
|
getFileNameFromTagSrc(src) {
|
|
18
23
|
const fileNameArr = src.split('/');
|
|
19
24
|
return fileNameArr[fileNameArr.length - 1];
|
|
20
25
|
}
|
|
26
|
+
|
|
21
27
|
addAttributestToTag(tag, attributes) {
|
|
22
28
|
tag.attributes = Object.assign({}, tag.attributes, attributes);
|
|
23
29
|
}
|
|
30
|
+
|
|
24
31
|
matchFileName(tag, fileName) {
|
|
25
32
|
return fileName.test(this.getFileNameFromTagSrc(tag.attributes.src));
|
|
26
33
|
}
|
|
34
|
+
|
|
27
35
|
blockingStrategy(tag) {
|
|
28
36
|
delete tag.attributes.defer;
|
|
29
37
|
delete tag.attributes.async;
|
|
30
38
|
}
|
|
39
|
+
|
|
31
40
|
deferStrategy(tag) {
|
|
32
41
|
delete tag.attributes.async;
|
|
33
42
|
}
|
|
43
|
+
|
|
34
44
|
asyncStrategy(tag) {
|
|
35
45
|
delete tag.attributes.defer;
|
|
36
46
|
}
|
|
47
|
+
|
|
37
48
|
moduleStrategy(tag) {
|
|
38
49
|
this.deferStrategy(tag);
|
|
39
50
|
}
|
|
51
|
+
|
|
40
52
|
matchStrategy(scriptLoadingStrategy, tag) {
|
|
41
53
|
if (scriptLoadingStrategy === 'blocking') {
|
|
42
54
|
this.blockingStrategy(tag);
|
|
43
55
|
}
|
|
56
|
+
|
|
44
57
|
if (scriptLoadingStrategy === 'defer') {
|
|
45
58
|
this.deferStrategy(tag);
|
|
46
59
|
}
|
|
60
|
+
|
|
47
61
|
if (scriptLoadingStrategy === 'async') {
|
|
48
62
|
this.asyncStrategy(tag);
|
|
49
63
|
}
|
|
64
|
+
|
|
50
65
|
if (scriptLoadingStrategy === 'module') {
|
|
51
66
|
this.moduleStrategy(tag);
|
|
52
67
|
}
|
|
53
68
|
}
|
|
69
|
+
|
|
54
70
|
matchAndApplyCustomLoadingStrategyToScripts(tags) {
|
|
55
71
|
Object.keys(this.scriptLoadingStrategy).forEach(scriptLoadingStrategy => {
|
|
56
72
|
const filesToMatch = this.scriptLoadingStrategy[scriptLoadingStrategy];
|
|
57
73
|
tags.forEach(tag => {
|
|
58
74
|
if (this.tagNamesToMatch.includes(tag.tagName) && tag.attributes.src) {
|
|
59
75
|
const isFileMatch = filesToMatch.some(fileName => this.matchFileName(tag, fileName));
|
|
76
|
+
|
|
60
77
|
if (isFileMatch) {
|
|
61
78
|
this.matchStrategy(scriptLoadingStrategy, tag);
|
|
62
79
|
this.addAttributestToTag(tag, {
|
|
63
80
|
[scriptLoadingStrategy]: true
|
|
64
81
|
});
|
|
65
82
|
}
|
|
66
|
-
}
|
|
67
|
-
// filesToMatch.forEach(fileName => {
|
|
83
|
+
} // filesToMatch.forEach(fileName => {
|
|
68
84
|
// if (!this.matchFileName(tag, fileName)) {
|
|
69
85
|
// return;
|
|
70
86
|
// }
|
|
@@ -73,9 +89,11 @@ class CustomScriptLoadingStrategyPlugin {
|
|
|
73
89
|
// [scriptLoadingStrategy]: true
|
|
74
90
|
// });
|
|
75
91
|
// });
|
|
92
|
+
|
|
76
93
|
});
|
|
77
94
|
});
|
|
78
95
|
}
|
|
96
|
+
|
|
79
97
|
apply(compiler) {
|
|
80
98
|
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
81
99
|
_htmlWebpackPlugin.default.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, callback) => {
|
|
@@ -85,5 +103,7 @@ class CustomScriptLoadingStrategyPlugin {
|
|
|
85
103
|
});
|
|
86
104
|
});
|
|
87
105
|
}
|
|
106
|
+
|
|
88
107
|
}
|
|
108
|
+
|
|
89
109
|
exports.CustomScriptLoadingStrategyPlugin = CustomScriptLoadingStrategyPlugin;
|