@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.2
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/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
- package/lib/babel/cmjs-plugins-presets.js +1 -8
- package/lib/babel/es-plugins-presets.js +1 -8
- package/lib/common/buildEs.js +1 -0
- package/lib/common/getEntries.js +2 -13
- package/lib/common/getPublicPathConfig.js +0 -6
- package/lib/common/index.js +1 -6
- package/lib/common/runPreProcess.js +6 -15
- package/lib/common/splitChunks.js +2 -21
- package/lib/common/sslcertUpdater.js +7 -18
- package/lib/common/templateParameters.js +0 -2
- package/lib/common/testPattern.js +10 -21
- package/lib/common/valueReplacer.js +1 -16
- package/lib/configs/jest.config.js +1 -10
- package/lib/configs/libAlias.js +8 -14
- package/lib/configs/resolvers.js +4 -14
- package/lib/configs/webpack.component.umd.config.js +1 -6
- package/lib/configs/webpack.css.umd.config.js +6 -14
- package/lib/configs/webpack.dev.config.js +1 -14
- package/lib/configs/webpack.docs.config.js +1 -9
- package/lib/configs/webpack.impact.config.js +1 -8
- package/lib/configs/webpack.prod.config.js +4 -17
- package/lib/constants.js +9 -18
- package/lib/deprecationLogger.js +0 -7
- package/lib/hooks/docsProptypeHook.js +4 -8
- package/lib/jest/commitedFilesResult.js +4 -46
- package/lib/jest/coverageCollector.js +1 -12
- package/lib/jest/jsonMaker.js +0 -6
- package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
- package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
- package/lib/jest/result.js +1 -23
- package/lib/jest/run.js +7 -18
- package/lib/jest/setup.js +8 -60
- package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
- package/lib/loaderUtils/getCSSLoaders.js +10 -22
- package/lib/loaderUtils/getDevJsLoaders.js +4 -13
- package/lib/loaderUtils/index.js +1 -4
- package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
- package/lib/loaderUtils/windowsModification.js +2 -3
- package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
- package/lib/loaders/composeLoader.js +13 -37
- package/lib/loaders/docsLoader.js +1 -12
- package/lib/loaders/docsPropsLoader.js +4 -8
- package/lib/loaders/enhancedReactLiveConverter.js +2 -23
- package/lib/loaders/fileBountryLoader.js +1 -3
- package/lib/loaders/fileLoader.js +12 -23
- package/lib/loaders/markdownLoader.js +14 -19
- package/lib/loaders/reactLiveConvertor.js +5 -15
- package/lib/loaders/scriptInstrumentLoader.js +7 -16
- package/lib/loaders/selectorMappingLoader.js +7 -26
- package/lib/loaders/workerLoader.js +9 -24
- package/lib/logger.js +0 -4
- package/lib/middlewares/HMRMiddleware.js +13 -27
- package/lib/middlewares/SSTMiddleware.js +1 -5
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
- package/lib/pluginUtils/getDevPlugins.js +9 -42
- package/lib/pluginUtils/getDocsPlugins.js +3 -13
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
- package/lib/pluginUtils/getLibraryPlugins.js +2 -8
- package/lib/pluginUtils/getProdPlugins.js +8 -47
- package/lib/pluginUtils/getServerPlugins.js +2 -8
- package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
- package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
- package/lib/pluginUtils/index.js +1 -9
- package/lib/plugins/CdnChangePlugin.js +2 -18
- package/lib/plugins/CleanupStatsPlugin.js +0 -5
- package/lib/plugins/CssOrderControlPlugin.js +3 -6
- package/lib/plugins/CustomAttributePlugin.js +14 -19
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
- package/lib/plugins/EFCPlugin.js +20 -34
- package/lib/plugins/EFCTemplatePlugin.js +19 -30
- package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
- package/lib/plugins/EventsHandlingPlugin.js +2 -4
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
- package/lib/plugins/I18nSplitPlugin/index.js +13 -24
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
- package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
- package/lib/plugins/ManifestPlugin.js +1 -18
- package/lib/plugins/MinifyPlugin.js +1 -10
- package/lib/plugins/ModuleStatsPlugin.js +1 -24
- package/lib/plugins/OptimizeJSPlugin.js +2 -10
- package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
- package/lib/plugins/PublicPathChangePlugin.js +6 -39
- package/lib/plugins/ReportGeneratePlugin.js +5 -32
- package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
- package/lib/plugins/ResourceHintsPlugin.js +4 -13
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
- package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
- package/lib/plugins/SelectorPlugin.js +6 -32
- package/lib/plugins/ServiceWorkerPlugin.js +5 -22
- package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
- package/lib/plugins/SourceMapHookPlugin.js +2 -12
- package/lib/plugins/StatsPlugin.js +0 -14
- package/lib/plugins/TPHashMappingPlugin.js +3 -18
- package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
- package/lib/plugins/VariableConversionCollector.js +15 -42
- package/lib/plugins/index.js +1 -20
- package/lib/plugins/libraryImpactPlugin.js +1 -33
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
- package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
- package/lib/plugins/utils/classHandling.js +0 -6
- package/lib/plugins/utils/fileHandling.js +6 -15
- package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
- package/lib/plugins/variableConvertorUtils.js +14 -29
- package/lib/plugins/webpackwatchrunplugin.js +0 -5
- package/lib/postcss-plugins/EmptyPlugin.js +3 -4
- package/lib/postcss-plugins/ExcludePlugin.js +1 -5
- package/lib/postcss-plugins/IncludePlugin.js +1 -5
- package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
- package/lib/postcss-plugins/SelectorReplace.js +1 -16
- package/lib/postcss-plugins/ValueReplacer.js +7 -6
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
- package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
- package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
- package/lib/schemas/index.js +3 -9
- package/lib/servers/clusterHubServer.js +1 -11
- package/lib/servers/devBuild.js +14 -26
- package/lib/servers/docsServer.js +1 -3
- package/lib/servers/docsServerCore.js +1 -22
- package/lib/servers/getCliPath.js +0 -9
- package/lib/servers/helpServer.js +1 -6
- package/lib/servers/httpsOptions.js +2 -8
- package/lib/servers/impactServer.js +3 -35
- package/lib/servers/mockserver.js +1 -10
- package/lib/servers/nowatchserver.js +12 -37
- package/lib/servers/requireLocalOrGlobal.js +6 -17
- package/lib/servers/scrServer.js +14 -21
- package/lib/servers/server.js +6 -36
- package/lib/servers/ssServer.js +1 -17
- package/lib/templates/CoverageScriptTemplate.js +0 -14
- package/lib/templates/WMSTemplate.js +7 -13
- package/lib/templates/linterConstant.js +2 -4
- package/lib/utils/babelPresets.js +3 -7
- package/lib/utils/clean.js +3 -9
- package/lib/utils/copy.js +1 -7
- package/lib/utils/copyTimezones.js +1 -9
- package/lib/utils/createEventStream.js +1 -6
- package/lib/utils/cssClassNameGenerate.js +10 -30
- package/lib/utils/cssURLReplacer.js +1 -22
- package/lib/utils/dependencyPostPublish.js +1 -10
- package/lib/utils/deprecationSupport.js +7 -32
- package/lib/utils/fileUtils.js +1 -28
- package/lib/utils/folderIterator.js +2 -13
- package/lib/utils/getComponents.js +0 -21
- package/lib/utils/getCurrentBranch.js +0 -5
- package/lib/utils/getDependenciesImpactList.js +1 -22
- package/lib/utils/getFileType.js +2 -10
- package/lib/utils/getHash.js +1 -8
- package/lib/utils/getIp.js +0 -2
- package/lib/utils/getOptions.js +16 -53
- package/lib/utils/getServerURL.js +1 -10
- package/lib/utils/index.js +4 -51
- package/lib/utils/init.js +0 -1
- package/lib/utils/initPreCommitHook.js +7 -30
- package/lib/utils/jsonHelper.js +3 -22
- package/lib/utils/libraryImpactConfig.js +2 -5
- package/lib/utils/lint/addScripts.js +2 -5
- package/lib/utils/lint/checkExistingConfig.js +3 -12
- package/lib/utils/lint/copyConfigs.js +0 -3
- package/lib/utils/lint/index.js +0 -9
- package/lib/utils/lint/lintScripts.js +0 -1
- package/lib/utils/lint/lintSetup.js +3 -4
- package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
- package/lib/utils/lint/question.js +0 -7
- package/lib/utils/lintReporter.js +0 -20
- package/lib/utils/log.js +0 -1
- package/lib/utils/mailSender.js +1 -8
- package/lib/utils/object-manipulation.js +1 -17
- package/lib/utils/pullOrigin.js +0 -4
- package/lib/utils/reinstallDependencies.js +1 -29
- package/lib/utils/removeAttributes.js +1 -8
- package/lib/utils/repoClone.js +3 -28
- package/lib/utils/request.js +0 -12
- package/lib/utils/rtl.js +5 -17
- package/lib/utils/selectorReplacer.js +10 -16
- package/lib/utils/setEnvVariables.js +0 -2
- package/lib/utils/ssTestHack.js +1 -11
- package/lib/utils/switchBranch.js +0 -5
- package/lib/utils/typeCheck.js +0 -1
- package/lib/utils/urlConcat.js +0 -4
- package/lib/utils/useExitCleanup.js +9 -10
- package/lib/utils/variableConverter.js +22 -31
- package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
- package/package.json +1 -1
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _utils = require("./utils");
|
9
|
-
|
10
|
-
|
8
|
+
const pluginName = 'I18nDebugPlugin';
|
9
|
+
// this plugin only for debug related purpose
|
11
10
|
|
12
11
|
class I18nDebugPlugin {
|
13
12
|
constructor(jsResourceI18nKeys) {
|
14
13
|
this.jsResourceI18nKeys = jsResourceI18nKeys;
|
15
14
|
this.warnings = [];
|
16
15
|
}
|
17
|
-
|
18
16
|
apply(compiler) {
|
19
17
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation, compilationParams) => {
|
20
18
|
// TEMP : only for debugging purpose
|
@@ -25,20 +23,19 @@ class I18nDebugPlugin {
|
|
25
23
|
if (!this.compilationParams || this.compilationParams.normalModuleFactory === factory) {
|
26
24
|
return;
|
27
25
|
}
|
28
|
-
|
29
26
|
const handler = parser => {
|
30
27
|
parser.hooks.program.tap(pluginName, (ast, commmets) => {
|
31
28
|
const {
|
32
29
|
module
|
33
|
-
} = parser.state;
|
34
|
-
|
30
|
+
} = parser.state;
|
31
|
+
//
|
35
32
|
if (!(module && /\.jsx?$/.test(module.resource))) {
|
36
33
|
return;
|
37
|
-
}
|
38
|
-
|
39
|
-
|
34
|
+
}
|
35
|
+
// i18n grep proper contract regex
|
40
36
|
let i18nKeys = (0, _utils.collectI18nKeysfromAST)(ast, this.jsResourceI18nKeys);
|
41
|
-
i18nKeys = i18nKeys.concat(
|
37
|
+
i18nKeys = i18nKeys.concat(
|
38
|
+
// i18n grep proper contract regex
|
42
39
|
(0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
|
43
40
|
i18nKeys.length && this.warnings.push({
|
44
41
|
message: 'skiped i18n keys',
|
@@ -48,12 +45,10 @@ class I18nDebugPlugin {
|
|
48
45
|
});
|
49
46
|
});
|
50
47
|
};
|
51
|
-
|
52
48
|
factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
|
53
|
-
factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
|
49
|
+
factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
|
50
|
+
// factory.hooks.parser.for('javascript/esm').tap(pluginName, handler);
|
54
51
|
});
|
55
52
|
}
|
56
|
-
|
57
53
|
}
|
58
|
-
|
59
54
|
exports.default = I18nDebugPlugin;
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.I18nDependencyTemplate = exports.I18nDependency = void 0;
|
7
|
-
|
8
7
|
var _webpack = require("webpack");
|
9
|
-
|
10
8
|
// const webpack = require('webpack');
|
9
|
+
|
11
10
|
class I18nDependency extends _webpack.Dependency {
|
12
11
|
constructor({
|
13
12
|
identifier,
|
@@ -19,26 +18,21 @@ class I18nDependency extends _webpack.Dependency {
|
|
19
18
|
this.i18nKeys = i18nKeys;
|
20
19
|
this.context = context;
|
21
20
|
}
|
22
|
-
|
23
21
|
getResourceIdentifier() {
|
24
22
|
return `i18n-module-${this.identifier}-${this.identifierIndex}`;
|
25
23
|
}
|
26
|
-
|
27
24
|
}
|
28
|
-
|
29
25
|
exports.I18nDependency = I18nDependency;
|
30
|
-
|
31
26
|
class I18nDependencyTemplate {
|
32
27
|
//eslint-disable-next-line no-empty-function
|
33
|
-
apply() {}
|
28
|
+
apply() {}
|
29
|
+
// apply(dep, source) {
|
34
30
|
// if (typeof dep.range === "number") {
|
35
31
|
// source.insert(0, `/* comment by I18nSplitPlugin , i18n keys = ${JSON.stringify(dep.i18nKeys)} */`);
|
36
32
|
// return;
|
37
33
|
// }
|
34
|
+
|
38
35
|
// source.replace(dep.range[0], dep.range[1] - 1, dep.expression);
|
39
36
|
// }
|
40
|
-
|
41
|
-
|
42
37
|
}
|
43
|
-
|
44
38
|
exports.I18nDependencyTemplate = I18nDependencyTemplate;
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _webpack = require("webpack");
|
9
|
-
|
10
8
|
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nKeysIdentifer"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
/**
|
15
11
|
* this plugin for the download i18n files
|
16
12
|
* So, if need to downoad i18n in browser this plugin handle that
|
@@ -29,9 +25,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
29
25
|
* some thing missing in this definetion
|
30
26
|
*
|
31
27
|
*/
|
28
|
+
|
32
29
|
const pluginName = 'DownloadLogicOfI18n';
|
33
30
|
const MODULE_TYPE = 'json/i18n';
|
34
|
-
|
35
31
|
class I18nDownlodLogic {
|
36
32
|
constructor({
|
37
33
|
filenameTemplate,
|
@@ -47,7 +43,6 @@ class I18nDownlodLogic {
|
|
47
43
|
};
|
48
44
|
this.finalChunkIds = new Map();
|
49
45
|
}
|
50
|
-
|
51
46
|
captureChunkIds(compilation) {
|
52
47
|
this.finalChunkIds.clear();
|
53
48
|
compilation.chunks.forEach(chunk => {
|
@@ -57,54 +52,48 @@ class I18nDownlodLogic {
|
|
57
52
|
});
|
58
53
|
});
|
59
54
|
}
|
60
|
-
|
61
55
|
getI18nChunkObject(mainChunk) {
|
62
56
|
const obj = {};
|
63
|
-
|
64
57
|
for (const chunk of mainChunk.getAllAsyncChunks()) {
|
65
58
|
const finalChunkId = chunk.id;
|
66
|
-
|
67
59
|
if (_I18nKeysIdentifer.default.isChunkHasI18n(chunk)) {
|
68
60
|
// Store using the final chunk ID
|
69
|
-
obj[finalChunkId] = 1;
|
61
|
+
obj[finalChunkId] = 1;
|
70
62
|
|
63
|
+
// Also keep track of which chunks have i18n content
|
71
64
|
this.finalChunkIds.set(finalChunkId, {
|
72
65
|
original: chunk.id,
|
73
66
|
name: chunk.name || null
|
74
67
|
});
|
75
68
|
}
|
76
69
|
}
|
77
|
-
|
78
70
|
return obj;
|
79
71
|
}
|
80
|
-
|
81
72
|
addDownloadLogicOfI18nInMainTemplate(mainTemplate) {
|
82
73
|
// Extend localVars to create a container for tracking loaded i18n chunks.
|
83
74
|
mainTemplate.hooks.localVars.tap(pluginName, (source, mainChunk) => {
|
84
75
|
const chunkMap = this.getI18nChunkObject(mainChunk);
|
85
|
-
|
86
76
|
if (!Object.keys(chunkMap).length) {
|
87
77
|
return source;
|
88
78
|
}
|
89
|
-
|
90
79
|
return _webpack.Template.asString([source, '', '// Object to store loaded I18N chunks', '// Using final chunk IDs from webpack', 'var installedI18nChunks = {', _webpack.Template.indent(mainChunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};']);
|
91
|
-
});
|
92
|
-
// we also download its associated i18n file (if available).
|
80
|
+
});
|
93
81
|
|
82
|
+
// Extend requireEnsure so that whenever a JS chunk is requested,
|
83
|
+
// we also download its associated i18n file (if available).
|
94
84
|
mainTemplate.hooks.requireEnsure.tap(pluginName, (source, mainChunk, hash) => {
|
95
85
|
const chunkMap = this.getI18nChunkObject(mainChunk);
|
96
|
-
|
97
86
|
if (!Object.keys(chunkMap).length) {
|
98
87
|
return source;
|
99
88
|
}
|
100
|
-
|
101
89
|
const {
|
102
90
|
crossOriginLoading
|
103
91
|
} = mainTemplate.outputOptions;
|
104
92
|
const {
|
105
93
|
localeVarName = 'document.documentElement.lang'
|
106
|
-
} = this.options;
|
94
|
+
} = this.options;
|
107
95
|
|
96
|
+
// Use the provided publicPath or fallback to the one provided by Webpack.
|
108
97
|
const publicPath = this.publicPath ? JSON.stringify(this.publicPath) : `${mainTemplate.requireFn}.p`;
|
109
98
|
return _webpack.Template.asString([source, `
|
110
99
|
(function() {
|
@@ -178,20 +167,20 @@ class I18nDownlodLogic {
|
|
178
167
|
`]);
|
179
168
|
});
|
180
169
|
}
|
170
|
+
|
181
171
|
/**
|
182
172
|
* Applies the plugin by tapping into the appropriate Webpack hooks.
|
183
173
|
* Now captures final chunk IDs after compilation is complete.
|
184
174
|
*
|
185
175
|
* @param {Compiler} compiler - The Webpack compiler instance.
|
186
176
|
*/
|
187
|
-
|
188
|
-
|
189
177
|
apply(compiler) {
|
190
178
|
// First capture final chunk IDs after compilation
|
191
179
|
compiler.hooks.afterCompile.tap(pluginName, compilation => {
|
192
180
|
this.captureChunkIds(compilation);
|
193
|
-
});
|
181
|
+
});
|
194
182
|
|
183
|
+
// Then inject download logic in thisCompilation
|
195
184
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
196
185
|
// console.log(`${pluginName}: Adding download logic with final chunk IDs`);
|
197
186
|
const {
|
@@ -200,7 +189,5 @@ class I18nDownlodLogic {
|
|
200
189
|
this.addDownloadLogicOfI18nInMainTemplate(mainTemplate);
|
201
190
|
});
|
202
191
|
}
|
203
|
-
|
204
192
|
}
|
205
|
-
|
206
193
|
exports.default = I18nDownlodLogic;
|
@@ -4,30 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _webpackSources = require("webpack-sources");
|
9
|
-
|
10
8
|
var _utils = require("./utils");
|
11
|
-
|
12
9
|
var _getI18nKeysFormModules = _interopRequireDefault(require("./utils/getI18nKeysFormModules"));
|
13
|
-
|
14
10
|
var _createRegularManifest = require("./utils/createRegularManifest");
|
15
|
-
|
16
11
|
var _createMetaManifest = require("./utils/createMetaManifest");
|
17
|
-
|
18
12
|
var _applyMetaManifest = require("./utils/applyMetaManifest");
|
19
|
-
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
-
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
22
14
|
/**
|
23
15
|
* this plugin was creating the chunk specific i18n chunk's.
|
24
16
|
*/
|
25
|
-
|
17
|
+
|
26
18
|
const pluginName = 'I18nFilesEmitter';
|
27
19
|
const MODULE_TYPE = 'json/i18n';
|
28
|
-
|
29
20
|
const i18ntype = locale => `${MODULE_TYPE}/${locale}`;
|
30
|
-
|
31
21
|
class I18nFilesEmitter {
|
32
22
|
constructor({
|
33
23
|
allI18nObject,
|
@@ -37,8 +27,7 @@ class I18nFilesEmitter {
|
|
37
27
|
jsonpFunc,
|
38
28
|
i18nMetaManifestFileName,
|
39
29
|
entryPointNames = ['main'],
|
40
|
-
masterChunkFileName = 'master.i18n.js'
|
41
|
-
publicPath
|
30
|
+
masterChunkFileName = 'master.i18n.js'
|
42
31
|
}) {
|
43
32
|
this.locales = locales;
|
44
33
|
this.allI18nObject = allI18nObject;
|
@@ -46,7 +35,7 @@ class I18nFilesEmitter {
|
|
46
35
|
this.jsonpFunc = jsonpFunc;
|
47
36
|
this.prevHashes = {};
|
48
37
|
this.i18nManifestFileName = i18nManifestFileName;
|
49
|
-
this.i18nMetaManifestFileName = i18nMetaManifestFileName || 'metaManifest.json';
|
38
|
+
this.i18nMetaManifestFileName = i18nMetaManifestFileName || 'i18n-chunk/metaManifest.json';
|
50
39
|
this.regularManifest = {};
|
51
40
|
this.detailedManifest = {};
|
52
41
|
this.entryPointNames = Array.isArray(entryPointNames) ? entryPointNames : [entryPointNames];
|
@@ -59,16 +48,10 @@ class I18nFilesEmitter {
|
|
59
48
|
this.movedKeys = new Set();
|
60
49
|
this.entryPointKeys = new Set();
|
61
50
|
this.combinedChunks = {};
|
62
|
-
this.
|
63
|
-
|
64
|
-
this.moduleIdMap = new Map(); // Map to track which modules belong to which chunks
|
65
|
-
|
66
|
-
this.moduleToChunks = new Map(); // Store original resource paths for stable identification
|
67
|
-
|
51
|
+
this.moduleIdMap = new Map();
|
52
|
+
this.moduleToChunks = new Map();
|
68
53
|
this.resourceToModule = new Map();
|
69
|
-
console.log(`I18nFilesEmitter initialized with publicPath: "${this.publicPath}"`);
|
70
54
|
}
|
71
|
-
|
72
55
|
emitAsset(compilation, filename, source, info) {
|
73
56
|
if (!compilation.emitAsset) {
|
74
57
|
compilation.assets[filename] = source;
|
@@ -76,7 +59,6 @@ class I18nFilesEmitter {
|
|
76
59
|
compilation.emitAsset(filename, source, info);
|
77
60
|
}
|
78
61
|
}
|
79
|
-
|
80
62
|
getI18nObjectByLocale(i18nKeys, locale) {
|
81
63
|
const data = {};
|
82
64
|
i18nKeys.forEach(key => {
|
@@ -86,12 +68,10 @@ class I18nFilesEmitter {
|
|
86
68
|
});
|
87
69
|
return data;
|
88
70
|
}
|
89
|
-
|
90
71
|
getTemplateString(i18nKeys, locale) {
|
91
72
|
const i18nObject = this.getI18nObjectByLocale(i18nKeys, locale);
|
92
73
|
return `${this.jsonpFunc}(${(0, _utils.jsonToString)(i18nObject)});`;
|
93
74
|
}
|
94
|
-
|
95
75
|
renderI18nLocaleChunk(chunk, locale, i18nKeys) {
|
96
76
|
const filenameTemplate = this.filenameTemplate.replace(/\[locale\]/g, locale);
|
97
77
|
const pathOptions = {
|
@@ -105,42 +85,38 @@ class I18nFilesEmitter {
|
|
105
85
|
identifier: `${pluginName}.${chunk.id}.${locale}`,
|
106
86
|
hash: chunk.contentHash[i18ntype(locale)]
|
107
87
|
};
|
108
|
-
}
|
109
|
-
|
110
|
-
|
88
|
+
}
|
111
89
|
captureModuleIds(compilation) {
|
112
90
|
console.log('Capturing final module IDs from compilation...');
|
113
91
|
this.moduleIdMap.clear();
|
114
92
|
this.resourceToModule.clear();
|
115
|
-
this.moduleToChunks.clear();
|
93
|
+
this.moduleToChunks.clear();
|
116
94
|
|
95
|
+
// Process all modules to build our mapping
|
117
96
|
compilation.modules.forEach(module => {
|
118
97
|
// Skip modules without resources
|
119
98
|
if (!module.resource) return;
|
120
99
|
const originalId = module.resource;
|
121
|
-
const finalId = module.id;
|
100
|
+
const finalId = module.id;
|
122
101
|
|
123
|
-
|
124
|
-
|
125
|
-
|
102
|
+
// Map resource path to final module ID
|
103
|
+
this.moduleIdMap.set(originalId, finalId);
|
104
|
+
// Map resource path to module object
|
105
|
+
this.resourceToModule.set(originalId, module);
|
126
106
|
|
107
|
+
// Build chunk membership for each module
|
127
108
|
const chunkIds = Array.from(module.chunksIterable || []).map(chunk => chunk.id).filter(Boolean);
|
128
|
-
|
129
109
|
if (chunkIds.length > 0) {
|
130
110
|
this.moduleToChunks.set(originalId, chunkIds);
|
131
111
|
}
|
132
112
|
});
|
133
|
-
console.log(`Captured ${this.moduleIdMap.size} module ID mappings`);
|
134
|
-
} // Modified to use stable resource identifiers
|
135
|
-
|
136
113
|
|
114
|
+
// console.log(`Captured ${this.moduleIdMap.size} module ID mappings`);
|
115
|
+
}
|
137
116
|
gatherModuleDetails(chunk, i18nKeys) {
|
138
|
-
if (!i18nKeys.length) return;
|
139
|
-
|
140
|
-
const stableModuleIds = Array.from(chunk.modulesIterable).map(module => module.resource).filter(Boolean); // If no stable IDs found, fallback to chunk ID
|
141
|
-
|
117
|
+
if (!i18nKeys.length) return;
|
118
|
+
const stableModuleIds = Array.from(chunk.modulesIterable).map(module => module.resource).filter(Boolean);
|
142
119
|
const moduleKey = stableModuleIds.length ? stableModuleIds[0] : `chunk_${chunk.id}`;
|
143
|
-
|
144
120
|
if (!this.detailedManifest[moduleKey]) {
|
145
121
|
this.detailedManifest[moduleKey] = {
|
146
122
|
chunkId: chunk.id,
|
@@ -148,12 +124,10 @@ class I18nFilesEmitter {
|
|
148
124
|
keysUsed: new Set()
|
149
125
|
};
|
150
126
|
}
|
151
|
-
|
152
127
|
i18nKeys.forEach(key => {
|
153
128
|
this.detailedManifest[moduleKey].keysUsed.add(key);
|
154
129
|
});
|
155
130
|
}
|
156
|
-
|
157
131
|
emitI18nFilesForChunk(chunk, compilation) {
|
158
132
|
const i18nKeys = (0, _getI18nKeysFormModules.default)(chunk.modulesIterable);
|
159
133
|
const manifestForChunk = {
|
@@ -161,20 +135,15 @@ class I18nFilesEmitter {
|
|
161
135
|
hasI18n: false,
|
162
136
|
hasChanges: false
|
163
137
|
};
|
164
|
-
|
165
138
|
if (!i18nKeys.length) {
|
166
139
|
return manifestForChunk;
|
167
140
|
}
|
168
|
-
|
169
141
|
this.gatherModuleDetails(chunk, i18nKeys);
|
170
|
-
manifestForChunk.hasI18n = true;
|
171
|
-
|
172
|
-
const isEntryPoint = this.isPartOfEntryPoint(chunk, compilation); // If it's an entry point, add its keys to our tracking set
|
173
|
-
|
142
|
+
manifestForChunk.hasI18n = true;
|
143
|
+
const isEntryPoint = this.isPartOfEntryPoint(chunk, compilation);
|
174
144
|
if (isEntryPoint) {
|
175
145
|
i18nKeys.forEach(key => this.entryPointKeys.add(key));
|
176
146
|
}
|
177
|
-
|
178
147
|
this.locales.forEach(locale => {
|
179
148
|
const result = this.renderI18nLocaleChunk(chunk, locale, i18nKeys);
|
180
149
|
const {
|
@@ -186,26 +155,20 @@ class I18nFilesEmitter {
|
|
186
155
|
} = result;
|
187
156
|
const filePath = compilation.getPath(filenameTemplate, pathOptions);
|
188
157
|
manifestForChunk.assets[locale] = filePath;
|
189
|
-
|
190
158
|
if (this.prevHashes[identifier] === hash) {
|
191
159
|
return;
|
192
160
|
}
|
193
|
-
|
194
161
|
manifestForChunk.hasChanges = true;
|
195
|
-
this.prevHashes[identifier] = hash;
|
196
|
-
|
197
|
-
const renderedContent = render().source(); // Emit the asset
|
198
|
-
|
162
|
+
this.prevHashes[identifier] = hash;
|
163
|
+
const renderedContent = render().source();
|
199
164
|
this.emitAsset(compilation, filePath, new _webpackSources.RawSource(renderedContent), {
|
200
165
|
locale,
|
201
166
|
chunkId: chunk.id,
|
202
167
|
chunkName: chunk.name
|
203
|
-
});
|
204
|
-
|
168
|
+
});
|
205
169
|
if (!this.combinedChunks[locale]) {
|
206
170
|
this.combinedChunks[locale] = [];
|
207
171
|
}
|
208
|
-
|
209
172
|
this.combinedChunks[locale].push({
|
210
173
|
path: filePath,
|
211
174
|
content: renderedContent,
|
@@ -214,36 +177,27 @@ class I18nFilesEmitter {
|
|
214
177
|
});
|
215
178
|
});
|
216
179
|
return manifestForChunk;
|
217
|
-
}
|
218
|
-
|
219
|
-
|
180
|
+
}
|
220
181
|
isPartOfEntryPoint(chunk, compilation) {
|
221
182
|
let isEntryChunk = false;
|
222
183
|
this.entryPointNames.forEach(entryName => {
|
223
184
|
const entryPoint = compilation.entrypoints.get(entryName);
|
224
|
-
|
225
185
|
if (entryPoint && entryPoint.chunks.includes(chunk)) {
|
226
186
|
isEntryChunk = true;
|
227
187
|
}
|
228
188
|
});
|
229
189
|
return isEntryChunk;
|
230
|
-
}
|
231
|
-
|
232
|
-
|
190
|
+
}
|
233
191
|
createMetaManifestWithFinalIds(compilation) {
|
234
|
-
console.log('Creating meta manifest with final module IDs...');
|
235
|
-
|
192
|
+
console.log('Creating meta manifest with final module IDs...');
|
236
193
|
const finalMetaManifest = {
|
237
194
|
modules: {},
|
238
195
|
masterKeys: []
|
239
|
-
};
|
240
|
-
|
196
|
+
};
|
241
197
|
for (const [resourcePath, moduleData] of Object.entries(this.detailedManifest)) {
|
242
|
-
// Get the final module ID if available
|
243
198
|
const finalId = this.moduleIdMap.get(resourcePath) || resourcePath;
|
244
199
|
const chunkName = moduleData.chunkName || `chunk_${finalId}`;
|
245
|
-
const keysArray = Array.isArray(moduleData.keysUsed) ? moduleData.keysUsed : Array.from(moduleData.keysUsed);
|
246
|
-
|
200
|
+
const keysArray = Array.isArray(moduleData.keysUsed) ? moduleData.keysUsed : Array.from(moduleData.keysUsed);
|
247
201
|
if (keysArray.length > 0) {
|
248
202
|
finalMetaManifest.modules[chunkName] = {
|
249
203
|
id: moduleData.chunkId,
|
@@ -252,61 +206,48 @@ class I18nFilesEmitter {
|
|
252
206
|
keys: keysArray
|
253
207
|
};
|
254
208
|
}
|
255
|
-
}
|
256
|
-
|
257
|
-
|
209
|
+
}
|
258
210
|
this.generatedMetaManifest = finalMetaManifest;
|
259
211
|
console.log(`Created meta manifest with ${Object.keys(finalMetaManifest.modules).length} modules`);
|
260
|
-
}
|
261
|
-
|
262
|
-
|
212
|
+
}
|
263
213
|
compareWithRemoteManifest(compilation) {
|
264
|
-
// Use the imported applyMetaManifest function with our updated module ID maps
|
265
214
|
(0, _applyMetaManifest.applyMetaManifest)(compilation, this);
|
266
|
-
}
|
267
|
-
|
268
|
-
|
215
|
+
}
|
269
216
|
emitMasterChunks(compilation) {
|
270
|
-
// Combine all the keys we need in the master chunk
|
271
217
|
const combinedKeys = new Set([...this.extraKeys, ...this.movedKeys, ...(this.generatedMetaManifest.masterKeys || [])]);
|
272
|
-
console.log(`Extra and moved keys to add to master chunk: ${combinedKeys.size}`);
|
273
|
-
console.log(`Entry point keys: ${this.entryPointKeys.size}`); // Add entry point keys to the master keys in meta manifest
|
274
218
|
|
219
|
+
// console.log(`Extra and moved keys to add to master chunk: ${combinedKeys.size}`);
|
220
|
+
// console.log(`Entry point keys: ${this.entryPointKeys.size}`);
|
221
|
+
|
222
|
+
// Add entry point keys to the master keys in meta manifest
|
275
223
|
if (this.generatedMetaManifest) {
|
276
224
|
this.generatedMetaManifest.masterKeys = [...this.generatedMetaManifest.masterKeys, ...Array.from(this.entryPointKeys)];
|
277
|
-
}
|
278
|
-
|
225
|
+
}
|
279
226
|
|
227
|
+
// Create a master object that contains all needed keys
|
280
228
|
const allMasterKeys = new Set([...combinedKeys, ...this.entryPointKeys]);
|
281
|
-
|
229
|
+
|
230
|
+
// console.log(`Creating master chunks with ${allMasterKeys.size} total keys`);
|
282
231
|
|
283
232
|
for (const locale of this.locales) {
|
284
233
|
try {
|
285
|
-
// console.log(`\n========== Processing master chunk for locale: ${locale} ==========`);
|
286
|
-
// Create the master i18n object with all required keys
|
287
234
|
const masterI18nObject = this.getI18nObjectByLocale([...allMasterKeys], locale);
|
288
|
-
console.log(`Master i18n object has ${Object.keys(masterI18nObject).length} keys`);
|
289
|
-
|
235
|
+
console.log(`Master i18n object has ${Object.keys(masterI18nObject).length} keys`);
|
290
236
|
const finalContent = `${this.jsonpFunc}(${(0, _utils.jsonToString)(masterI18nObject)});`;
|
291
|
-
const outputPath = `i18n-chunk/${locale}/${this.masterChunkFileName}`;
|
292
|
-
|
237
|
+
const outputPath = `i18n-chunk/${locale}/${this.masterChunkFileName}`;
|
293
238
|
this.emitAsset(compilation, outputPath, new _webpackSources.RawSource(finalContent), {
|
294
239
|
locale,
|
295
240
|
chunkName: 'master',
|
296
241
|
desc: 'Combined master i18n chunk'
|
297
|
-
});
|
298
|
-
|
242
|
+
});
|
299
243
|
if (!this.regularManifest.master) {
|
300
244
|
this.regularManifest.master = {};
|
301
245
|
}
|
302
|
-
|
303
|
-
this.regularManifest.master[locale] = outputPath; // console.log(`Emitted master chunk for locale ${locale}: ${outputPath} (${Object.keys(masterI18nObject).length} total keys)`);
|
246
|
+
this.regularManifest.master[locale] = outputPath;
|
304
247
|
} catch (error) {
|
305
|
-
console.error(`ERROR processing master chunk for locale ${locale}:`, error.message);
|
306
|
-
|
248
|
+
console.error(`ERROR processing master chunk for locale ${locale}:`, error.message);
|
307
249
|
try {
|
308
|
-
console.log(`Attempting to emit a fallback master chunk for locale ${locale}`);
|
309
|
-
|
250
|
+
console.log(`Attempting to emit a fallback master chunk for locale ${locale}`);
|
310
251
|
const fallbackI18nObject = this.getI18nObjectByLocale([...combinedKeys], locale);
|
311
252
|
const fallbackContent = `${this.jsonpFunc}(${(0, _utils.jsonToString)(fallbackI18nObject)});`;
|
312
253
|
const outputPath = `i18n-chunk/${locale}/${this.masterChunkFileName}`;
|
@@ -315,11 +256,9 @@ class I18nFilesEmitter {
|
|
315
256
|
chunkName: 'master',
|
316
257
|
desc: 'Fallback master i18n chunk (only moved/extra keys)'
|
317
258
|
});
|
318
|
-
|
319
259
|
if (!this.regularManifest.master) {
|
320
260
|
this.regularManifest.master = {};
|
321
261
|
}
|
322
|
-
|
323
262
|
this.regularManifest.master[locale] = outputPath;
|
324
263
|
console.log(`Emitted fallback master chunk for locale ${locale}: ${outputPath}`);
|
325
264
|
} catch (fallbackError) {
|
@@ -328,51 +267,34 @@ class I18nFilesEmitter {
|
|
328
267
|
}
|
329
268
|
}
|
330
269
|
}
|
331
|
-
|
332
270
|
emitI18nAssert(compilation) {
|
333
|
-
console.log('Starting I18n asset emission process...');
|
334
|
-
|
335
|
-
this.
|
336
|
-
|
337
|
-
this.entryPointKeys = new Set(); // 1. Process chunks and collect keys
|
338
|
-
|
271
|
+
console.log('Starting I18n asset emission process...');
|
272
|
+
this.captureModuleIds(compilation);
|
273
|
+
this.entryPointKeys = new Set();
|
339
274
|
compilation.chunks.forEach(chunk => {
|
340
275
|
const manifestForChunk = this.emitI18nFilesForChunk(chunk, compilation);
|
341
|
-
|
342
276
|
if (manifestForChunk.hasI18n) {
|
343
277
|
this.regularManifest[chunk.id] = manifestForChunk.assets;
|
344
278
|
}
|
345
|
-
});
|
346
|
-
|
347
|
-
this.
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
this.emitMasterChunks(compilation); // 5. Create the regular manifest
|
352
|
-
|
353
|
-
(0, _createRegularManifest.createRegularManifest)(compilation, this); // 6. Emit the final meta manifest with updated master keys
|
354
|
-
|
279
|
+
});
|
280
|
+
this.createMetaManifestWithFinalIds(compilation);
|
281
|
+
this.compareWithRemoteManifest(compilation);
|
282
|
+
this.emitMasterChunks(compilation);
|
283
|
+
(0, _createRegularManifest.createRegularManifest)(compilation, this);
|
355
284
|
const metaManifestSource = new _webpackSources.RawSource(JSON.stringify(this.generatedMetaManifest, null, 2));
|
356
285
|
this.emitAsset(compilation, this.i18nMetaManifestFileName, metaManifestSource, {
|
357
286
|
desc: 'Updated meta manifest with master keys'
|
358
287
|
});
|
359
288
|
console.log('Completed I18n asset emission process');
|
360
289
|
}
|
361
|
-
|
362
290
|
apply(compiler) {
|
363
|
-
// Use the afterCompile hook to capture module info after compilation
|
364
291
|
compiler.hooks.afterCompile.tap(pluginName, compilation => {
|
365
|
-
// console.log(`${pluginName}: Capturing compilation information after compile phase`);
|
366
292
|
this.compilation = compilation;
|
367
|
-
});
|
368
|
-
|
293
|
+
});
|
369
294
|
compiler.hooks.emit.tapAsync(pluginName, (compilation, callback) => {
|
370
|
-
// console.log(`${pluginName}: Emitting I18n assets with final module IDs`);
|
371
295
|
this.emitI18nAssert(compilation);
|
372
296
|
callback();
|
373
297
|
});
|
374
298
|
}
|
375
|
-
|
376
299
|
}
|
377
|
-
|
378
300
|
exports.default = I18nFilesEmitter;
|