@zohodesk/react-cli 1.0.2-exp.2 → 1.0.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.
Files changed (149) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/Changelog.md +1019 -1019
  5. package/README.md +1184 -1165
  6. package/bin/cli.js +483 -483
  7. package/docs/CustomChunks.md +26 -26
  8. package/docs/DevServerPort.md +39 -39
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/SelectorWeight.md +8 -8
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +729 -729
  16. package/docs/warnings_while_install.txt +35 -35
  17. package/files/eslintrc.js +62 -62
  18. package/files/prettierrc.js +3 -3
  19. package/lib/common/testPattern.js +0 -2
  20. package/lib/common/valueReplacer.js +1 -3
  21. package/lib/configs/resolvers.js +14 -3
  22. package/lib/configs/webpack.css.umd.config.js +4 -4
  23. package/lib/configs/webpack.dev.config.js +0 -6
  24. package/lib/configs/webpack.docs.config.js +0 -4
  25. package/lib/configs/webpack.impact.config.js +0 -4
  26. package/lib/configs/webpack.prod.config.js +0 -6
  27. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  28. package/lib/loaderUtils/getCSSLoaders.js +47 -81
  29. package/lib/loaderUtils/windowsModification.js +1 -6
  30. package/lib/loaders/selectorMappingLoader.js +9 -9
  31. package/lib/loaders/workerLoader.js +9 -9
  32. package/lib/logger.js +20 -0
  33. package/lib/pluginUtils/getDevPlugins.js +12 -18
  34. package/lib/pluginUtils/getProdPlugins.js +10 -6
  35. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  36. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  37. package/lib/plugins/CustomAttributePlugin.js +82 -0
  38. package/lib/plugins/CustomAttributePlugin.md +35 -0
  39. package/lib/plugins/EFCPlugin.js +9 -9
  40. package/lib/plugins/EFCPlugin.md +6 -6
  41. package/lib/plugins/EFCTemplatePlugin.js +10 -12
  42. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -13
  43. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
  44. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  45. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  46. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +10 -15
  47. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  48. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  49. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  50. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
  51. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  52. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  53. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  54. package/lib/plugins/SelectorPlugin.js +36 -53
  55. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  56. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  57. package/lib/plugins/{MinifyPlugin.js → UglifyCSSPlugin.js} +3 -3
  58. package/lib/plugins/VariableConversionCollector.js +84 -97
  59. package/lib/plugins/composeCommonPlugin.js +30 -0
  60. package/lib/plugins/index.js +7 -7
  61. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  62. package/lib/postcss-plugins/IncludePlugin.js +0 -1
  63. package/lib/postcss-plugins/RTLSplitPlugin.js +14 -20
  64. package/lib/postcss-plugins/ValueReplacer.js +14 -5
  65. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  66. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  67. package/lib/postcss-plugins/hoverActivePlugin.js +3 -9
  68. package/lib/postcss-plugins/variableModificationPlugin/index.js +20 -3
  69. package/lib/postcss-plugins/variableModifier.js +24 -58
  70. package/lib/schemas/index.js +11 -35
  71. package/lib/servers/devBuild.js +13 -11
  72. package/lib/servers/httpsOptions.js +12 -13
  73. package/lib/servers/nowatchserver.js +5 -3
  74. package/lib/servers/requireLocalOrGlobal.js +61 -0
  75. package/lib/servers/server.js +3 -5
  76. package/lib/sh/pre-commit.sh +34 -34
  77. package/lib/sh/reportPublish.sh +45 -45
  78. package/lib/utils/buildstats.html +148 -148
  79. package/lib/utils/cssClassNameGenerate.js +12 -41
  80. package/lib/utils/resultSchema.json +73 -73
  81. package/npm8.md +9 -9
  82. package/package-lock.json +14407 -0
  83. package/package.json +120 -122
  84. package/postpublish.js +8 -8
  85. package/templates/app/.eslintrc.js +140 -140
  86. package/templates/app/README.md +12 -12
  87. package/templates/app/app/index.html +24 -24
  88. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  89. package/templates/app/app/properties/i18nkeys.json +3 -3
  90. package/templates/app/docs/all.html +69 -69
  91. package/templates/app/mockapi/index.js +18 -18
  92. package/templates/app/package.json +37 -37
  93. package/templates/app/src/actions/SampleActions/index.js +37 -37
  94. package/templates/app/src/actions/index.js +65 -65
  95. package/templates/app/src/appUrls.js +19 -19
  96. package/templates/app/src/components/Alert/Alert.js +134 -134
  97. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  98. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  99. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  100. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  101. package/templates/app/src/components/Sample/SampleList.js +61 -61
  102. package/templates/app/src/components/Slider/Slider.css +41 -41
  103. package/templates/app/src/components/Slider/Slider.js +55 -55
  104. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  105. package/templates/app/src/containers/AppContainer/index.js +96 -96
  106. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  107. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  108. package/templates/app/src/containers/DevTools/index.js +10 -10
  109. package/templates/app/src/containers/Header/index.js +67 -67
  110. package/templates/app/src/containers/Header/index.module.css +43 -43
  111. package/templates/app/src/containers/Redirect/index.js +63 -63
  112. package/templates/app/src/containers/Redirector/index.js +47 -47
  113. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  114. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  115. package/templates/app/src/historyChange.js +5 -5
  116. package/templates/app/src/index.html +10 -10
  117. package/templates/app/src/index.js +24 -24
  118. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  119. package/templates/app/src/reducers/alertData.js +11 -11
  120. package/templates/app/src/reducers/index.js +6 -6
  121. package/templates/app/src/reducers/samples.js +19 -19
  122. package/templates/app/src/store/configureStore.dev.js +51 -51
  123. package/templates/app/src/store/configureStore.js +5 -5
  124. package/templates/app/src/store/configureStore.prod.js +26 -26
  125. package/templates/app/src/util/Common.js +5 -5
  126. package/templates/app/src/util/RequestAPI.js +132 -132
  127. package/templates/docs/all.html +249 -249
  128. package/templates/docs/component.html +178 -178
  129. package/templates/docs/components.html +221 -221
  130. package/templates/docs/css/b.min.css +6 -6
  131. package/templates/docs/css/component.css +42 -42
  132. package/templates/docs/css/componentTest.css +6 -6
  133. package/templates/docs/css/hopscotch.css +585 -585
  134. package/templates/docs/css/style.css +1022 -1022
  135. package/templates/docs/impactReportTemplate.html +154 -154
  136. package/templates/docs/index.html +1501 -1501
  137. package/templates/docs/js/active-line.js +72 -72
  138. package/templates/docs/js/b.min.js +7 -7
  139. package/templates/docs/js/codemirror.js +9680 -9680
  140. package/templates/docs/js/designTokens.js +334 -334
  141. package/templates/docs/js/j.min.js +4 -4
  142. package/templates/docs/js/javascript.js +874 -874
  143. package/templates/docs/js/matchbrackets.js +145 -145
  144. package/lib/loaderUtils/tests/windowsModification.test.js +0 -10
  145. package/lib/loaders/composeLoader.js +0 -175
  146. package/lib/plugins/utils/classHandling.js +0 -20
  147. package/lib/plugins/utils/fileHandling.js +0 -92
  148. package/lib/plugins/utils/tests/fileHandling.test.js +0 -30
  149. package/lib/postcss-plugins/EmptyPlugin.js +0 -8
