@zohodesk/react-cli 1.1.18 → 1.1.19-exp.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/README.md +6 -0
  2. package/lib/babel/babel-option-utils/babel-preset-react-option.js +22 -0
  3. package/lib/babel/cmjs-plugins-presets.js +7 -1
  4. package/lib/babel/es-plugins-presets.js +7 -1
  5. package/lib/configs/webpack.prod.config.js +9 -2
  6. package/lib/loaderUtils/getDevJsLoaders.js +7 -2
  7. package/lib/loaders/workerLoader.js +39 -24
  8. package/npm-shrinkwrap.json +19077 -15
  9. package/package.json +1 -1
  10. package/packages/client_build_tool/lib/allCommandsConfigs.js +23 -0
  11. package/packages/client_build_tool/lib/buildToolLoggers.js +32 -0
  12. package/packages/client_build_tool/lib/commands/build/commandExecutor.js +21 -0
  13. package/packages/client_build_tool/lib/commands/build/config.js +12 -0
  14. package/packages/client_build_tool/lib/commands/build/errorHander.js +10 -0
  15. package/packages/client_build_tool/lib/commands/build/index.js +35 -0
  16. package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +40 -0
  17. package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +17 -0
  18. package/packages/client_build_tool/lib/commands/buildEs/config.js +12 -0
  19. package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +17 -0
  20. package/packages/client_build_tool/lib/commands/buildLib/config.js +12 -0
  21. package/packages/client_build_tool/lib/commands/start/commandExecutor.js +13 -0
  22. package/packages/client_build_tool/lib/commands/start/config.js +12 -0
  23. package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +10 -0
  24. package/packages/client_build_tool/lib/commands/start/errorHander.js +10 -0
  25. package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +36 -0
  26. package/packages/client_build_tool/lib/commands/start/postProcesser.js +10 -0
  27. package/packages/client_build_tool/lib/commands/start/preProcesser.js +10 -0
  28. package/packages/client_build_tool/lib/commandsRouter.js +71 -0
  29. package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +44 -0
  30. package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +31 -0
  31. package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +51 -0
  32. package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +21 -0
  33. package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +16 -0
  34. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +111 -0
  35. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +1 -0
  36. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +11 -0
  37. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +136 -0
  38. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +95 -0
  39. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +25 -0
  40. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +29 -0
  41. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +24 -0
  42. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +99 -0
  43. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +81 -0
  44. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +201 -0
  45. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +401 -0
  46. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +67 -0
  47. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +23 -0
  48. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +29 -0
  49. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +49 -0
  50. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +77 -0
  51. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +63 -0
  52. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +19 -0
  53. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +31 -0
  54. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +127 -0
  55. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +1 -0
  56. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +63 -0
  57. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +89 -0
  58. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +34 -0
  59. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +15 -0
  60. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +155 -0
  61. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +49 -0
  62. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +58 -0
  63. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +139 -0
  64. package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +34 -0
  65. package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +30 -0
  66. package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +17 -0
  67. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +14 -0
  68. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +24 -0
  69. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +18 -0
  70. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +21 -0
  71. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +138 -0
  72. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +83 -0
  73. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +23 -0
  74. package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +133 -0
  75. package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +39 -0
  76. package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +28 -0
  77. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +18 -0
  78. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +38 -0
  79. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +24 -0
  80. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +28 -0
  81. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +35 -0
  82. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +16 -0
  83. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +23 -0
  84. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +19 -0
  85. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +27 -0
  86. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +18 -0
  87. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +15 -0
  88. package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +39 -0
  89. package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +36 -0
  90. package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +42 -0
  91. package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +12 -0
  92. package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +17 -0
  93. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +24 -0
  94. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +50 -0
  95. package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +16 -0
  96. package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +38 -0
  97. package/packages/client_build_tool/lib/shared/commands-utlis/index.js +29 -0
  98. package/packages/client_build_tool/lib/shared/commands-utlis/log.js +13 -0
  99. package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +11 -0
  100. package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +11 -0
  101. package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +35 -0
  102. package/packages/client_build_tool/lib/shared/constants.js +33 -0
  103. package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +37 -0
  104. package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +37 -0
  105. package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +119 -0
  106. package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +65 -0
  107. package/packages/client_build_tool/lib/shared/schemas/getCWD.js +23 -0
  108. package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +21 -0
  109. package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +32 -0
  110. package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +480 -0
  111. package/packages/client_build_tool/lib/shared/schemas/readOptions.js +55 -0
  112. package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +26 -0
  113. package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +152 -0
  114. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +37 -0
  115. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +27 -0
  116. package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +40 -0
  117. package/packages/client_build_tool/lib/shared/server/corsHandleing.js +28 -0
  118. package/packages/client_build_tool/lib/shared/server/getIp.js +30 -0
  119. package/packages/client_build_tool/lib/shared/server/getServerURL.js +29 -0
  120. package/packages/client_build_tool/lib/shared/server/httpsOptions.js +53 -0
  121. package/packages/client_build_tool/lib/shared/server/initExpressApp.js +19 -0
  122. package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +66 -0
  123. package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +24 -0
  124. package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +40 -0
  125. package/packages/client_build_tool/lib/shared/server/startHttpServer.js +26 -0
  126. package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +34 -0
  127. package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +41 -0
  128. package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +44 -0
  129. package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +1 -0
  130. package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +19 -0
  131. package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +32 -0
  132. package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +48 -0
  133. package/packages/client_build_tool/lib/shared/server/urlConcat.js +25 -0
  134. package/packages/client_build_tool/lib/shared/utils/utils.js +1 -0
  135. package/packages/client_build_tool/node_modules/history/CHANGES.md +395 -0
  136. package/packages/client_build_tool/node_modules/history/DOMUtils.js +3 -0
  137. package/packages/client_build_tool/node_modules/history/ExecutionEnvironment.js +3 -0
  138. package/packages/client_build_tool/node_modules/history/LICENSE +21 -0
  139. package/packages/client_build_tool/node_modules/history/LocationUtils.js +3 -0
  140. package/packages/client_build_tool/node_modules/history/PathUtils.js +3 -0
  141. package/packages/client_build_tool/node_modules/history/README.md +282 -0
  142. package/packages/client_build_tool/node_modules/history/cjs/history.js +933 -0
  143. package/packages/client_build_tool/node_modules/history/cjs/history.min.js +1 -0
  144. package/packages/client_build_tool/node_modules/history/createBrowserHistory.js +3 -0
  145. package/packages/client_build_tool/node_modules/history/createHashHistory.js +3 -0
  146. package/packages/client_build_tool/node_modules/history/createMemoryHistory.js +3 -0
  147. package/packages/client_build_tool/node_modules/history/createTransitionManager.js +3 -0
  148. package/packages/client_build_tool/node_modules/history/es/DOMUtils.js +7 -0
  149. package/packages/client_build_tool/node_modules/history/es/ExecutionEnvironment.js +7 -0
  150. package/packages/client_build_tool/node_modules/history/es/LocationUtils.js +7 -0
  151. package/packages/client_build_tool/node_modules/history/es/PathUtils.js +7 -0
  152. package/packages/client_build_tool/node_modules/history/es/createBrowserHistory.js +7 -0
  153. package/packages/client_build_tool/node_modules/history/es/createHashHistory.js +7 -0
  154. package/packages/client_build_tool/node_modules/history/es/createMemoryHistory.js +7 -0
  155. package/packages/client_build_tool/node_modules/history/es/createTransitionManager.js +7 -0
  156. package/packages/client_build_tool/node_modules/history/es/warnAboutDeprecatedESMImport.js +35 -0
  157. package/packages/client_build_tool/node_modules/history/esm/history.js +904 -0
  158. package/packages/client_build_tool/node_modules/history/index.js +7 -0
  159. package/packages/client_build_tool/node_modules/history/package.json +117 -0
  160. package/packages/client_build_tool/node_modules/history/umd/history.js +1059 -0
  161. package/packages/client_build_tool/node_modules/history/umd/history.min.js +1 -0
  162. package/packages/client_build_tool/node_modules/history/warnAboutDeprecatedCJSRequire.js +35 -0
