@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. package/README.md +35 -40
  2. package/docs/SelectorWeight.md +6 -0
  3. package/docs/VariableConversion.md +33 -1
  4. package/lib/babel/cmjs-plugins-presets.js +4 -0
  5. package/lib/babel/es-plugins-presets.js +4 -0
  6. package/lib/common/getEntries.js +10 -0
  7. package/lib/common/getPublicPathConfig.js +6 -0
  8. package/lib/common/index.js +5 -0
  9. package/lib/common/splitChunks.js +13 -2
  10. package/lib/common/sslcertUpdater.js +17 -6
  11. package/lib/common/templateParameters.js +2 -0
  12. package/lib/common/testPattern.js +21 -10
  13. package/lib/common/valueReplacer.js +15 -0
  14. package/lib/configs/jest.config.js +9 -0
  15. package/lib/configs/libAlias.js +2 -4
  16. package/lib/configs/webpack.component.umd.config.js +5 -0
  17. package/lib/configs/webpack.css.umd.config.js +13 -5
  18. package/lib/configs/webpack.dev.config.js +36 -2
  19. package/lib/configs/webpack.docs.config.js +21 -1
  20. package/lib/configs/webpack.impact.config.js +19 -1
  21. package/lib/configs/webpack.prod.config.js +37 -3
  22. package/lib/hooks/docsProptypeHook.js +7 -3
  23. package/lib/jest/commitedFilesResult.js +45 -3
  24. package/lib/jest/coverageCollector.js +11 -0
  25. package/lib/jest/jsonMaker.js +6 -0
  26. package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
  27. package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
  28. package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
  29. package/lib/jest/result.js +22 -0
  30. package/lib/jest/run.js +17 -6
  31. package/lib/jest/setup.js +57 -5
  32. package/lib/loaderUtils/configsAssetsLoaders.js +11 -1
  33. package/lib/loaderUtils/getCSSLoaders.js +35 -20
  34. package/lib/loaderUtils/getDevJsLoaders.js +8 -0
  35. package/lib/loaderUtils/index.js +3 -0
  36. package/lib/loaderUtils/windowsModification.js +11 -0
  37. package/lib/loaders/docsLoader.js +7 -0
  38. package/lib/loaders/docsPropsLoader.js +7 -3
  39. package/lib/loaders/fileBountryLoader.js +2 -0
  40. package/lib/loaders/fileLoader.js +22 -11
  41. package/lib/loaders/scriptInstrumentLoader.js +13 -5
  42. package/lib/loaders/selectorMappingLoader.js +25 -7
  43. package/lib/loaders/workerLoader.js +20 -4
  44. package/lib/middlewares/HMRMiddleware.js +26 -13
  45. package/lib/middlewares/SSTMiddleware.js +3 -0
  46. package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
  47. package/lib/pluginUtils/getDevPlugins.js +63 -17
  48. package/lib/pluginUtils/getDocsPlugins.js +10 -1
  49. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
  50. package/lib/pluginUtils/getLibraryPlugins.js +5 -0
  51. package/lib/pluginUtils/getProdPlugins.js +72 -23
  52. package/lib/pluginUtils/getServerPlugins.js +5 -0
  53. package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
  54. package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
  55. package/lib/pluginUtils/index.js +8 -0
  56. package/lib/plugins/CdnChangePlugin.js +14 -0
  57. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  58. package/lib/plugins/EFCPlugin.js +34 -23
  59. package/lib/plugins/EFCTemplatePlugin.js +32 -23
  60. package/lib/plugins/I18NInjectIntoIndexPlugin.js +34 -8
  61. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
  62. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  63. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +39 -8
  64. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +29 -14
  65. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +22 -13
  66. package/lib/plugins/I18nSplitPlugin/index.js +23 -13
  67. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  68. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  69. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  70. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
  71. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
  73. package/lib/plugins/ManifestPlugin.js +17 -0
  74. package/lib/plugins/ModuleStatsPlugin.js +23 -0
  75. package/lib/plugins/OptimizeJSPlugin.js +7 -0
  76. package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
  77. package/lib/plugins/PublicPathChangePlugin.js +36 -4
  78. package/lib/plugins/ReportGeneratePlugin.js +30 -4
  79. package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
  80. package/lib/plugins/ResourceHintsPlugin.js +10 -3
  81. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  82. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -9
  83. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  84. package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
  85. package/lib/plugins/SelectorPlugin.js +97 -0
  86. package/lib/plugins/ServiceWorkerPlugin.js +20 -4
  87. package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
  88. package/lib/plugins/SourceMapHookPlugin.js +9 -0
  89. package/lib/plugins/TPHashMappingPlugin.js +15 -1
  90. package/lib/plugins/UglifyCSSPlugin.js +9 -0
  91. package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
  92. package/lib/plugins/VariableConversionCollector.js +252 -0
  93. package/lib/plugins/composeCommonPlugin.js +30 -0
  94. package/lib/plugins/index.js +19 -0
  95. package/lib/plugins/libraryImpactPlugin.js +32 -0
  96. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  97. package/lib/postcss-plugins/ExcludePlugin.js +4 -0
  98. package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
  99. package/lib/postcss-plugins/ValueReplacer.js +6 -9
  100. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  101. package/lib/postcss-plugins/hoverActivePlugin.js +66 -30
  102. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +40 -13
  103. package/lib/postcss-plugins/variableModificationPlugin/index.js +215 -141
  104. package/lib/postcss-plugins/variableModifier.js +20 -13
  105. package/lib/schemas/index.js +23 -4
  106. package/lib/servers/clusterHubServer.js +10 -0
  107. package/lib/servers/devBuild.js +24 -13
  108. package/lib/servers/docsServer.js +2 -0
  109. package/lib/servers/docsServerCore.js +21 -0
  110. package/lib/servers/getCliPath.js +9 -0
  111. package/lib/servers/helpServer.js +5 -0
  112. package/lib/servers/httpsOptions.js +4 -0
  113. package/lib/servers/impactServer.js +34 -2
  114. package/lib/servers/mockserver.js +9 -0
  115. package/lib/servers/nowatchserver.js +34 -12
  116. package/lib/servers/scrServer.js +20 -13
  117. package/lib/servers/server.js +35 -7
  118. package/lib/servers/ssServer.js +16 -0
  119. package/lib/templates/CoverageScriptTemplate.js +14 -0
  120. package/lib/templates/WMSTemplate.js +12 -6
  121. package/lib/utils/babelPresets.js +2 -0
  122. package/lib/utils/clean.js +8 -2
  123. package/lib/utils/copy.js +6 -0
  124. package/lib/utils/copyTimezones.js +8 -0
  125. package/lib/utils/createEventStream.js +4 -0
  126. package/lib/utils/cssClassNameGenerate.js +19 -3
  127. package/lib/utils/cssURLReplacer.js +50 -38
  128. package/lib/utils/dependencyPostPublish.js +9 -0
  129. package/lib/utils/fileUtils.js +26 -0
  130. package/lib/utils/folderIterator.js +10 -0
  131. package/lib/utils/getComponents.js +21 -0
  132. package/lib/utils/getCurrentBranch.js +5 -0
  133. package/lib/utils/getDependenciesImpactList.js +21 -0
  134. package/lib/utils/getFileType.js +49 -0
  135. package/lib/utils/getHash.js +7 -0
  136. package/lib/utils/getIp.js +2 -0
  137. package/lib/utils/getOptions.js +39 -14
  138. package/lib/utils/getServerURL.js +7 -0
  139. package/lib/utils/index.js +47 -2
  140. package/lib/utils/init.js +1 -0
  141. package/lib/utils/initPreCommitHook.js +29 -6
  142. package/lib/utils/jsonHelper.js +19 -2
  143. package/lib/utils/libraryImpactConfig.js +2 -0
  144. package/lib/utils/lint/addScripts.js +5 -2
  145. package/lib/utils/lint/checkExistingConfig.js +12 -3
  146. package/lib/utils/lint/copyConfigs.js +3 -0
  147. package/lib/utils/lint/index.js +9 -0
  148. package/lib/utils/lint/lintScripts.js +1 -0
  149. package/lib/utils/lint/lintSetup.js +4 -3
  150. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  151. package/lib/utils/lint/question.js +7 -0
  152. package/lib/utils/lintReporter.js +20 -0
  153. package/lib/utils/mailSender.js +7 -0
  154. package/lib/utils/pullOrigin.js +4 -0
  155. package/lib/utils/reinstallDependencies.js +28 -0
  156. package/lib/utils/removeAttributes.js +7 -0
  157. package/lib/utils/repoClone.js +27 -2
  158. package/lib/utils/request.js +12 -0
  159. package/lib/utils/rtl.js +16 -4
  160. package/lib/utils/setEnvVariables.js +2 -0
  161. package/lib/utils/ssTestHack.js +10 -0
  162. package/lib/utils/switchBranch.js +4 -0
  163. package/lib/utils/urlConcat.js +4 -0
  164. package/lib/utils/useExitCleanup.js +10 -9
  165. package/package.json +10 -9
