@zohodesk/client_build_tool 0.0.22-exp.4 → 0.0.22-exp.5
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 -723
- package/README_backup.md +0 -723
- package/app/README.MD +30 -0
- package/app/es/test.js +47 -0
- package/app/package.json +12 -0
- package/lib/schemas/defaultConfigValues.js +3 -6
- package/lib/shared/babel/babelWebConfig.js +2 -1
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/utils.js +15 -0
- package/lib/shared/bundler/webpack/entryConfig.js +2 -3
- package/lib/shared/bundler/webpack/moduleConcatenationConfig.js +18 -0
- package/lib/shared/bundler/webpack/optimizationConfig.js +8 -10
- package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +1 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +1 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +1 -1
- package/package.json +1 -1
- package/es/allCommandsConfigs.js +0 -15
- package/es/commands/build/commandExecutor.js +0 -6
- package/es/commands/build/config.js +0 -5
- package/es/commands/build/optionsProcessor.js +0 -25
- package/es/commands/build/preProcessor.js +0 -4
- package/es/commands/buildEs/commandExecutor.js +0 -29
- package/es/commands/buildEs/config.js +0 -5
- package/es/commands/buildEs/preProcessor.js +0 -9
- package/es/commands/buildLib/commandExecutor.js +0 -24
- package/es/commands/buildLib/config.js +0 -5
- package/es/commands/buildLib/preProcessor.js +0 -9
- package/es/commands/mockserver/commandExecutor.js +0 -32
- package/es/commands/mockserver/config.js +0 -5
- package/es/commands/pre_process/commandExecutor.js +0 -10
- package/es/commands/pre_process/config.js +0 -5
- package/es/commands/start/commandExecutor.js +0 -4
- package/es/commands/start/config.js +0 -5
- package/es/commands/start/optionsProcessor.js +0 -21
- package/es/commands/start/preProcessor.js +0 -4
- package/es/commands/template/commandExecutor.js +0 -17
- package/es/commands/template/config.js +0 -5
- package/es/commands/version/commandExecutor.js +0 -5
- package/es/commands/version/config.js +0 -5
- package/es/commandsRouter.js +0 -58
- package/es/index.js +0 -4
- package/es/logger.js +0 -23
- package/es/schemas/applyValuesToSchema/index.js +0 -25
- package/es/schemas/applyValuesToSchema/isObject.js +0 -3
- package/es/schemas/applyValuesToSchema/isValid.js +0 -7
- package/es/schemas/cliArgsToObject.js +0 -32
- package/es/schemas/defaultConfigValues.js +0 -394
- package/es/schemas/defaultConfigValuesOnly.js +0 -196
- package/es/schemas/deprecatedOptionsHandler.js +0 -60
- package/es/schemas/getNpmVersion.js +0 -13
- package/es/schemas/giveDefaultValue.js +0 -11
- package/es/schemas/npmConfigToObject.js +0 -27
- package/es/schemas/readOptions.js +0 -67
- package/es/schemas/readOptionsForConfigFile.js +0 -28
- package/es/shared/babel/addDefaultPlugins.js +0 -8
- package/es/shared/babel/babelWebConfig.js +0 -43
- package/es/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -21
- package/es/shared/babel/getBabelPlugin.js +0 -36
- package/es/shared/babel/runBabelForJSFile.js +0 -15
- package/es/shared/babel/runBabelForTsFile.js +0 -34
- package/es/shared/bundler/webpack/common/decidePublicPath.js +0 -45
- package/es/shared/bundler/webpack/common/libAlias.js +0 -24
- package/es/shared/bundler/webpack/common/modeUtils.js +0 -24
- package/es/shared/bundler/webpack/common/nameTemplates.js +0 -95
- package/es/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -12
- package/es/shared/bundler/webpack/configCustomLoaders.js +0 -3
- package/es/shared/bundler/webpack/cssLoaders.js +0 -8
- package/es/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +0 -76
- package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +0 -102
- package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +0 -36
- package/es/shared/bundler/webpack/custom_plugins/ChunkHierarchyPlugin.js +0 -65
- package/es/shared/bundler/webpack/custom_plugins/CssCustomOrderPlugin.js +0 -37
- package/es/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +0 -97
- package/es/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +0 -98
- package/es/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +0 -211
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +0 -160
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -66
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +0 -201
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +0 -59
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -82
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -13
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -15
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -72
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -23
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +0 -40
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -59
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -15
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -22
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -35
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -70
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -56
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -6
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -10
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -2
- package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -121
- package/es/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +0 -85
- package/es/shared/bundler/webpack/custom_plugins/InjectChunkGraphPlugin.js +0 -47
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +0 -20
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +0 -11
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -26
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -11
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -34
- package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -11
- package/es/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +0 -79
- package/es/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -0
- package/es/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +0 -185
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -47
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -70
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
- package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -14
- package/es/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -63
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -9
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +0 -63
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +0 -43
- package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +0 -7
- package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -104
- package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -6
- package/es/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +0 -74
- package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +0 -10
- package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +0 -36
- package/es/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +0 -35
- package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +0 -52
- package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +0 -341
- package/es/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +0 -67
- package/es/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -7
- package/es/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +0 -43
- package/es/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +0 -79
- package/es/shared/bundler/webpack/defaultVendorPatternList.js +0 -3
- package/es/shared/bundler/webpack/devtoolConfig.js +0 -6
- package/es/shared/bundler/webpack/entryConfig.js +0 -25
- package/es/shared/bundler/webpack/externals.js +0 -10
- package/es/shared/bundler/webpack/getCSSLoaders.js +0 -17
- package/es/shared/bundler/webpack/getFilenameFromModule.js +0 -15
- package/es/shared/bundler/webpack/jsLoaders.js +0 -16
- package/es/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -4
- package/es/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -10
- package/es/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +0 -45
- package/es/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -11
- package/es/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +0 -23
- package/es/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -13
- package/es/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -71
- package/es/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -56
- package/es/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -11
- package/es/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -40
- package/es/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -116
- package/es/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +0 -5
- package/es/shared/bundler/webpack/loaders/workerLoader.js +0 -121
- package/es/shared/bundler/webpack/optimizationConfig.js +0 -42
- package/es/shared/bundler/webpack/outputConfig.js +0 -35
- package/es/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +0 -30
- package/es/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -27
- package/es/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +0 -17
- package/es/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -16
- package/es/shared/bundler/webpack/pluginConfigs/configChunkHierarchyPlugin.js +0 -10
- package/es/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +0 -50
- package/es/shared/bundler/webpack/pluginConfigs/configCssCustomOrderPlugin.js +0 -8
- package/es/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -12
- package/es/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -67
- package/es/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -37
- package/es/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -43
- package/es/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -52
- package/es/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -17
- package/es/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -29
- package/es/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -8
- package/es/shared/bundler/webpack/pluginConfigs/configInjectChunkGraphPlugin.js +0 -12
- package/es/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -36
- package/es/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -13
- package/es/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +0 -19
- package/es/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -18
- package/es/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +0 -11
- package/es/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -19
- package/es/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +0 -20
- package/es/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +0 -18
- package/es/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -29
- package/es/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -12
- package/es/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +0 -20
- package/es/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +0 -15
- package/es/shared/bundler/webpack/plugins.js +0 -33
- package/es/shared/bundler/webpack/resolvers.js +0 -70
- package/es/shared/bundler/webpack/splitChunksConfig.js +0 -106
- package/es/shared/bundler/webpack/statsConfig.js +0 -23
- package/es/shared/bundler/webpack/tsLoaders.js +0 -16
- package/es/shared/bundler/webpack/utils/index.js +0 -8
- package/es/shared/bundler/webpack/utils/object-manipulation.js +0 -82
- package/es/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -29
- package/es/shared/bundler/webpack/webpackBuild.js +0 -14
- package/es/shared/bundler/webpack/webpackConfig.js +0 -35
- package/es/shared/commands-utils/doBasicRequirementCheck.js +0 -10
- package/es/shared/commands-utils/getCliPath.js +0 -28
- package/es/shared/commands-utils/index.js +0 -3
- package/es/shared/commands-utils/log.js +0 -4
- package/es/shared/commands-utils/readArgsFormCommandLine.js +0 -4
- package/es/shared/commands-utils/readOptionFormCommandLine.js +0 -4
- package/es/shared/commands-utils/spawnSyncIO.js +0 -24
- package/es/shared/constants.js +0 -22
- package/es/shared/fileUtils/copyFile.js +0 -23
- package/es/shared/fileUtils/directoryIterator.js +0 -12
- package/es/shared/fileUtils/watchRun.js +0 -96
- package/es/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +0 -18
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +0 -2
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +0 -58
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +0 -122
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +0 -22
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -11
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +0 -13
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -17
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +0 -32
- package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -28
- package/es/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +0 -125
- package/es/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -82
- package/es/shared/postcss/custom_postcss_plugins/ValueReplacer.js +0 -50
- package/es/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +0 -318
- package/es/shared/postcss/filterPluginsAllowedForSpecficFile.js +0 -41
- package/es/shared/postcss/getAllowedPostCssPlugins.js +0 -20
- package/es/shared/postcss/getSpecificPostCssPlugin.js +0 -38
- package/es/shared/postcss/runPostCssForCssFile.js +0 -25
- package/es/shared/pre_process/runPreProcess.js +0 -47
- package/es/shared/server/configWebpackDevMiddleware.js +0 -26
- package/es/shared/server/corsHandling.js +0 -23
- package/es/shared/server/getIp.js +0 -18
- package/es/shared/server/getServerURL.js +0 -28
- package/es/shared/server/httpsOptions.js +0 -36
- package/es/shared/server/initExpressApp.js +0 -9
- package/es/shared/server/initialHTMLHandling.js +0 -92
- package/es/shared/server/mockApiHandler.js +0 -53
- package/es/shared/server/mockServer.js +0 -34
- package/es/shared/server/serveContextFiles.js +0 -17
- package/es/shared/server/serverBywebpackDevMiddleware.js +0 -21
- package/es/shared/server/startHttpServer.js +0 -18
- package/es/shared/server/startHttpsServer.js +0 -26
- package/es/shared/server/unwanted/addHttp2Server.js +0 -32
- package/es/shared/server/unwanted/configWebpackDevMiddleware.js +0 -35
- package/es/shared/server/unwanted/mockApiSupport.js +0 -11
- package/es/shared/server/unwanted/websocketMockSetup.js +0 -36
- package/es/shared/server/urlConcat.js +0 -35
- package/es/shared/utils/requireLocalOrGlobal.js +0 -57
- package/es/shared/utils/utils.js +0 -0
- package/es/shared/utils/versionPrint.js +0 -9
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
RawSource
|
|
3
|
-
} = require('webpack-sources');
|
|
4
|
-
|
|
5
|
-
class InjectChunkGraphPlugin {
|
|
6
|
-
constructor(resourceHints) {
|
|
7
|
-
this.chunkNames = resourceHints.PreloadChunkNames || [];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
apply(compiler) {
|
|
11
|
-
compiler.hooks.thisCompilation.tap('InjectChunkGraphPlugin', compilation => {
|
|
12
|
-
compilation.hooks.processAssets.tap({
|
|
13
|
-
name: 'InjectChunkGraphPlugin',
|
|
14
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
15
|
-
}, () => {
|
|
16
|
-
const stats = compilation.getStats().toJson({
|
|
17
|
-
all: true
|
|
18
|
-
});
|
|
19
|
-
const chunkGraph = {};
|
|
20
|
-
this.chunkNames.forEach(chunkName => {
|
|
21
|
-
const chunkGroup = stats.namedChunkGroups?.[chunkName];
|
|
22
|
-
|
|
23
|
-
if (!chunkGroup) {
|
|
24
|
-
compilation.warnings.push(new Error(`[InjectChunkGraphPlugin] Chunk group "${chunkName}" not found.`));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
chunkGraph[chunkName] = chunkGroup.chunks;
|
|
29
|
-
}); // Find runtime chunk file
|
|
30
|
-
|
|
31
|
-
const runtimeChunk = stats.chunks.find(chunk => chunk.names?.some(n => n.includes('runtime~main')));
|
|
32
|
-
const runtimeChunkName = runtimeChunk.files[0];
|
|
33
|
-
const originalSource = compilation.assets[runtimeChunkName].source();
|
|
34
|
-
const newSource = originalSource.replace('__PRELOAD_CHUNK_GRAPH__', `${JSON.stringify(chunkGraph)}`); // Update the runtime asset with injected code
|
|
35
|
-
|
|
36
|
-
compilation.updateAsset(runtimeChunkName, new RawSource(newSource));
|
|
37
|
-
|
|
38
|
-
if (runtimeChunkName.includes('smap/')) {
|
|
39
|
-
compilation.updateAsset(runtimeChunkName.replace('smap/', ''), new RawSource(newSource));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = InjectChunkGraphPlugin;
|
package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { removeHashFromFileName } from "./removeHashFromFileName";
|
|
3
|
-
export function addFilesNamesToManifestJson(_ref) {
|
|
4
|
-
let {
|
|
5
|
-
manifestJson,
|
|
6
|
-
option,
|
|
7
|
-
assets,
|
|
8
|
-
hashDigestLength
|
|
9
|
-
} = _ref;
|
|
10
|
-
const json = manifestJson;
|
|
11
|
-
Object.keys(assets).forEach(filename => {
|
|
12
|
-
const fileName = path.parse(filename).base;
|
|
13
|
-
|
|
14
|
-
if (option.test(filename)) {
|
|
15
|
-
const filenameNameWithoutHash = removeHashFromFileName(fileName, hashDigestLength);
|
|
16
|
-
json[filenameNameWithoutHash] = fileName;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return json;
|
|
20
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { removeHashFromFileName } from "./removeHashFromFileName";
|
|
3
|
-
export function createInitialEntriesForManifestJson(initialFileNames, hashLength) {
|
|
4
|
-
const initialEntries = {};
|
|
5
|
-
initialFileNames.forEach(filename => {
|
|
6
|
-
const fileName = path.parse(filename).base;
|
|
7
|
-
const filenameNameWithoutHash = removeHashFromFileName(fileName, hashLength);
|
|
8
|
-
initialEntries[filenameNameWithoutHash] = fileName;
|
|
9
|
-
});
|
|
10
|
-
return initialEntries;
|
|
11
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { findInitialFileNames } from "./findInitialFileNames";
|
|
2
|
-
import { addFilesNamesToManifestJson } from "./addFilesNamesToManifestJson";
|
|
3
|
-
import { createInitialEntriesForManifestJson } from "./createInitialEntries";
|
|
4
|
-
export function createManifestJson(_ref) {
|
|
5
|
-
let {
|
|
6
|
-
option,
|
|
7
|
-
hashDigestLength,
|
|
8
|
-
compilation,
|
|
9
|
-
assets
|
|
10
|
-
} = _ref;
|
|
11
|
-
const manifestJson = {};
|
|
12
|
-
|
|
13
|
-
if (option.needInitialEntries) {
|
|
14
|
-
const initialFileNames = findInitialFileNames(compilation);
|
|
15
|
-
const initialEntries = createInitialEntriesForManifestJson(initialFileNames, hashDigestLength);
|
|
16
|
-
manifestJson.entryFiles = initialEntries;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const outputJson = addFilesNamesToManifestJson({
|
|
20
|
-
manifestJson,
|
|
21
|
-
option,
|
|
22
|
-
assets,
|
|
23
|
-
hashDigestLength
|
|
24
|
-
});
|
|
25
|
-
return outputJson;
|
|
26
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function findInitialFileNames(compilation) {
|
|
2
|
-
const initialEntries = [];
|
|
3
|
-
compilation.entrypoints.forEach(element => {
|
|
4
|
-
element.chunks.forEach(chunk => {
|
|
5
|
-
Array.from(chunk.files).forEach(filename => {
|
|
6
|
-
initialEntries.push(filename);
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
return initialEntries;
|
|
11
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Compilation } from 'webpack';
|
|
2
|
-
import { createManifestJson } from "./createManifestJson";
|
|
3
|
-
const pluginName = 'AddFileToManifestJson';
|
|
4
|
-
export class AddFileToManifestJson {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.options = options;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
apply(compiler) {
|
|
10
|
-
const {
|
|
11
|
-
RawSource
|
|
12
|
-
} = compiler.webpack.sources;
|
|
13
|
-
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
14
|
-
compilation.hooks.processAssets.tap({
|
|
15
|
-
name: pluginName,
|
|
16
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
17
|
-
}, assets => {
|
|
18
|
-
const {
|
|
19
|
-
hashDigestLength
|
|
20
|
-
} = compilation.outputOptions;
|
|
21
|
-
this.options.forEach(option => {
|
|
22
|
-
const manifestJson = createManifestJson({
|
|
23
|
-
option,
|
|
24
|
-
hashDigestLength,
|
|
25
|
-
compilation,
|
|
26
|
-
assets
|
|
27
|
-
});
|
|
28
|
-
compilation.emitAsset(option.outputJsonFileName, new RawSource(JSON.stringify(manifestJson)));
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function removeHashFromFileName(fileName, hashDigestLength) {
|
|
2
|
-
let outputFileName = '';
|
|
3
|
-
fileName.split('.').forEach(iterateValue => {
|
|
4
|
-
if (outputFileName === '') {
|
|
5
|
-
outputFileName += iterateValue;
|
|
6
|
-
} else if (iterateValue.length < hashDigestLength) {
|
|
7
|
-
outputFileName += `.${iterateValue}`;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
return outputFileName;
|
|
11
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import SingleEntryPlugin from "webpack/lib/SingleEntryPlugin.js";
|
|
2
|
-
import { nameTemplates } from "../../common/nameTemplates";
|
|
3
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
4
|
-
const pluginName = 'MurphyInjectorPlugin';
|
|
5
|
-
|
|
6
|
-
class MurphyInjectorPlugin {
|
|
7
|
-
constructor() {
|
|
8
|
-
let entries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
9
|
-
let options = arguments.length > 1 ? arguments[1] : undefined;
|
|
10
|
-
this.entries = entries;
|
|
11
|
-
this.options = options;
|
|
12
|
-
this.jsTemplate = options.cdnMapping.jsTemplate || '{{__JS_CDN__}}';
|
|
13
|
-
this.cdnMapping = options.cdnMapping;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
apply(compiler) {
|
|
17
|
-
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
18
|
-
this.entries.forEach(_ref => {
|
|
19
|
-
let {
|
|
20
|
-
name,
|
|
21
|
-
file
|
|
22
|
-
} = _ref;
|
|
23
|
-
// Create child compiler for this entry
|
|
24
|
-
const childCompiler = compilation.createChildCompiler(`additional-entry ${name}`, {
|
|
25
|
-
filename: nameTemplates('js', this.options),
|
|
26
|
-
// output filename
|
|
27
|
-
chunkFilename: `${name}.[id].js`,
|
|
28
|
-
publicPath: compiler.options.output.publicPath,
|
|
29
|
-
globalObject: "self" // safe for workers too
|
|
30
|
-
|
|
31
|
-
}); // Attach the entry point
|
|
32
|
-
|
|
33
|
-
new SingleEntryPlugin(compiler.context, file, name).apply(childCompiler); // Run the child compiler
|
|
34
|
-
|
|
35
|
-
childCompiler.runAsChild((err, entries, childCompilation) => {
|
|
36
|
-
if (err) {
|
|
37
|
-
compilation.errors.push(err);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (childCompilation.errors && childCompilation.errors.length) {
|
|
42
|
-
compilation.errors.push(...childCompilation.errors);
|
|
43
|
-
} // Files are emitted automatically by child compiler
|
|
44
|
-
// ⚡ Hook HtmlWebpackPlugin and inject this file
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
HtmlWebpackPlugin.getHooks(compilation).alterAssetTags.tapAsync(pluginName, (data, cb) => {
|
|
48
|
-
let fileName = '';
|
|
49
|
-
const childFiles = childCompilation.entrypoints.get(name).getFiles();
|
|
50
|
-
|
|
51
|
-
if (childFiles.length !== 1) {
|
|
52
|
-
compilation.errors.push(new Error(`${pluginName}: Expected exactly 1 child file for entry "${name}", but got ${childFiles.length}.`));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (this.cdnMapping.isCdnEnabled) {
|
|
56
|
-
fileName = `${this.jsTemplate}${childFiles[0]}`;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
;
|
|
60
|
-
data.assetTags.scripts.unshift({
|
|
61
|
-
tagName: "script",
|
|
62
|
-
voidTag: false,
|
|
63
|
-
attributes: {
|
|
64
|
-
src: fileName
|
|
65
|
-
},
|
|
66
|
-
meta: {
|
|
67
|
-
plugin: pluginName
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
cb(null, data);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export default MurphyInjectorPlugin;
|
|
File without changes
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { Template, RuntimeGlobals, RuntimeModule } from 'webpack';
|
|
2
|
-
const pluginName = 'prefetch-preload-chunk-plugin';
|
|
3
|
-
/**
|
|
4
|
-
* NOTE: below functions are useable in webpack 5.79.0 as per day 28 Apr 2023
|
|
5
|
-
* Please checkout for future changes
|
|
6
|
-
* Here List of functions that take chunkId as Argument and return url without publicPath
|
|
7
|
-
* `__webpack_require__.u(chunkId)` - return's JS script urlPath
|
|
8
|
-
* `__webpack_require__.miniCssF(chunkId)` - return's CSS script urlPath
|
|
9
|
-
* `__webpack_require__.miniI18nF(chunkId)` - return's I18N script urlPath
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* if url has .undefined. then chunk or url not valid or that file nt available
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export default class ResourceHintsPlugin {
|
|
16
|
-
constructor(_ref) {
|
|
17
|
-
let {
|
|
18
|
-
publicPath,
|
|
19
|
-
resourceHints
|
|
20
|
-
} = _ref;
|
|
21
|
-
this.resourceHints = resourceHints;
|
|
22
|
-
this.allowPrefetchingMultipleChunks = resourceHints.allowPrefetchingMultipleChunks;
|
|
23
|
-
this.publicPathsTemplateObj = {
|
|
24
|
-
js: publicPath,
|
|
25
|
-
css: publicPath,
|
|
26
|
-
i18n: publicPath
|
|
27
|
-
};
|
|
28
|
-
} // eslint-disable-next-line class-methods-use-this
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
apply(compiler) {
|
|
32
|
-
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
33
|
-
const enabledChunks = new WeakSet();
|
|
34
|
-
|
|
35
|
-
const handler = (entryRuntimeChunk, set) => {
|
|
36
|
-
if (enabledChunks.has(entryRuntimeChunk)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
enabledChunks.add(entryRuntimeChunk);
|
|
41
|
-
set.add(RuntimeGlobals.getFullHash); // set.add(RuntimeGlobals.getChunkCssFilename);
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
publicPathsTemplateObj
|
|
45
|
-
} = this;
|
|
46
|
-
compilation.addRuntimeModule(entryRuntimeChunk, // eslint-disable-next-line no-use-before-define
|
|
47
|
-
new ResourceHintsRuntimePlugin(compiler, {
|
|
48
|
-
chunk: entryRuntimeChunk,
|
|
49
|
-
allowPrefetchingMultipleChunks: this.allowPrefetchingMultipleChunks,
|
|
50
|
-
publicPathsTemplateObj
|
|
51
|
-
}));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.ensureChunkHandlers).tap(pluginName, handler);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
class ResourceHintsRuntimePlugin extends RuntimeModule {
|
|
61
|
-
constructor(compiler, _ref2) {
|
|
62
|
-
let {
|
|
63
|
-
chunk,
|
|
64
|
-
publicPathsTemplateObj,
|
|
65
|
-
allowPrefetchingMultipleChunks
|
|
66
|
-
} = _ref2;
|
|
67
|
-
super('ResourceHintsRuntimePlugin loading', 10);
|
|
68
|
-
this.compiler = compiler;
|
|
69
|
-
this.publicPathsTemplateObj = publicPathsTemplateObj;
|
|
70
|
-
this.allowPrefetchingMultipleChunks = allowPrefetchingMultipleChunks;
|
|
71
|
-
this.chunk = chunk;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
generate() {
|
|
75
|
-
const {
|
|
76
|
-
chunk
|
|
77
|
-
} = this;
|
|
78
|
-
const idNameMap = chunk.getChunkMaps().name;
|
|
79
|
-
const nameIdMap = {};
|
|
80
|
-
let needsMap = this.allowPrefetchingMultipleChunks;
|
|
81
|
-
Object.keys(idNameMap).forEach(key => {
|
|
82
|
-
const value = idNameMap[key];
|
|
83
|
-
nameIdMap[value] = key;
|
|
84
|
-
|
|
85
|
-
if (key !== value) {
|
|
86
|
-
needsMap = true;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
let {
|
|
90
|
-
js: jsPP,
|
|
91
|
-
css: cssPP,
|
|
92
|
-
i18n: i18nPP
|
|
93
|
-
} = this.publicPathsTemplateObj;
|
|
94
|
-
jsPP = jsPP || RuntimeGlobals.publicPath;
|
|
95
|
-
cssPP = cssPP || RuntimeGlobals.publicPath;
|
|
96
|
-
i18nPP = i18nPP || RuntimeGlobals.publicPath;
|
|
97
|
-
/**
|
|
98
|
-
* naming abbr
|
|
99
|
-
* ntc -> nameToChunkIdMap
|
|
100
|
-
* cns -> chunkNames
|
|
101
|
-
* clt -> createLinkTag
|
|
102
|
-
* lpp -> loadAsPreloadOrPrefetch
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
return Template.asString([`const ntc = ${JSON.stringify(needsMap ? nameIdMap : {})};
|
|
106
|
-
const cns = Object.keys(ntc);
|
|
107
|
-
|
|
108
|
-
function clt(href, rel) {
|
|
109
|
-
let link = document.createElement("link");
|
|
110
|
-
link.href = href;
|
|
111
|
-
link.rel = rel;
|
|
112
|
-
__webpack_require__.nc && link.setAttribute("nonce", __webpack_require__.nc)
|
|
113
|
-
if(href.endsWith(".css")) {
|
|
114
|
-
link.as="style";
|
|
115
|
-
} else if (href.endsWith(".js")) {
|
|
116
|
-
link.as="script";
|
|
117
|
-
}
|
|
118
|
-
document.head.appendChild(link);
|
|
119
|
-
}
|
|
120
|
-
function isValidUrl(url) {
|
|
121
|
-
//return !url.includes(".undefined.");
|
|
122
|
-
return url.indexOf(".undefined") === -1;
|
|
123
|
-
}
|
|
124
|
-
function lpp(_chunkId, rel) {
|
|
125
|
-
let chunkId = ${RuntimeGlobals.require}.getChunkId(_chunkId);
|
|
126
|
-
// ${RuntimeGlobals.require}.e(chunkId);
|
|
127
|
-
if(__webpack_require__.O.j(chunkId)) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const jsUrl = ${jsPP} + __webpack_require__.u(chunkId);
|
|
131
|
-
const cssUrl = ${cssPP} + __webpack_require__.miniCssF(chunkId);
|
|
132
|
-
isValidUrl(jsUrl) && clt(jsUrl, rel);
|
|
133
|
-
isValidUrl(cssUrl) && clt(cssUrl, rel);
|
|
134
|
-
if(__webpack_require__.miniI18nF) {
|
|
135
|
-
const i18nUrl = ${i18nPP} + __webpack_require__.miniI18nF(chunkId);
|
|
136
|
-
isValidUrl(i18nUrl) && clt(i18nUrl, rel);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
${RuntimeGlobals.require}.getChunkId = function getChunkId(chunkId) {
|
|
141
|
-
${needsMap ? 'chunkId = ntc[chunkId]||chunkId;' : ''}
|
|
142
|
-
return chunkId;
|
|
143
|
-
}
|
|
144
|
-
${RuntimeGlobals.require}.getChunkIds = function getChunkIds(chunkId) {
|
|
145
|
-
${// eslint-disable-next-line no-nested-ternary
|
|
146
|
-
this.allowPrefetchingMultipleChunks ? `
|
|
147
|
-
const isRegExAsChunkId = chunkId instanceof RegExp;
|
|
148
|
-
if(isRegExAsChunkId) {
|
|
149
|
-
return cns.filter(chunkName => chunkId.test(chunkName)).map(chunkName => ntc[chunkName]);
|
|
150
|
-
}
|
|
151
|
-
return [${RuntimeGlobals.require}.getChunkId(chunkId)];
|
|
152
|
-
` : `return [${RuntimeGlobals.require}.getChunkId(chunkId)];`}
|
|
153
|
-
}
|
|
154
|
-
// Prefetch a chunk (${pluginName})
|
|
155
|
-
${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {
|
|
156
|
-
${`
|
|
157
|
-
let chunkIds = ${RuntimeGlobals.require}.getChunkIds(chunkId);
|
|
158
|
-
chunkIds.forEach(idOfAChunk => {
|
|
159
|
-
${RuntimeGlobals.require}.e(idOfAChunk);
|
|
160
|
-
})`}
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
// Preload a chunk (${pluginName})
|
|
164
|
-
${RuntimeGlobals.require}.plc = function preloadChunk(chunkId) {
|
|
165
|
-
let idOfAChunk = ${RuntimeGlobals.require}.getChunkIds(chunkId)[0];
|
|
166
|
-
lpp(idOfAChunk, "preload");
|
|
167
|
-
}
|
|
168
|
-
` // `// Prefetch a chunk (${pluginName})`,
|
|
169
|
-
// `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
|
|
170
|
-
// Template.indent([
|
|
171
|
-
// `chunkId = ${RuntimeGlobals.require}.getChunkId(chunkId)`,
|
|
172
|
-
// `${RuntimeGlobals.require}.e(chunkId);`
|
|
173
|
-
// ]),
|
|
174
|
-
// '};',
|
|
175
|
-
// `// Preload a chunk (${pluginName})`,
|
|
176
|
-
// `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
|
|
177
|
-
// Template.indent([
|
|
178
|
-
// `chunkId = ${RuntimeGlobals.require}.getChunkId(chunkId)`,
|
|
179
|
-
// `${RuntimeGlobals.require}.e(chunkId);`
|
|
180
|
-
// ]),
|
|
181
|
-
// '};'
|
|
182
|
-
]);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin'; // import { JavascriptModulesPlugin } from 'webpack';
|
|
2
|
-
|
|
3
|
-
import JavascriptModulesPlugin from 'webpack/lib/javascript/JavascriptModulesPlugin';
|
|
4
|
-
import { replaceCssDirTemplateMapper } from "./replaceCssDirTemplate";
|
|
5
|
-
const pluginName = 'OverwriteCssPathForRTL';
|
|
6
|
-
export default class OverwriteCssPathForRTL {
|
|
7
|
-
constructor() {
|
|
8
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
9
|
-
dirVarName: 'document.dir'
|
|
10
|
-
};
|
|
11
|
-
this.dirVarName = options.dirVarName || 'document.dir';
|
|
12
|
-
this.templateLabel = options.templateLabel || '{{--dir}}';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
overwriteCssPathinHTML(compilation) {
|
|
16
|
-
// NOTE: need to reconsider It is not working as expected
|
|
17
|
-
HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, data => {
|
|
18
|
-
const {
|
|
19
|
-
assets
|
|
20
|
-
} = data;
|
|
21
|
-
return { ...data,
|
|
22
|
-
assets: { ...assets,
|
|
23
|
-
css: assets.css && replaceCssDirTemplateMapper(assets.css, this.templateLabel)
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
overwriteCssPathinRequireEnsure(compilation, compiler) {
|
|
30
|
-
const {
|
|
31
|
-
RawSource
|
|
32
|
-
} = compiler.webpack.sources;
|
|
33
|
-
JavascriptModulesPlugin.getCompilationHooks(compilation).renderMain.tap(pluginName, source => {
|
|
34
|
-
const templateText = `"+(${this.dirVarName} === "rtl" ? "rtl": "ltr")+"`;
|
|
35
|
-
const replacedStr = source.source().replace(/\[dir\]/g, templateText);
|
|
36
|
-
return new RawSource(replacedStr);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
apply(compiler) {
|
|
41
|
-
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
42
|
-
this.overwriteCssPathinHTML(compilation);
|
|
43
|
-
this.overwriteCssPathinRequireEnsure(compilation, compiler);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
|
-
// import rtlcss from 'rtlcss';
|
|
3
|
-
import { Compilation } from 'webpack';
|
|
4
|
-
import OverwriteCssPathForRTL from "./OverwriteCssPathForRTL";
|
|
5
|
-
import { separateRtlAndLtr } from "../../../../postcss/custom_postcss_plugins/RTLSplitPlugin";
|
|
6
|
-
import { isCss, isDirRelatedCss } from "../../utils";
|
|
7
|
-
const pluginName = 'RtlCssPlugin';
|
|
8
|
-
export class RtlCssPlugin {
|
|
9
|
-
constructor() {
|
|
10
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {Object} Options
|
|
14
|
-
* @property {String} dirVarName
|
|
15
|
-
* @property {Boolean} sourcemap
|
|
16
|
-
* @property {Object} config
|
|
17
|
-
*/
|
|
18
|
-
this.options = {
|
|
19
|
-
// dirVarName: options.dirVarName || 'document.dir',
|
|
20
|
-
sourcemap: options.sourcemap,
|
|
21
|
-
config: options.config
|
|
22
|
-
};
|
|
23
|
-
this.templateLabel = options.templateLabel || '{{--dir}}';
|
|
24
|
-
this.dirVarName = options.dirVarName || 'document.dir';
|
|
25
|
-
this.rtlSplitOptions = {
|
|
26
|
-
disableMinifySelector: options.disableMinifySelector
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
apply(compiler) {
|
|
31
|
-
const {
|
|
32
|
-
RawSource
|
|
33
|
-
} = compiler.webpack.sources;
|
|
34
|
-
new OverwriteCssPathForRTL({
|
|
35
|
-
templateLabel: this.templateLabel,
|
|
36
|
-
dirVarName: this.dirVarName
|
|
37
|
-
}).apply(compiler); // const { filename, sourcemap, config } = this.options;
|
|
38
|
-
// const { devtool } = compiler.options;
|
|
39
|
-
// const postcssOptions = {
|
|
40
|
-
// map: (sourcemap === undefined && !!devtool) || !!sourcemap
|
|
41
|
-
// };
|
|
42
|
-
|
|
43
|
-
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
44
|
-
// compilation.hooks.shouldGenerateChunkAssets.tap(pluginName, (...args) => {
|
|
45
|
-
// console.log('shouldGenerateChunkAssets', args);
|
|
46
|
-
// });
|
|
47
|
-
compilation.hooks.processAssets.tap({
|
|
48
|
-
name: pluginName,
|
|
49
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_COMPATIBILITY
|
|
50
|
-
}, assets => {
|
|
51
|
-
Object.keys(assets).filter(isCss).filter(isDirRelatedCss).forEach(chunkFilename => {
|
|
52
|
-
const {
|
|
53
|
-
source: asset
|
|
54
|
-
} = compilation.getAsset(chunkFilename);
|
|
55
|
-
const sourceStr = asset.source();
|
|
56
|
-
const {
|
|
57
|
-
ltr,
|
|
58
|
-
rtl
|
|
59
|
-
} = separateRtlAndLtr(sourceStr, this.rtlSplitOptions);
|
|
60
|
-
const ltrFilename = chunkFilename.replace('[dir]', 'ltr');
|
|
61
|
-
const rtlFilename = chunkFilename.replace('[dir]', 'rtl');
|
|
62
|
-
compilation.renameAsset(chunkFilename, ltrFilename);
|
|
63
|
-
compilation.updateAsset(ltrFilename, new RawSource(ltr));
|
|
64
|
-
compilation.emitAsset(rtlFilename, new RawSource(rtl));
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# RTL Split
|
|
2
|
-
|
|
3
|
-
we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
|
|
4
|
-
It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
|
|
5
|
-
Here is problem mostly no one need rtl and ltr related css at the same time in browser,
|
|
6
|
-
we are try to split them by [dir] and load which type of css is needed.
|
|
7
|
-
For this purpose we created RTL Split Plugin
|
|
8
|
-
|
|
9
|
-
# To Try it out rtl-ltr split
|
|
10
|
-
|
|
11
|
-
### how to use this feature?
|
|
12
|
-
|
|
13
|
-
to use this feature use have give the below oprtions
|
|
14
|
-
`package.json`
|
|
15
|
-
|
|
16
|
-
```json
|
|
17
|
-
{
|
|
18
|
-
/// ...some things
|
|
19
|
-
"react-cli": {
|
|
20
|
-
// ...some things
|
|
21
|
-
"css": {
|
|
22
|
-
"plugins": {
|
|
23
|
-
"rtlSplit": {
|
|
24
|
-
"enableRTLSplit": true,
|
|
25
|
-
"templateLabel": "{{--dir}}", // this is for html template css file path dir template
|
|
26
|
-
"disableMinifySelector": false,
|
|
27
|
-
"dirVarName": "document.dir" // this will be used for download css based on dir
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// ...some things
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
```
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function replaceCssDirTemplate(filePath, cssDirTemplate) {
|
|
2
|
-
return filePath // added for efc and service worker handling
|
|
3
|
-
.replaceAll('[dir]', cssDirTemplate).replace('.ltr.css', `.${cssDirTemplate}.css`);
|
|
4
|
-
}
|
|
5
|
-
export function replaceCssDirTemplateMapper(assets, cssDirTemplate) {
|
|
6
|
-
return assets.map(filePath => replaceCssDirTemplate(filePath, cssDirTemplate));
|
|
7
|
-
}
|
|
8
|
-
export function replaceI18nLocalTemplate(filePath, localeTemplate) {
|
|
9
|
-
return filePath // added for efc and service worker handling
|
|
10
|
-
.replaceAll('[locale]', localeTemplate);
|
|
11
|
-
}
|
|
12
|
-
export function replaceI18nLocaleTemplateMapper(assets, localeTemplate) {
|
|
13
|
-
return assets.map(filePath => replaceI18nLocalTemplate(filePath, localeTemplate));
|
|
14
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Compilation } from 'webpack';
|
|
2
|
-
const pluginName = 'RuntimeResourceCleanupPlugin';
|
|
3
|
-
export default class RuntimeResourceCleanup {
|
|
4
|
-
constructor(_ref) {
|
|
5
|
-
let {
|
|
6
|
-
enable: scriptCleanUpEnabled,
|
|
7
|
-
chunkLoadingGlobal,
|
|
8
|
-
...options
|
|
9
|
-
} = _ref;
|
|
10
|
-
this.options = options;
|
|
11
|
-
this.scriptCleanUpEnabled = scriptCleanUpEnabled;
|
|
12
|
-
this.chunkLoadingGlobal = chunkLoadingGlobal;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
apply(compiler) {
|
|
16
|
-
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
17
|
-
compilation.hooks.processAssets.tap({
|
|
18
|
-
name: pluginName,
|
|
19
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
20
|
-
}, assets => {
|
|
21
|
-
const runtimeFiles = Object.keys(assets).filter(assetName => /.+?runtime.*\.js$/.test(assetName));
|
|
22
|
-
const searchString = 'chunkLoadingGlobal.forEach';
|
|
23
|
-
|
|
24
|
-
function generateScriptCleanUpCode(attributes) {
|
|
25
|
-
const [[attributeKey, attributeValue]] = Object.entries(attributes);
|
|
26
|
-
const selectorForGettingResources = `[${attributeKey}="${attributeValue}"]`;
|
|
27
|
-
return `
|
|
28
|
-
document.querySelectorAll('${selectorForGettingResources}').forEach(resource => resource.remove());
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function generateRunTimeObjectCleanupCode() {
|
|
33
|
-
return `
|
|
34
|
-
Object.keys(__webpack_modules__).forEach(moduleKey => __webpack_modules__[moduleKey] = null);
|
|
35
|
-
Object.keys(__webpack_module_cache__).forEach(moduleCacheKey => __webpack_module_cache__[moduleCacheKey] = null);
|
|
36
|
-
__webpack_modules__ = null;
|
|
37
|
-
__webpack_module_cache__ = null;
|
|
38
|
-
Object.keys(__webpack_require__).forEach(staticMethodsKey => __webpack_require__[staticMethodsKey] = null);
|
|
39
|
-
__webpack_require__ = null;
|
|
40
|
-
`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function attachUninstallMethodToChunkGlobal() {
|
|
44
|
-
const {
|
|
45
|
-
chunkLoadingGlobal
|
|
46
|
-
} = this;
|
|
47
|
-
return `self['${chunkLoadingGlobal}'].unInstall = function() {
|
|
48
|
-
${generateRunTimeObjectCleanupCode()};
|
|
49
|
-
${this.scriptCleanUpEnabled ? generateScriptCleanUpCode(this.options.attributes) : ''}
|
|
50
|
-
}`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
runtimeFiles.forEach(runtTimeFile => {
|
|
54
|
-
const runTimeSource = assets[runtTimeFile].source();
|
|
55
|
-
const newRunTimeCode = runTimeSource.replace(searchString, `${attachUninstallMethodToChunkGlobal.call(this)};${searchString}`);
|
|
56
|
-
const newRunTimeResource = new compiler.webpack.sources.RawSource(newRunTimeCode);
|
|
57
|
-
compilation.updateAsset(runtTimeFile, newRunTimeResource);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function hasPrevNodeIgnore(index, prevNode, ignoreComment) {
|
|
2
|
-
return index !== 0 && prevNode && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === ignoreComment;
|
|
3
|
-
}
|
|
4
|
-
export function isAtRule(rule) {
|
|
5
|
-
return rule.parent && rule.parent.type === 'atrule';
|
|
6
|
-
}
|
|
7
|
-
export function isInsideMediaQuery(rule) {
|
|
8
|
-
return !!(isAtRule(rule) && rule.parent.name === 'media');
|
|
9
|
-
}
|