package/README.md CHANGED
@@ -44,6 +44,12 @@ Now to run app
44
44
 
45
45
  # Change Logs
46
46
 
47
+ # 1.1.19 (5-2-2024)
48
+
49
+ **Feature:-**
50
+
51
+ - Added config to remove additon of `babel/react` extend code for 'spread' operator usage on JSX.
52
+
47
53
  # 1.1.18 (30-01-2024)
48
54
 
49
55
  **Feature:-**
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getReactPreset;
7
+
8
+ function getReactPresetOptions() {
9
+ return {
10
+ runtime: 'classic',
11
+ // change it to 'automatic', when react version updated to 18.
12
+ useSpread: true
13
+ };
14
+ }
15
+
16
+ function getReactPreset({
17
+ disableES5Transpile
18
+ }) {
19
+ const reactPreset = require.resolve('@babel/preset-react');
20
+
21
+ return disableES5Transpile ? [reactPreset, getReactPresetOptions()] : reactPreset;
22
+ }
@@ -7,6 +7,10 @@ exports.default = void 0;
7
7
 
8
8
  var _utils = require("../utils");
9
9
 
10
+ var _babelPresetReactOption = _interopRequireDefault(require("./babel-option-utils/babel-preset-react-option"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  let {
11
15
  module: {
12
16
  mode
@@ -15,7 +19,9 @@ let {
15
19
  let isProd = mode.toLowerCase() === 'prod';
16
20
 
17
21
  var _default = () => ({
18
- presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
22
+ presets: [require.resolve('@babel/preset-env'), (0, _babelPresetReactOption.default)({
23
+ disableES5Transpile: false
24
+ })],
19
25
  plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
20
26
  __DOCS__: false
21
27
  } : {}]]
@@ -7,6 +7,10 @@ exports.default = void 0;
7
7
 
8
8
  var _utils = require("../utils");
9
9
 
10
+ var _babelPresetReactOption = _interopRequireDefault(require("./babel-option-utils/babel-preset-react-option"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  let {
11
15
  module: {
12
16
  mode,
@@ -25,7 +29,9 @@ var _default = () => ({
25
29
  }
26
30
  } : {
27
31
  modules: false
28
- }], require.resolve('@babel/preset-react')],
32
+ }], (0, _babelPresetReactOption.default)({
33
+ disableES5Transpile
34
+ })],
29
35
  plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
30
36
  __DOCS__: false
31
37
  } : {}], require.resolve('@babel/plugin-syntax-dynamic-import')]