@@ -6,25 +6,25 @@ var _fs = _interopRequireDefault(require("fs"));
6
6
 
7
7
  var _utils = require("../utils");
8
8
 
9
+ var _logger = require("../logger");
10
+
9
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
12
 
11
- let options = (0, _utils.getOptions)();
13
+ const options = (0, _utils.getOptions)();
12
14
  const {
13
15
  cssSelectorZipPath
14
16
  } = options.impactService;
15
17
 
16
- const zipname = _path.default.parse(cssSelectorZipPath).name; // console.log({ cssSelectorZipPath, zipname });
17
- // TODO:NOTE: need to check about .. path related files creation
18
+ const zipname = _path.default.parse(cssSelectorZipPath).name; // TODO:NOTE: need to check about .. path related files creation
18
19
  // for now no css files have given form react-cli need to make sure about it.
19
20
 
20
21
 
21
- let zippath = _path.default.join(process.cwd(), cssSelectorZipPath);
22
+ const zippath = _path.default.join(process.cwd(), cssSelectorZipPath);
22
23
 
23
24
  if (_fs.default.existsSync(_path.default.join(process.cwd(), cssSelectorZipPath))) {
24
25
  _fs.default.rmSync(zippath);
25
26
 
26
- console.log('zip file deleted', zippath); // fs.rmSync(zippath, {force:true})
27
- // console.log('created folder ==> ', dpath);
27
+ (0, _logger.messageLogger)('zip file deleted', zippath); // fs.rmSync(zippath, {force:true})
28
28
  } // const minicssComment =