@@ -1,21 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _reactDocgen = _interopRequireDefault(require("react-docgen"));
4
+
4
5
  var _path = _interopRequireDefault(require("path"));
6
+
5
7
  var _utils = require("../utils");
8
+
6
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
- // import loaderUtils from 'loader-utils';
8
10
 
11
+ // import loaderUtils from 'loader-utils';
9
12
  module.exports = source => {
10
- (void 0).cacheable && (void 0).cacheable();
11
- // let query = loaderUtils.parseQuery(this.query);
13
+ (void 0).cacheable && (void 0).cacheable(); // let query = loaderUtils.parseQuery(this.query);
12
14
 
13
15
  let value = {};
16
+
14
17
  try {
15
18
  value = _reactDocgen.default.parse(source);
16
19
  } catch (e) {
17
20
  (0, _utils.log)('ERROR in docgen-loader', e);
18
21
  }
22
+
19
23
  let comNameAry = (void 0).resourcePath.split(_path.default.sep);
20
24
  let comName = comNameAry[comNameAry.length - 1];
21
25
  let name = comName.substring(0, comName.lastIndexOf('.'));
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
5
7
  module.exports = function (source) {
6
8
  const {
7
9
  rootContext,
@@ -1,55 +1,64 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  var _loaderUtils = _interopRequireDefault(require("loader-utils"));
6
+
5
7
  var _common = require("../common");
8
+
6
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
7
11
  module.exports = function (content) {
8
12
  let {
9
13
  userRequest
10
14
  } = this._module.issuer;
11
15
  this.cacheable && this.cacheable();
16
+
12
17
  if (!this.emitFile) {
13
18
  throw new Error('emitFile is required from module system');
14
19
  }
15
- let options = _loaderUtils.default.getOptions(this) || {};
16
- let query = this.resourceQuery ? _loaderUtils.default.parseQuery(this.resourceQuery) : {};
17
20
 
18
- // let configKey = query.config || 'fileLoader';
21
+ let options = _loaderUtils.default.getOptions(this) || {};
22
+ let query = this.resourceQuery ? _loaderUtils.default.parseQuery(this.resourceQuery) : {}; // let configKey = query.config || 'fileLoader';
19
23
 
20
24
  let config = {
21
25
  // publicPath: false,
22
26
  useRelativePath: false,
23
- name: '[hash].[ext]'
24
- // publicPathStrigify: true
25
- };
27
+ name: '[hash].[ext]' // publicPathStrigify: true
28
+
29
+ }; // options takes precedence over config
26
30
 
27
- // options takes precedence over config
28
31
  Object.keys(options).forEach(attr => {
29
32
  config[attr] = options[attr];
30
- });
33
+ }); // query takes precedence over config and options
31
34
 
32
- // query takes precedence over config and options
33
35
  Object.keys(query).forEach(attr => {
34
36
  config[attr] = query[attr];
35
37
  });
36
38
  let context = config.context || options.context;
39
+
37
40
  let url = _loaderUtils.default.interpolateName(this, config.name, {
38
41
  context: context,
39
42
  content: content,
40
43
  regExp: config.regExp
41
44
  });
45
+
42
46
  let outputPath = '';
43
47
  let filePath = this.resourcePath;
48
+
44
49
  if (config.useRelativePath) {
45
50
  let issuerContext = this._module && this._module.issuer && this._module.issuer.context || context;
51
+
46
52
  let relativeUrl = issuerContext && _path.default.relative(issuerContext, filePath).split(_path.default.sep).join('/');
53
+
47
54
  let relativePath = relativeUrl && `${_path.default.dirname(relativeUrl)}/`;
55
+
48
56
  if (~relativePath.indexOf('../')) {
49
57
  outputPath = _path.default.posix.join(outputPath, relativePath, url);
50
58
  } else {
51
59
  outputPath = relativePath + url;
52
60
  }
61
+
53
62
  url = relativePath + url;
54
63
  } else if (config.outputPath) {
55
64
  // support functions as outputPath to generate them dynamically
@@ -58,9 +67,9 @@ module.exports = function (content) {
58
67
  } else {
59
68
  outputPath = url;
60
69
  }
70
+
61
71
  let requestFromJS = /\.js$/.test(userRequest);
62
- let publicPath = requestFromJS ? (0, _common.getPublicPathConfig)(url) : `__webpack_public_path__ + ${JSON.stringify(url)}`;
63
- // if (config.publicPath !== false) {
72
+ let publicPath = requestFromJS ? (0, _common.getPublicPathConfig)(url) : `__webpack_public_path__ + ${JSON.stringify(url)}`; // if (config.publicPath !== false) {
64
73
  // // support functions as publicPath to generate them dynamically
65
74
  // if (config.publicPathStringify) {
66
75
  // publicPath = JSON.Stringify(
@@ -79,6 +88,8 @@ module.exports = function (content) {
79
88
  if (query.emitFile === undefined || query.emitFile) {
80
89
  this.emitFile(outputPath, content);
81
90
  }
91
+
82
92
  return `module.exports = ${publicPath};`;
83
93
  };
94
+
84
95
  module.exports.raw = true;
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var esprima = _interopRequireWildcard(require("esprima"));
4
+
4
5
  var _escodegen = _interopRequireDefault(require("escodegen"));
6
+
5
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+
6
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+
7
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+
8
13
  let start = {
9
14
  type: 'ExpressionStatement',
10
15
  expression: {
@@ -48,21 +53,26 @@ let start = {
48
53
  }]
49
54
  }
50
55
  };
56
+
51
57
  let scriptInstrumentLoader = function (source) {
52
58
  let parsed = esprima.parseModule(source, {
53
59
  jsx: true
54
60
  });
61
+
55
62
  for (let i in parsed.body) {
56
63
  if (parsed.body[i].type === 'FunctionDeclaration' || parsed.body[i].type === 'ExportDefaultDeclaration' || parsed.body[i].type === 'ExportNamedDeclaration') {
57
64
  let ParsedTemp;
65
+
58
66
  if (parsed.body[i].type === 'FunctionDeclaration') {
59
67
  ParsedTemp = parsed.body[i];
60
68
  } else {
61
69
  ParsedTemp = parsed.body[i].declaration;
62
70
  }
71
+
63
72
  if (ParsedTemp) {
64
73
  if (ParsedTemp.id) {
65
74
  let funcname = ParsedTemp.id.name;
75
+
66
76
  if (funcname !== 'mapStateToProps') {
67
77
  if (!funcname.includes('_')) {
68
78
  let startFunc = JSON.parse(JSON.stringify(start));
@@ -77,8 +87,8 @@ let scriptInstrumentLoader = function (source) {
77
87
  }
78
88
  }
79
89
  }
80
- return _escodegen.default.generate(parsed);
81
- // function removeDuplicates(arr) {
90
+
91
+ return _escodegen.default.generate(parsed); // function removeDuplicates(arr) {
82
92
  // let uniqueArray = [];
83
93
  // for (let i = 0; i < arr.length; i++) {
84
94
  // if (uniqueArray.indexOf(arr[i]) == -1) {
@@ -90,9 +100,7 @@ let scriptInstrumentLoader = function (source) {
90
100
  // funcArray = removeDuplicates(funcArray);
91
101
  };
92
102
 
93
- module.exports = scriptInstrumentLoader;
94
-
95
- // let start = {
103
+ module.exports = scriptInstrumentLoader; // let start = {
96
104
  // type: 'ExpressionStatement',
97
105
  // expression: {
98
106
  // type: 'CallExpression',
@@ -1,57 +1,75 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  var _fs = _interopRequireDefault(require("fs"));
6
+
5
7
  var _utils = require("../utils");
8
+
6
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
7
11
  let options = (0, _utils.getOptions)();
8
12
  const {
9
13
  cssSelectorZipPath
10
14
  } = options.impactService;
11
- const zipname = _path.default.parse(cssSelectorZipPath).name;
12
- // console.log({ cssSelectorZipPath, zipname });
13
15
 
16
+ const zipname = _path.default.parse(cssSelectorZipPath).name; // console.log({ cssSelectorZipPath, zipname });
14
17
  // TODO:NOTE: need to check about .. path related files creation
15
18
  // for now no css files have given form react-cli need to make sure about it.
16
19
 
20
+
17
21
  let zippath = _path.default.join(process.cwd(), cssSelectorZipPath);
22
+
18
23
  if (_fs.default.existsSync(_path.default.join(process.cwd(), cssSelectorZipPath))) {
19
24
  _fs.default.rmSync(zippath);
20
- console.log('zip file deleted', zippath);
21
- // fs.rmSync(zippath, {force:true})
22
- // console.log('created folder ==> ', dpath);
23
- }
24
25
 
25
- // const minicssComment =
26
+ console.log('zip file deleted', zippath); // fs.rmSync(zippath, {force:true})
27
+ // console.log('created folder ==> ', dpath);
28
+ } // const minicssComment =
26
29
  // '// extracted by mini-css-extract-plugin\n';
30
+
31
+
27
32
  const startStr = '// extracted by mini-css-extract-plugin\n' + 'module.exports = ';
33
+
28
34
  module.exports = function (source) {
29
35
  const {
30
36
  rootContext,
31
37
  resourcePath
32
38
  } = this;
39
+
33
40
  const relativePath = _path.default.relative(rootContext, resourcePath);
41
+
34
42
  let fpath = _path.default.join(rootContext, zipname, relativePath);
43
+
35
44
  let originalpath = _path.default.join(rootContext, relativePath);
45
+
36
46
  if (relativePath.startsWith('..')) {
37
47
  throw `unexpected path ${relativePath}`;
38
48
  }
49
+
39
50
  let dpath = fpath.slice(0, fpath.lastIndexOf(_path.default.sep));
51
+
40
52
  if (!_fs.default.existsSync(originalpath)) {
41
53
  throw `originalpath not exixt ${originalpath}`;
42
54
  }
55
+
43
56
  if (!_fs.default.existsSync(dpath)) {
44
57
  _fs.default.mkdirSync(dpath, {
45
58
  recursive: true
46
59
  });
47
60
  }
61
+
48
62
  let jsonStr = '{}';
63
+
49
64
  if (source.startsWith(startStr)) {
50
65
  // source will be like
51
66
  // `// extracted by mini-css-extract-plugin\nmodule.exports = {"app":"zd-app"};`
52
67
  jsonStr = source.slice(startStr.length, -1);
53
68
  }
69
+
54
70
  _fs.default.writeFileSync(`${fpath}_map`, jsonStr);
71
+
55
72
  _fs.default.writeFileSync(fpath, _fs.default.readFileSync(originalpath));
73
+
56
74
  return source;
57
75
  };
@@ -5,14 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = loader;
7
7
  exports.pitch = pitch;
8
+
8
9
  var _path = _interopRequireDefault(require("path"));
10
+
9
11
  var _loaderUtils = require("loader-utils");
12
+
10
13
  var _schemaUtils = _interopRequireDefault(require("schema-utils"));
14
+
11
15
  var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntryPlugin"));
16
+
12
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
13
19
  /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
14
20
  import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
15
-
16
21
  const schema = {
17
22
  'type': 'object',
18
23
  'properties': {
@@ -40,18 +45,22 @@ const schema = {
40
45
  }
41
46
  },
42
47
  'additionalProperties': false
43
- };
44
- // eslint-disable-next-line
48
+ }; // eslint-disable-next-line
49
+
45
50
  function loader() {}
51
+
46
52
  function getDefaultFilename(filename) {
47
53
  if (typeof filename === 'function') {
48
54
  return filename;
49
55
  }
56
+
50
57
  return filename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
51
58
  }
59
+
52
60
  function getDefaultChunkFilename(chunkFilename) {
53
61
  return chunkFilename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
54
62
  }
63
+
55
64
  function pitch(request) {
56
65
  this.cacheable(false);
57
66
  const options = (0, _loaderUtils.getOptions)(this);
@@ -71,7 +80,6 @@ function pitch(request) {
71
80
  globalObject: 'self'
72
81
  };
73
82
  workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
74
-
75
83
  /*
76
84
  new WebWorkerTemplatePlugin().apply(workerContext.compiler);
77
85
 
@@ -87,19 +95,25 @@ function pitch(request) {
87
95
  const cb = this.async();
88
96
  workerContext.compiler.runAsChild((errorArg, entries, compilation) => {
89
97
  let error = errorArg;
98
+
90
99
  if (!error && compilation.errors && compilation.errors.length) {
91
100
  // eslint-disable-next-line
92
101
  error = compilation.errors[0];
93
102
  }
103
+
94
104
  const entry = entries && entries[0] && entries[0].files.values().next().value;
105
+
95
106
  if (!error && !entry) {
96
107
  error = Error(`WorkerPlugin: no entry for ${request}`);
97
108
  }
109
+
98
110
  if (error) {
99
111
  return cb(error);
100
112
  }
113
+
101
114
  function workerCode() {
102
115
  let blob;
116
+
103
117
  try {
104
118
  blob = new Blob([`importScripts('${this.workerUrl}');`], {
105
119
  'type': 'application/javascript'
@@ -107,11 +121,13 @@ function pitch(request) {
107
121
  } catch (e1) {
108
122
  throw new Error(e1);
109
123
  }
124
+
110
125
  let url = window.URL || window.webkitURL;
111
126
  let blobUrl = url.createObjectURL(blob);
112
127
  let worker = new Worker(blobUrl);
113
128
  return worker;
114
129
  }
130
+
115
131
  return cb(null, `${options.esModule ? 'export default' : 'module.exports ='} {\n
116
132
  workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
117
133
  getInstance: ${workerCode} \n
@@ -4,24 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = HMRMiddleware;
7
+
7
8
  function pathMatch(url, path) {
8
9
  if (url === path) {
9
10
  return true;
10
11
  }
12
+
11
13
  let q = url.indexOf('?');
14
+
12
15
  if (q === -1) {
13
16
  return false;
14
17
  }
18
+
15
19
  return url.substring(0, q) === path;
16
20
  }
21
+
17
22
  function createEventStream(heartbeat) {
18
23
  let clientId = 0;
19
24
  let clients = {};
25
+
20
26
  function everyClient(fn) {
21
27
  Object.keys(clients).forEach(id => {
22
28
  fn(clients[id]);
23
29
  });
24
30
  }
31
+
25
32
  setInterval(() => {
26
33
  everyClient(client => {
27
34
  client.write(`data: ${JSON.stringify({
@@ -52,20 +59,22 @@ function createEventStream(heartbeat) {
52
59
  }
53
60
  };
54
61
  }
62
+
55
63
  function extractBundles(stats) {
56
64
  // Stats has modules, single bundle
57
65
  if (stats.modules) {
58
66
  return [stats];
59
- }
67
+ } // Stats has children, multiple bundles
68
+
60
69
 
61
- // Stats has children, multiple bundles
62
70
  if (stats.children && stats.children.length) {
63
71
  return stats.children;
64
- }
72
+ } // Not sure, assume single
73
+
65
74
 
66
- // Not sure, assume single
67
75
  return [stats];
68
76
  }
77
+
69
78
  function publishStats(action, statsResult, eventStream, log) {
70
79
  // For multi-compiler, stats will be an object with a 'children' array of stats
71
80
  let bundles = extractBundles(statsResult.toJson({
@@ -74,8 +83,7 @@ function publishStats(action, statsResult, eventStream, log) {
74
83
  bundles.forEach(stats => {
75
84
  if (log) {
76
85
  log(`webpack built ${stats.name ? `${stats.name} ` : ''}${stats.hash} in ${stats.time}ms`);
77
- }
78
- // if (
86
+ } // if (
79
87
  // // !force &&
80
88
  // action !== 'sync' &&
81
89
  // stats &&
@@ -87,10 +95,13 @@ function publishStats(action, statsResult, eventStream, log) {
87
95
  // type: 'still-ok'
88
96
  // });
89
97
  // }
98
+
99
+
90
100
  eventStream.publish({
91
101
  type: 'hash',
92
102
  data: stats.hash
93
103
  });
104
+
94
105
  if (stats.errors.length > 0) {
95
106
  eventStream.publish({
96
107
  type: 'errors',
@@ -108,9 +119,9 @@ function publishStats(action, statsResult, eventStream, log) {
108
119
  }
109
120
  });
110
121
  }
122
+
111
123
  function HMRMiddleware(compiler, opts = {}) {
112
- opts.log =
113
- // eslint-disable-next-line no-console
124
+ opts.log = // eslint-disable-next-line no-console
114
125
  typeof opts.log === 'undefined' ? console.log.bind(console) : opts.log;
115
126
  opts.path = opts.path || '/__webpack_hmr';
116
127
  opts.heartbeat = opts.heartbeat || 10 * 1000;
@@ -122,13 +133,16 @@ function HMRMiddleware(compiler, opts = {}) {
122
133
  opts.log('webpack compilation starts...');
123
134
  loggedInfo = true;
124
135
  }
136
+
125
137
  callback && callback();
126
138
  });
127
139
  compiler.hooks.compile.tap('HMRMiddleware', () => {
128
140
  latestStats = null;
141
+
129
142
  if (opts.log) {
130
143
  opts.log('webpack building...');
131
144
  }
145
+
132
146
  eventStream.publish({
133
147
  type: 'building'
134
148
  });
@@ -138,12 +152,13 @@ function HMRMiddleware(compiler, opts = {}) {
138
152
  latestStats = statsResult;
139
153
  publishStats('built', latestStats, eventStream, opts.log);
140
154
  });
155
+
141
156
  let middleware = function (req, res, next) {
142
157
  if (!pathMatch(req.url, opts.path)) {
143
158
  return next();
144
159
  }
145
- eventStream.handler(req, res);
146
- // if (latestStats) {
160
+
161
+ eventStream.handler(req, res); // if (latestStats) {
147
162
  // // Explicitly not passing in `log` fn as we don't want to log again on
148
163
  // // the server
149
164
  // // publishStats('sync', latestStats, eventStream);
@@ -152,9 +167,7 @@ function HMRMiddleware(compiler, opts = {}) {
152
167
 
153
168
  middleware.publish = eventStream.publish;
154
169
  return middleware;
155
- }
156
-
157
- // function buildModuleMap(modules) {
170
+ } // function buildModuleMap(modules) {
158
171
  // let map = {};
159
172
  // modules.forEach(function(module) {
160
173
  // map[module.id] = module.name;
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _utils = require("../utils");
9
+
8
10
  function SSTMiddleware(compiler, callback) {
9
11
  compiler.hooks.done.tap('SSTMiddleware', stats => {
10
12
  (0, _utils.log)('Compilation finished!');
@@ -14,5 +16,6 @@ function SSTMiddleware(compiler, callback) {
14
16
  next();
15
17
  };
16
18
  }
19
+
17
20
  var _default = SSTMiddleware;
18
21
  exports.default = _default;
@@ -4,11 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.configHtmlWebpackPlugins = configHtmlWebpackPlugins;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
11
+
9
12
  var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
13
+
10
14
  var _common = require("../common");
15
+
11
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
12
18
  const defaultHTMLMiniFyOption = {
13
19
  collapseWhitespace: true,
14
20
  minifyCSS: true,
@@ -20,6 +26,7 @@ const defaultHTMLMiniFyOption = {
20
26
  removeStyleLinkTypeAttributes: true,
21
27
  useShortDoctype: true
22
28
  };
29
+
23
30
  function configHtmlWebpackPlugins(plugins, {
24
31
  enableChunkHash = false,
25
32
  folder,
@@ -40,12 +47,11 @@ function configHtmlWebpackPlugins(plugins, {
40
47
  scriptLoading: 'defer',
41
48
  inject: inject
42
49
  };
43
- console.log({
44
- optionsHtmlWebpack
45
- });
50
+
46
51
  if (hasEFC) {
47
52
  optionsHtmlWebpack.excludeChunks = ['efc', 'widget'];
48
53
  }
54
+
49
55
  plugins.push(new _htmlWebpackPlugin.default(optionsHtmlWebpack));
50
56
  crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
51
57
  crossorigin: 'anonymous'