@@ -14,6 +14,8 @@ var _configsAssetsLoaders = require("../loaderUtils/configsAssetsLoaders");
14
14
 
15
15
  var _resolvers = require("./resolvers");
16
16
 
17
+ var _babelPresetReactOption = _interopRequireDefault(require("../babel/babel-option-utils/babel-preset-react-option"));
18
+
17
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
20
 
19
21
  // import TerserPlugin from 'terser-webpack-plugin';
@@ -127,8 +129,13 @@ module.exports = {
127
129
  }
128
130
  } : {
129
131
  modules: false
130
- }], require.resolve('@babel/preset-react')],
131
- plugins: disableES5Transpile ? [removeAttribute ? require.resolve('../utils/removeAttributes') : false, require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('@babel/plugin-proposal-object-rest-spread'), shouldRemovePropTypes ? [require.resolve('babel-plugin-transform-react-remove-prop-types'), removePropTypes] : false, devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
132
+ }], (0, _babelPresetReactOption.default)({
133
+ disableES5Transpile
134
+ })],
135
+ plugins: disableES5Transpile ? [removeAttribute ? require.resolve('../utils/removeAttributes') : false, require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), // require.resolve(
136
+ // '@babel/plugin-proposal-object-rest-spread'
137
+ // ), REMOVING IT, BECAUSE WE ALREADY SUPPORT SPREAD SYNTAX FROM LIBRARIES.
138
+ shouldRemovePropTypes ? [require.resolve('babel-plugin-transform-react-remove-prop-types'), removePropTypes] : false, devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
132
139
  exclude: ['error', 'log']
