@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,16 +4,12 @@ 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
|
var _I18nDependency = require("./I18nDependency");
|
11
|
-
|
12
9
|
var _NullFactory = _interopRequireDefault(require("webpack/lib/NullFactory"));
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
16
11
|
const pluginName = 'I18nKeysIdentifer';
|
12
|
+
|
17
13
|
/**
|
18
14
|
* this plugin search the i18 keys and make it as I18nDependency.
|
19
15
|
* how it works?
|
@@ -23,17 +19,14 @@ const pluginName = 'I18nKeysIdentifer';
|
|
23
19
|
* after the walk of AST we get some I18n keys
|
24
20
|
* then we make it as I18nDependency.
|
25
21
|
*/
|
26
|
-
|
27
22
|
class I18nKeysIdentifer {
|
28
23
|
constructor(jsResourceI18nKeys) {
|
29
24
|
this.jsResourceI18nKeys = jsResourceI18nKeys;
|
30
25
|
}
|
31
|
-
|
32
26
|
defineConfigarationForI18nDependency(compilation) {
|
33
27
|
compilation.dependencyFactories.set(_I18nDependency.I18nDependency, new _NullFactory.default());
|
34
28
|
compilation.dependencyTemplates.set(_I18nDependency.I18nDependency, new _I18nDependency.I18nDependencyTemplate());
|
35
29
|
}
|
36
|
-
|
37
30
|
addI18nDependency(module, i18nKeys) {
|
38
31
|
const identifier = `i18n ${module.resource}`;
|
39
32
|
const dep = new _I18nDependency.I18nDependency({
|
@@ -42,46 +35,43 @@ class I18nKeysIdentifer {
|
|
42
35
|
}, module.context, 0);
|
43
36
|
module.addDependency(dep);
|
44
37
|
}
|
45
|
-
|
46
38
|
apply(compiler) {
|
47
39
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation, params) => {
|
48
40
|
// this below hook was tapped for we use I18nDependency
|
49
41
|
// so we must define module factory for I18nDependency
|
50
42
|
// and we must define how it import statement look like I18nDependencyTemplate
|
51
|
-
this.defineConfigarationForI18nDependency(compilation);
|
43
|
+
this.defineConfigarationForI18nDependency(compilation);
|
52
44
|
|
45
|
+
// handler for parser
|
53
46
|
const handler = parser => {
|
54
47
|
parser.hooks.program.tap(pluginName, (ast, commmets) => {
|
55
48
|
const {
|
56
49
|
module
|
57
|
-
} = parser.state;
|
58
|
-
|
50
|
+
} = parser.state;
|
51
|
+
//
|
59
52
|
if (!(module && /\.jsx?$/.test(module.resource))) {
|
60
53
|
return;
|
61
|
-
}
|
62
|
-
|
63
|
-
|
54
|
+
}
|
55
|
+
// i18n grep proper contract regex
|
64
56
|
let i18nKeys = (0, _utils.collectI18nKeysfromAST)(ast, this.jsResourceI18nKeys);
|
65
|
-
i18nKeys = i18nKeys.concat(
|
57
|
+
i18nKeys = i18nKeys.concat(
|
58
|
+
// i18n grep proper contract regex
|
66
59
|
(0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
|
67
|
-
|
68
60
|
if (i18nKeys.length) {
|
69
61
|
this.addI18nDependency(module, i18nKeys);
|
70
62
|
}
|
71
63
|
});
|
72
|
-
};
|
64
|
+
};
|
73
65
|
|
66
|
+
// this below hook was tapped for collect I18n Key from files and add as Deppenensy
|
74
67
|
|
75
68
|
const factory = params.normalModuleFactory;
|
76
69
|
factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
|
77
70
|
factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
|
78
71
|
});
|
79
72
|
}
|
80
|
-
|
81
73
|
}
|
82
|
-
|
83
74
|
exports.default = I18nKeysIdentifer;
|
84
|
-
|
85
75
|
I18nKeysIdentifer.isChunkHasI18n = function (chunk) {
|
86
76
|
for (const module of chunk.modulesIterable) {
|
87
77
|
for (const dep of module.dependencies) {
|
@@ -90,6 +80,5 @@ I18nKeysIdentifer.isChunkHasI18n = function (chunk) {
|
|
90
80
|
}
|
91
81
|
}
|
92
82
|
}
|
93
|
-
|
94
83
|
return false;
|
95
84
|
};
|
@@ -4,23 +4,14 @@ 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
|
var _webpack = require("webpack");
|
11
|
-
|
12
9
|
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nKeysIdentifer"));
|
13
|
-
|
14
10
|
var _I18nFilesEmitter = _interopRequireDefault(require("./I18nFilesEmitter"));
|
15
|
-
|
16
11
|
var _I18nDownlodLogic = _interopRequireDefault(require("./I18nDownlodLogic"));
|
17
|
-
|
18
12
|
var _getI18nKeysFormModules = _interopRequireDefault(require("./utils/getI18nKeysFormModules"));
|
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
|
// #region initial
|
23
|
-
|
24
15
|
/**
|
25
16
|
* @TODO:
|
26
17
|
* [?] add comment line options for properties file and get all keys form property file do right way to genarate them
|
@@ -39,16 +30,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
39
30
|
* - file means your machine files
|
40
31
|
* - asset means that also file but that will create by webpack after build
|
41
32
|
*/
|
33
|
+
|
42
34
|
// const getI18nLocales = require('./utils/getI18nLocales');
|
43
35
|
// const { ConcatSource, SourceMapSource, OriginalSource } = sources;
|
44
36
|
const {
|
45
37
|
createHash
|
46
38
|
} = _webpack.util;
|
47
39
|
const MODULE_TYPE = 'json/i18n';
|
48
|
-
|
49
40
|
const i18ntype = locale => `${MODULE_TYPE}/${locale}`;
|
50
|
-
|
51
41
|
const pluginName = 'i18n-plugin';
|
42
|
+
|
52
43
|
/**
|
53
44
|
* @typedef I18nPluginOptions
|
54
45
|
* @property {String} filenameTemplate this was template for i18n chunk
|
@@ -77,15 +68,16 @@ class I18nPlugin {
|
|
77
68
|
propertiesFolder,
|
78
69
|
jsonpFunc
|
79
70
|
} = this.options;
|
80
|
-
this.publicPath = publicPath;
|
81
|
-
|
71
|
+
this.publicPath = publicPath;
|
72
|
+
// gethere i18n keys and values
|
82
73
|
this.jsResourceI18nKeys = jsResource ? (0, _utils.getPropertiesAsJSON)(jsResource) : {};
|
83
74
|
this.allI18nObject = (0, _utils.getAllI18n)({
|
84
75
|
folderPath: propertiesFolder,
|
85
76
|
disableDefault,
|
86
77
|
jsResourceI18nKeys: this.jsResourceI18nKeys
|
87
|
-
});
|
78
|
+
});
|
88
79
|
|
80
|
+
// initialize base data's and plugis
|
89
81
|
this.locales = Object.keys(this.allI18nObject);
|
90
82
|
this.i18nKeysIdentifer = new _I18nKeysIdentifer.default(this.jsResourceI18nKeys);
|
91
83
|
this.i18nFilesEmitter = new _I18nFilesEmitter.default({
|
@@ -102,7 +94,6 @@ class I18nPlugin {
|
|
102
94
|
localeVarName
|
103
95
|
});
|
104
96
|
}
|
105
|
-
|
106
97
|
maintainHashForAllI18nAssets(compilation) {
|
107
98
|
/**
|
108
99
|
* we write chunkHash logic inside of our plugin Because we only add Dependency not Module.
|
@@ -122,14 +113,13 @@ class I18nPlugin {
|
|
122
113
|
hashDigestLength
|
123
114
|
} = outputOptions;
|
124
115
|
const i18nKeys = (0, _getI18nKeysFormModules.default)(chunk.modulesIterable);
|
125
|
-
|
126
116
|
if (!i18nKeys.length) {
|
127
117
|
return;
|
128
118
|
}
|
129
|
-
|
130
119
|
const {
|
131
120
|
contentHash
|
132
|
-
} = chunk;
|
121
|
+
} = chunk;
|
122
|
+
// contentHash = {
|
133
123
|
// javascript: 'abcd2938',
|
134
124
|
// 'css/mini-extract': 'askdijasod'
|
135
125
|
// };
|
@@ -141,19 +131,20 @@ class I18nPlugin {
|
|
141
131
|
});
|
142
132
|
});
|
143
133
|
}
|
144
|
-
|
145
134
|
apply(compiler) {
|
146
135
|
this.i18nKeysIdentifer.apply(compiler);
|
147
136
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
148
137
|
// this below hook was tapped for hash for the specific i18nChunk Files and write logic to requireEnsure
|
149
|
-
this.maintainHashForAllI18nAssets(compilation);
|
138
|
+
this.maintainHashForAllI18nAssets(compilation);
|
139
|
+
|
140
|
+
// const { mainTemplate } = compilation;
|
150
141
|
// this.addDownloadLogicOfI18nInMainTemplate(mainTemplate);
|
151
142
|
});
|
152
143
|
this.i18nFilesEmitter.apply(compiler);
|
153
144
|
this.i18nDownlodLogic.apply(compiler);
|
154
145
|
}
|
155
|
-
|
156
146
|
}
|
147
|
+
|
157
148
|
/*
|
158
149
|
// TODO: need to reimplement this logic
|
159
150
|
// NOTE: this logic for split all content hash per mani chunk
|
@@ -180,6 +171,4 @@ class I18nPlugin {
|
|
180
171
|
|
181
172
|
}
|
182
173
|
*/
|
183
|
-
|
184
|
-
|
185
174
|
exports.default = I18nPlugin;
|
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.applyMetaManifest = applyMetaManifest;
|
7
|
-
|
8
7
|
var _fs = _interopRequireDefault(require("fs"));
|
9
|
-
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
-
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
9
|
function applyMetaManifest(compilation, plugin) {
|
13
10
|
const {
|
14
11
|
moduleIdMap
|
15
12
|
} = plugin;
|
16
13
|
const manifestPath = './metaManifest.json';
|
17
|
-
|
18
14
|
if (!plugin.detailedManifest || Object.keys(plugin.detailedManifest).length === 0) {
|
19
15
|
console.warn('No detailedManifest available, skipping manifest comparison');
|
20
16
|
return {
|
@@ -22,48 +18,53 @@ function applyMetaManifest(compilation, plugin) {
|
|
22
18
|
movedKeys: new Set(),
|
23
19
|
error: 'No detailedManifest available'
|
24
20
|
};
|
25
|
-
}
|
26
|
-
|
21
|
+
}
|
27
22
|
|
23
|
+
// Track keys in current build
|
28
24
|
const currentBuildKeys = new Set();
|
29
25
|
const currentKeyToModule = new Map();
|
30
26
|
const currentModules = new Map();
|
31
27
|
const currentKeySets = new Map();
|
32
|
-
const moduleIdToName = new Map();
|
28
|
+
const moduleIdToName = new Map();
|
33
29
|
|
30
|
+
// Process current build modules with final IDs
|
34
31
|
for (const [resourcePath, chunkData] of Object.entries(plugin.detailedManifest)) {
|
35
32
|
// Get the final module ID if it exists in our mapping
|
36
33
|
const finalModuleId = moduleIdMap.get(resourcePath) || resourcePath;
|
37
|
-
const chunkName = chunkData.chunkName || `chunk_${chunkData.chunkId || "unknown"}`;
|
34
|
+
const chunkName = chunkData.chunkName || `chunk_${chunkData.chunkId || "unknown"}`;
|
38
35
|
|
36
|
+
// Store module name mapping for better logging
|
39
37
|
moduleIdToName.set(finalModuleId, chunkName);
|
40
|
-
const keys = Array.isArray(chunkData.keysUsed) ? chunkData.keysUsed : Array.from(chunkData.keysUsed);
|
38
|
+
const keys = Array.isArray(chunkData.keysUsed) ? chunkData.keysUsed : Array.from(chunkData.keysUsed);
|
41
39
|
|
42
|
-
|
40
|
+
// Skip empty modules
|
41
|
+
if (keys.length === 0) continue;
|
43
42
|
|
43
|
+
// Sort keys for consistent comparison
|
44
44
|
const sortedKeys = [...keys].sort();
|
45
|
-
const keySetString = sortedKeys.join(',');
|
45
|
+
const keySetString = sortedKeys.join(',');
|
46
46
|
|
47
|
+
// Store module data using final IDs
|
47
48
|
currentModules.set(finalModuleId, {
|
48
49
|
id: finalModuleId,
|
49
50
|
resourcePath: resourcePath,
|
50
51
|
chunkId: chunkData.chunkId,
|
51
52
|
name: chunkName,
|
52
53
|
keys: sortedKeys
|
53
|
-
});
|
54
|
+
});
|
54
55
|
|
55
|
-
|
56
|
+
// Store key set for module fingerprinting
|
57
|
+
currentKeySets.set(keySetString, finalModuleId);
|
56
58
|
|
59
|
+
// Store individual key mappings
|
57
60
|
keys.forEach(key => {
|
58
61
|
currentBuildKeys.add(key);
|
59
62
|
currentKeyToModule.set(key, finalModuleId);
|
60
63
|
});
|
61
64
|
}
|
62
|
-
|
63
65
|
const currentKeyCount = currentBuildKeys.size;
|
64
66
|
const currentModuleCount = currentModules.size;
|
65
67
|
console.log(`Current build: ${currentKeyCount} keys in ${currentModuleCount} modules`);
|
66
|
-
|
67
68
|
try {
|
68
69
|
// Read from specified manifest path
|
69
70
|
if (!_fs.default.existsSync(manifestPath)) {
|
@@ -74,11 +75,10 @@ function applyMetaManifest(compilation, plugin) {
|
|
74
75
|
error: `Meta manifest not found at ${manifestPath}`
|
75
76
|
};
|
76
77
|
}
|
77
|
-
|
78
78
|
const fileContent = _fs.default.readFileSync(manifestPath, 'utf8');
|
79
|
+
const remoteMetaManifest = JSON.parse(fileContent);
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
// Handle non-existent or invalid modules
|
82
82
|
if (!remoteMetaManifest.modules) {
|
83
83
|
console.warn('Meta manifest does not contain modules section');
|
84
84
|
return {
|
@@ -86,65 +86,72 @@ function applyMetaManifest(compilation, plugin) {
|
|
86
86
|
movedKeys: new Set(),
|
87
87
|
error: 'Meta manifest does not contain modules section'
|
88
88
|
};
|
89
|
-
}
|
90
|
-
|
89
|
+
}
|
91
90
|
|
91
|
+
// Track all keys in remote manifest modules
|
92
92
|
const remoteModuleKeys = new Set();
|
93
93
|
const remoteKeyToModule = new Map();
|
94
94
|
const remoteModules = new Map();
|
95
95
|
const remoteKeySets = new Map();
|
96
96
|
const remoteModuleIdToName = new Map();
|
97
|
-
const moduleEquivalenceMap = new Map();
|
97
|
+
const moduleEquivalenceMap = new Map();
|
98
98
|
|
99
|
+
// Process remote manifest modules
|
99
100
|
for (const [moduleId, moduleData] of Object.entries(remoteMetaManifest.modules)) {
|
100
101
|
if (moduleData.keys && Array.isArray(moduleData.keys)) {
|
101
102
|
// Store module name for better logging
|
102
103
|
const moduleName = moduleId;
|
103
|
-
remoteModuleIdToName.set(moduleId, moduleName);
|
104
|
+
remoteModuleIdToName.set(moduleId, moduleName);
|
104
105
|
|
105
|
-
|
106
|
+
// Skip empty modules
|
107
|
+
if (moduleData.keys.length === 0) continue;
|
106
108
|
|
109
|
+
// Sort keys for consistent comparison
|
107
110
|
const sortedKeys = [...moduleData.keys].sort();
|
108
|
-
const keySetString = sortedKeys.join(',');
|
111
|
+
const keySetString = sortedKeys.join(',');
|
109
112
|
|
113
|
+
// Store module data
|
110
114
|
remoteModules.set(moduleId, {
|
111
115
|
id: moduleData.id || moduleId,
|
112
116
|
name: moduleName,
|
113
117
|
keys: sortedKeys,
|
114
118
|
keyCount: moduleData.keys.length
|
115
|
-
});
|
119
|
+
});
|
116
120
|
|
117
|
-
|
121
|
+
// Store key set
|
122
|
+
remoteKeySets.set(keySetString, moduleId);
|
118
123
|
|
124
|
+
// Store individual key mappings
|
119
125
|
moduleData.keys.forEach(key => {
|
120
126
|
remoteModuleKeys.add(key);
|
121
127
|
remoteKeyToModule.set(key, moduleId);
|
122
128
|
});
|
123
129
|
}
|
124
|
-
}
|
125
|
-
|
130
|
+
}
|
126
131
|
|
132
|
+
// Get keys from the master chunk in the remote manifest (if it exists)
|
127
133
|
const remoteMasterKeys = new Set();
|
128
|
-
|
129
134
|
if (remoteMetaManifest.masterKeys && Array.isArray(remoteMetaManifest.masterKeys)) {
|
130
135
|
remoteMetaManifest.masterKeys.forEach(key => {
|
131
136
|
remoteMasterKeys.add(key);
|
132
137
|
});
|
133
|
-
}
|
134
|
-
|
138
|
+
}
|
135
139
|
|
140
|
+
// Get all unique keys from the remote manifest (modules + master)
|
136
141
|
const remoteAllKeys = new Set([...remoteModuleKeys, ...remoteMasterKeys]);
|
137
142
|
const remoteKeyCount = remoteAllKeys.size;
|
138
143
|
const remoteModuleCount = remoteModules.size;
|
139
144
|
const remoteMasterKeyCount = remoteMasterKeys.size;
|
140
|
-
console.log(`Remote manifest: ${remoteKeyCount} keys in ${remoteModuleCount} modules, ${remoteMasterKeyCount} master keys`);
|
145
|
+
console.log(`Remote manifest: ${remoteKeyCount} keys in ${remoteModuleCount} modules, ${remoteMasterKeyCount} master keys`);
|
141
146
|
|
147
|
+
// Find intersection and differences for keys
|
142
148
|
const inBothSets = new Set([...currentBuildKeys].filter(key => remoteAllKeys.has(key)));
|
143
149
|
const missingKeys = new Set([...remoteAllKeys].filter(key => !currentBuildKeys.has(key)));
|
144
150
|
const extraKeys = new Set([...currentBuildKeys].filter(key => !remoteAllKeys.has(key)));
|
145
|
-
console.log(`Key comparison: ${inBothSets.size} shared keys, ${missingKeys.size} missing, ${extraKeys.size} new`);
|
146
|
-
// 1. First pass: Match by module name
|
151
|
+
console.log(`Key comparison: ${inBothSets.size} shared keys, ${missingKeys.size} missing, ${extraKeys.size} new`);
|
147
152
|
|
153
|
+
// Enhanced multi-level module equivalence mapping
|
154
|
+
// 1. First pass: Match by module name
|
148
155
|
for (const [remoteId, remoteModule] of remoteModules.entries()) {
|
149
156
|
if (remoteModule.name) {
|
150
157
|
// Find a current module with matching name
|
@@ -155,11 +162,10 @@ function applyMetaManifest(compilation, plugin) {
|
|
155
162
|
}
|
156
163
|
}
|
157
164
|
}
|
158
|
-
}
|
159
|
-
|
165
|
+
}
|
160
166
|
|
167
|
+
// 2. Second pass: Match by resource path
|
161
168
|
const unmatchedRemote = [...remoteModules.keys()].filter(id => !moduleEquivalenceMap.has(id));
|
162
|
-
|
163
169
|
for (const remoteId of unmatchedRemote) {
|
164
170
|
for (const [resourcePath, currentModuleId] of moduleIdMap.entries()) {
|
165
171
|
if (resourcePath.includes(remoteId)) {
|
@@ -167,38 +173,35 @@ function applyMetaManifest(compilation, plugin) {
|
|
167
173
|
break;
|
168
174
|
}
|
169
175
|
}
|
170
|
-
}
|
171
|
-
|
176
|
+
}
|
172
177
|
|
178
|
+
// 3. Third pass: Match by key set fingerprint
|
173
179
|
const stillUnmatchedRemote = [...remoteModules.keys()].filter(id => !moduleEquivalenceMap.has(id));
|
174
|
-
|
175
180
|
for (const remoteId of stillUnmatchedRemote) {
|
176
181
|
const remoteModule = remoteModules.get(remoteId);
|
177
182
|
const keySetString = remoteModule.keys.join(',');
|
178
|
-
|
179
183
|
if (currentKeySets.has(keySetString)) {
|
180
184
|
moduleEquivalenceMap.set(remoteId, currentKeySets.get(keySetString));
|
181
185
|
}
|
182
|
-
}
|
183
|
-
|
186
|
+
}
|
184
187
|
|
188
|
+
// Find moved keys based on enhanced module equivalence map
|
185
189
|
const trulyMovedKeys = new Set();
|
186
190
|
const keyMovementDetails = new Map();
|
187
|
-
|
188
191
|
for (const key of inBothSets) {
|
189
192
|
// Skip keys that are in the master chunk
|
190
193
|
if (remoteMasterKeys.has(key)) {
|
191
194
|
continue;
|
192
195
|
}
|
193
|
-
|
194
196
|
const remoteModuleId = remoteKeyToModule.get(key);
|
195
|
-
const currentModuleId = currentKeyToModule.get(key);
|
197
|
+
const currentModuleId = currentKeyToModule.get(key);
|
196
198
|
|
199
|
+
// Normalize module names for comparison
|
197
200
|
const remoteModuleName = remoteModuleIdToName.get(remoteModuleId) || remoteModuleId;
|
198
|
-
const currentModuleName = moduleIdToName.get(currentModuleId) || currentModuleId;
|
201
|
+
const currentModuleName = moduleIdToName.get(currentModuleId) || currentModuleId;
|
199
202
|
|
203
|
+
// Only consider a key moved if it's actually in a different module
|
200
204
|
const moduleNameComparison = remoteModuleName !== currentModuleName;
|
201
|
-
|
202
205
|
if (moduleNameComparison) {
|
203
206
|
trulyMovedKeys.add(key);
|
204
207
|
keyMovementDetails.set(key, {
|
@@ -209,9 +212,9 @@ function applyMetaManifest(compilation, plugin) {
|
|
209
212
|
type: 'module_change'
|
210
213
|
});
|
211
214
|
}
|
212
|
-
}
|
213
|
-
|
215
|
+
}
|
214
216
|
|
217
|
+
// Get keys from unmatched modules that exist in the current build
|
215
218
|
const unmatchedRemoteModules = [...remoteModules.keys()].filter(id => !moduleEquivalenceMap.has(id));
|
216
219
|
unmatchedRemoteModules.forEach(moduleId => {
|
217
220
|
const module = remoteModules.get(moduleId);
|
@@ -220,8 +223,9 @@ function applyMetaManifest(compilation, plugin) {
|
|
220
223
|
// Only add the key if it exists in the current build
|
221
224
|
if (currentBuildKeys.has(key)) {
|
222
225
|
const currentModuleId = currentKeyToModule.get(key);
|
223
|
-
const currentModuleName = moduleIdToName.get(currentModuleId) || currentModuleId;
|
226
|
+
const currentModuleName = moduleIdToName.get(currentModuleId) || currentModuleId;
|
224
227
|
|
228
|
+
// Only add if actually in a different module
|
225
229
|
if (moduleName !== currentModuleName) {
|
226
230
|
trulyMovedKeys.add(key);
|
227
231
|
keyMovementDetails.set(key, {
|
@@ -236,32 +240,34 @@ function applyMetaManifest(compilation, plugin) {
|
|
236
240
|
});
|
237
241
|
});
|
238
242
|
const movedKeyCount = trulyMovedKeys.size;
|
239
|
-
console.log(`Found ${extraKeys.size} new keys and ${movedKeyCount} moved keys`);
|
243
|
+
console.log(`Found ${extraKeys.size} new keys and ${movedKeyCount} moved keys`);
|
240
244
|
|
245
|
+
// Add extra and moved keys to the plugin's tracking for master chunk inclusion
|
241
246
|
plugin.extraKeys = extraKeys;
|
242
|
-
plugin.movedKeys = trulyMovedKeys;
|
247
|
+
plugin.movedKeys = trulyMovedKeys;
|
243
248
|
|
249
|
+
// Store key counts for reference
|
244
250
|
plugin.keyStats = {
|
245
251
|
current: currentKeyCount,
|
246
252
|
remote: remoteKeyCount,
|
247
253
|
extra: extraKeys.size,
|
248
254
|
moved: movedKeyCount
|
249
|
-
};
|
255
|
+
};
|
250
256
|
|
257
|
+
// Update master keys in the generated meta manifest
|
251
258
|
if (plugin.generatedMetaManifest) {
|
252
259
|
// Only include extra (new) and moved keys in the master keys
|
253
260
|
const masterKeys = [...Array.from(extraKeys), ...Array.from(trulyMovedKeys)];
|
254
261
|
plugin.generatedMetaManifest.masterKeys = masterKeys;
|
255
262
|
}
|
256
|
-
|
257
263
|
return {
|
258
264
|
extraKeys,
|
259
265
|
movedKeys: trulyMovedKeys,
|
260
266
|
keyStats: plugin.keyStats
|
261
267
|
};
|
262
268
|
} catch (error) {
|
263
|
-
console.error(`Error during manifest comparison: ${error.message}`);
|
264
|
-
|
269
|
+
console.error(`Error during manifest comparison: ${error.message}`);
|
270
|
+
// Return empty sets for keys if there was an error
|
265
271
|
plugin.extraKeys = new Set();
|
266
272
|
plugin.movedKeys = new Set();
|
267
273
|
return {
|
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.collectI18nKeysfromAST = collectI18nKeysfromAST;
|
7
7
|
exports.collectI18nKeysfromComments = collectI18nKeysfromComments;
|
8
|
-
|
9
8
|
const {
|
10
9
|
walk
|
11
10
|
} = require('estree-walker');
|
12
|
-
|
13
11
|
function collectI18nKeysfromAST(ast, allI18n) {
|
14
12
|
let i18nKeys = {};
|
15
13
|
walk(ast, {
|
@@ -23,42 +21,34 @@ function collectI18nKeysfromAST(ast, allI18n) {
|
|
23
21
|
});
|
24
22
|
return Object.keys(i18nKeys);
|
25
23
|
}
|
26
|
-
|
27
24
|
const prefixI18nComment = 'I18N';
|
28
25
|
const prefixI18nComment1 = 'dynamic-i18n-key';
|
29
|
-
|
30
26
|
function getI18nKeysFromComment(comment) {
|
31
27
|
let commentString = comment.value.trim();
|
32
28
|
let i18nKeyStr;
|
33
|
-
|
34
29
|
if (commentString.startsWith(prefixI18nComment)) {
|
35
30
|
i18nKeyStr = commentString.slice(prefixI18nComment.length).trim();
|
36
31
|
} else if (commentString.startsWith(prefixI18nComment1)) {
|
37
32
|
i18nKeyStr = commentString.slice(prefixI18nComment1.length).trim();
|
38
33
|
}
|
39
|
-
|
40
34
|
if (!i18nKeyStr) {
|
41
35
|
return [];
|
42
36
|
}
|
43
|
-
|
44
37
|
const i18nKeys = i18nKeyStr.split(',');
|
45
38
|
return i18nKeys;
|
46
|
-
}
|
47
|
-
|
39
|
+
}
|
48
40
|
|
41
|
+
// export function fromComments(comments, allI18n) {
|
49
42
|
function collectI18nKeysfromComments(comments, allI18n) {
|
50
43
|
// TODO: need to implement
|
51
44
|
let i18nKeys = {};
|
52
|
-
|
53
45
|
for (let comment of comments) {
|
54
46
|
let keys = getI18nKeysFromComment(comment);
|
55
|
-
|
56
47
|
for (let key of keys) {
|
57
48
|
if (key && allI18n[key]) {
|
58
49
|
i18nKeys[key] = allI18n[key];
|
59
50
|
}
|
60
51
|
}
|
61
52
|
}
|
62
|
-
|
63
53
|
return Object.keys(i18nKeys);
|
64
54
|
}
|
@@ -4,59 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createMetaManifest = createMetaManifest;
|
7
|
-
|
8
7
|
var _webpackSources = require("webpack-sources");
|
9
|
-
|
10
8
|
function createMetaManifest(compilation, plugin, skipEmit = false) {
|
11
9
|
const {
|
12
10
|
detailedManifest
|
13
|
-
} = plugin;
|
14
|
-
|
11
|
+
} = plugin;
|
15
12
|
const i18nMetaManifestFileName = plugin.i18nMetaManifestFileName;
|
16
|
-
|
17
13
|
if (!skipEmit) {
|
18
14
|
console.log('Generating meta manifest:', i18nMetaManifestFileName);
|
19
|
-
}
|
20
|
-
|
21
|
-
|
15
|
+
}
|
22
16
|
const finalMetaManifest = {
|
23
17
|
modules: {}
|
24
|
-
};
|
25
|
-
|
18
|
+
};
|
26
19
|
for (const [chunkId, chunkData] of Object.entries(detailedManifest)) {
|
27
20
|
const chunkName = chunkData.chunkName || `chunk_${chunkId}`;
|
28
|
-
const keysArray = Array.isArray(chunkData.keysUsed) ? chunkData.keysUsed : Array.from(chunkData.keysUsed);
|
29
|
-
|
21
|
+
const keysArray = Array.isArray(chunkData.keysUsed) ? chunkData.keysUsed : Array.from(chunkData.keysUsed);
|
30
22
|
if (keysArray.length > 0) {
|
31
23
|
finalMetaManifest.modules[chunkName] = {
|
32
24
|
id: chunkId,
|
33
25
|
keys: keysArray
|
34
26
|
};
|
35
27
|
}
|
36
|
-
}
|
37
|
-
|
38
|
-
|
28
|
+
}
|
39
29
|
if (plugin.extraKeys && plugin.movedKeys) {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
finalMetaManifest.masterKeys = Array.from(masterKeysSet); // Log the keys being added to master chunk
|
44
|
-
|
30
|
+
const masterKeysSet = new Set([...(Array.from(plugin.extraKeys) || []), ...(Array.from(plugin.movedKeys) || [])]);
|
31
|
+
finalMetaManifest.masterKeys = Array.from(masterKeysSet);
|
45
32
|
if (finalMetaManifest.masterKeys.length > 0) {
|
46
|
-
console.log(`Extra and moved keys to add to master chunk: ${finalMetaManifest.masterKeys.length}`);
|
47
|
-
|
33
|
+
console.log(`Extra and moved keys to add to master chunk: ${finalMetaManifest.masterKeys.length}`);
|
48
34
|
finalMetaManifest.masterKeys.forEach(key => {
|
49
35
|
console.log(` - ${key}`);
|
50
36
|
});
|
51
37
|
}
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
plugin.generatedMetaManifest = finalMetaManifest; // Only emit if not skipped
|
56
|
-
|
38
|
+
}
|
39
|
+
plugin.generatedMetaManifest = finalMetaManifest;
|
57
40
|
if (!skipEmit) {
|
58
41
|
const metaManifestSource = new _webpackSources.RawSource(JSON.stringify(finalMetaManifest, null, 2));
|
59
|
-
|
60
42
|
if (!compilation.emitAsset) {
|
61
43
|
compilation.assets[i18nMetaManifestFileName] = metaManifestSource;
|
62
44
|
} else {
|
@@ -65,6 +47,5 @@ function createMetaManifest(compilation, plugin, skipEmit = false) {
|
|
65
47
|
});
|
66
48
|
}
|
67
49
|
}
|
68
|
-
|
69
50
|
return finalMetaManifest;
|
70
51
|
}
|