29
29
  // '// extracted by mini-css-extract-plugin\n';
30
30
 
@@ -39,15 +39,15 @@ module.exports = function (source) {
39
39
 
40
40
  const relativePath = _path.default.relative(rootContext, resourcePath);
41
41
 
42
- let fpath = _path.default.join(rootContext, zipname, relativePath);
42
+ const fpath = _path.default.join(rootContext, zipname, relativePath);
43
43
 
44
- let originalpath = _path.default.join(rootContext, relativePath);
44
+ const originalpath = _path.default.join(rootContext, relativePath);
45
45
 
46
46
  if (relativePath.startsWith('..')) {
47
47
  throw `unexpected path ${relativePath}`;
48
48
  }
49
49
 
50
- let dpath = fpath.slice(0, fpath.lastIndexOf(_path.default.sep));
50
+ const dpath = fpath.slice(0, fpath.lastIndexOf(_path.default.sep));
51
51
 
52
52
  if (!_fs.default.existsSync(originalpath)) {
53
53
  throw `originalpath not exixt ${originalpath}`;
@@ -16,7 +16,7 @@ var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntry
16
16
 
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
18
 
19
- /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
19
+ /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
20
20
  import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
21
21
  const schema = {
22
22
  'type': 'object',
@@ -80,14 +80,14 @@ function pitch(request) {
80
80
  globalObject: 'self'
81
81
  };
82
82
  workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
83
- /*
84
- new WebWorkerTemplatePlugin().apply(workerContext.compiler);
85
-
86
- if (compilerOptions.externals) {
87
- new ExternalsPlugin(
88
- getExternalsType(compilerOptions),
89
- compilerOptions.externals
90
- ).apply(workerContext.compiler);
83
+ /*
84
+ new WebWorkerTemplatePlugin().apply(workerContext.compiler);
85
+
86
+ if (compilerOptions.externals) {
87
+ new ExternalsPlugin(
88
+ getExternalsType(compilerOptions),
89
+ compilerOptions.externals
90
+ ).apply(workerContext.compiler);
91
91
  } */
92
92
 
93
93
  new _SingleEntryPlugin.default(this.context, `!!${request}`, _path.default.parse(this.resourcePath).name).apply(workerContext.compiler);
package/lib/logger.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.errorLogger = errorLogger;
7
+ exports.messageLogger = messageLogger;
8
+ exports.warnLogger = warnLogger;
9
+
10
+ function messageLogger(...args) {
11
+ console.log(...args);
12
+ }
13
+
14
+ function errorLogger(...args) {
15
+ console.error(...args);
16
+ }
17
+
18
+ function warnLogger(...args) {
19
+ console.warn(...args);
20
+ }
@@ -25,6 +25,8 @@ var _webpack = _interopRequireDefault(require("webpack"));
25
25
 
26
26
  var _plugins = require("../plugins");
27
27
 
28
+ var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
29
+
28
30
  var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
29
31
 
30
32
  var _VariableConversionCollector = _interopRequireDefault(require("../plugins/VariableConversionCollector"));
@@ -42,14 +44,13 @@ const getDevPlugins = (options, publicPath) => {
42
44
  tpFolder,
43
45
  folder,
44
46
  instrumentScript,
47
+ customAttributes,
45
48
  devCssFileBountry,
46
49
  context,
47
50
  hasEFC: prevOptionForEnableEFC,
48
51
  hasShadowDOM,
49
52
  cssVariableReplacementConfig,
50
53
  plugins: pluginObject,
51
- patterns,
52
- patternsRootDir,
53
54
  exclude,
54
55
  selectorWeightConfig,
55
56
  server: {
@@ -88,6 +89,7 @@ const getDevPlugins = (options, publicPath) => {
88
89
  NODE_ENV: JSON.stringify(mode === 'dev-no-warn' ? 'production' : 'development')
89
90
  }
90
91
  }), new _miniCssExtractPlugin.default({
92
+ attributes: customAttributes.cssAttributes,
91
93
  filename: cssLTRFileNameTempalte,
92
94
  // ignoreOrder: true,
93
95
  chunkFilename: cssLTRFileNameTempalte
@@ -111,11 +113,11 @@ const getDevPlugins = (options, publicPath) => {
111
113
  }
112
114
 
113
115
  const i18nManifestFileName = 'i18n-manifest.json';
114
- /**
115
- * NOTE:
116
- * this file name ext .i18n.js added
117
- * Because, in service worker they maintain cache as file name based
118
- * So, to make differce we added .i18n.js ext.
116
+ /**
117
+ * NOTE:
118
+ * this file name ext .i18n.js added
119
+ * Because, in service worker they maintain cache as file name based
120
+ * So, to make differce we added .i18n.js ext.
119
121
  */
120
122
 
121
123
  const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
@@ -186,6 +188,7 @@ const getDevPlugins = (options, publicPath) => {
186
188
  mainChunkName: 'main'
187
189
  }));
188
190
  instrumentScript && pluginsArr.push(new _plugins.ScriptInstrumentPlugin());
191
+ customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
189
192
  hasShadowDOM && pluginsArr.push(new _plugins.ShadowDOMSupportPlugin());
190
193
 
191
194
  if (devCssFileBountry) {
@@ -196,26 +199,17 @@ const getDevPlugins = (options, publicPath) => {
196
199
 
197
200
  if (pluginObject.cssVariableReplacement) {
198
201
  pluginsArr.push(new _VariableConversionCollector.default({
199
- cssVariableReplacementConfig,
200
- patterns,
201
- patternsRootDir
202
+ cssVariableReplacementConfig
202
203
  }));
203
204
  }
204
205
 
205
206
  if (pluginObject.selectorWeight) {
206
207
  pluginsArr.push(new _SelectorPlugin.default({
207
208
  selectorWeightConfig,
208
- exclude: exclude.selectorWeight,
209
- patterns,
210
- patternsRootDir
209
+ exclude: exclude.selectorWeight
211
210
  }));
212
211
  }
213
212
 
214
- if (pluginObject.minifier) {
215
- // console.log('minifier active');
216
- pluginsArr.push(new _plugins.MinifierPlugin());
217
- }
218
-
219
213
  return pluginsArr.filter(Boolean);
220
214
  };
221
215
 
@@ -29,6 +29,8 @@ var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"
29
29
 
30
30
  var _plugins = require("../plugins");
31
31
 
32
+ var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
33
+
32
34
  var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
33
35
 
34
36
  var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
@@ -63,6 +65,7 @@ const getProdPlugins = (options, publicPath = '') => {
63
65
  resourceHints,
64
66
  serviceWorker,
65
67
  htmlTemplate,
68
+ customAttributes,
66
69
  tpHashMapping,
67
70
  cdnMapping,
68
71
  crossorigin
@@ -102,7 +105,7 @@ const getProdPlugins = (options, publicPath = '') => {
102
105
  // ignoreOrder: true,
103
106
  filename: cssLTRFileNameTempalte,
104
107
  chunkFilename: cssLTRFileNameTempalte
105
- }), new _plugins.ResourceHintsPlugin(), new _plugins.MinifyPlugin()];
108
+ }), new _plugins.ResourceHintsPlugin(), new _plugins.UglifyCSSPlugin()];
106
109
 
