@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -179
- package/.prettierrc +6 -6
- package/README.md +1028 -951
- package/bin/cli.js +483 -483
- 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/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +678 -0
- 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 +0 -4
- package/lib/babel/es-plugins-presets.js +0 -4
- package/lib/common/getEntries.js +0 -10
- package/lib/common/getPublicPathConfig.js +0 -6
- package/lib/common/index.js +0 -5
- package/lib/common/splitChunks.js +2 -13
- package/lib/common/sslcertUpdater.js +6 -17
- package/lib/common/templateParameters.js +0 -2
- package/lib/common/testPattern.js +10 -21
- package/lib/common/valueReplacer.js +0 -15
- package/lib/configs/jest.config.js +8 -21
- package/lib/configs/libAlias.js +11 -2
- package/lib/configs/webpack.component.umd.config.js +0 -5
- package/lib/configs/webpack.css.umd.config.js +5 -13
- package/lib/configs/webpack.dev.config.js +13 -24
- package/lib/configs/webpack.docs.config.js +6 -12
- package/lib/configs/webpack.impact.config.js +6 -10
- package/lib/configs/webpack.prod.config.js +15 -26
- package/lib/hooks/docsProptypeHook.js +3 -7
- package/lib/jest/commitedFilesResult.js +3 -45
- package/lib/jest/coverageCollector.js +0 -11
- package/lib/jest/jsonMaker.js +0 -6
- package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
- package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
- package/lib/jest/result.js +0 -22
- package/lib/jest/run.js +6 -17
- package/lib/jest/setup.js +5 -57
- package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
- package/lib/loaderUtils/getCSSLoaders.js +41 -28
- package/lib/loaderUtils/getDevJsLoaders.js +0 -8
- package/lib/loaderUtils/index.js +0 -3
- package/lib/loaders/docsLoader.js +0 -7
- package/lib/loaders/docsPropsLoader.js +3 -7
- package/lib/loaders/fileBountryLoader.js +0 -2
- package/lib/loaders/fileLoader.js +11 -22
- package/lib/loaders/scriptInstrumentLoader.js +5 -13
- package/lib/loaders/selectorMappingLoader.js +7 -25
- package/lib/loaders/workerLoader.js +13 -29
- package/lib/middlewares/HMRMiddleware.js +13 -26
- package/lib/middlewares/SSTMiddleware.js +0 -3
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
- package/lib/pluginUtils/getDevPlugins.js +20 -64
- package/lib/pluginUtils/getDocsPlugins.js +1 -10
- package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
- package/lib/pluginUtils/getLibraryPlugins.js +0 -5
- package/lib/pluginUtils/getProdPlugins.js +32 -78
- package/lib/pluginUtils/getServerPlugins.js +0 -5
- package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
- package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
- package/lib/pluginUtils/index.js +0 -8
- package/lib/plugins/CdnChangePlugin.js +0 -14
- package/lib/plugins/CleanupStatsPlugin.js +0 -5
- package/lib/plugins/EFCPlugin.js +23 -34
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +23 -32
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +70 -80
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
- 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 +0 -6
- package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
- package/lib/plugins/ManifestPlugin.js +0 -17
- package/lib/plugins/ModuleStatsPlugin.js +0 -23
- package/lib/plugins/OptimizeJSPlugin.js +0 -7
- package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
- package/lib/plugins/PublicPathChangePlugin.js +4 -36
- package/lib/plugins/ReportGeneratePlugin.js +4 -30
- package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
- package/lib/plugins/ResourceHintsPlugin.js +20 -27
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
- package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
- package/lib/plugins/ServiceWorkerPlugin.js +13 -29
- package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
- package/lib/plugins/SourceMapHookPlugin.js +0 -9
- package/lib/plugins/TPHashMappingPlugin.js +5 -19
- package/lib/plugins/UglifyCSSPlugin.js +0 -9
- package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
- package/lib/plugins/index.js +0 -19
- package/lib/plugins/libraryImpactPlugin.js +0 -32
- package/lib/plugins/webpackwatchrunplugin.js +0 -5
- package/lib/postcss-plugins/ExcludePlugin.js +0 -4
- package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
- package/lib/postcss-plugins/ValueReplacer.js +9 -6
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
- package/lib/postcss-plugins/variableModifier.js +14 -20
- package/lib/schemas/index.js +28 -13
- package/lib/servers/clusterHubServer.js +0 -10
- package/lib/servers/devBuild.js +13 -24
- package/lib/servers/docsServer.js +0 -2
- package/lib/servers/docsServerCore.js +0 -21
- package/lib/servers/getCliPath.js +1 -10
- package/lib/servers/helpServer.js +0 -5
- package/lib/servers/httpsOptions.js +0 -4
- package/lib/servers/impactServer.js +2 -34
- package/lib/servers/mockserver.js +0 -9
- package/lib/servers/nowatchserver.js +12 -34
- package/lib/servers/scrServer.js +13 -20
- package/lib/servers/server.js +7 -35
- package/lib/servers/ssServer.js +0 -16
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/CoverageScriptTemplate.js +0 -14
- package/lib/templates/WMSTemplate.js +6 -12
- package/lib/utils/babelPresets.js +0 -2
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +2 -8
- package/lib/utils/copy.js +0 -6
- package/lib/utils/copyTimezones.js +0 -8
- package/lib/utils/createEventStream.js +0 -4
- package/lib/utils/cssClassNameGenerate.js +3 -19
- package/lib/utils/cssURLReplacer.js +0 -25
- package/lib/utils/dependencyPostPublish.js +0 -9
- package/lib/utils/fileUtils.js +0 -26
- package/lib/utils/folderIterator.js +0 -10
- package/lib/utils/getComponents.js +0 -21
- package/lib/utils/getCurrentBranch.js +0 -5
- package/lib/utils/getDependenciesImpactList.js +0 -21
- package/lib/utils/getHash.js +0 -7
- package/lib/utils/getIp.js +0 -2
- package/lib/utils/getOptions.js +38 -35
- package/lib/utils/getServerURL.js +0 -7
- package/lib/utils/index.js +2 -47
- package/lib/utils/init.js +0 -1
- package/lib/utils/initPreCommitHook.js +6 -29
- package/lib/utils/jsonHelper.js +2 -19
- package/lib/utils/libraryImpactConfig.js +0 -2
- 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/mailSender.js +0 -7
- package/lib/utils/pullOrigin.js +0 -4
- package/lib/utils/reinstallDependencies.js +0 -28
- package/lib/utils/removeAttributes.js +0 -7
- package/lib/utils/repoClone.js +2 -27
- package/lib/utils/request.js +0 -12
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +4 -16
- package/lib/utils/setEnvVariables.js +0 -2
- package/lib/utils/ssTestHack.js +0 -10
- package/lib/utils/switchBranch.js +0 -4
- package/lib/utils/urlConcat.js +0 -4
- package/lib/utils/useExitCleanup.js +9 -10
- package/npm8.md +9 -9
- package/package.json +146 -148
- 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 -1493
- 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,24 +4,16 @@ 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 _path = _interopRequireDefault(require("path"));
|
13
|
-
|
14
10
|
var _fs = require("fs");
|
15
|
-
|
16
11
|
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
17
|
-
|
18
12
|
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
|
19
|
-
|
20
13
|
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
21
|
-
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
|
-
|
24
15
|
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
16
|
+
|
25
17
|
const cliOptions = (0, _utils.getOptions)();
|
26
18
|
const {
|
27
19
|
i18n: {
|
@@ -34,25 +26,32 @@ const {
|
|
34
26
|
} = cliOptions;
|
35
27
|
const {
|
36
28
|
createSDkFile
|
37
|
-
} = efcOptios;
|
29
|
+
} = efcOptios;
|
30
|
+
|
31
|
+
// for smap relate changes
|
38
32
|
// CdnChangePlugin
|
39
33
|
// SourceMapHookPlugin
|
40
34
|
|
41
35
|
class EFCTemplatePlugin {
|
42
36
|
constructor(options = {}) {
|
43
37
|
// console.log(' templateFilePath ', process.cwd(), options.templateFilePath, templateFilePath);
|
44
|
-
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
|
45
|
-
|
38
|
+
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
|
39
|
+
// console.log(' templateFilePath ', this.templateFilePath);
|
46
40
|
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
47
|
-
this.publicPath = options.publicPath;
|
41
|
+
this.publicPath = options.publicPath;
|
42
|
+
|
43
|
+
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
48
44
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
45
|
+
|
49
46
|
// IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
|
50
47
|
// So when debugging consider this as well
|
51
48
|
// this.options = Object.assign({}, efcOptios, options);
|
52
49
|
|
53
50
|
this.entryPointName = options.entryPointName || 'efc';
|
54
51
|
this.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
|
55
|
-
}
|
52
|
+
}
|
53
|
+
|
54
|
+
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
56
55
|
// getI18nManifest(compilation) {
|
57
56
|
// const i18nManifestFile =
|
58
57
|
// compilation.assets[this.options.i18nManifestFileName];
|
@@ -63,13 +62,12 @@ class EFCTemplatePlugin {
|
|
63
62
|
// return {};
|
64
63
|
// }
|
65
64
|
|
66
|
-
|
67
65
|
getI18nAssetsStr(entryPoint, compilation) {
|
68
66
|
// NOTE: we have used lang variable inside
|
69
67
|
if (!chunkSplitEnable) {
|
70
68
|
let i18nAsstes = {};
|
71
|
-
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
72
|
-
|
69
|
+
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
70
|
+
//hook for i18n url contains i18n/ may cause problem
|
73
71
|
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
74
72
|
let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
75
73
|
let splittedFileName = fileName.split('.');
|
@@ -78,30 +76,30 @@ class EFCTemplatePlugin {
|
|
78
76
|
}, {});
|
79
77
|
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
80
78
|
}
|
81
|
-
|
82
79
|
let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
83
80
|
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
84
81
|
}
|
85
|
-
|
86
82
|
templateReplacer(entryPoint, compilation) {
|
87
|
-
const cssDirTemplate = '@dir@';
|
83
|
+
const cssDirTemplate = '@dir@';
|
84
|
+
// const i18nManifest = this.getI18nManifest(compilation);
|
88
85
|
|
89
86
|
const initialFiles = entryPoint.getFiles();
|
90
87
|
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
|
91
88
|
const initialJsFiles = filteredInitialFiles.filter(file => /\.js$/.test(file));
|
92
89
|
let initialCssFiles = filteredInitialFiles.filter(file => /\.css$/.test(file));
|
93
|
-
|
94
90
|
if (enableRTLSplit) {
|
95
91
|
initialCssFiles = initialCssFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate));
|
96
|
-
}
|
92
|
+
}
|
93
|
+
|
94
|
+
// const i18nAssets = getShortI18nAssets(
|
97
95
|
// entryPoint.chunks,
|
98
96
|
// i18nManifest,
|
99
97
|
// '' // i18nJsPath
|
100
98
|
// );
|
101
99
|
|
102
|
-
|
103
100
|
const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
|
104
101
|
);
|
102
|
+
|
105
103
|
let templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
|
106
104
|
return templateStr.replace('((\'getInitalAssets\'))', `function getInitalAssets(assetsType, lang) {
|
107
105
|
if (assetsType === "js") {
|
@@ -116,36 +114,29 @@ class EFCTemplatePlugin {
|
|
116
114
|
return [];
|
117
115
|
}`).replace('((\'@dir@\'))', '\'@dir@\'').replace('((\'publicPath\'))', this.publicPath).replace('((\'@locale@\'))', '\'@locale@\'');
|
118
116
|
}
|
119
|
-
|
120
117
|
apply(compiler) {
|
121
118
|
if (!createSDkFile) {
|
122
119
|
return;
|
123
120
|
}
|
124
|
-
|
125
121
|
compiler.hooks.emit.tap('EFCTemplatePlugin', compilation => {
|
126
122
|
const {
|
127
123
|
entryPointName,
|
128
124
|
outputFile
|
129
125
|
} = this;
|
130
126
|
const entryPoint = compilation.entrypoints.get(entryPointName);
|
131
|
-
|
132
127
|
if (!entryPoint) {
|
133
128
|
return;
|
134
129
|
}
|
135
|
-
|
136
130
|
if (!(0, _fs.existsSync)(this.templateFilePath)) {
|
137
131
|
console.error(`EFC Template file not exists ${this.templateFilePath}`);
|
138
132
|
return;
|
139
133
|
}
|
140
|
-
|
141
134
|
const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
|
142
|
-
compilation.assets[outputFile] = source;
|
135
|
+
compilation.assets[outputFile] = source;
|
136
|
+
// console.log('EFCTemplatePlugin working');
|
143
137
|
// eslint-disable-next-line no-console
|
144
|
-
|
145
138
|
console.log('The EFC embedded code was created successfully..!!!');
|
146
139
|
});
|
147
140
|
}
|
148
|
-
|
149
141
|
}
|
150
|
-
|
151
142
|
exports.default = EFCTemplatePlugin;
|
@@ -4,34 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
9
|
-
|
10
8
|
var _utils = require("../utils");
|
11
|
-
|
12
9
|
var _urlConcat = require("../utils/urlConcat");
|
13
|
-
|
14
10
|
var _path = _interopRequireDefault(require("path"));
|
15
|
-
|
16
11
|
var _webpackSources = require("webpack-sources");
|
17
|
-
|
18
12
|
var _hashUtils = require("./I18nSplitPlugin/utils/hashUtils");
|
19
|
-
|
20
13
|
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
21
|
-
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
|
-
|
24
15
|
let i18nObj = null;
|
25
16
|
let options = (0, _utils.getOptions)();
|
26
|
-
|
27
17
|
function newAssign(target, data) {
|
28
18
|
return Object.assign({}, target, data);
|
29
19
|
}
|
30
|
-
|
31
20
|
const {
|
32
21
|
i18n
|
33
22
|
} = options;
|
34
|
-
|
35
23
|
class I18NInjectIntoIndexPlugin {
|
36
24
|
constructor(options) {
|
37
25
|
this.isDevelopment = options.isDevelopment;
|
@@ -41,35 +29,30 @@ class I18NInjectIntoIndexPlugin {
|
|
41
29
|
this.i18nManifestFileName = options.i18nManifestFileName;
|
42
30
|
this.entryPointName = options.mainChunkName;
|
43
31
|
}
|
44
|
-
|
45
32
|
getI18nFileUrlPath(chunk, compilation) {
|
46
33
|
let urlpath = (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, this.templateLabel);
|
47
34
|
return (0, _urlConcat.urlConcat)(this.publicPath, urlpath);
|
48
35
|
}
|
49
|
-
|
50
36
|
getI18nManifest(compilation) {
|
51
37
|
const i18nManifestFile = compilation.assets[this.i18nManifestFileName];
|
52
|
-
|
53
38
|
if (!i18nManifestFile) {
|
54
39
|
return {};
|
55
40
|
}
|
56
|
-
|
57
41
|
const manifest = JSON.parse(i18nManifestFile.source());
|
58
42
|
return manifest;
|
59
43
|
}
|
60
|
-
|
61
44
|
injectI18nURLsToHTML(compilation) {
|
62
45
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync('I18NInjectIntoIndexPlugin', (data, cb) => {
|
63
46
|
const {
|
64
47
|
assets
|
65
|
-
} = data;
|
66
|
-
|
48
|
+
} = data;
|
49
|
+
// Manipulate the content
|
67
50
|
const i18nManifest = this.getI18nManifest(compilation);
|
68
51
|
const entryPoint = compilation.entrypoints.get(this.entryPointName);
|
69
|
-
const i18nScriptURLs = entryPoint.chunks.filter(c => !!i18nManifest[c.id]).map(c => this.getI18nFileUrlPath(c, compilation));
|
52
|
+
const i18nScriptURLs = entryPoint.chunks.filter(c => !!i18nManifest[c.id]).map(c => this.getI18nFileUrlPath(c, compilation));
|
53
|
+
// .map(url => getI18nScriptTagObj(url));
|
70
54
|
// .join('');
|
71
55
|
// Tell webpack to move on
|
72
|
-
|
73
56
|
cb(null, newAssign(data, {
|
74
57
|
assets: newAssign(assets, {
|
75
58
|
js: i18nScriptURLs.concat(assets.js)
|
@@ -77,7 +60,6 @@ class I18NInjectIntoIndexPlugin {
|
|
77
60
|
}));
|
78
61
|
});
|
79
62
|
}
|
80
|
-
|
81
63
|
withI18nSpitHandling(compiler) {
|
82
64
|
compiler.hooks.make.tap('I18NInjectIntoIndexPlugin', compilation => {
|
83
65
|
// let cdns = Object.keys(this.publicPaths);
|
@@ -86,19 +68,17 @@ class I18NInjectIntoIndexPlugin {
|
|
86
68
|
this.injectI18nURLsToHTML(compilation);
|
87
69
|
return;
|
88
70
|
}
|
89
|
-
|
90
71
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeEmit.tapAsync('I18NInjectIntoIndexPlugin', (data, cb) => {
|
91
72
|
// Manipulate the content
|
92
73
|
const i18nManifest = this.getI18nManifest(compilation);
|
93
74
|
const entryPoint = compilation.entrypoints.get(this.entryPointName);
|
94
75
|
let i18nAssets = (0, _hashUtils.getShortI18nAssets)(entryPoint.chunks, i18nManifest, this.publicPath);
|
95
|
-
data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets)));
|
96
|
-
|
76
|
+
data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets)));
|
77
|
+
// Tell webpack to move on
|
97
78
|
cb(null, data);
|
98
79
|
});
|
99
80
|
});
|
100
81
|
}
|
101
|
-
|
102
82
|
apply(compiler) {
|
103
83
|
if (i18n.chunkSplitEnable) {
|
104
84
|
this.withI18nSpitHandling(compiler);
|
@@ -106,36 +86,30 @@ class I18NInjectIntoIndexPlugin {
|
|
106
86
|
this.withoutI18nSpitHandling(compiler);
|
107
87
|
}
|
108
88
|
}
|
109
|
-
|
110
89
|
withoutI18nSpitHandling(compiler) {
|
111
90
|
compiler.hooks.emit.tap('I18NInjectIntoIndexPlugin', compilation => {
|
112
91
|
// let cdns = Object.keys(this.publicPaths);
|
113
92
|
if (i18nObj === null) {
|
114
|
-
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
115
|
-
|
93
|
+
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
94
|
+
//hook for i18n url contains i18n/ may cause problem
|
116
95
|
i18nObj = i18nFiles.reduce((res, next) => {
|
117
96
|
let fileName = next.replace(`i18n${_path.default.sep}`, '');
|
118
97
|
let splittedFileName = fileName.split('.');
|
119
|
-
/* if (this.isDevelopment) {
|
120
|
-
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
121
|
-
} else {
|
122
|
-
res[splittedFileName[0]] = fileName;
|
98
|
+
/* if (this.isDevelopment) {
|
99
|
+
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
100
|
+
} else {
|
101
|
+
res[splittedFileName[0]] = fileName;
|
123
102
|
} */
|
124
|
-
|
125
103
|
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
126
104
|
return res;
|
127
105
|
}, {});
|
128
106
|
}
|
129
|
-
|
130
107
|
let [indexFile] = Object.keys(compilation.assets).filter(filename => /\.html$/g.test(filename));
|
131
|
-
|
132
108
|
if (indexFile) {
|
133
109
|
let source = compilation.assets[indexFile].source();
|
134
110
|
compilation.assets[indexFile] = new _webpackSources.RawSource(source.replace(new RegExp('<!--I18nInfoToServer(.*)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nObj))));
|
135
111
|
}
|
136
112
|
});
|
137
113
|
}
|
138
|
-
|
139
114
|
}
|
140
|
-
|
141
115
|
exports.default = I18NInjectIntoIndexPlugin;
|
@@ -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
|
@@ -24,22 +22,21 @@ class I18nDebugPlugin {
|
|
24
22
|
compiler.hooks.normalModuleFactory.tap(pluginName, factory => {
|
25
23
|
if (!this.compilationParams || this.compilationParams.normalModuleFactory === factory) {
|
26
24
|
return;
|
27
|
-
}
|
28
|
-
|
29
|
-
|
25
|
+
}
|
26
|
+
// console.log('skiped');
|
30
27
|
let handler = parser => {
|
31
28
|
parser.hooks.program.tap(pluginName, (ast, commmets) => {
|
32
29
|
const {
|
33
30
|
module
|
34
|
-
} = parser.state;
|
35
|
-
|
31
|
+
} = parser.state;
|
32
|
+
//
|
36
33
|
if (!(module && /\.jsx?$/.test(module.resource))) {
|
37
34
|
return;
|
38
|
-
}
|
39
|
-
|
40
|
-
|
35
|
+
}
|
36
|
+
// i18n grep proper contract regex
|
41
37
|
let i18nKeys = (0, _utils.collectI18nKeysfromAST)(ast, this.jsResourceI18nKeys);
|
42
|
-
i18nKeys = i18nKeys.concat(
|
38
|
+
i18nKeys = i18nKeys.concat(
|
39
|
+
// i18n grep proper contract regex
|
43
40
|
(0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
|
44
41
|
i18nKeys.length && this.warnings.push({
|
45
42
|
message: 'skiped i18n keys',
|
@@ -49,12 +46,10 @@ class I18nDebugPlugin {
|
|
49
46
|
});
|
50
47
|
});
|
51
48
|
};
|
52
|
-
|
53
49
|
factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
|
54
|
-
factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
|
50
|
+
factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
|
51
|
+
// factory.hooks.parser.for('javascript/esm').tap(pluginName, handler);
|
55
52
|
});
|
56
53
|
}
|
57
|
-
|
58
54
|
}
|
59
|
-
|
60
55
|
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,59 +4,49 @@ 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
9
|
var _hashUtils = require("./utils/hashUtils");
|
13
|
-
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*
|
31
|
-
*
|
32
|
-
*
|
11
|
+
/**
|
12
|
+
* this plugin for the download i18n files
|
13
|
+
* So, if need to downoad i18n in browser this plugin handle that
|
14
|
+
*
|
15
|
+
*
|
16
|
+
* this plugin works
|
17
|
+
* how it works?
|
18
|
+
* this plugin hook the requireEnsure method and we write logic for current compiled file download logic
|
19
|
+
*
|
20
|
+
* hinds:-
|
21
|
+
* requireEnsure method was loader for all js chunk's ,
|
22
|
+
* which means if we use dynamic import then this function will create script tag for that dynamic resource
|
23
|
+
* so every dynamic js chunk will load by this function,
|
24
|
+
* So we update this function with when dynamic jschunk call the nour code also execute
|
25
|
+
*
|
26
|
+
* some thing missing in this definetion
|
27
|
+
*
|
33
28
|
*/
|
29
|
+
|
34
30
|
// import { REGEXP_HASH, REGEXP_CHUNKHASH } from './utils/hashUtils';
|
35
|
-
const pluginName = 'DownloadLogicOfI18n'; // const pluginName = 'i18n-plugin';
|
36
31
|
|
32
|
+
const pluginName = 'DownloadLogicOfI18n';
|
33
|
+
// const pluginName = 'i18n-plugin';
|
37
34
|
const MODULE_TYPE = 'json/i18n';
|
38
|
-
|
39
35
|
const ltype = locale => `${MODULE_TYPE}/${locale}`;
|
40
|
-
|
41
36
|
function hashesWithLength(hashes, length) {
|
42
37
|
const shortChunkHashMap = {};
|
43
|
-
|
44
38
|
for (let key of Object.keys(hashes)) {
|
45
39
|
if (typeof hashes[key] === 'string') {
|
46
40
|
shortChunkHashMap[key] = hashes.slice(0, length);
|
47
41
|
}
|
48
42
|
}
|
49
|
-
|
50
43
|
return shortChunkHashMap;
|
51
44
|
}
|
52
|
-
|
53
45
|
function getContentHashMaxLength(filenameTemplate) {
|
54
46
|
let length = 0;
|
55
47
|
let matches = filenameTemplate.match(_hashUtils.REGEXP_CONTENTHASH);
|
56
|
-
|
57
48
|
for (let match of matches) {
|
58
49
|
let tem = match.match(/\d+/);
|
59
|
-
|
60
50
|
if (tem) {
|
61
51
|
length = Math.max(parseInt(tem[0]), length);
|
62
52
|
} else {
|
@@ -64,10 +54,8 @@ function getContentHashMaxLength(filenameTemplate) {
|
|
64
54
|
break;
|
65
55
|
}
|
66
56
|
}
|
67
|
-
|
68
57
|
return length;
|
69
58
|
}
|
70
|
-
|
71
59
|
class I18nDownlodLogic {
|
72
60
|
constructor({
|
73
61
|
filenameTemplate,
|
@@ -82,67 +70,53 @@ class I18nDownlodLogic {
|
|
82
70
|
localeVarName
|
83
71
|
};
|
84
72
|
}
|
85
|
-
|
86
73
|
getShortContentHashes(chunk, hashLength) {
|
87
74
|
let allContenHashes = {};
|
88
75
|
const chunkMaps = chunk.getChunkMaps();
|
89
76
|
this.locales.forEach(locale => {
|
90
77
|
allContenHashes[locale] = chunkMaps.contentHash[ltype(locale)];
|
91
78
|
});
|
92
|
-
|
93
79
|
if (!length) {
|
94
80
|
return allContenHashes;
|
95
81
|
}
|
96
|
-
|
97
82
|
let shortContentHashMap = {};
|
98
|
-
|
99
83
|
for (const locale of this.locales) {
|
100
84
|
shortContentHashMap[locale] = hashesWithLength(allContenHashes[locale], hashLength);
|
101
85
|
}
|
102
|
-
|
103
86
|
return shortContentHashMap;
|
104
87
|
}
|
105
|
-
|
106
88
|
getI18nChunkObject(mainChunk) {
|
107
89
|
const obj = {};
|
108
|
-
|
109
90
|
for (const chunk of mainChunk.getAllAsyncChunks()) {
|
110
91
|
if (_I18nKeysIdentifer.default.isChunkHasI18n(chunk)) {
|
111
92
|
obj[chunk.id] = 1;
|
112
93
|
}
|
113
94
|
}
|
114
|
-
|
115
95
|
return obj;
|
116
96
|
}
|
117
|
-
|
118
97
|
addDownloadLogicOfI18nInMainTemplate(mainTemplate) {
|
119
98
|
mainTemplate.hooks.localVars.tap(pluginName, (source, mainChunk) => {
|
120
99
|
const chunkMap = this.getI18nChunkObject(mainChunk);
|
121
|
-
|
122
100
|
if (!Object.keys(chunkMap).length) {
|
123
101
|
return source;
|
124
102
|
}
|
125
|
-
|
126
103
|
return _webpack.Template.asString([source, '', '// object to store loaded I18N chunks', 'var installedI18nChunks = {', _webpack.Template.indent(mainChunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};']);
|
127
104
|
});
|
128
105
|
mainTemplate.hooks.requireEnsure.tap(pluginName, (source, mainChunk, hash) => {
|
129
|
-
/**
|
130
|
-
* for Information this is tapped in mainTemplate ,
|
131
|
-
* So this hooks argument chunk is main chunk means entry chunk mostly.
|
132
|
-
* if any chunk has i18n then we must write our download i18n logic,
|
106
|
+
/**
|
107
|
+
* for Information this is tapped in mainTemplate ,
|
108
|
+
* So this hooks argument chunk is main chunk means entry chunk mostly.
|
109
|
+
* if any chunk has i18n then we must write our download i18n logic,
|
133
110
|
*/
|
134
111
|
const chunkMap = this.getI18nChunkObject(mainChunk);
|
135
|
-
|
136
112
|
if (!Object.keys(chunkMap).length) {
|
137
113
|
return source;
|
138
114
|
}
|
139
|
-
/**
|
140
|
-
* chunkMaps has
|
141
|
-
* @property {Object} hash [it has key as chunk id and value as chunkHash ]
|
142
|
-
* @property {Object} name [it has key as chunk id and value as chunk name ]
|
115
|
+
/**
|
116
|
+
* chunkMaps has
|
117
|
+
* @property {Object} hash [it has key as chunk id and value as chunkHash ]
|
118
|
+
* @property {Object} name [it has key as chunk id and value as chunk name ]
|
143
119
|
*/
|
144
|
-
|
145
|
-
|
146
120
|
const chunkMaps = mainChunk.getChunkMaps();
|
147
121
|
const {
|
148
122
|
crossOriginLoading
|
@@ -151,19 +125,18 @@ class I18nDownlodLogic {
|
|
151
125
|
filenameTemplate,
|
152
126
|
localeVarName = 'document.documentElement.lang'
|
153
127
|
} = this.options;
|
154
|
-
const i18nSrcPath = mainTemplate.getAssetPath(JSON.stringify(filenameTemplate).replace(/\[locale\]/gi, '"+ locale +"'),
|
128
|
+
const i18nSrcPath = mainTemplate.getAssetPath(JSON.stringify(filenameTemplate).replace(/\[locale\]/gi, '"+ locale +"'),
|
129
|
+
// "i18n-chunk/[locale]/[name].[chunkhash].js"
|
155
130
|
{
|
156
131
|
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
157
132
|
hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
158
133
|
chunk: {
|
159
134
|
id: '" + chunkId + "',
|
160
135
|
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
161
|
-
|
162
136
|
hashWithLength(length) {
|
163
137
|
const shortChunkHashMap = hashesWithLength(chunkMaps.hash, length);
|
164
138
|
return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
|
165
139
|
},
|
166
|
-
|
167
140
|
// contentHash: contentHashMap,
|
168
141
|
// contentHashWithLength: contentHashLengthMap,
|
169
142
|
contentHash: {
|
@@ -176,33 +149,31 @@ class I18nDownlodLogic {
|
|
176
149
|
},
|
177
150
|
contentHashType: MODULE_TYPE
|
178
151
|
});
|
179
|
-
|
180
|
-
|
181
|
-
*
|
182
|
-
*
|
152
|
+
|
153
|
+
/** IDEA:
|
154
|
+
* as my suggestion ignore this `jsop` approch,
|
155
|
+
* Because json parse is faster then js parse.
|
156
|
+
* my suggestion is make ajax or fetch request
|
183
157
|
*/
|
184
158
|
|
185
159
|
const buf = [];
|
186
|
-
/*
|
187
|
-
if (REGEXP_HASH.test(filenameTemplate)) {
|
188
|
-
buf.push(
|
189
|
-
`var hash = ${mainTemplate.renderCurrentHashCode(hash)};`
|
190
|
-
);
|
191
|
-
}
|
192
|
-
if (REGEXP_CHUNKHASH.test(filenameTemplate)) {
|
193
|
-
buf.push(`var chunkHashes = ${JSON.stringify(chunkMaps.hash)};`);
|
194
|
-
}
|
160
|
+
/*
|
161
|
+
if (REGEXP_HASH.test(filenameTemplate)) {
|
162
|
+
buf.push(
|
163
|
+
`var hash = ${mainTemplate.renderCurrentHashCode(hash)};`
|
164
|
+
);
|
165
|
+
}
|
166
|
+
if (REGEXP_CHUNKHASH.test(filenameTemplate)) {
|
167
|
+
buf.push(`var chunkHashes = ${JSON.stringify(chunkMaps.hash)};`);
|
168
|
+
}
|
195
169
|
*/
|
196
|
-
|
197
170
|
if ((0, _hashUtils.hasContentHash)(filenameTemplate)) {
|
198
171
|
const hashLength = getContentHashMaxLength(filenameTemplate);
|
199
172
|
const contentHashes = this.getShortContentHashes(mainChunk, hashLength);
|
200
173
|
buf.push(_webpack.Template.asString(['// all i18n files contentHash ', `var i18nContentHashes = ${JSON.stringify(contentHashes)};`, '', 'if (!i18nContentHashes[locale]) {', ' console.warn("this locale is "+locale + " not has support")', ' return;', '}', 'if (!i18nContentHashes[locale][chunkId]) {', ' console.warn("this chunkId is " + chunkId + " does not have \'"+locale+"\' locale chunk")', ' return;', '}']));
|
201
174
|
buf.push('var contentHash = i18nContentHashes[locale][chunkId]');
|
202
175
|
}
|
203
|
-
|
204
176
|
const hashUtils = _webpack.Template.asString(buf);
|
205
|
-
|
206
177
|
const publicPath = this.publicPath ? JSON.stringify(this.publicPath) : `${mainTemplate.requireFn}.p`;
|
207
178
|
return _webpack.Template.asString([source, `
|
208
179
|
(function() {
|
@@ -216,7 +187,8 @@ class I18nDownlodLogic {
|
|
216
187
|
} else if(installedI18nChunks[chunkId] !== 0 && i18nChunks[chunkId]) {
|
217
188
|
promises.push(installedI18nChunks[chunkId] = new Promise(function(resolve, reject) {
|
218
189
|
var srcPath = (${i18nSrcPath});
|
219
|
-
${''
|
190
|
+
${''
|
191
|
+
// TODO: I think this is the area for download chunk of i18n we can
|
220
192
|
// change mainTemplate.requireFn as our cdn server urls !!!
|
221
193
|
// and we can change the i18n download logic here
|
222
194
|
}
|
@@ -251,7 +223,6 @@ class I18nDownlodLogic {
|
|
251
223
|
})()`]);
|
252
224
|
});
|
253
225
|
}
|
254
|
-
|
255
226
|
apply(compiler) {
|
256
227
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
257
228
|
const {
|
@@ -260,7 +231,5 @@ class I18nDownlodLogic {
|
|
260
231
|
this.addDownloadLogicOfI18nInMainTemplate(mainTemplate);
|
261
232
|
});
|
262
233
|
}
|
263
|
-
|
264
234
|
}
|
265
|
-
|
266
235
|
exports.default = I18nDownlodLogic;
|