133
140
  }] : null].filter(Boolean) : [removeAttribute ? require.resolve('../utils/removeAttributes') : false, shouldRemovePropTypes ? [require.resolve('babel-plugin-transform-react-remove-prop-types'), removePropTypes] : false, [require.resolve('@babel/plugin-transform-runtime'), {
134
141
  helpers: true,
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
 
10
+ var _babelPresetReactOption = _interopRequireDefault(require("../babel/babel-option-utils/babel-preset-react-option"));
11
+
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
 
12
14
  let getDevJsLoaders = options => {
@@ -40,8 +42,11 @@ let getDevJsLoaders = options => {
40
42
  }
41
43
  } : {
42
44
  modules: false
43
- }], require.resolve('@babel/preset-react')],
44
- plugins: disableES5Transpile ? [require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('@babel/plugin-proposal-object-rest-spread'), devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
45
+ }], (0, _babelPresetReactOption.default)({
46
+ disableES5Transpile
47
+ })],
48
+ plugins: disableES5Transpile ? [require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), // require.resolve('@babel/plugin-proposal-object-rest-spread'),
49
+ devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
45
50
  exclude: ['error', 'log']
46
51
  }] : null].filter(Boolean) : [require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('@babel/plugin-proposal-object-rest-spread'), devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
47
52
  exclude: ['error', 'log']
@@ -19,32 +19,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
19
  /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
20
20
  import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
21
21
  const schema = {
22
- 'type': 'object',
23
- 'properties': {
24
- 'publicPath': {
25
- 'anyOf': [{
26
- 'type': 'string'
22
+ type: 'object',
23
+ properties: {
24
+ publicPath: {
25
+ anyOf: [{
26
+ type: 'string'
27
27
  }, {
28
- 'instanceof': 'Function'
28
+ instanceof: 'Function'
29
29
  }]
30
30
  },
31
- 'filename': {
32
- 'anyOf': [{
33
- 'type': 'string',
34
- 'minLength': 1
31
+ filename: {
32
+ anyOf: [{
33
+ type: 'string',
34
+ minLength: 1
35
35
  }, {
36
- 'instanceof': 'Function'
36
+ instanceof: 'Function'
37
37
  }]
38
38
  },
39
- 'chunkFilename': {
40
- 'type': 'string',
41
- 'minLength': 1
39
+ chunkFilename: {
40
+ type: 'string',
41
+ minLength: 1
42
42
  },
43
- 'esModule': {
44
- 'type': 'boolean'
43
+ esModule: {
44
+ type: 'boolean'
45
45
  }
46
46
  },
47
- 'additionalProperties': false
47
+ additionalProperties: false
48
48
  }; // eslint-disable-next-line
49
49
 
50
50
  function loader() {}
@@ -112,25 +112,40 @@ function pitch(request) {
112
112
  }
113
113
 
114
114
  function workerCode() {
115
+ if (this.workerInstance) {
116
+ return this.workerInstance;
117
+ }
118
+
115
119
  let blob;
116
120
 
117
121
  try {
118
122
  blob = new Blob([`importScripts('${this.workerUrl}');`], {
119
- 'type': 'application/javascript'
123
+ type: 'application/javascript'
120
124
  });
121
125
  } catch (e1) {
122
126
  throw new Error(e1);
123
127
  }
124
128
 
125
- let url = window.URL || window.webkitURL;
126
- let blobUrl = url.createObjectURL(blob);
127
- let worker = new Worker(blobUrl);
128
- return worker;
129
+ const url = window.URL || window.webkitURL;
130
+ const blobUrl = url.createObjectURL(blob);
131
+ this.workerInstance = new Worker(blobUrl);
132
+ return this.workerInstance;
129
133
  }
130
134
 
131
- return cb(null, `${options.esModule ? 'export default' : 'module.exports ='} {\n
135
+ return cb(null, `const workerObj ={\n
136
+ workerInstance: null, \n
132
137
  workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
133
138
  getInstance: ${workerCode} \n
134
- }`);
139
+ };\n
140
+ workerObj.getInstance();
141
+ ${options.esModule ? 'export default' : 'module.exports ='} workerObj;
142
+ `); // return cb(
143
+ // null,
144
+ // `${options.esModule ? 'export default' : 'module.exports ='} {\n
145
+ // workerInstance: null, \n
146
+ // workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
147
+ // getInstance: ${workerCode} \n
148
+ // }`
149
+ // );
135
150
  });
136
151
  }