107
110
  if (enableRTLSplit) {
108
111
  pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
@@ -116,11 +119,11 @@ const getProdPlugins = (options, publicPath = '') => {
116
119
  }
117
120
 
118
121
  const i18nManifestFileName = 'i18n-manifest.json';
119
- /**
120
- * NOTE:
121
- * this file name ext .i18n.js added
122
- * Because, in service worker they maintain cache as file name based
123
- * So, to make differce we added .i18n.js ext.
122
+ /**
123
+ * NOTE:
124
+ * this file name ext .i18n.js added
125
+ * Because, in service worker they maintain cache as file name based
126
+ * So, to make differce we added .i18n.js ext.
124
127
  */
125
128
 
126
129
  const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
@@ -279,6 +282,7 @@ const getProdPlugins = (options, publicPath = '') => {
279
282
  } // plugins.push(new VariableConversionCollector({}));
280
283
 
281
284
 
285
+ customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
282
286
  return pluginsArr;
283
287
  };
284
288
 
@@ -27,7 +27,7 @@ let getUMDCSSPlugins = () => {
27
27
  }), new _miniCssExtractPlugin.default({
28
28
  filename: 'css/[name].css',
29
29
  chunkFilename: 'css/[id].css'
30
- }), new _plugins.MinifyPlugin()];
30
+ }), new _plugins.UglifyCSSPlugin()];
31
31
  return plugins;
