@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.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/.eslintignore +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/README.md +1025 -1028
- package/bin/cli.js +482 -482
- package/cert/Tsicsezwild-22-23.crt +37 -37
- package/cert/Tsicsezwild-22-23.key +27 -27
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +719 -678
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/babel/cmjs-plugins-presets.js +4 -0
- package/lib/babel/es-plugins-presets.js +4 -0
- package/lib/common/getEntries.js +10 -0
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +5 -0
- package/lib/common/splitChunks.js +13 -2
- package/lib/common/sslcertUpdater.js +17 -6
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +15 -0
- package/lib/configs/jest.config.js +9 -0
- package/lib/configs/libAlias.js +2 -4
- package/lib/configs/webpack.component.umd.config.js +5 -0
- package/lib/configs/webpack.css.umd.config.js +13 -5
- package/lib/configs/webpack.dev.config.js +36 -2
- package/lib/configs/webpack.docs.config.js +21 -1
- package/lib/configs/webpack.impact.config.js +19 -1
- package/lib/configs/webpack.prod.config.js +37 -3
- package/lib/hooks/docsProptypeHook.js +7 -3
- package/lib/jest/commitedFilesResult.js +45 -3
- package/lib/jest/coverageCollector.js +11 -0
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
- package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
- package/lib/jest/result.js +22 -0
- package/lib/jest/run.js +17 -6
- package/lib/jest/setup.js +57 -5
- package/lib/loaderUtils/configsAssetsLoaders.js +44 -34
- package/lib/loaderUtils/getCSSLoaders.js +35 -20
- package/lib/loaderUtils/getDevJsLoaders.js +8 -0
- package/lib/loaderUtils/index.js +3 -0
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/docsLoader.js +7 -0
- package/lib/loaders/docsPropsLoader.js +7 -3
- package/lib/loaders/fileBountryLoader.js +2 -0
- package/lib/loaders/fileLoader.js +22 -11
- package/lib/loaders/scriptInstrumentLoader.js +13 -5
- package/lib/loaders/selectorMappingLoader.js +25 -7
- package/lib/loaders/workerLoader.js +29 -13
- package/lib/middlewares/HMRMiddleware.js +26 -13
- package/lib/middlewares/SSTMiddleware.js +3 -0
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
- package/lib/pluginUtils/getDevPlugins.js +68 -22
- package/lib/pluginUtils/getDocsPlugins.js +10 -1
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
- package/lib/pluginUtils/getLibraryPlugins.js +5 -0
- package/lib/pluginUtils/getProdPlugins.js +77 -28
- package/lib/pluginUtils/getServerPlugins.js +5 -0
- package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
- package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
- package/lib/pluginUtils/index.js +8 -0
- package/lib/plugins/CdnChangePlugin.js +14 -0
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/EFCPlugin.js +34 -23
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +32 -23
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +80 -70
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
- package/lib/plugins/ManifestPlugin.js +17 -0
- package/lib/plugins/ModuleStatsPlugin.js +23 -0
- package/lib/plugins/OptimizeJSPlugin.js +7 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
- package/lib/plugins/PublicPathChangePlugin.js +36 -4
- package/lib/plugins/ReportGeneratePlugin.js +30 -4
- package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
- package/lib/plugins/ResourceHintsPlugin.js +27 -20
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +29 -13
- package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
- package/lib/plugins/SourceMapHookPlugin.js +9 -0
- package/lib/plugins/TPHashMappingPlugin.js +19 -5
- package/lib/plugins/UglifyCSSPlugin.js +9 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
- package/lib/plugins/VariableConversionCollector.js +322 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +19 -0
- package/lib/plugins/libraryImpactPlugin.js +32 -0
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/ExcludePlugin.js +4 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +37 -24
- package/lib/postcss-plugins/ValueReplacer.js +6 -9
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
- package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -141
- package/lib/postcss-plugins/variableModifier.js +20 -13
- package/lib/schemas/index.js +23 -4
- package/lib/servers/clusterHubServer.js +10 -0
- package/lib/servers/devBuild.js +24 -13
- package/lib/servers/docsServer.js +2 -0
- package/lib/servers/docsServerCore.js +21 -0
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +5 -0
- package/lib/servers/httpsOptions.js +4 -0
- package/lib/servers/impactServer.js +34 -2
- package/lib/servers/mockserver.js +9 -0
- package/lib/servers/nowatchserver.js +34 -12
- package/lib/servers/scrServer.js +20 -13
- package/lib/servers/server.js +35 -7
- package/lib/servers/ssServer.js +16 -0
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +12 -6
- package/lib/utils/babelPresets.js +2 -0
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +8 -2
- package/lib/utils/copy.js +6 -0
- package/lib/utils/copyTimezones.js +8 -0
- package/lib/utils/createEventStream.js +4 -0
- package/lib/utils/cssClassNameGenerate.js +19 -3
- package/lib/utils/cssURLReplacer.js +25 -0
- package/lib/utils/dependencyPostPublish.js +9 -0
- package/lib/utils/fileUtils.js +26 -0
- package/lib/utils/folderIterator.js +10 -0
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +21 -0
- package/lib/utils/getHash.js +7 -0
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +39 -14
- package/lib/utils/getServerURL.js +7 -0
- package/lib/utils/index.js +47 -2
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +29 -6
- package/lib/utils/jsonHelper.js +19 -2
- package/lib/utils/libraryImpactConfig.js +2 -0
- package/lib/utils/lint/addScripts.js +5 -2
- package/lib/utils/lint/checkExistingConfig.js +12 -3
- package/lib/utils/lint/copyConfigs.js +3 -0
- package/lib/utils/lint/index.js +9 -0
- package/lib/utils/lint/lintScripts.js +1 -0
- package/lib/utils/lint/lintSetup.js +4 -3
- package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
- package/lib/utils/lint/question.js +7 -0
- package/lib/utils/lintReporter.js +20 -0
- package/lib/utils/mailSender.js +7 -0
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +28 -0
- package/lib/utils/removeAttributes.js +7 -0
- package/lib/utils/repoClone.js +27 -2
- package/lib/utils/request.js +12 -0
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +16 -4
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +10 -0
- package/lib/utils/switchBranch.js +4 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/npm8.md +9 -9
- package/package.json +146 -146
- package/postpublish.js +6 -6
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1501
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
|
@@ -4,20 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
class CleanUpStatsPlugin {
|
|
8
9
|
shouldPickStatChild(child) {
|
|
9
10
|
return child.name.indexOf('mini-css-extract-plugin') !== 0;
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
apply(compiler) {
|
|
12
14
|
compiler.hooks.done.tap('CleanUpStatsPlugin', stats => {
|
|
13
15
|
const {
|
|
14
16
|
children
|
|
15
17
|
} = stats.compilation;
|
|
18
|
+
|
|
16
19
|
if (Array.isArray(children)) {
|
|
17
20
|
// eslint-disable-next-line no-param-reassign
|
|
18
21
|
stats.compilation.children = children.filter(child => this.shouldPickStatChild(child));
|
|
19
22
|
}
|
|
20
23
|
});
|
|
21
24
|
}
|
|
25
|
+
|
|
22
26
|
}
|
|
27
|
+
|
|
23
28
|
exports.default = CleanUpStatsPlugin;
|
package/lib/plugins/EFCPlugin.js
CHANGED
|
@@ -4,16 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpackSources = require("webpack-sources");
|
|
9
|
+
|
|
8
10
|
var _utils = require("../utils");
|
|
11
|
+
|
|
9
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
|
|
10
14
|
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
|
15
|
+
|
|
11
16
|
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
|
|
17
|
+
|
|
12
18
|
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
|
19
|
+
|
|
13
20
|
var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
|
|
21
|
+
|
|
14
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
|
16
23
|
|
|
24
|
+
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
|
17
25
|
const cliOptions = (0, _utils.getOptions)();
|
|
18
26
|
const {
|
|
19
27
|
app: {
|
|
@@ -31,18 +39,17 @@ const {
|
|
|
31
39
|
createSDkFile,
|
|
32
40
|
cdnStatement
|
|
33
41
|
} = efcOptios;
|
|
42
|
+
|
|
34
43
|
class EFCPlugin {
|
|
35
44
|
constructor(options = {}) {
|
|
36
45
|
this.isDevelopment = options.isDevelopment;
|
|
37
46
|
this.templateFilePath = options.templateFilePath;
|
|
38
47
|
this.serverUrl = options.serverUrl;
|
|
39
|
-
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
|
40
|
-
|
|
41
|
-
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
|
48
|
+
this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
|
42
49
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
|
43
|
-
|
|
44
50
|
// IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
|
|
45
51
|
// So when debugging consider this as well
|
|
52
|
+
|
|
46
53
|
this.options = Object.assign({}, efcOptios, options);
|
|
47
54
|
this.options.entryPointName = options.entryPointName || 'efc';
|
|
48
55
|
this.options.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
|
|
@@ -51,8 +58,7 @@ class EFCPlugin {
|
|
|
51
58
|
const cssDirAttr = this.options.cssDirAttr || 'data-efc-dir';
|
|
52
59
|
const localeDefaultValue = this.options.localeDefaultValue || 'en_US';
|
|
53
60
|
const cssDirDefaultValue = this.options.cssDirDefaultValue || 'ltr';
|
|
54
|
-
this.options.localeStatement = options.localeStatement ||
|
|
55
|
-
// Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
|
|
61
|
+
this.options.localeStatement = options.localeStatement || // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
|
|
56
62
|
// Statment 2: return langEle ? langEle.getAttribute('${localeAttr}') : 'en_US';
|
|
57
63
|
// We are using statement1 not statment2,
|
|
58
64
|
// Because even that attribute doesn't have value, We need default value
|
|
@@ -64,9 +70,7 @@ class EFCPlugin {
|
|
|
64
70
|
let dirEle = document.querySelector('[${cssDirAttr}]');
|
|
65
71
|
return dirEle && dirEle.getAttribute('${cssDirAttr}') || '${cssDirDefaultValue}';
|
|
66
72
|
})();`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
|
73
|
+
} // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
|
70
74
|
// getI18nManifest(compilation) {
|
|
71
75
|
// const i18nManifestFile =
|
|
72
76
|
// compilation.assets[this.options.i18nManifestFileName];
|
|
@@ -77,11 +81,12 @@ class EFCPlugin {
|
|
|
77
81
|
// return {};
|
|
78
82
|
// }
|
|
79
83
|
|
|
84
|
+
|
|
80
85
|
getI18nAssetsStr(entryPoint, compilation) {
|
|
81
86
|
if (!chunkSplitEnable) {
|
|
82
87
|
let i18nAsstes = {};
|
|
83
|
-
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
|
84
|
-
|
|
88
|
+
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
|
89
|
+
|
|
85
90
|
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
|
86
91
|
let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
|
87
92
|
let splittedFileName = fileName.split('.');
|
|
@@ -90,9 +95,11 @@ class EFCPlugin {
|
|
|
90
95
|
}, {});
|
|
91
96
|
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
|
92
97
|
}
|
|
98
|
+
|
|
93
99
|
let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
|
94
100
|
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
|
95
101
|
}
|
|
102
|
+
|
|
96
103
|
createFileContent(compilation) {
|
|
97
104
|
const {
|
|
98
105
|
entryPointName,
|
|
@@ -104,19 +111,18 @@ class EFCPlugin {
|
|
|
104
111
|
const {
|
|
105
112
|
serverUrl
|
|
106
113
|
} = this;
|
|
107
|
-
const cssDirTemplate = '@dir@';
|
|
108
|
-
|
|
109
|
-
const entryPoint = compilation.entrypoints.get(entryPointName);
|
|
110
|
-
|
|
114
|
+
const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
|
|
115
|
+
|
|
116
|
+
const entryPoint = compilation.entrypoints.get(entryPointName); // const chunk = compilation.namedChunks.get(entryPointName);
|
|
117
|
+
|
|
111
118
|
const [jsPath, cssPath,,, i18nJsPath] = !this.isDevelopment ? publicPaths : [];
|
|
112
119
|
const initialFiles = entryPoint.getFiles();
|
|
113
|
-
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
|
|
114
|
-
|
|
115
|
-
// const i18nAssets = getShortI18nAssets(
|
|
120
|
+
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file)); // const i18nAssets = getShortI18nAssets(
|
|
116
121
|
// entryPoint.chunks,
|
|
117
122
|
// i18nManifest,
|
|
118
123
|
// i18nJsPath
|
|
119
124
|
// );
|
|
125
|
+
|
|
120
126
|
const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, i18nJsPath);
|
|
121
127
|
return `(() => {
|
|
122
128
|
const lang = ${localeStatement};
|
|
@@ -195,12 +201,12 @@ class EFCPlugin {
|
|
|
195
201
|
})();
|
|
196
202
|
`;
|
|
197
203
|
}
|
|
204
|
+
|
|
198
205
|
apply(compiler) {
|
|
199
206
|
if (!createSDkFile) {
|
|
200
207
|
return;
|
|
201
|
-
}
|
|
208
|
+
} //console.log('this.templateFilePath', this.templateFilePath, this.options);
|
|
202
209
|
|
|
203
|
-
//console.log('this.templateFilePath', this.templateFilePath, this.options);
|
|
204
210
|
|
|
205
211
|
if (this.templateFilePath) {
|
|
206
212
|
new _EFCTemplatePlugin.default({
|
|
@@ -211,20 +217,25 @@ class EFCPlugin {
|
|
|
211
217
|
}).apply(compiler);
|
|
212
218
|
return;
|
|
213
219
|
}
|
|
220
|
+
|
|
214
221
|
compiler.hooks.emit.tap('EFCPlugin', compilation => {
|
|
215
222
|
const {
|
|
216
223
|
entryPointName,
|
|
217
224
|
outputFile
|
|
218
225
|
} = this.options;
|
|
219
226
|
const entryPoint = compilation.entrypoints.get(entryPointName);
|
|
227
|
+
|
|
220
228
|
if (!entryPoint) {
|
|
221
229
|
return;
|
|
222
230
|
}
|
|
231
|
+
|
|
223
232
|
const source = new _webpackSources.RawSource(this.createFileContent(compilation));
|
|
224
|
-
compilation.assets[outputFile] = source;
|
|
225
|
-
|
|
233
|
+
compilation.assets[outputFile] = source; // eslint-disable-next-line no-console
|
|
234
|
+
|
|
226
235
|
console.log('The EFC embedded code was created successfully..!!!');
|
|
227
236
|
});
|
|
228
237
|
}
|
|
238
|
+
|
|
229
239
|
}
|
|
240
|
+
|
|
230
241
|
exports.default = EFCPlugin;
|
package/lib/plugins/EFCPlugin.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# EFC Plugin
|
|
2
|
-
|
|
3
|
-
In EFC plugin we are create sdk file for efc related purpose
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# document will be soon
|
|
1
|
+
# EFC Plugin
|
|
2
|
+
|
|
3
|
+
In EFC plugin we are create sdk file for efc related purpose
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# document will be soon
|
|
@@ -4,16 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpackSources = require("webpack-sources");
|
|
9
|
+
|
|
8
10
|
var _utils = require("../utils");
|
|
11
|
+
|
|
9
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
|
|
10
14
|
var _fs = require("fs");
|
|
15
|
+
|
|
11
16
|
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
|
17
|
+
|
|
12
18
|
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
|
|
19
|
+
|
|
13
20
|
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
|
21
|
+
|
|
14
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
|
16
23
|
|
|
24
|
+
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
|
17
25
|
const cliOptions = (0, _utils.getOptions)();
|
|
18
26
|
const {
|
|
19
27
|
i18n: {
|
|
@@ -26,32 +34,25 @@ const {
|
|
|
26
34
|
} = cliOptions;
|
|
27
35
|
const {
|
|
28
36
|
createSDkFile
|
|
29
|
-
} = efcOptios;
|
|
30
|
-
|
|
31
|
-
// for smap relate changes
|
|
37
|
+
} = efcOptios; // for smap relate changes
|
|
32
38
|
// CdnChangePlugin
|
|
33
39
|
// SourceMapHookPlugin
|
|
34
40
|
|
|
35
41
|
class EFCTemplatePlugin {
|
|
36
42
|
constructor(options = {}) {
|
|
37
43
|
// console.log(' templateFilePath ', process.cwd(), options.templateFilePath, templateFilePath);
|
|
38
|
-
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
|
|
39
|
-
// console.log(' templateFilePath ', this.templateFilePath);
|
|
40
|
-
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
|
41
|
-
this.publicPath = options.publicPath;
|
|
44
|
+
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath); // console.log(' templateFilePath ', this.templateFilePath);
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
|
47
|
+
this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
|
44
48
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
|
45
|
-
|
|
46
49
|
// IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
|
|
47
50
|
// So when debugging consider this as well
|
|
48
51
|
// this.options = Object.assign({}, efcOptios, options);
|
|
49
52
|
|
|
50
53
|
this.entryPointName = options.entryPointName || 'efc';
|
|
51
54
|
this.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
|
55
|
+
} // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
|
55
56
|
// getI18nManifest(compilation) {
|
|
56
57
|
// const i18nManifestFile =
|
|
57
58
|
// compilation.assets[this.options.i18nManifestFileName];
|
|
@@ -62,12 +63,13 @@ class EFCTemplatePlugin {
|
|
|
62
63
|
// return {};
|
|
63
64
|
// }
|
|
64
65
|
|
|
66
|
+
|
|
65
67
|
getI18nAssetsStr(entryPoint, compilation) {
|
|
66
68
|
// NOTE: we have used lang variable inside
|
|
67
69
|
if (!chunkSplitEnable) {
|
|
68
70
|
let i18nAsstes = {};
|
|
69
|
-
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
|
70
|
-
|
|
71
|
+
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
|
72
|
+
|
|
71
73
|
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
|
72
74
|
let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
|
73
75
|
let splittedFileName = fileName.split('.');
|
|
@@ -76,30 +78,30 @@ class EFCTemplatePlugin {
|
|
|
76
78
|
}, {});
|
|
77
79
|
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
|
78
80
|
}
|
|
81
|
+
|
|
79
82
|
let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
|
80
83
|
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
|
81
84
|
}
|
|
85
|
+
|
|
82
86
|
templateReplacer(entryPoint, compilation) {
|
|
83
|
-
const cssDirTemplate = '@dir@';
|
|
84
|
-
// const i18nManifest = this.getI18nManifest(compilation);
|
|
87
|
+
const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
|
|
85
88
|
|
|
86
89
|
const initialFiles = entryPoint.getFiles();
|
|
87
90
|
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
|
|
88
91
|
const initialJsFiles = filteredInitialFiles.filter(file => /\.js$/.test(file));
|
|
89
92
|
let initialCssFiles = filteredInitialFiles.filter(file => /\.css$/.test(file));
|
|
93
|
+
|
|
90
94
|
if (enableRTLSplit) {
|
|
91
95
|
initialCssFiles = initialCssFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// const i18nAssets = getShortI18nAssets(
|
|
96
|
+
} // const i18nAssets = getShortI18nAssets(
|
|
95
97
|
// entryPoint.chunks,
|
|
96
98
|
// i18nManifest,
|
|
97
99
|
// '' // i18nJsPath
|
|
98
100
|
// );
|
|
99
101
|
|
|
102
|
+
|
|
100
103
|
const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
|
|
101
104
|
);
|
|
102
|
-
|
|
103
105
|
let templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
|
|
104
106
|
return templateStr.replace('((\'getInitalAssets\'))', `function getInitalAssets(assetsType, lang) {
|
|
105
107
|
if (assetsType === "js") {
|
|
@@ -114,29 +116,36 @@ class EFCTemplatePlugin {
|
|
|
114
116
|
return [];
|
|
115
117
|
}`).replace('((\'@dir@\'))', '\'@dir@\'').replace('((\'publicPath\'))', this.publicPath).replace('((\'@locale@\'))', '\'@locale@\'');
|
|
116
118
|
}
|
|
119
|
+
|
|
117
120
|
apply(compiler) {
|
|
118
121
|
if (!createSDkFile) {
|
|
119
122
|
return;
|
|
120
123
|
}
|
|
124
|
+
|
|
121
125
|
compiler.hooks.emit.tap('EFCTemplatePlugin', compilation => {
|
|
122
126
|
const {
|
|
123
127
|
entryPointName,
|
|
124
128
|
outputFile
|
|
125
129
|
} = this;
|
|
126
130
|
const entryPoint = compilation.entrypoints.get(entryPointName);
|
|
131
|
+
|
|
127
132
|
if (!entryPoint) {
|
|
128
133
|
return;
|
|
129
134
|
}
|
|
135
|
+
|
|
130
136
|
if (!(0, _fs.existsSync)(this.templateFilePath)) {
|
|
131
137
|
console.error(`EFC Template file not exists ${this.templateFilePath}`);
|
|
132
138
|
return;
|
|
133
139
|
}
|
|
140
|
+
|
|
134
141
|
const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
|
|
135
|
-
compilation.assets[outputFile] = source;
|
|
136
|
-
// console.log('EFCTemplatePlugin working');
|
|
142
|
+
compilation.assets[outputFile] = source; // console.log('EFCTemplatePlugin working');
|
|
137
143
|
// eslint-disable-next-line no-console
|
|
144
|
+
|
|
138
145
|
console.log('The EFC embedded code was created successfully..!!!');
|
|
139
146
|
});
|
|
140
147
|
}
|
|
148
|
+
|
|
141
149
|
}
|
|
150
|
+
|
|
142
151
|
exports.default = EFCTemplatePlugin;
|
|
@@ -4,22 +4,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
9
|
+
|
|
8
10
|
var _utils = require("../utils");
|
|
11
|
+
|
|
9
12
|
var _urlConcat = require("../utils/urlConcat");
|
|
13
|
+
|
|
10
14
|
var _path = _interopRequireDefault(require("path"));
|
|
15
|
+
|
|
11
16
|
var _webpackSources = require("webpack-sources");
|
|
17
|
+
|
|
12
18
|
var _hashUtils = require("./I18nSplitPlugin/utils/hashUtils");
|
|
19
|
+
|
|
13
20
|
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
|
21
|
+
|
|
14
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
15
24
|
let i18nObj = null;
|
|
16
25
|
let options = (0, _utils.getOptions)();
|
|
26
|
+
|
|
17
27
|
function newAssign(target, data) {
|
|
18
28
|
return Object.assign({}, target, data);
|
|
19
29
|
}
|
|
30
|
+
|
|
20
31
|
const {
|
|
21
32
|
i18n
|
|
22
33
|
} = options;
|
|
34
|
+
|
|
23
35
|
class I18NInjectIntoIndexPlugin {
|
|
24
36
|
constructor(options) {
|
|
25
37
|
this.isDevelopment = options.isDevelopment;
|
|
@@ -29,30 +41,35 @@ class I18NInjectIntoIndexPlugin {
|
|
|
29
41
|
this.i18nManifestFileName = options.i18nManifestFileName;
|
|
30
42
|
this.entryPointName = options.mainChunkName;
|
|
31
43
|
}
|
|
44
|
+
|
|
32
45
|
getI18nFileUrlPath(chunk, compilation) {
|
|
33
46
|
let urlpath = (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, this.templateLabel);
|
|
34
47
|
return (0, _urlConcat.urlConcat)(this.publicPath, urlpath);
|
|
35
48
|
}
|
|
49
|
+
|
|
36
50
|
getI18nManifest(compilation) {
|
|
37
51
|
const i18nManifestFile = compilation.assets[this.i18nManifestFileName];
|
|
52
|
+
|
|
38
53
|
if (!i18nManifestFile) {
|
|
39
54
|
return {};
|
|
40
55
|
}
|
|
56
|
+
|
|
41
57
|
const manifest = JSON.parse(i18nManifestFile.source());
|
|
42
58
|
return manifest;
|
|
43
59
|
}
|
|
60
|
+
|
|
44
61
|
injectI18nURLsToHTML(compilation) {
|
|
45
62
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync('I18NInjectIntoIndexPlugin', (data, cb) => {
|
|
46
63
|
const {
|
|
47
64
|
assets
|
|
48
|
-
} = data;
|
|
49
|
-
|
|
65
|
+
} = data; // Manipulate the content
|
|
66
|
+
|
|
50
67
|
const i18nManifest = this.getI18nManifest(compilation);
|
|
51
68
|
const entryPoint = compilation.entrypoints.get(this.entryPointName);
|
|
52
|
-
const i18nScriptURLs = entryPoint.chunks.filter(c => !!i18nManifest[c.id]).map(c => this.getI18nFileUrlPath(c, compilation));
|
|
53
|
-
// .map(url => getI18nScriptTagObj(url));
|
|
69
|
+
const i18nScriptURLs = entryPoint.chunks.filter(c => !!i18nManifest[c.id]).map(c => this.getI18nFileUrlPath(c, compilation)); // .map(url => getI18nScriptTagObj(url));
|
|
54
70
|
// .join('');
|
|
55
71
|
// Tell webpack to move on
|
|
72
|
+
|
|
56
73
|
cb(null, newAssign(data, {
|
|
57
74
|
assets: newAssign(assets, {
|
|
58
75
|
js: i18nScriptURLs.concat(assets.js)
|
|
@@ -60,6 +77,7 @@ class I18NInjectIntoIndexPlugin {
|
|
|
60
77
|
}));
|
|
61
78
|
});
|
|
62
79
|
}
|
|
80
|
+
|
|
63
81
|
withI18nSpitHandling(compiler) {
|
|
64
82
|
compiler.hooks.make.tap('I18NInjectIntoIndexPlugin', compilation => {
|
|
65
83
|
// let cdns = Object.keys(this.publicPaths);
|
|
@@ -68,17 +86,19 @@ class I18NInjectIntoIndexPlugin {
|
|
|
68
86
|
this.injectI18nURLsToHTML(compilation);
|
|
69
87
|
return;
|
|
70
88
|
}
|
|
89
|
+
|
|
71
90
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeEmit.tapAsync('I18NInjectIntoIndexPlugin', (data, cb) => {
|
|
72
91
|
// Manipulate the content
|
|
73
92
|
const i18nManifest = this.getI18nManifest(compilation);
|
|
74
93
|
const entryPoint = compilation.entrypoints.get(this.entryPointName);
|
|
75
94
|
let i18nAssets = (0, _hashUtils.getShortI18nAssets)(entryPoint.chunks, i18nManifest, this.publicPath);
|
|
76
|
-
data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets)));
|
|
77
|
-
|
|
95
|
+
data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets))); // Tell webpack to move on
|
|
96
|
+
|
|
78
97
|
cb(null, data);
|
|
79
98
|
});
|
|
80
99
|
});
|
|
81
100
|
}
|
|
101
|
+
|
|
82
102
|
apply(compiler) {
|
|
83
103
|
if (i18n.chunkSplitEnable) {
|
|
84
104
|
this.withI18nSpitHandling(compiler);
|
|
@@ -86,30 +106,36 @@ class I18NInjectIntoIndexPlugin {
|
|
|
86
106
|
this.withoutI18nSpitHandling(compiler);
|
|
87
107
|
}
|
|
88
108
|
}
|
|
109
|
+
|
|
89
110
|
withoutI18nSpitHandling(compiler) {
|
|
90
111
|
compiler.hooks.emit.tap('I18NInjectIntoIndexPlugin', compilation => {
|
|
91
112
|
// let cdns = Object.keys(this.publicPaths);
|
|
92
113
|
if (i18nObj === null) {
|
|
93
|
-
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
|
94
|
-
|
|
114
|
+
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
|
115
|
+
|
|
95
116
|
i18nObj = i18nFiles.reduce((res, next) => {
|
|
96
117
|
let fileName = next.replace(`i18n${_path.default.sep}`, '');
|
|
97
118
|
let splittedFileName = fileName.split('.');
|
|
98
|
-
/* if (this.isDevelopment) {
|
|
99
|
-
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
|
100
|
-
} else {
|
|
101
|
-
res[splittedFileName[0]] = fileName;
|
|
119
|
+
/* if (this.isDevelopment) {
|
|
120
|
+
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
|
121
|
+
} else {
|
|
122
|
+
res[splittedFileName[0]] = fileName;
|
|
102
123
|
} */
|
|
124
|
+
|
|
103
125
|
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
|
104
126
|
return res;
|
|
105
127
|
}, {});
|
|
106
128
|
}
|
|
129
|
+
|
|
107
130
|
let [indexFile] = Object.keys(compilation.assets).filter(filename => /\.html$/g.test(filename));
|
|
131
|
+
|
|
108
132
|
if (indexFile) {
|
|
109
133
|
let source = compilation.assets[indexFile].source();
|
|
110
134
|
compilation.assets[indexFile] = new _webpackSources.RawSource(source.replace(new RegExp('<!--I18nInfoToServer(.*)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nObj))));
|
|
111
135
|
}
|
|
112
136
|
});
|
|
113
137
|
}
|
|
138
|
+
|
|
114
139
|
}
|
|
140
|
+
|
|
115
141
|
exports.default = I18NInjectIntoIndexPlugin;
|
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _utils = require("./utils");
|
|
8
|
-
|
|
9
|
-
// this plugin only for debug related purpose
|
|
9
|
+
|
|
10
|
+
const pluginName = 'I18nDebugPlugin'; // this plugin only for debug related purpose
|
|
10
11
|
|
|
11
12
|
class I18nDebugPlugin {
|
|
12
13
|
constructor(jsResourceI18nKeys) {
|
|
13
14
|
this.jsResourceI18nKeys = jsResourceI18nKeys;
|
|
14
15
|
this.warnings = [];
|
|
15
16
|
}
|
|
17
|
+
|
|
16
18
|
apply(compiler) {
|
|
17
19
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation, compilationParams) => {
|
|
18
20
|
// TEMP : only for debugging purpose
|
|
@@ -22,21 +24,22 @@ class I18nDebugPlugin {
|
|
|
22
24
|
compiler.hooks.normalModuleFactory.tap(pluginName, factory => {
|
|
23
25
|
if (!this.compilationParams || this.compilationParams.normalModuleFactory === factory) {
|
|
24
26
|
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
+
} // console.log('skiped');
|
|
28
|
+
|
|
29
|
+
|
|
27
30
|
let handler = parser => {
|
|
28
31
|
parser.hooks.program.tap(pluginName, (ast, commmets) => {
|
|
29
32
|
const {
|
|
30
33
|
module
|
|
31
|
-
} = parser.state;
|
|
32
|
-
|
|
34
|
+
} = parser.state; //
|
|
35
|
+
|
|
33
36
|
if (!(module && /\.jsx?$/.test(module.resource))) {
|
|
34
37
|
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
38
|
+
} // i18n grep proper contract regex
|
|
39
|
+
|
|
40
|
+
|
|
37
41
|
let i18nKeys = (0, _utils.collectI18nKeysfromAST)(ast, this.jsResourceI18nKeys);
|
|
38
|
-
i18nKeys = i18nKeys.concat(
|
|
39
|
-
// i18n grep proper contract regex
|
|
42
|
+
i18nKeys = i18nKeys.concat( // i18n grep proper contract regex
|
|
40
43
|
(0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
|
|
41
44
|
i18nKeys.length && this.warnings.push({
|
|
42
45
|
message: 'skiped i18n keys',
|
|
@@ -46,10 +49,12 @@ class I18nDebugPlugin {
|
|
|
46
49
|
});
|
|
47
50
|
});
|
|
48
51
|
};
|
|
52
|
+
|
|
49
53
|
factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
|
|
50
|
-
factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
|
|
51
|
-
// factory.hooks.parser.for('javascript/esm').tap(pluginName, handler);
|
|
54
|
+
factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler); // factory.hooks.parser.for('javascript/esm').tap(pluginName, handler);
|
|
52
55
|
});
|
|
53
56
|
}
|
|
57
|
+
|
|
54
58
|
}
|
|
59
|
+
|
|
55
60
|
exports.default = I18nDebugPlugin;
|
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.I18nDependencyTemplate = exports.I18nDependency = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpack = require("webpack");
|
|
8
|
-
// const webpack = require('webpack');
|
|
9
9
|
|
|
10
|
+
// const webpack = require('webpack');
|
|
10
11
|
class I18nDependency extends _webpack.Dependency {
|
|
11
12
|
constructor({
|
|
12
13
|
identifier,
|
|
@@ -18,21 +19,26 @@ class I18nDependency extends _webpack.Dependency {
|
|
|
18
19
|
this.i18nKeys = i18nKeys;
|
|
19
20
|
this.context = context;
|
|
20
21
|
}
|
|
22
|
+
|
|
21
23
|
getResourceIdentifier() {
|
|
22
24
|
return `i18n-module-${this.identifier}-${this.identifierIndex}`;
|
|
23
25
|
}
|
|
26
|
+
|
|
24
27
|
}
|
|
28
|
+
|
|
25
29
|
exports.I18nDependency = I18nDependency;
|
|
30
|
+
|
|
26
31
|
class I18nDependencyTemplate {
|
|
27
32
|
//eslint-disable-next-line no-empty-function
|
|
28
|
-
apply() {}
|
|
29
|
-
// apply(dep, source) {
|
|
33
|
+
apply() {} // apply(dep, source) {
|
|
30
34
|
// if (typeof dep.range === "number") {
|
|
31
35
|
// source.insert(0, `/* comment by I18nSplitPlugin , i18n keys = ${JSON.stringify(dep.i18nKeys)} */`);
|
|
32
36
|
// return;
|
|
33
37
|
// }
|
|
34
|
-
|
|
35
38
|
// source.replace(dep.range[0], dep.range[1] - 1, dep.expression);
|
|
36
39
|
// }
|
|
40
|
+
|
|
41
|
+
|
|
37
42
|
}
|
|
43
|
+
|
|
38
44
|
exports.I18nDependencyTemplate = I18nDependencyTemplate;
|