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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. package/README.md +13 -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.dev.config.js +7 -2
  6. package/lib/configs/webpack.prod.config.js +9 -2
  7. package/lib/loaderUtils/getDevJsLoaders.js +5 -1
  8. package/lib/schemas/index.js +4 -0
  9. package/npm-shrinkwrap.json +31 -5
  10. package/package.json +1 -1
  11. package/packages/client_build_tool/lib/allCommandsConfigs.js +23 -0
  12. package/packages/client_build_tool/lib/buildToolLoggers.js +32 -0
  13. package/packages/client_build_tool/lib/commands/build/commandExecutor.js +21 -0
  14. package/packages/client_build_tool/lib/commands/build/config.js +12 -0
  15. package/packages/client_build_tool/lib/commands/build/errorHander.js +10 -0
  16. package/packages/client_build_tool/lib/commands/build/index.js +35 -0
  17. package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +40 -0
  18. package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +17 -0
  19. package/packages/client_build_tool/lib/commands/buildEs/config.js +12 -0
  20. package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +17 -0
  21. package/packages/client_build_tool/lib/commands/buildLib/config.js +12 -0
  22. package/packages/client_build_tool/lib/commands/start/commandExecutor.js +13 -0
  23. package/packages/client_build_tool/lib/commands/start/config.js +12 -0
  24. package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +10 -0
  25. package/packages/client_build_tool/lib/commands/start/errorHander.js +10 -0
  26. package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +36 -0
  27. package/packages/client_build_tool/lib/commands/start/postProcesser.js +10 -0
  28. package/packages/client_build_tool/lib/commands/start/preProcesser.js +10 -0
  29. package/packages/client_build_tool/lib/commandsRouter.js +71 -0
  30. package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +44 -0
  31. package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +31 -0
  32. package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +51 -0
  33. package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +21 -0
  34. package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +16 -0
  35. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +111 -0
  36. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +1 -0
  37. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +11 -0
  38. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +136 -0
  39. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +95 -0
  40. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +25 -0
  41. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +29 -0
  42. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +24 -0
  43. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +99 -0
  44. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +81 -0
  45. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +201 -0
  46. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +401 -0
  47. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +67 -0
  48. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +23 -0
  49. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +29 -0
  50. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +49 -0
  51. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +77 -0
  52. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +63 -0
  53. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +19 -0
  54. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +31 -0
  55. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +127 -0
  56. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +1 -0
  57. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +63 -0
  58. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +89 -0
  59. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +34 -0
  60. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +15 -0
  61. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +155 -0
  62. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +49 -0
  63. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +58 -0
  64. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +139 -0
  65. package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +34 -0
  66. package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +30 -0
  67. package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +17 -0
  68. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +14 -0
  69. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +24 -0
  70. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +18 -0
  71. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +21 -0
  72. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +138 -0
  73. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +83 -0
  74. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +23 -0
  75. package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +133 -0
  76. package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +39 -0
  77. package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +28 -0
  78. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +18 -0
  79. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +38 -0
  80. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +24 -0
  81. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +28 -0
  82. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +35 -0
  83. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +16 -0
  84. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +23 -0
  85. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +19 -0
  86. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +27 -0
  87. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +18 -0
  88. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +15 -0
  89. package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +39 -0
  90. package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +36 -0
  91. package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +42 -0
  92. package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +12 -0
  93. package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +17 -0
  94. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +24 -0
  95. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +50 -0
  96. package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +16 -0
  97. package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +38 -0
  98. package/packages/client_build_tool/lib/shared/commands-utlis/index.js +29 -0
  99. package/packages/client_build_tool/lib/shared/commands-utlis/log.js +13 -0
  100. package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +11 -0
  101. package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +11 -0
  102. package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +35 -0
  103. package/packages/client_build_tool/lib/shared/constants.js +33 -0
  104. package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +37 -0
  105. package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +37 -0
  106. package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +119 -0
  107. package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +65 -0
  108. package/packages/client_build_tool/lib/shared/schemas/getCWD.js +23 -0
  109. package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +21 -0
  110. package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +32 -0
  111. package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +480 -0
  112. package/packages/client_build_tool/lib/shared/schemas/readOptions.js +55 -0
  113. package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +26 -0
  114. package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +152 -0
  115. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +37 -0
  116. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +27 -0
  117. package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +40 -0
  118. package/packages/client_build_tool/lib/shared/server/corsHandleing.js +28 -0
  119. package/packages/client_build_tool/lib/shared/server/getIp.js +30 -0
  120. package/packages/client_build_tool/lib/shared/server/getServerURL.js +29 -0
  121. package/packages/client_build_tool/lib/shared/server/httpsOptions.js +53 -0
  122. package/packages/client_build_tool/lib/shared/server/initExpressApp.js +19 -0
  123. package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +66 -0
  124. package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +24 -0
  125. package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +40 -0
  126. package/packages/client_build_tool/lib/shared/server/startHttpServer.js +26 -0
  127. package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +34 -0
  128. package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +41 -0
  129. package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +44 -0
  130. package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +1 -0
  131. package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +19 -0
  132. package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +32 -0
  133. package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +48 -0
  134. package/packages/client_build_tool/lib/shared/server/urlConcat.js +25 -0
  135. package/packages/client_build_tool/lib/shared/utils/utils.js +1 -0
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.commandExecutor = commandExecutor;
7
+
8
+ var _serverBywebpackDevMiddleware = require("../../shared/server/serverBywebpackDevMiddleware");
9
+
10
+ function commandExecutor(options) {
11
+ // require("../../shared/server/devServer").run(options);
12
+ (0, _serverBywebpackDevMiddleware.run)(options);
13
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ name: "start",
9
+ alias: ["dstart", "devSeverStart"],
10
+ dirname: __dirname
11
+ };
12
+ exports.default = _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deprecationHandler = deprecationHandler;
7
+
8
+ function deprecationHandler(options) {// options.app.deprecated &&
9
+ // console.log('options.app.deprecated this option was deprecated since V1.3.1' );
10
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.errorHander = errorHander;
7
+
8
+ function errorHander(e) {
9
+ console.error(e);
10
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.optionsProcesser = optionsProcesser;
7
+
8
+ var _path = require("path");
9
+
10
+ var _decidePublicPath = require("../../shared/bundler/webpack/common/decidePublicPath");
11
+
12
+ var _urlConcat = require("../../shared/server/urlConcat");
13
+
14
+ function optionsProcesser(options) {
15
+ const {
16
+ server,
17
+ context
18
+ } = options;
19
+ const {
20
+ disableContextURL
21
+ } = server;
22
+ const serverExtras = (0, _decidePublicPath.modifiedServerOptions)(options);
23
+ const publicPath = (0, _decidePublicPath.decidePublicPath)(serverExtras);
24
+ const contextURL = disableContextURL ? '' : `/${context}`;
25
+ const serverURL = (0, _urlConcat.urlConcat)(publicPath, contextURL);
26
+ const contextFolderPath = (0, _path.join)(process.cwd(), context);
27
+ const defaultApplyedOptions = { ...options,
28
+ serverExtras,
29
+ publicPath,
30
+ contextURL,
31
+ serverURL,
32
+ contextFolderPath,
33
+ httpsOptions: serverExtras.httpsOptions
34
+ };
35
+ return defaultApplyedOptions;
36
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.postProcesser = postProcesser;
7
+
8
+ function postProcesser(options) {
9
+ console.log('postProcesser');
10
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.preProcesser = preProcesser;
7
+
8
+ function preProcesser(options) {
9
+ console.log('preProcesser');
10
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.route = route;
7
+
8
+ var _fs = require("fs");
9
+
10
+ var _path = require("path");
11
+
12
+ var _allCommandsConfigs = _interopRequireDefault(require("./allCommandsConfigs"));
13
+
14
+ var _buildToolLoggers = require("./buildToolLoggers");
15
+
16
+ var _readOptions = require("./shared/schemas/readOptions");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function runCommand(commandConfig) {
21
+ const options = (0, _readOptions.getOptions)();
22
+ const {
23
+ dirname
24
+ } = commandConfig;
25
+
26
+ function runRespectiveFile(name, data) {
27
+ const commandExecutorPath = (0, _path.join)(dirname, name + ".js");
28
+
29
+ if ((0, _fs.existsSync)(commandExecutorPath)) {
30
+ const commandExecutor = require(commandExecutorPath);
31
+
32
+ return (commandExecutor[name] || commandExecutor.default)(data);
33
+ } else {
34
+ (0, _buildToolLoggers.debugLogger)("file not found", commandExecutorPath);
35
+ }
36
+ }
37
+
38
+ const processedOption = runRespectiveFile("optionsProcesser", options) || options;
39
+ runRespectiveFile("deprecationHandler", processedOption); // runRespectiveFile("errorHandler", () => {
40
+
41
+ runRespectiveFile("preProcesser", processedOption);
42
+ runRespectiveFile("commandExecutor", processedOption);
43
+ runRespectiveFile("postProcesser", processedOption); // });
44
+ }
45
+
46
+ function route(option, args) {
47
+ // TODO: need to modify this log
48
+ (0, _buildToolLoggers.debugLogger)("the command was " + option, args);
49
+ const commandConfig = findCommandConfig(option);
50
+
51
+ if (commandConfig) {
52
+ try {
53
+ runCommand(commandConfig);
54
+ } catch (error) {
55
+ console.error(error);
56
+ }
57
+ } else {
58
+ // TODO: need to write proper error message
59
+ (0, _buildToolLoggers.warnLogger)("Un known command", option, "please check the document");
60
+ }
61
+ }
62
+
63
+ function findCommandConfig(option) {
64
+ for (const commandConfig of _allCommandsConfigs.default) {
65
+ if (commandConfig.name === option || commandConfig.alias.includes(option)) {
66
+ return commandConfig;
67
+ }
68
+ }
69
+
70
+ return null;
71
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.decidePublicPath = decidePublicPath;
7
+ exports.modifiedServerOptions = modifiedServerOptions;
8
+
9
+ var _getServerURL = require("../../../server/getServerURL");
10
+
11
+ var _httpsOptions = require("../../../server/httpsOptions");
12
+
13
+ function decidePublicPath(serverExtras) {
14
+ return serverExtras.isHttps ? serverExtras.httpsUrl : serverExtras.httpUrl;
15
+ }
16
+
17
+ function modifiedServerOptions(options) {
18
+ const {
19
+ server
20
+ } = options;
21
+ const {
22
+ port
23
+ } = server;
24
+ const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
25
+ const machineDomain = (0, _getServerURL.getServerDomain)(server);
26
+ const httpPort = port + 1;
27
+ return {
28
+ httpsOptions,
29
+ machineDomain,
30
+ httpsPort: port,
31
+ httpPort,
32
+ httpsUrl: (0, _getServerURL.getServerUrl)({
33
+ domain: machineDomain,
34
+ port,
35
+ protocol: 'https'
36
+ }),
37
+ httpUrl: (0, _getServerURL.getServerUrl)({
38
+ domain: machineDomain,
39
+ port: httpPort,
40
+ protocol: 'http'
41
+ }),
42
+ isHttps: !!httpsOptions
43
+ };
44
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.libAlias = void 0;
7
+ // the reason for alias at the time was code tree shaking
8
+ // tree shaking was most compactable with ES module system
9
+ // FIXME: But there is a posiblity when these package does not have lib,
10
+ // app will work because of alias, But may be jest won't work because of not alais
11
+ // So need to think about use alais in jest
12
+ const libAlias = {
13
+ '@zohodesk/components/lib': '@zohodesk/components/es',
14
+ // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
15
+ '@zohodesk/dot/lib': '@zohodesk/dot/es',
16
+ '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
17
+ '@zohodesk/icons/lib': '@zohodesk/icons/es',
18
+ '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
19
+ '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
20
+ '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
21
+ '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
22
+ '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
23
+ '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
24
+ '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
25
+ '@zohodesk/storage/lib': '@zohodesk/storage/es',
26
+ '@zohodesk/svg/lib': '@zohodesk/svg/es',
27
+ '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
28
+ '@zohodesk/variables/lib': '@zohodesk/variables/es',
29
+ '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
30
+ };
31
+ exports.libAlias = libAlias;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.nameTemplates = nameTemplates;
7
+ // NOTE: these below code can be done in js,
8
+ // we did copy paste in order to aviod unnecessary confussion
9
+ const templates = {
10
+ js: ['js/[name].js', 'js/[name].[contenthash].js'],
11
+ chunkjs: ['js-chunks/[name].js', 'js-chunks/[name].[contenthash].js'],
12
+ i18njs: ['i18n-chunks/[locale]/[name].i18n.js', 'i18n-chunks/[locale]/[name].[chunkhash].i18n.js'],
13
+ i18nchunkjs: ['i18n-chunks/[locale]/[name].i18n.js', // 'i18n-chunks/[locale]/[name].[chunkhash].i18n.js'
14
+ 'i18n-chunks/[locale]/[name].[contenthash].i18n.js'],
15
+ i18nmanifest: ['i18n-manifest.json', 'i18n-manifest.json'],
16
+ workerjs: ['js/[name].js', 'js/[name].[contenthash].js'],
17
+ css: ['css/[name].css', 'css/[name].[contenthash].css'],
18
+
19
+ /**
20
+ * NOTE: when you change (cssdir) this line it will have affect on Below files will be affected
21
+ * custom_plugins/RtlSplitPlugin/*
22
+ * pluginConfigs/configMiniCSSExtractPlugin.js
23
+ * pluginConfigs/configRtlCssPlugin.js
24
+ * */
25
+ cssdir: ['css/[name].[dir].css', 'css/[name].[contenthash].[dir].css'],
26
+ image: ['images/[name][ext]', 'images/[name].[contenthash][ext]'],
27
+ font: ['fonts/[name][ext]', 'fonts/[name].[contenthash][ext]'],
28
+ svg: ['fonts/[name][ext]', 'fonts/[name].[contenthash][ext]'],
29
+ audio: ['fonts/[name][ext]', 'fonts/[name].[contenthash][ext]'],
30
+ video: ['videos/[name][ext]', 'videos/[name].[contenthash][ext]']
31
+ };
32
+
33
+ function createNameTemplate(name, enableChunkHash) {
34
+ // const ext = `${enableChunkHash ? '.[hash:20]' : ''}[ext]`;
35
+ return enableChunkHash ? name[1] : name[0];
36
+ }
37
+
38
+ function nameTemplates(type, options) {
39
+ const {
40
+ enableChunkHash
41
+ } = options;
42
+ const tname = templates[type];
43
+
44
+ if (!tname) {
45
+ throw Error(`specifiyed type not valid Type: ${type}`);
46
+ }
47
+
48
+ return createNameTemplate(tname, enableChunkHash);
49
+ } // export function cssDirNameTemplate(dir, options) {
50
+ // return nameTemplates('cssdir', options).replace(/\[dir\]/g, dir);
51
+ // }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.publicPathAsExpression = publicPathAsExpression;
7
+ exports.resourceBasedPublicPath = resourceBasedPublicPath;
8
+
9
+ // const publicPaths = {
10
+ // };
11
+ function resourceBasedPublicPath(resoruceType, options) {
12
+ return options.publicPath;
13
+ }
14
+
15
+ function publicPathAsExpression(resoruceType, options) {
16
+ if (resoruceType === 'i18n') {
17
+ return options.i18nChunkSplit.localeVarName;
18
+ }
19
+
20
+ return JSON.stringify(options.publicPath);
21
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cssLoaders = cssLoaders;
7
+
8
+ var _getCSSLoaders = require("./getCSSLoaders");
9
+
10
+ function cssLoaders(options) {
11
+ return [{
12
+ test: /\.css$/,
13
+ // exclude: /\.module\.css$/,
14
+ use: (0, _getCSSLoaders.getCSSLoaders)(options)
15
+ }];
16
+ }
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
+
10
+ var _webpack = require("webpack");
11
+
12
+ var _readOptions = require("../../../schemas/readOptions");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const pluginName = 'CdnChangePlugin';
17
+ const MODULE_TYPE = 'css/mini-extract';
18
+
19
+ const isI18nFile = url => url.endsWith('.i18n.js');
20
+
21
+ const {
22
+ app: {
23
+ enableSMap
24
+ }
25
+ } = (0, _readOptions.getOptions)();
26
+
27
+ class CdnChangeRuntimePlugin extends _webpack.RuntimeModule {
28
+ constructor(compiler, {
29
+ variableName
30
+ }) {
31
+ super('cdn loading', 10);
32
+ console.log('cdn loading', variableName);
33
+ this.variableName = variableName;
34
+ }
35
+
36
+ generate() {
37
+ console.log('changeing public pah');
38
+ return `${_webpack.RuntimeGlobals.getChunkCssFilename} = function(chunkId) {
39
+ const cssCdnUrl = window[${this.variableName}]/chunkId;
40
+ console.log(chunkId);
41
+ return cssCdnUrl;
42
+ }`;
43
+ }
44
+
45
+ }
46
+
47
+ class CdnChangePlugin {
48
+ constructor(options) {
49
+ console.log("Insdie", options);
50
+ this.i18nTemplate = options.i18nTemplate || '{{__I18N_CDN__}}';
51
+ this.variableName = options.variableName || '__CSS_CDN__';
52
+ this.cssTemplate = options.cssTemplate || '{{__CSS_CDN__}}';
53
+ this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
54
+ }
55
+
56
+ apply(compiler) {
57
+ compiler.hooks.thisCompilation.tap(pluginName, compilation => {
58
+ const enabledChunks = new WeakSet();
59
+
60
+ const handler = (entryRuntimeChunk, set) => {
61
+ if (enabledChunks.has(entryRuntimeChunk)) {
62
+ return;
63
+ }
64
+
65
+ enabledChunks.add(entryRuntimeChunk);
66
+
67
+ if (typeof chunkFilename === 'string' && /\[(full)?hash(:\d+)?\]/.test(chunkFilename)) {
68
+ set.add(_webpack.RuntimeGlobals.getFullHash);
69
+ }
70
+
71
+ set.add(_webpack.RuntimeGlobals.getChunkCssFilename);
72
+ compilation.addRuntimeModule(entryRuntimeChunk, new CdnChangeRuntimePlugin(set, {
73
+ compiler,
74
+ variableName: this.variableName
75
+ }));
76
+ };
77
+
78
+ compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.ensureChunkHandlers).tap(pluginName, handler);
79
+ });
80
+ compiler.hooks.compilation.tap(pluginName, compilation => {
81
+ _htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, (data, cb) => {
82
+ data.assets = Object.assign({}, data.assets, {
83
+ css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
84
+ js: data.assets.js.map(js => {
85
+ if (enableSMap && !isI18nFile(js)) {
86
+ console.log("js file ==>", js);
87
+ js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
88
+ }
89
+
90
+ return `${isI18nFile(js) ? this.i18nTemplate : this.jsTemplate}${js}`;
91
+ })
92
+ });
93
+ cb && cb(null, data);
94
+ });
95
+ });
96
+ }
97
+
98
+ }
99
+
100
+ var _default = CdnChangePlugin; // Cdn Change Plugin for runtime chunks???
101
+
102
+ /**
103
+ * the filename of the script part of the chunk
104
+ */
105
+ // exports.getChunkScriptFilename = "__webpack_require__.u";
106
+ // /**
107
+ // * the filename of the css part of the chunk
108
+ // */
109
+ // exports.getChunkCssFilename = "__webpack_require__.k";
110
+
111
+ exports.default = _default;
@@ -0,0 +1,11 @@
1
+ # I18n Split Plugin ContributionGuide
2
+ we have modifyed mini-css-extract-plugin to sute our needs of i18n related extraction and downloading.
3
+ So In future may be when we need to update mini-css-extract-plugin Kindly cross check with this I18n Plugin as well.
4
+
5
+ Even not breaking change, may be just performacne update or feature update. addeding that to this plugin will be use full. Kindly consider it.
6
+
7
+ ## Thing we Ignored
8
+ * we use webpack ast hook for adding I18nDependency. So we did not need `loader.js`
9
+ * we ignore order of import in single chunk since I18n going to be download as object.
10
+ we did not need it.
11
+ *
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("./utils");
9
+
10
+ /* eslint-disable max-classes-per-file */
11
+ // import { I18nDependency } from './1I18nDependency';
12
+ const pluginName = 'I18nKeysIdentifer';
13
+ /**
14
+ * this plugin search the i18 keys and make it as I18nDependency.
15
+ * how it works?
16
+ * this plugin get jsResourceI18nKeys in constructor.
17
+ * we walk throught the js files AST
18
+ * if any string literal in that AST is in jsResourceI18nKeys then we consider that string as I18n key
19
+ * after the walk of AST we get some I18n keys
20
+ * then we make it as I18nDependency.
21
+ */
22
+
23
+ class I18nKeysIdentifer {
24
+ constructor({
25
+ jsResourceI18nKeys
26
+ }, {
27
+ I18nDependency,
28
+ I18nModule
29
+ }) {
30
+ this.jsResourceI18nKeys = jsResourceI18nKeys;
31
+ this.I18nDependency = I18nDependency;
32
+ this.I18nModule = I18nModule;
33
+ this.modulesI18nKeysMap = {};
34
+ }
35
+
36
+ defineConfigarationForI18nDependency(compilation) {
37
+ const {
38
+ I18nModule,
39
+ I18nDependency
40
+ } = this;
41
+
42
+ class I18nModuleFactory {
43
+ // eslint-disable-next-line class-methods-use-this
44
+ create({
45
+ dependencies: [dependency]
46
+ }, callback) {
47
+ callback(undefined, new I18nModule(dependency));
48
+ }
49
+
50
+ }
51
+
52
+ compilation.dependencyFactories.set(I18nDependency, new I18nModuleFactory());
53
+
54
+ class I18nDependencyTemplate {
55
+ // eslint-disable-next-line class-methods-use-this
56
+ apply() {}
57
+
58
+ }
59
+
60
+ compilation.dependencyTemplates.set(I18nDependency, new I18nDependencyTemplate());
61
+ }
62
+
63
+ addI18nDependency(module, i18nKeys) {
64
+ const identifier = `i18n ${module.resource}`;
65
+ const dep = new this.I18nDependency({
66
+ identifier,
67
+ content: JSON.stringify(i18nKeys),
68
+ i18nKeys
69
+ }, module.context, 0);
70
+ module.addDependency(dep);
71
+ }
72
+
73
+ apply(compiler) {
74
+ // const { splitChunks } = compiler.options.optimization;
75
+ // if (splitChunks) {
76
+ // if (splitChunks.defaultSizeTypes.includes('...')) {
77
+ // splitChunks.defaultSizeTypes.push(MODULE_TYPE);
78
+ // }
79
+ // }
80
+ compiler.hooks.thisCompilation.tap(pluginName, compilation => {
81
+ // this below hook was tapped for we use I18nDependency
82
+ // so we must define module factory for I18nDependency
83
+ // and we must define how it import statement look like I18nDependencyTemplate
84
+ this.defineConfigarationForI18nDependency(compilation);
85
+ });
86
+ compiler.hooks.normalModuleFactory.tap(pluginName, factory => {
87
+ // handler for parser
88
+ const handler = parser => {
89
+ parser.hooks.program.tap(pluginName, (ast, commmets) => {
90
+ const {
91
+ module
92
+ } = parser.state; //
93
+
94
+ if (!(module && /\.jsx?$/.test(module.resource))) {
95
+ return;
96
+ } // i18n grep proper contract regex
97
+
98
+
99
+ let i18nKeys = (0, _utils.collectI18nKeysfromAST)(ast, this.jsResourceI18nKeys);
100
+ i18nKeys = i18nKeys.concat( // i18n grep proper contract regex
101
+ (0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
102
+
103
+ if (i18nKeys.length) {
104
+ // console.log(
105
+ // 'i18nKeys.length',
106
+ // module.resource,
107
+ // i18nKeys.length < 5 ? i18nKeys : i18nKeys.length
108
+ // );
109
+ this.modulesI18nKeysMap[module.resource] = i18nKeys;
110
+ this.addI18nDependency(module, i18nKeys);
111
+ }
112
+ });
113
+ }; // this below hook was tapped for collect I18n Key from files and add as Deppenensy
114
+ // const factory = params.normalModuleFactory;
115
+
116
+
117
+ factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
118
+ factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
119
+ });
120
+ }
121
+
122
+ } // I18nKeysIdentifer.isChunkHasI18n = function (chunk) {
123
+ // // eslint-disable-next-line no-restricted-syntax
124
+ // for (const module of chunk.modulesIterable) {
125
+ // // eslint-disable-next-line no-restricted-syntax
126
+ // for (const dep of module.dependencies) {
127
+ // if (dep instanceof I18nDependency) {
128
+ // return true;
129
+ // }
130
+ // }
131
+ // }
132
+ // return false;
133
+ // };
134
+
135
+
136
+ exports.default = I18nKeysIdentifer;