32
32
  };
33
33
 
@@ -27,7 +27,7 @@ let getUMDComponentPlugins = isDocs => {
27
27
  }), new _miniCssExtractPlugin.default({
28
28
  filename: 'css/[name].css',
29
29
  chunkFilename: 'css/[name].css'
30
- }), new _plugins.MinifyPlugin()];
30
+ }), new _plugins.UglifyCSSPlugin()];
31
31
  return plugins;
32
32
  };
33
33
 
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CustomAttributePlugin = void 0;
7
+
8
+ var _Template = _interopRequireDefault(require("webpack/lib/Template"));
9
+
10
+ var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ /* eslint-disable no-use-before-define */
15
+ class CustomAttributePlugin {
16
+ constructor(options) {
17
+ this.options = {
18
+ attributes: options.attributes,
19
+ useHTMLAttribute: options.attributes && !options.jsAttributes && !options.cssAttributes && !options.i18nAttributes,
20
+ jsAttributes: options.jsAttributes || options.attributes || {},
21
+ cssAttributes: options.cssAttributes || options.attributes || {},
22
+ i18nAttributes: options.i18nAttributes || options.attributes || {}
23
+ };
24
+ }
25
+
26
+ addCustomAttributeToDynamicScriptTags(mainTemplate) {
27
+ const {
28
+ jsAttributes,
29
+ cssAttributes,
30
+ i18nAttributes
31
+ } = this.options; // NOTE: To add custom Attributes to js Script tags
32
+
33
+ mainTemplate.hooks.jsonpScript.tap('CustomAttributePlugin', source => {
34
+ const str = attributeSetTemplate(jsAttributes, 'script');
35
+ return _Template.default.asString([source, ...str]);
36
+ }); // NOTE: To add custom Attributes to css link tags
37
+
38
+ mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
39
+ const str = attributeSetTemplate(cssAttributes, 'linkTag');
40
+ const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`); // console.log({ s: source, r: replacedStr });
41
+
42
+ return replacedStr;
43
+ }); // NOTE: To add custom Attributes to i18n split js Script tags
44
+
45
+ mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
46
+ const str = attributeSetTemplate(i18nAttributes, 'scriptTag');
47
+ const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`); // console.log({ s: source, r: replacedStr });
48
+
49
+ return replacedStr;
50
+ });
51
+ }
52
+
53
+ apply(compiler) {
54
+ // NOTE: we not using this, Reason currently this option is only need for EFC,
55
+ // So it do not needed.
56
+ const {
57
+ attributes,
58
+ useHTMLAttribute
59
+ } = this.options;
60
+ useHTMLAttribute && new _htmlWebpackInjectAttributesPlugin.default(attributes).apply(compiler);
61
+ compiler.hooks.thisCompilation.tap({
62
+ name: 'CustomAttributePlugin',
63
+ stage: 1,
64
+ fn: compilation => {
65
+ this.addCustomAttributeToDynamicScriptTags(compilation.mainTemplate);
66
+ }
67
+ });
68
+ }
69
+
70
+ }
71
+
72
+ exports.CustomAttributePlugin = CustomAttributePlugin;
73
+
74
+ function attributeSetTemplate(jsAttributes, variableName) {
75
+ let str = [];
76
+ Object.keys(jsAttributes).forEach(key => {
77
+ const val = jsAttributes[key];
78
+ str.push(`${variableName}.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(val)});`);
79
+ }); // console.log({ str });
80
+
81
+ return str;
82
+ }
@@ -0,0 +1,35 @@
1
+ # CustomAttributePlugin
2
+ In this plugin we added all dynamic chunks tags (like js script tags , css script tags, i18n split script tags) to extra custom attribute
3
+
4
+ ## Options
5
+
6
+ ```json
7
+ {
8
+ "name": "some",
9
+ "react-cli": {
10
+ "app": {
11
+ "customAttributes": {// this is the all options
12
+ "enable": false,
13
+ "attributes": null,
14
+ "jsAttributes": null,
15
+ "cssAttributes": null,
16
+ "i18nAttributes": null
17
+ }
18
+ }
19
+ }
20
+ ```
21
+
22
+ ### enable [Boolean]
23
+ this decides is this plugin or feature needs to be enabled of not.
24
+
25
+
26
+ ### attributes [Object]
27
+ It was object of key value pairs Example Given Option {"data-app-name":"myapp"}
28
+ Then all dynamically (js script tags , css script tags, i18n split script tags) added tags via webpack
29
+
30
+ ### jsAttributes [Object]
31
+ same as [attributes] but only for js script tags
32
+ ### cssAttributes [Object]
33
+ same as [attributes] but only for css script tags
34
+ ### i18nAttributes [Object]
35
+ same as [attributes] but only for i18n split script tags
@@ -19,6 +19,8 @@ var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
19
19
 
