@zohodesk/react-cli 1.1.29-exp.2 → 1.1.29-exp.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +13 -2
- package/lib/babel/es-plugins-presets.js +14 -3
- package/lib/common/buildEs.js +0 -1
- package/lib/common/getEntries.js +13 -2
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +6 -1
- package/lib/common/runPreProcess.js +15 -6
- package/lib/common/splitChunks.js +21 -2
- package/lib/common/sslcertUpdater.js +18 -7
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +16 -1
- package/lib/configs/jest.config.js +11 -2
- package/lib/configs/libAlias.js +16 -10
- package/lib/configs/resolvers.js +16 -6
- package/lib/configs/webpack.component.umd.config.js +6 -1
- package/lib/configs/webpack.css.umd.config.js +14 -6
- package/lib/configs/webpack.dev.config.js +14 -1
- package/lib/configs/webpack.docs.config.js +9 -1
- package/lib/configs/webpack.impact.config.js +8 -1
- package/lib/configs/webpack.prod.config.js +17 -4
- package/lib/constants.js +18 -9
- package/lib/deprecationLogger.js +7 -0
- package/lib/hooks/docsProptypeHook.js +8 -4
- package/lib/jest/commitedFilesResult.js +46 -4
- package/lib/jest/coverageCollector.js +12 -1
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
- package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
- package/lib/jest/result.js +23 -1
- package/lib/jest/run.js +18 -7
- package/lib/jest/setup.js +60 -8
- package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
- package/lib/loaderUtils/getCSSLoaders.js +22 -10
- package/lib/loaderUtils/getDevJsLoaders.js +13 -4
- package/lib/loaderUtils/index.js +4 -1
- package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
- package/lib/loaderUtils/windowsModification.js +3 -2
- package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
- package/lib/loaders/composeLoader.js +37 -13
- package/lib/loaders/docsLoader.js +12 -1
- package/lib/loaders/docsPropsLoader.js +8 -4
- package/lib/loaders/enhancedReactLiveConverter.js +23 -2
- package/lib/loaders/fileBountryLoader.js +3 -1
- package/lib/loaders/fileLoader.js +23 -12
- package/lib/loaders/markdownLoader.js +19 -14
- package/lib/loaders/reactLiveConvertor.js +15 -5
- package/lib/loaders/scriptInstrumentLoader.js +16 -7
- package/lib/loaders/selectorMappingLoader.js +26 -7
- package/lib/loaders/workerLoader.js +24 -9
- package/lib/logger.js +4 -0
- package/lib/middlewares/HMRMiddleware.js +27 -13
- package/lib/middlewares/SSTMiddleware.js +5 -1
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
- package/lib/pluginUtils/getDevPlugins.js +42 -9
- package/lib/pluginUtils/getDocsPlugins.js +13 -3
- package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
- package/lib/pluginUtils/getLibraryPlugins.js +8 -2
- package/lib/pluginUtils/getProdPlugins.js +47 -8
- package/lib/pluginUtils/getServerPlugins.js +8 -2
- package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
- package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
- package/lib/pluginUtils/index.js +9 -1
- package/lib/plugins/CdnChangePlugin.js +18 -2
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/CssOrderControlPlugin.js +6 -3
- package/lib/plugins/CustomAttributePlugin.js +19 -14
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
- package/lib/plugins/EFCPlugin.js +34 -20
- package/lib/plugins/EFCTemplatePlugin.js +30 -19
- package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
- package/lib/plugins/EventsHandlingPlugin.js +4 -2
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
- package/lib/plugins/I18nSplitPlugin/index.js +24 -13
- 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 +8 -1
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
- package/lib/plugins/ManifestPlugin.js +18 -1
- package/lib/plugins/MinifyPlugin.js +10 -1
- package/lib/plugins/ModuleStatsPlugin.js +24 -1
- package/lib/plugins/OptimizeJSPlugin.js +10 -2
- package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
- package/lib/plugins/PublicPathChangePlugin.js +39 -6
- package/lib/plugins/ReportGeneratePlugin.js +32 -5
- package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
- package/lib/plugins/ResourceHintsPlugin.js +13 -4
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
- package/lib/plugins/SelectorPlugin.js +32 -6
- package/lib/plugins/ServiceWorkerPlugin.js +22 -5
- package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
- package/lib/plugins/SourceMapHookPlugin.js +12 -2
- package/lib/plugins/StatsPlugin.js +14 -0
- package/lib/plugins/TPHashMappingPlugin.js +18 -3
- package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
- package/lib/plugins/VariableConversionCollector.js +42 -15
- package/lib/plugins/index.js +20 -1
- package/lib/plugins/libraryImpactPlugin.js +33 -1
- package/lib/plugins/utils/classHandling.js +6 -0
- package/lib/plugins/utils/fileHandling.js +15 -6
- package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
- package/lib/plugins/variableConvertorUtils.js +29 -14
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/EmptyPlugin.js +4 -3
- package/lib/postcss-plugins/ExcludePlugin.js +5 -1
- package/lib/postcss-plugins/IncludePlugin.js +5 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
- package/lib/postcss-plugins/SelectorReplace.js +16 -1
- package/lib/postcss-plugins/ValueReplacer.js +6 -7
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
- package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
- package/lib/schemas/index.js +10 -3
- package/lib/servers/clusterHubServer.js +11 -1
- package/lib/servers/devBuild.js +26 -14
- package/lib/servers/docsServer.js +3 -1
- package/lib/servers/docsServerCore.js +22 -1
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +6 -1
- package/lib/servers/httpsOptions.js +8 -2
- package/lib/servers/impactServer.js +35 -3
- package/lib/servers/mockserver.js +10 -1
- package/lib/servers/nowatchserver.js +37 -12
- package/lib/servers/requireLocalOrGlobal.js +17 -6
- package/lib/servers/scrServer.js +21 -14
- package/lib/servers/server.js +36 -6
- package/lib/servers/ssServer.js +17 -1
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +13 -7
- package/lib/templates/linterConstant.js +4 -2
- package/lib/utils/babelPresets.js +7 -3
- package/lib/utils/clean.js +9 -3
- package/lib/utils/copy.js +7 -1
- package/lib/utils/copyTimezones.js +9 -1
- package/lib/utils/createEventStream.js +6 -1
- package/lib/utils/cssClassNameGenerate.js +30 -10
- package/lib/utils/cssURLReplacer.js +22 -1
- package/lib/utils/dependencyPostPublish.js +10 -1
- package/lib/utils/deprecationSupport.js +32 -7
- package/lib/utils/fileUtils.js +28 -1
- package/lib/utils/folderIterator.js +13 -2
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +22 -1
- package/lib/utils/getFileType.js +10 -2
- package/lib/utils/getHash.js +8 -1
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +53 -16
- package/lib/utils/getServerURL.js +10 -1
- package/lib/utils/index.js +51 -4
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +30 -7
- package/lib/utils/jsonHelper.js +22 -3
- package/lib/utils/libraryImpactConfig.js +5 -2
- 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/log.js +1 -0
- package/lib/utils/mailSender.js +8 -1
- package/lib/utils/object-manipulation.js +17 -1
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +29 -1
- package/lib/utils/removeAttributes.js +8 -1
- package/lib/utils/repoClone.js +28 -3
- package/lib/utils/request.js +12 -0
- package/lib/utils/rtl.js +17 -5
- package/lib/utils/selectorReplacer.js +16 -10
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +11 -1
- package/lib/utils/switchBranch.js +5 -0
- package/lib/utils/typeCheck.js +1 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/lib/utils/variableConverter.js +31 -22
- package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
- package/package.json +3 -2
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
- package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
@@ -4,16 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
class CssOrderControlPlugin {
|
8
9
|
constructor(options) {
|
9
10
|
this.options = {
|
10
11
|
className: options.className
|
11
12
|
};
|
12
13
|
}
|
14
|
+
|
13
15
|
apply(compiler) {
|
14
16
|
// NOTE: we not using this, Reason currently this option is only need for EFC,
|
15
17
|
// So it do not needed.
|
16
|
-
|
17
18
|
const className = this.options.className;
|
18
19
|
compiler.hooks.thisCompilation.tap({
|
19
20
|
name: 'CssOrderControlPlugin',
|
@@ -22,12 +23,14 @@ class CssOrderControlPlugin {
|
|
22
23
|
compilation.mainTemplate.hooks.requireEnsure.tap('CssOrderControlPlugin', source => {
|
23
24
|
// const str = attributeSetTemplate(cssAttributes, 'linkTag');
|
24
25
|
const replacedStr = source.replace('head.appendChild(linkTag);', `var referenceTag = document.getElementById('${className}');
|
25
|
-
head.insertBefore(linkTag, referenceTag);`);
|
26
|
-
|
26
|
+
head.insertBefore(linkTag, referenceTag);`); // console.log({ s: source, r: replacedStr });
|
27
|
+
|
27
28
|
return replacedStr;
|
28
29
|
});
|
29
30
|
}
|
30
31
|
});
|
31
32
|
}
|
33
|
+
|
32
34
|
}
|
35
|
+
|
33
36
|
exports.default = CssOrderControlPlugin;
|
@@ -4,11 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.CustomAttributePlugin = void 0;
|
7
|
+
|
7
8
|
var _Template = _interopRequireDefault(require("webpack/lib/Template"));
|
9
|
+
|
8
10
|
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
10
|
-
/* eslint-disable no-use-before-define */
|
11
11
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
/* eslint-disable no-use-before-define */
|
12
15
|
class CustomAttributePlugin {
|
13
16
|
constructor(options) {
|
14
17
|
this.options = {
|
@@ -19,35 +22,34 @@ class CustomAttributePlugin {
|
|
19
22
|
i18nAttributes: options.i18nAttributes || options.attributes || {}
|
20
23
|
};
|
21
24
|
}
|
25
|
+
|
22
26
|
addCustomAttributeToDynamicScriptTags(mainTemplate) {
|
23
27
|
const {
|
24
28
|
jsAttributes,
|
25
29
|
cssAttributes,
|
26
30
|
i18nAttributes
|
27
|
-
} = this.options;
|
31
|
+
} = this.options; // NOTE: To add custom Attributes to js Script tags
|
28
32
|
|
29
|
-
// NOTE: To add custom Attributes to js Script tags
|
30
33
|
mainTemplate.hooks.jsonpScript.tap('CustomAttributePlugin', source => {
|
31
34
|
const str = attributeSetTemplate(jsAttributes, 'script');
|
32
35
|
return _Template.default.asString([source, ...str]);
|
33
|
-
});
|
36
|
+
}); // NOTE: To add custom Attributes to css link tags
|
34
37
|
|
35
|
-
// NOTE: To add custom Attributes to css link tags
|
36
38
|
mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
|
37
39
|
const str = attributeSetTemplate(cssAttributes, 'linkTag');
|
38
|
-
const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`);
|
39
|
-
|
40
|
+
const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`); // console.log({ s: source, r: replacedStr });
|
41
|
+
|
40
42
|
return replacedStr;
|
41
|
-
});
|
43
|
+
}); // NOTE: To add custom Attributes to i18n split js Script tags
|
42
44
|
|
43
|
-
// NOTE: To add custom Attributes to i18n split js Script tags
|
44
45
|
mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
|
45
46
|
const str = attributeSetTemplate(i18nAttributes, 'scriptTag');
|
46
|
-
const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`);
|
47
|
-
|
47
|
+
const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`); // console.log({ s: source, r: replacedStr });
|
48
|
+
|
48
49
|
return replacedStr;
|
49
50
|
});
|
50
51
|
}
|
52
|
+
|
51
53
|
apply(compiler) {
|
52
54
|
// NOTE: we not using this, Reason currently this option is only need for EFC,
|
53
55
|
// So it do not needed.
|
@@ -64,14 +66,17 @@ class CustomAttributePlugin {
|
|
64
66
|
}
|
65
67
|
});
|
66
68
|
}
|
69
|
+
|
67
70
|
}
|
71
|
+
|
68
72
|
exports.CustomAttributePlugin = CustomAttributePlugin;
|
73
|
+
|
69
74
|
function attributeSetTemplate(jsAttributes, variableName) {
|
70
75
|
let str = [];
|
71
76
|
Object.keys(jsAttributes).forEach(key => {
|
72
77
|
const val = jsAttributes[key];
|
73
78
|
str.push(`${variableName}.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(val)});`);
|
74
|
-
});
|
75
|
-
|
79
|
+
}); // console.log({ str });
|
80
|
+
|
76
81
|
return str;
|
77
82
|
}
|
@@ -4,9 +4,13 @@ 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"));
|
8
|
-
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
9
12
|
const pluginName = 'CustomScriptLoadingStrategyPlugin';
|
13
|
+
|
10
14
|
class CustomScriptLoadingStrategyPlugin {
|
11
15
|
constructor({
|
12
16
|
scriptLoadingStategey
|
@@ -14,57 +18,69 @@ class CustomScriptLoadingStrategyPlugin {
|
|
14
18
|
this.scriptLoadingStrategy = scriptLoadingStategey;
|
15
19
|
this.tagNamesToMatch = ['script'];
|
16
20
|
}
|
21
|
+
|
17
22
|
getFileNameFromTagSrc(src) {
|
18
23
|
const fileNameArr = src.split('/');
|
19
24
|
return fileNameArr[fileNameArr.length - 1];
|
20
25
|
}
|
26
|
+
|
21
27
|
addAttributestToTag(tag, attributes) {
|
22
28
|
tag.attributes = Object.assign({}, tag.attributes, attributes);
|
23
29
|
}
|
30
|
+
|
24
31
|
matchFileName(tag, fileName) {
|
25
32
|
return fileName.test(this.getFileNameFromTagSrc(tag.attributes.src));
|
26
33
|
}
|
34
|
+
|
27
35
|
blockingStrategy(tag) {
|
28
36
|
delete tag.attributes.defer;
|
29
37
|
delete tag.attributes.async;
|
30
38
|
}
|
39
|
+
|
31
40
|
deferStrategy(tag) {
|
32
41
|
delete tag.attributes.async;
|
33
42
|
}
|
43
|
+
|
34
44
|
asyncStrategy(tag) {
|
35
45
|
delete tag.attributes.defer;
|
36
46
|
}
|
47
|
+
|
37
48
|
moduleStrategy(tag) {
|
38
49
|
this.deferStrategy(tag);
|
39
50
|
}
|
51
|
+
|
40
52
|
matchStrategy(scriptLoadingStrategy, tag) {
|
41
53
|
if (scriptLoadingStrategy === 'blocking') {
|
42
54
|
this.blockingStrategy(tag);
|
43
55
|
}
|
56
|
+
|
44
57
|
if (scriptLoadingStrategy === 'defer') {
|
45
58
|
this.deferStrategy(tag);
|
46
59
|
}
|
60
|
+
|
47
61
|
if (scriptLoadingStrategy === 'async') {
|
48
62
|
this.asyncStrategy(tag);
|
49
63
|
}
|
64
|
+
|
50
65
|
if (scriptLoadingStrategy === 'module') {
|
51
66
|
this.moduleStrategy(tag);
|
52
67
|
}
|
53
68
|
}
|
69
|
+
|
54
70
|
matchAndApplyCustomLoadingStrategyToScripts(tags) {
|
55
71
|
Object.keys(this.scriptLoadingStrategy).forEach(scriptLoadingStrategy => {
|
56
72
|
const filesToMatch = this.scriptLoadingStrategy[scriptLoadingStrategy];
|
57
73
|
tags.forEach(tag => {
|
58
74
|
if (this.tagNamesToMatch.includes(tag.tagName) && tag.attributes.src) {
|
59
75
|
const isFileMatch = filesToMatch.some(fileName => this.matchFileName(tag, fileName));
|
76
|
+
|
60
77
|
if (isFileMatch) {
|
61
78
|
this.matchStrategy(scriptLoadingStrategy, tag);
|
62
79
|
this.addAttributestToTag(tag, {
|
63
80
|
[scriptLoadingStrategy]: true
|
64
81
|
});
|
65
82
|
}
|
66
|
-
}
|
67
|
-
// filesToMatch.forEach(fileName => {
|
83
|
+
} // filesToMatch.forEach(fileName => {
|
68
84
|
// if (!this.matchFileName(tag, fileName)) {
|
69
85
|
// return;
|
70
86
|
// }
|
@@ -73,9 +89,11 @@ class CustomScriptLoadingStrategyPlugin {
|
|
73
89
|
// [scriptLoadingStrategy]: true
|
74
90
|
// });
|
75
91
|
// });
|
92
|
+
|
76
93
|
});
|
77
94
|
});
|
78
95
|
}
|
96
|
+
|
79
97
|
apply(compiler) {
|
80
98
|
compiler.hooks.compilation.tap(pluginName, compilation => {
|
81
99
|
_htmlWebpackPlugin.default.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, callback) => {
|
@@ -85,5 +103,7 @@ class CustomScriptLoadingStrategyPlugin {
|
|
85
103
|
});
|
86
104
|
});
|
87
105
|
}
|
106
|
+
|
88
107
|
}
|
108
|
+
|
89
109
|
exports.default = CustomScriptLoadingStrategyPlugin;
|
package/lib/plugins/EFCPlugin.js
CHANGED
@@ -4,17 +4,26 @@ 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
|
var _logger = require("../logger");
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
16
|
-
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
17
23
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25
|
+
|
26
|
+
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
18
27
|
const cliOptions = (0, _utils.getOptions)();
|
19
28
|
const {
|
20
29
|
app: {
|
@@ -32,18 +41,17 @@ const {
|
|
32
41
|
createSDkFile,
|
33
42
|
cdnStatement
|
34
43
|
} = efcOptios;
|
44
|
+
|
35
45
|
class EFCPlugin {
|
36
46
|
constructor(options = {}) {
|
37
47
|
this.isDevelopment = options.isDevelopment;
|
38
48
|
this.templateFilePath = options.templateFilePath;
|
39
49
|
this.serverUrl = options.serverUrl;
|
40
|
-
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
41
|
-
|
42
|
-
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
50
|
+
this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
43
51
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
44
|
-
|
45
52
|
// IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
|
46
53
|
// So when debugging consider this as well
|
54
|
+
|
47
55
|
this.options = Object.assign({}, efcOptios, options);
|
48
56
|
this.options.entryPointName = options.entryPointName || 'efc';
|
49
57
|
this.options.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
|
@@ -52,8 +60,7 @@ class EFCPlugin {
|
|
52
60
|
const cssDirAttr = this.options.cssDirAttr || 'data-efc-dir';
|
53
61
|
const localeDefaultValue = this.options.localeDefaultValue || 'en_US';
|
54
62
|
const cssDirDefaultValue = this.options.cssDirDefaultValue || 'ltr';
|
55
|
-
this.options.localeStatement = options.localeStatement ||
|
56
|
-
// Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
|
63
|
+
this.options.localeStatement = options.localeStatement || // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
|
57
64
|
// Statment 2: return langEle ? langEle.getAttribute('${localeAttr}') : 'en_US';
|
58
65
|
// We are using statement1 not statment2,
|
59
66
|
// Because even that attribute doesn't have value, We need default value
|
@@ -65,9 +72,7 @@ class EFCPlugin {
|
|
65
72
|
let dirEle = document.querySelector('[${cssDirAttr}]');
|
66
73
|
return dirEle && dirEle.getAttribute('${cssDirAttr}') || '${cssDirDefaultValue}';
|
67
74
|
})();`;
|
68
|
-
}
|
69
|
-
|
70
|
-
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
75
|
+
} // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
71
76
|
// getI18nManifest(compilation) {
|
72
77
|
// const i18nManifestFile =
|
73
78
|
// compilation.assets[this.options.i18nManifestFileName];
|
@@ -78,11 +83,12 @@ class EFCPlugin {
|
|
78
83
|
// return {};
|
79
84
|
// }
|
80
85
|
|
86
|
+
|
81
87
|
getI18nAssetsStr(entryPoint, compilation) {
|
82
88
|
if (!chunkSplitEnable) {
|
83
89
|
let i18nAsstes = {};
|
84
|
-
const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
85
|
-
|
90
|
+
const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
91
|
+
|
86
92
|
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
87
93
|
const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
88
94
|
const splittedFileName = fileName.split('.');
|
@@ -91,9 +97,11 @@ class EFCPlugin {
|
|
91
97
|
}, {});
|
92
98
|
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
93
99
|
}
|
100
|
+
|
94
101
|
const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
95
102
|
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
96
103
|
}
|
104
|
+
|
97
105
|
createFileContent(compilation) {
|
98
106
|
const {
|
99
107
|
entryPointName,
|
@@ -105,19 +113,18 @@ class EFCPlugin {
|
|
105
113
|
const {
|
106
114
|
serverUrl
|
107
115
|
} = this;
|
108
|
-
const cssDirTemplate = '@dir@';
|
109
|
-
|
110
|
-
const entryPoint = compilation.entrypoints.get(entryPointName);
|
111
|
-
|
116
|
+
const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
|
117
|
+
|
118
|
+
const entryPoint = compilation.entrypoints.get(entryPointName); // const chunk = compilation.namedChunks.get(entryPointName);
|
119
|
+
|
112
120
|
const [jsPath, cssPath,,, i18nJsPath] = !this.isDevelopment ? publicPaths : [];
|
113
121
|
const initialFiles = entryPoint.getFiles();
|
114
|
-
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
|
115
|
-
|
116
|
-
// const i18nAssets = getShortI18nAssets(
|
122
|
+
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file)); // const i18nAssets = getShortI18nAssets(
|
117
123
|
// entryPoint.chunks,
|
118
124
|
// i18nManifest,
|
119
125
|
// i18nJsPath
|
120
126
|
// );
|
127
|
+
|
121
128
|
const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, i18nJsPath);
|
122
129
|
return `(() => {
|
123
130
|
const lang = ${localeStatement};
|
@@ -196,10 +203,12 @@ class EFCPlugin {
|
|
196
203
|
})();
|
197
204
|
`;
|
198
205
|
}
|
206
|
+
|
199
207
|
apply(compiler) {
|
200
208
|
if (!createSDkFile) {
|
201
209
|
return;
|
202
210
|
}
|
211
|
+
|
203
212
|
if (this.templateFilePath) {
|
204
213
|
new _EFCTemplatePlugin.default({
|
205
214
|
templateFilePath: this.templateFilePath,
|
@@ -209,19 +218,24 @@ class EFCPlugin {
|
|
209
218
|
}).apply(compiler);
|
210
219
|
return;
|
211
220
|
}
|
221
|
+
|
212
222
|
compiler.hooks.emit.tap('EFCPlugin', compilation => {
|
213
223
|
const {
|
214
224
|
entryPointName,
|
215
225
|
outputFile
|
216
226
|
} = this.options;
|
217
227
|
const entryPoint = compilation.entrypoints.get(entryPointName);
|
228
|
+
|
218
229
|
if (!entryPoint) {
|
219
230
|
return;
|
220
231
|
}
|
232
|
+
|
221
233
|
const source = new _webpackSources.RawSource(this.createFileContent(compilation));
|
222
234
|
compilation.assets[outputFile] = source;
|
223
235
|
(0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
|
224
236
|
});
|
225
237
|
}
|
238
|
+
|
226
239
|
}
|
240
|
+
|
227
241
|
exports.default = EFCPlugin;
|
@@ -4,17 +4,26 @@ 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
|
var _logger = require("../logger");
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
16
|
-
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
17
23
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25
|
+
|
26
|
+
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
18
27
|
const cliOptions = (0, _utils.getOptions)();
|
19
28
|
const {
|
20
29
|
i18n: {
|
@@ -27,9 +36,7 @@ const {
|
|
27
36
|
} = cliOptions;
|
28
37
|
const {
|
29
38
|
createSDkFile
|
30
|
-
} = efcOptios;
|
31
|
-
|
32
|
-
// for smap relate changes
|
39
|
+
} = efcOptios; // for smap relate changes
|
33
40
|
// CdnChangePlugin
|
34
41
|
// SourceMapHookPlugin
|
35
42
|
|
@@ -37,20 +44,15 @@ class EFCTemplatePlugin {
|
|
37
44
|
constructor(options = {}) {
|
38
45
|
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
|
39
46
|
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
40
|
-
this.publicPath = options.publicPath;
|
41
|
-
|
42
|
-
// NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
47
|
+
this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
43
48
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
44
|
-
|
45
49
|
// IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
|
46
50
|
// So when debugging consider this as well
|
47
51
|
// this.options = Object.assign({}, efcOptios, options);
|
48
52
|
|
49
53
|
this.entryPointName = options.entryPointName || 'efc';
|
50
54
|
this.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
|
51
|
-
}
|
52
|
-
|
53
|
-
// 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
|
54
56
|
// getI18nManifest(compilation) {
|
55
57
|
// const i18nManifestFile =
|
56
58
|
// compilation.assets[this.options.i18nManifestFileName];
|
@@ -61,12 +63,13 @@ class EFCTemplatePlugin {
|
|
61
63
|
// return {};
|
62
64
|
// }
|
63
65
|
|
66
|
+
|
64
67
|
getI18nAssetsStr(entryPoint, compilation) {
|
65
68
|
// NOTE: we have used lang variable inside
|
66
69
|
if (!chunkSplitEnable) {
|
67
70
|
let i18nAsstes = {};
|
68
|
-
const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
|
69
|
-
|
71
|
+
const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
72
|
+
|
70
73
|
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
71
74
|
const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
72
75
|
const splittedFileName = fileName.split('.');
|
@@ -75,27 +78,28 @@ class EFCTemplatePlugin {
|
|
75
78
|
}, {});
|
76
79
|
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
77
80
|
}
|
81
|
+
|
78
82
|
const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
79
83
|
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
80
84
|
}
|
85
|
+
|
81
86
|
templateReplacer(entryPoint, compilation) {
|
82
|
-
const cssDirTemplate = '@dir@';
|
83
|
-
// const i18nManifest = this.getI18nManifest(compilation);
|
87
|
+
const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
|
84
88
|
|
85
89
|
const initialFiles = entryPoint.getFiles();
|
86
90
|
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
|
87
91
|
const initialJsFiles = filteredInitialFiles.filter(file => /\.js$/.test(file));
|
88
92
|
let initialCssFiles = filteredInitialFiles.filter(file => /\.css$/.test(file));
|
93
|
+
|
89
94
|
if (enableRTLSplit) {
|
90
95
|
initialCssFiles = initialCssFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate));
|
91
|
-
}
|
92
|
-
|
93
|
-
// const i18nAssets = getShortI18nAssets(
|
96
|
+
} // const i18nAssets = getShortI18nAssets(
|
94
97
|
// entryPoint.chunks,
|
95
98
|
// i18nManifest,
|
96
99
|
// '' // i18nJsPath
|
97
100
|
// );
|
98
101
|
|
102
|
+
|
99
103
|
const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
|
100
104
|
);
|
101
105
|
const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
|
@@ -112,27 +116,34 @@ class EFCTemplatePlugin {
|
|
112
116
|
return [];
|
113
117
|
}`).replace('((\'@dir@\'))', '\'@dir@\'').replace('((\'publicPath\'))', this.publicPath).replace('((\'@locale@\'))', '\'@locale@\'');
|
114
118
|
}
|
119
|
+
|
115
120
|
apply(compiler) {
|
116
121
|
if (!createSDkFile) {
|
117
122
|
return;
|
118
123
|
}
|
124
|
+
|
119
125
|
compiler.hooks.emit.tap('EFCTemplatePlugin', compilation => {
|
120
126
|
const {
|
121
127
|
entryPointName,
|
122
128
|
outputFile
|
123
129
|
} = this;
|
124
130
|
const entryPoint = compilation.entrypoints.get(entryPointName);
|
131
|
+
|
125
132
|
if (!entryPoint) {
|
126
133
|
return;
|
127
134
|
}
|
135
|
+
|
128
136
|
if (!(0, _fs.existsSync)(this.templateFilePath)) {
|
129
137
|
console.error(`EFC Template file not exists ${this.templateFilePath}`);
|
130
138
|
return;
|
131
139
|
}
|
140
|
+
|
132
141
|
const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
|
133
142
|
compilation.assets[outputFile] = source;
|
134
143
|
(0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
|
135
144
|
});
|
136
145
|
}
|
146
|
+
|
137
147
|
}
|
148
|
+
|
138
149
|
exports.default = EFCTemplatePlugin;
|
@@ -3,11 +3,13 @@
|
|
3
3
|
const {
|
4
4
|
Template
|
5
5
|
} = require('webpack');
|
6
|
+
|
6
7
|
const plugInName = 'EFCResourceCleanup';
|
7
8
|
module.exports = class EfcResouceCleanupPlugin {
|
8
9
|
constructor(options) {
|
9
10
|
this.options = options;
|
10
11
|
}
|
12
|
+
|
11
13
|
apply(compiler) {
|
12
14
|
compiler.hooks.thisCompilation.tap(plugInName, ({
|
13
15
|
mainTemplate
|
@@ -37,4 +39,5 @@ module.exports = class EfcResouceCleanupPlugin {
|
|
37
39
|
});
|
38
40
|
});
|
39
41
|
}
|
42
|
+
|
40
43
|
};
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.EventsHandlingPlugin = void 0;
|
7
|
-
/* eslint-disable no-use-before-define */
|
8
7
|
|
8
|
+
/* eslint-disable no-use-before-define */
|
9
9
|
class EventsHandlingPlugin {
|
10
10
|
constructor(options) {}
|
11
|
+
|
11
12
|
apply(compiler) {
|
12
13
|
// NOTE: we not using this, Reason currently this option is only need for EFC,
|
13
14
|
// So it do not needed.
|
14
|
-
|
15
15
|
compiler.hooks.thisCompilation.tap({
|
16
16
|
name: 'CustomAttributePlugin',
|
17
17
|
stage: 1,
|
@@ -28,5 +28,7 @@ class EventsHandlingPlugin {
|
|
28
28
|
}
|
29
29
|
});
|
30
30
|
}
|
31
|
+
|
31
32
|
}
|
33
|
+
|
32
34
|
exports.EventsHandlingPlugin = EventsHandlingPlugin;
|