20
20
  var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
21
21
 
22
+ var _logger = require("../logger");
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
24
26
  // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
@@ -85,18 +87,18 @@ class EFCPlugin {
85
87
  getI18nAssetsStr(entryPoint, compilation) {
86
88
  if (!chunkSplitEnable) {
87
89
  let i18nAsstes = {};
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
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
89
91
 
90
92
  i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
91
- let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
92
- let splittedFileName = fileName.split('.');
93
+ const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
94
+ const splittedFileName = fileName.split('.');
93
95
  res[splittedFileName[0]] = i18nFilePath;
94
96
  return res;
95
97
  }, {});
96
98
  return `[${JSON.stringify(i18nAsstes)}[lang]]`;
97
99
  }
98
100
 
99
- let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
101
+ const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
100
102
  return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
101
103
  }
102
104
 
@@ -205,8 +207,7 @@ class EFCPlugin {
205
207
  apply(compiler) {
206
208
  if (!createSDkFile) {
207
209
  return;
208
- } //console.log('this.templateFilePath', this.templateFilePath, this.options);
209
-
210
+ }
210
211
 
211
212
  if (this.templateFilePath) {
212
213
  new _EFCTemplatePlugin.default({
@@ -230,9 +231,8 @@ class EFCPlugin {
230
231
  }
231
232
 
232
233
  const source = new _webpackSources.RawSource(this.createFileContent(compilation));
233
- compilation.assets[outputFile] = source; // eslint-disable-next-line no-console
234
-
235
- console.log('The EFC embedded code was created successfully..!!!');
234
+ compilation.assets[outputFile] = source;
235
+ (0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
236
236
  });
237
237
  }
238
238
 
@@ -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
@@ -19,6 +19,8 @@ var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nK
19
19
 
20
20
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
21
21
 
22
+ var _logger = require("../logger");
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
24
26
  // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
@@ -40,9 +42,7 @@ const {
40
42
 
41
43
  class EFCTemplatePlugin {
42
44
  constructor(options = {}) {
43
- // console.log(' templateFilePath ', process.cwd(), options.templateFilePath, templateFilePath);
44
- this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath); // console.log(' templateFilePath ', this.templateFilePath);
45
-
45
+ this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
46
46
  this.i18nFileNameTemplate = options.i18nFileNameTemplate;
47
47
  this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
48
48
  // this.i18nManifestFileName = options.i18nManifestFileName;
@@ -68,18 +68,18 @@ class EFCTemplatePlugin {
68
68
  // NOTE: we have used lang variable inside
69
69
  if (!chunkSplitEnable) {
70
70
  let i18nAsstes = {};
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
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
72
 
73
73
  i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
74
- let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
75
- let splittedFileName = fileName.split('.');
74
+ const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
75
+ const splittedFileName = fileName.split('.');
76
76
  res[splittedFileName[0]] = i18nFilePath;
77
77
  return res;
78
78
  }, {});
79
79
  return `[${JSON.stringify(i18nAsstes)}[lang]]`;
80
80
  }
81
81
 
82
- let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
82
+ const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
83
83
  return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
84
84
  }
85
85
 
@@ -102,7 +102,7 @@ class EFCTemplatePlugin {
102
102
 
103
103
  const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
104
104
  );
105
- let templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
105
+ const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
106
106
  return templateStr.replace('((\'getInitalAssets\'))', `function getInitalAssets(assetsType, lang) {
107
107
  if (assetsType === "js") {
108
108
  return ${JSON.stringify(initialJsFiles)}
@@ -139,10 +139,8 @@ class EFCTemplatePlugin {
139
139
  }
140
140
 
141
141
  const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
142
- compilation.assets[outputFile] = source; // console.log('EFCTemplatePlugin working');
143
- // eslint-disable-next-line no-console
144
-
145
- console.log('The EFC embedded code was created successfully..!!!');
142
+ compilation.assets[outputFile] = source;
143
+ (0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
146
144
  });
147
145
  }
148
146
 
@@ -22,7 +22,7 @@ var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUr
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
 
24
24
  let i18nObj = null;
25
- let options = (0, _utils.getOptions)();
25
+ const options = (0, _utils.getOptions)();
26
26
 
27
27
  function newAssign(target, data) {
28
28
  return Object.assign({}, target, data);
@@ -43,7 +43,7 @@ class I18NInjectIntoIndexPlugin {
43
43
  }
44
44
 
45
45
  getI18nFileUrlPath(chunk, compilation) {
46
- let urlpath = (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, this.templateLabel);
46
+ const urlpath = (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, this.templateLabel);
47
47
  return (0, _urlConcat.urlConcat)(this.publicPath, urlpath);
48
48
  }
49
49
 
@@ -81,7 +81,6 @@ class I18NInjectIntoIndexPlugin {
81
81
  withI18nSpitHandling(compiler) {
82
82
  compiler.hooks.make.tap('I18NInjectIntoIndexPlugin', compilation => {
83
83
  // let cdns = Object.keys(this.publicPaths);
84
- // console.log('compilation.assets', Object.keys(compilation.assets).filter(a => a.includes('i18n')));
85
84
  if (!(0, _hashUtils.hasContentHash)(this.i18nFileNameTemplate)) {
86
85
  this.injectI18nURLsToHTML(compilation);
87
86
  return;
@@ -91,7 +90,7 @@ class I18NInjectIntoIndexPlugin {
91
90
  // Manipulate the content
92
91
  const i18nManifest = this.getI18nManifest(compilation);
93
92
  const entryPoint = compilation.entrypoints.get(this.entryPointName);
94
- let i18nAssets = (0, _hashUtils.getShortI18nAssets)(entryPoint.chunks, i18nManifest, this.publicPath);
93
+ const i18nAssets = (0, _hashUtils.getShortI18nAssets)(entryPoint.chunks, i18nManifest, this.publicPath);
95
94
  data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets))); // Tell webpack to move on
96
95
 
97
96
  cb(null, data);
@@ -111,15 +110,15 @@ class I18NInjectIntoIndexPlugin {
111
110
  compiler.hooks.emit.tap('I18NInjectIntoIndexPlugin', compilation => {
112
111
  // let cdns = Object.keys(this.publicPaths);
113
112
  if (i18nObj === null) {
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
113
+ const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
115
114
 
116
115
  i18nObj = i18nFiles.reduce((res, next) => {
117
- let fileName = next.replace(`i18n${_path.default.sep}`, '');
118
- let splittedFileName = fileName.split('.');
119
- /* if (this.isDevelopment) {
120
- res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
121
- } else {
122
- res[splittedFileName[0]] = fileName;
116
+ const fileName = next.replace(`i18n${_path.default.sep}`, '');
117
+ const splittedFileName = fileName.split('.');
118
+ /* if (this.isDevelopment) {
119
+ res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
120
+ } else {
121
+ res[splittedFileName[0]] = fileName;
123
122
  } */
124
123
 
125
124
  res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
@@ -127,10 +126,10 @@ class I18NInjectIntoIndexPlugin {
127
126
  }, {});
128
127
  }
129
128
 
130
- let [indexFile] = Object.keys(compilation.assets).filter(filename => /\.html$/g.test(filename));
129
+ const [indexFile] = Object.keys(compilation.assets).filter(filename => /\.html$/g.test(filename));
131
130
 
132
131
  if (indexFile) {
133
- let source = compilation.assets[indexFile].source();
132
+ const source = compilation.assets[indexFile].source();
134
133
  compilation.assets[indexFile] = new _webpackSources.RawSource(source.replace(new RegExp('<!--I18nInfoToServer(.*)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nObj))));
135
134
  }
136
135
  });
@@ -24,10 +24,9 @@ class I18nDebugPlugin {
24
24
  compiler.hooks.normalModuleFactory.tap(pluginName, factory => {
25
25
  if (!this.compilationParams || this.compilationParams.normalModuleFactory === factory) {
26
26
  return;
27
- } // console.log('skiped');
27
+ }
28
28
 
29
-
30
- let handler = parser => {
29
+ const handler = parser => {
31
30
  parser.hooks.program.tap(pluginName, (ast, commmets) => {
32
31
  const {
33
32
  module