@pinnacle0/webpack-util 0.3.26 → 0.3.27

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 (139) hide show
  1. package/package.json +1 -1
  2. package/src/CanadyarnRunner.d.ts +14 -0
  3. package/src/CanadyarnRunner.js +38 -0
  4. package/src/CanadyarnRunner.js.map +1 -0
  5. package/src/CodeStyleChecker.d.ts +10 -0
  6. package/src/CodeStyleChecker.js +44 -0
  7. package/src/CodeStyleChecker.js.map +1 -0
  8. package/src/Constant.d.ts +21 -0
  9. package/src/{Constant.ts → Constant.js} +5 -1
  10. package/src/Constant.js.map +1 -0
  11. package/src/CoreUtil.d.ts +11 -0
  12. package/src/CoreUtil.js +26 -0
  13. package/src/CoreUtil.js.map +1 -0
  14. package/src/ProjectStructureChecker.d.ts +18 -0
  15. package/src/ProjectStructureChecker.js +113 -0
  16. package/src/ProjectStructureChecker.js.map +1 -0
  17. package/src/TestRunner.d.ts +8 -0
  18. package/src/TestRunner.js +30 -0
  19. package/src/TestRunner.js.map +1 -0
  20. package/src/TypescriptTypeChecker.d.ts +11 -0
  21. package/src/TypescriptTypeChecker.js +32 -0
  22. package/src/TypescriptTypeChecker.js.map +1 -0
  23. package/src/WebpackBuilder.d.ts +38 -0
  24. package/src/{WebpackBuilder.ts → WebpackBuilder.js} +51 -71
  25. package/src/WebpackBuilder.js.map +1 -0
  26. package/src/WebpackConfigGenerator/ConfigEntryDescriptorsFactory.d.ts +13 -0
  27. package/src/WebpackConfigGenerator/{ConfigEntryDescriptorsFactory.ts → ConfigEntryDescriptorsFactory.js} +29 -36
  28. package/src/WebpackConfigGenerator/ConfigEntryDescriptorsFactory.js.map +1 -0
  29. package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.d.ts +9 -0
  30. package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.js +20 -0
  31. package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.js.map +1 -0
  32. package/src/WebpackConfigGenerator/Plugin/css.plugin.d.ts +16 -0
  33. package/src/WebpackConfigGenerator/Plugin/css.plugin.js +33 -0
  34. package/src/WebpackConfigGenerator/Plugin/css.plugin.js.map +1 -0
  35. package/src/WebpackConfigGenerator/Plugin/html.plugin.d.ts +16 -0
  36. package/src/WebpackConfigGenerator/Plugin/html.plugin.js +48 -0
  37. package/src/WebpackConfigGenerator/Plugin/html.plugin.js.map +1 -0
  38. package/src/WebpackConfigGenerator/Plugin/index.d.ts +27 -0
  39. package/src/WebpackConfigGenerator/Plugin/index.js +32 -0
  40. package/src/WebpackConfigGenerator/Plugin/index.js.map +1 -0
  41. package/src/WebpackConfigGenerator/Plugin/moment.plugin.d.ts +10 -0
  42. package/src/WebpackConfigGenerator/Plugin/{moment.plugin.ts → moment.plugin.js} +12 -5
  43. package/src/WebpackConfigGenerator/Plugin/moment.plugin.js.map +1 -0
  44. package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.d.ts +4 -0
  45. package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.js +28 -0
  46. package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.js.map +1 -0
  47. package/src/WebpackConfigGenerator/Plugin/ts.plugin.d.ts +16 -0
  48. package/src/WebpackConfigGenerator/Plugin/ts.plugin.js +31 -0
  49. package/src/WebpackConfigGenerator/Plugin/ts.plugin.js.map +1 -0
  50. package/src/WebpackConfigGenerator/Plugin/webpack.plugin.d.ts +14 -0
  51. package/src/WebpackConfigGenerator/Plugin/webpack.plugin.js +24 -0
  52. package/src/WebpackConfigGenerator/Plugin/webpack.plugin.js.map +1 -0
  53. package/src/WebpackConfigGenerator/Rule/RegExpUtil.d.ts +4 -0
  54. package/src/WebpackConfigGenerator/Rule/{RegExpUtil.ts → RegExpUtil.js} +14 -8
  55. package/src/WebpackConfigGenerator/Rule/RegExpUtil.js.map +1 -0
  56. package/src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin.d.ts +13 -0
  57. package/src/WebpackConfigGenerator/Rule/{core-fe-hmr-babel-plugin.ts → core-fe-hmr-babel-plugin.js} +9 -43
  58. package/src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin.js.map +1 -0
  59. package/src/WebpackConfigGenerator/Rule/image.rule.d.ts +9 -0
  60. package/src/WebpackConfigGenerator/Rule/{image.rule.ts → image.rule.js} +8 -5
  61. package/src/WebpackConfigGenerator/Rule/image.rule.js.map +1 -0
  62. package/src/WebpackConfigGenerator/Rule/index.d.ts +13 -0
  63. package/src/WebpackConfigGenerator/Rule/index.js +18 -0
  64. package/src/WebpackConfigGenerator/Rule/index.js.map +1 -0
  65. package/src/WebpackConfigGenerator/Rule/other.rule.d.ts +12 -0
  66. package/src/WebpackConfigGenerator/Rule/other.rule.js +22 -0
  67. package/src/WebpackConfigGenerator/Rule/other.rule.js.map +1 -0
  68. package/src/WebpackConfigGenerator/Rule/stylesheet.rule.d.ts +17 -0
  69. package/src/WebpackConfigGenerator/Rule/{stylesheet.rule.ts → stylesheet.rule.js} +30 -34
  70. package/src/WebpackConfigGenerator/Rule/stylesheet.rule.js.map +1 -0
  71. package/src/WebpackConfigGenerator/Rule/ts.rule.d.ts +18 -0
  72. package/src/WebpackConfigGenerator/Rule/{ts.rule.ts → ts.rule.js} +16 -18
  73. package/src/WebpackConfigGenerator/Rule/ts.rule.js.map +1 -0
  74. package/src/WebpackConfigGenerator/WebpackConfigSerializationUtil.d.ts +10 -0
  75. package/src/WebpackConfigGenerator/{WebpackConfigSerializationUtil.ts → WebpackConfigSerializationUtil.js} +22 -23
  76. package/src/WebpackConfigGenerator/WebpackConfigSerializationUtil.js.map +1 -0
  77. package/src/WebpackConfigGenerator/WebpackEntryFactory.d.ts +9 -0
  78. package/src/WebpackConfigGenerator/WebpackEntryFactory.js +14 -0
  79. package/src/WebpackConfigGenerator/WebpackEntryFactory.js.map +1 -0
  80. package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.d.ts +11 -0
  81. package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.js +16 -0
  82. package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.js.map +1 -0
  83. package/src/WebpackConfigGenerator/WebpackResolveAliasFactory.d.ts +11 -0
  84. package/src/WebpackConfigGenerator/{WebpackResolveAliasFactory.ts → WebpackResolveAliasFactory.js} +13 -16
  85. package/src/WebpackConfigGenerator/WebpackResolveAliasFactory.js.map +1 -0
  86. package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.d.ts +7 -0
  87. package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.js +16 -0
  88. package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.js.map +1 -0
  89. package/src/WebpackConfigGenerator/WebpackResolveModulesFactory.d.ts +7 -0
  90. package/src/WebpackConfigGenerator/{WebpackResolveModulesFactory.ts → WebpackResolveModulesFactory.js} +7 -9
  91. package/src/WebpackConfigGenerator/WebpackResolveModulesFactory.js.map +1 -0
  92. package/src/WebpackConfigGenerator/index.d.ts +31 -0
  93. package/src/WebpackConfigGenerator/index.js +191 -0
  94. package/src/WebpackConfigGenerator/index.js.map +1 -0
  95. package/src/WebpackServerStarter.d.ts +28 -0
  96. package/src/WebpackServerStarter.js +111 -0
  97. package/src/WebpackServerStarter.js.map +1 -0
  98. package/src/index.d.ts +10 -0
  99. package/src/index.js +8 -0
  100. package/src/index.js.map +1 -0
  101. package/src/{type.ts → type.d.ts} +4 -8
  102. package/src/type.js +3 -0
  103. package/src/type.js.map +1 -0
  104. package/config/jest.config.ts +0 -35
  105. package/config/tsconfig.script.json +0 -10
  106. package/config/tsconfig.src.json +0 -12
  107. package/config/tsconfig.test.json +0 -11
  108. package/script/build.ts +0 -65
  109. package/script/format.ts +0 -7
  110. package/src/CanadyarnRunner.ts +0 -35
  111. package/src/CodeStyleChecker.ts +0 -44
  112. package/src/CoreUtil.ts +0 -24
  113. package/src/ProjectStructureChecker.ts +0 -119
  114. package/src/TestRunner.ts +0 -28
  115. package/src/TypescriptTypeChecker.ts +0 -29
  116. package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.ts +0 -24
  117. package/src/WebpackConfigGenerator/Plugin/css.plugin.ts +0 -31
  118. package/src/WebpackConfigGenerator/Plugin/html.plugin.ts +0 -47
  119. package/src/WebpackConfigGenerator/Plugin/index.ts +0 -33
  120. package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.ts +0 -22
  121. package/src/WebpackConfigGenerator/Plugin/ts.plugin.ts +0 -29
  122. package/src/WebpackConfigGenerator/Plugin/webpack.plugin.ts +0 -21
  123. package/src/WebpackConfigGenerator/Rule/index.ts +0 -17
  124. package/src/WebpackConfigGenerator/Rule/other.rule.ts +0 -23
  125. package/src/WebpackConfigGenerator/WebpackEntryFactory.ts +0 -22
  126. package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.ts +0 -22
  127. package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.ts +0 -19
  128. package/src/WebpackConfigGenerator/index.ts +0 -213
  129. package/src/WebpackServerStarter.ts +0 -138
  130. package/src/index.ts +0 -9
  131. package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/__snapshots__/shouldIgnore.test.ts.snap +0 -21
  132. package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/__snapshots__/shouldTransform.test.ts.snap +0 -53
  133. package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/shouldIgnore.test.ts +0 -36
  134. package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/shouldTransform.test.ts +0 -72
  135. package/test/WebpackConfigGenerator/plugin/fixture/script.js +0 -2
  136. package/test/WebpackConfigGenerator/plugin/fixture/script1.js +0 -1
  137. package/test/WebpackConfigGenerator/plugin/script-tag-crossorigin-plugin.test.ts +0 -58
  138. package/test/test-project/package.json +0 -5
  139. package/tsconfig.json +0 -15
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ScriptTagCrossOriginPlugin = void 0;
7
+ const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
8
+ const PLUGIN_NAME = "ScriptTagCrossOriginPlugin";
9
+ // This plugin adds crossorigin="anonymous" to html-webpack-plugin generated <script> tags, only work with html-webpack-plugin@4.0.0+
10
+ class ScriptTagCrossOriginPlugin {
11
+ apply(compiler) {
12
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
13
+ const hook = html_webpack_plugin_1.default.getHooks(compilation).alterAssetTags;
14
+ hook.tap(PLUGIN_NAME, result => {
15
+ var _a;
16
+ const { assetTags } = result;
17
+ for (const scriptTag of assetTags.scripts) {
18
+ if (((_a = scriptTag.attributes) === null || _a === void 0 ? void 0 : _a.src) && /.js$/.test(scriptTag.attributes.src.toString())) {
19
+ scriptTag.attributes.crossorigin = "anonymous";
20
+ }
21
+ }
22
+ return result;
23
+ });
24
+ });
25
+ }
26
+ }
27
+ exports.ScriptTagCrossOriginPlugin = ScriptTagCrossOriginPlugin;
28
+ //# sourceMappingURL=script-tag-crossorigin-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-tag-crossorigin-plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAoD;AAGpD,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAEjD,qIAAqI;AACrI,MAAa,0BAA0B;IACnC,KAAK,CAAC,QAA0B;QAC5B,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE;YACtD,MAAM,IAAI,GAAG,6BAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC;YACpE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE;;gBAC3B,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC;gBAC3B,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,OAAO,EAAE;oBACvC,IAAI,CAAA,MAAA,SAAS,CAAC,UAAU,0CAAE,GAAG,KAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE;wBAC/E,SAAS,CAAC,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC;qBAClD;iBACJ;gBACD,OAAO,MAAM,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAfD,gEAeC"}
@@ -0,0 +1,16 @@
1
+ import type webpack from "webpack";
2
+ interface TerserPluginOptions {
3
+ sourceMap: boolean;
4
+ }
5
+ /**
6
+ * Applies Terser to minimize javascript
7
+ * after bundles/chunks are built.
8
+ */
9
+ export declare function terserPlugin({ sourceMap }: TerserPluginOptions): webpack.WebpackPluginInstance;
10
+ /**
11
+ * Adds react fast refresh functionality.
12
+ * Requires babel plugin "react-refresh/babel".
13
+ * Should not be used in production.
14
+ */
15
+ export declare function reactRefreshPlugin(): webpack.WebpackPluginInstance;
16
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.reactRefreshPlugin = exports.terserPlugin = void 0;
7
+ const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
8
+ const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
9
+ const WebpackConfigSerializationUtil_1 = require("../WebpackConfigSerializationUtil");
10
+ /**
11
+ * Applies Terser to minimize javascript
12
+ * after bundles/chunks are built.
13
+ */
14
+ function terserPlugin({ sourceMap }) {
15
+ return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("TerserWebpackPlugin", terser_webpack_plugin_1.default, {
16
+ terserOptions: {
17
+ sourceMap,
18
+ },
19
+ });
20
+ }
21
+ exports.terserPlugin = terserPlugin;
22
+ /**
23
+ * Adds react fast refresh functionality.
24
+ * Requires babel plugin "react-refresh/babel".
25
+ * Should not be used in production.
26
+ */
27
+ function reactRefreshPlugin() {
28
+ return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("ReactRefreshPlugin", react_refresh_webpack_plugin_1.default);
29
+ }
30
+ exports.reactRefreshPlugin = reactRefreshPlugin;
31
+ //# sourceMappingURL=ts.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts.plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Plugin/ts.plugin.ts"],"names":[],"mappings":";;;;;;AAAA,wGAA6E;AAC7E,kFAAwD;AAExD,sFAAiF;AAMjF;;;GAGG;AACH,SAAgB,YAAY,CAAC,EAAC,SAAS,EAAsB;IACzD,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,qBAAqB,EAAE,+BAAmB,EAAE;QACjG,aAAa,EAAE;YACX,SAAS;SACZ;KACJ,CAAC,CAAC;AACP,CAAC;AAND,oCAMC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB;IAC9B,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,oBAAoB,EAAE,sCAAyB,CAAC,CAAC;AAC9G,CAAC;AAFD,gDAEC"}
@@ -0,0 +1,14 @@
1
+ import webpack from "webpack";
2
+ interface WebpackProgressPluginOptions {
3
+ enableProfiling: boolean;
4
+ }
5
+ /**
6
+ * Reports progress during compilation.
7
+ * Basically the same behavior as running webpack-cli with:
8
+ * `$ webpack --progress`
9
+ */
10
+ export declare function webpackProgressPlugin({ enableProfiling }: WebpackProgressPluginOptions): webpack.WebpackPluginInstance;
11
+ export declare function webpackDefinePlugin(map: {
12
+ [key: string]: string;
13
+ }): webpack.WebpackPluginInstance;
14
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.webpackDefinePlugin = exports.webpackProgressPlugin = void 0;
7
+ const webpack_1 = __importDefault(require("webpack"));
8
+ const WebpackConfigSerializationUtil_1 = require("../WebpackConfigSerializationUtil");
9
+ /**
10
+ * Reports progress during compilation.
11
+ * Basically the same behavior as running webpack-cli with:
12
+ * `$ webpack --progress`
13
+ */
14
+ function webpackProgressPlugin({ enableProfiling }) {
15
+ return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("webpack.ProgressPlugin", webpack_1.default.ProgressPlugin, {
16
+ profile: enableProfiling,
17
+ });
18
+ }
19
+ exports.webpackProgressPlugin = webpackProgressPlugin;
20
+ function webpackDefinePlugin(map) {
21
+ return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("webpack.DefinePlugin", webpack_1.default.DefinePlugin, map);
22
+ }
23
+ exports.webpackDefinePlugin = webpackDefinePlugin;
24
+ //# sourceMappingURL=webpack.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Plugin/webpack.plugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,sFAAiF;AAMjF;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,EAAC,eAAe,EAA+B;IACjF,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,wBAAwB,EAAE,iBAAO,CAAC,cAAc,EAAE;QACvG,OAAO,EAAE,eAAe;KAC3B,CAAC,CAAC;AACP,CAAC;AAJD,sDAIC;AAED,SAAgB,mBAAmB,CAAC,GAA4B;IAC5D,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,sBAAsB,EAAE,iBAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AAChH,CAAC;AAFD,kDAEC"}
@@ -0,0 +1,4 @@
1
+ export declare class RegExpUtil {
2
+ static fileExtension(...extensions: [string, ...string[]]): RegExp;
3
+ private static validateFileExtension;
4
+ }
@@ -1,20 +1,26 @@
1
- export class RegExpUtil {
2
- static fileExtension(...extensions: [string, ...string[]]): RegExp {
3
- const escapedExtensions: string[] = [];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegExpUtil = void 0;
4
+ class RegExpUtil {
5
+ static fileExtension(...extensions) {
6
+ const escapedExtensions = [];
4
7
  for (const ext of extensions) {
5
8
  RegExpUtil.validateFileExtension(ext);
6
- escapedExtensions.push(ext.replace(/\./g, String.raw`\.`));
9
+ escapedExtensions.push(ext.replace(/\./g, String.raw `\.`));
7
10
  }
8
11
  return new RegExp(`(${escapedExtensions.join("|")})$`);
9
12
  }
10
-
11
- private static validateFileExtension(ext: string): void {
13
+ static validateFileExtension(ext) {
12
14
  if (ext.trim() === "") {
13
15
  throw new Error("Extension cannot be empty.");
14
- } else if (/\s/.test(ext)) {
16
+ }
17
+ else if (/\s/.test(ext)) {
15
18
  throw new Error(`Extension cannot contain whitespace, received: "${ext}".`);
16
- } else if (!/^(\.[a-z0-9]+)+$/.test(ext)) {
19
+ }
20
+ else if (!/^(\.[a-z0-9]+)+$/.test(ext)) {
17
21
  throw new Error(`Extension should begin with dot, and contains lowercase letters and numbers, received: "${ext}".`);
18
22
  }
19
23
  }
20
24
  }
25
+ exports.RegExpUtil = RegExpUtil;
26
+ //# sourceMappingURL=RegExpUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegExpUtil.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/RegExpUtil.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IACnB,MAAM,CAAC,aAAa,CAAC,GAAG,UAAiC;QACrD,MAAM,iBAAiB,GAAa,EAAE,CAAC;QACvC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;YAC1B,UAAU,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YACtC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAA,IAAI,CAAC,CAAC,CAAC;SAC9D;QACD,OAAO,IAAI,MAAM,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,GAAW;QAC5C,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,IAAI,CAAC,CAAC;SAC/E;aAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,2FAA2F,GAAG,IAAI,CAAC,CAAC;SACvH;IACL,CAAC;CACJ;AAnBD,gCAmBC"}
@@ -0,0 +1,13 @@
1
+ import type * as babel from "@babel/core";
2
+ interface State extends Pick<babel.PluginPass, "file" | "key" | "opts" | "cwd" | "filename"> {
3
+ hasInjectedDeclineWebpackHMRNode: boolean;
4
+ }
5
+ /**
6
+ * Injects `if (module.hot) module.hot.decline()` code snippet in files that contains "core-fe" Module classes.
7
+ *
8
+ * This tells webpack HMR to force refresh the browser when a file containing "core-fe" Module classes is changed,
9
+ * otherwise react loses refrence of the MainComponent created by `ModuleProxy` in "core-fe"
10
+ * and throws a runtime error during development (which is bad for developer experience).
11
+ */
12
+ export default function ({ types: t }: typeof babel): babel.PluginObj<State>;
13
+ export {};
@@ -1,9 +1,5 @@
1
- import type * as babel from "@babel/core";
2
-
3
- interface State extends Pick<babel.PluginPass, "file" | "key" | "opts" | "cwd" | "filename"> {
4
- hasInjectedDeclineWebpackHMRNode: boolean;
5
- }
6
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
7
3
  /**
8
4
  * Injects `if (module.hot) module.hot.decline()` code snippet in files that contains "core-fe" Module classes.
9
5
  *
@@ -11,68 +7,39 @@ interface State extends Pick<babel.PluginPass, "file" | "key" | "opts" | "cwd" |
11
7
  * otherwise react loses refrence of the MainComponent created by `ModuleProxy` in "core-fe"
12
8
  * and throws a runtime error during development (which is bad for developer experience).
13
9
  */
14
- export default function ({types: t}: typeof babel): babel.PluginObj<State> {
10
+ function default_1({ types: t }) {
15
11
  return {
16
12
  visitor: {
17
13
  ImportDeclaration(path, state) {
18
14
  if (state.hasInjectedDeclineWebpackHMRNode) {
19
15
  return;
20
16
  }
21
-
22
- const {
23
- node: {
24
- source: {value: importSource},
25
- specifiers: importSpecifiers,
26
- },
27
- } = path;
28
-
17
+ const { node: { source: { value: importSource }, specifiers: importSpecifiers, }, } = path;
29
18
  if (importSource !== "core-fe") {
30
19
  return;
31
20
  }
32
-
33
21
  if (!hasImportSpecifierOfIdentifierModule(t, importSpecifiers)) {
34
22
  return;
35
23
  }
36
-
37
24
  // We now know the TS/JS file has included `Module`, inject the code snippet
38
- const programPath = path.findParent(parentPath => t.isProgram(parentPath.node))! as babel.NodePath<babel.types.Program>;
39
-
25
+ const programPath = path.findParent(parentPath => t.isProgram(parentPath.node));
40
26
  // prettier-ignore
41
- const declineWebpackHMRNode = t.ifStatement(
42
- t.memberExpression(
43
- t.identifier("module"),
44
- t.identifier("hot")
45
- ),
46
- t.expressionStatement(
47
- t.callExpression(
48
- t.memberExpression(
49
- t.memberExpression(
50
- t.identifier("module"),
51
- t.identifier("hot"),
52
- ),
53
- t.identifier("decline"),
54
- ),
55
- [],
56
- ),
57
- ),
58
- );
59
-
27
+ const declineWebpackHMRNode = t.ifStatement(t.memberExpression(t.identifier("module"), t.identifier("hot")), t.expressionStatement(t.callExpression(t.memberExpression(t.memberExpression(t.identifier("module"), t.identifier("hot")), t.identifier("decline")), [])));
60
28
  // Append `if (module.hot) module.hot.decline()` to end of program body
61
29
  programPath.pushContainer("body", declineWebpackHMRNode);
62
-
63
30
  // We only need to inject the code snippet once per file, mark as injected
64
31
  state.hasInjectedDeclineWebpackHMRNode = true;
65
32
  },
66
33
  },
67
34
  };
68
35
  }
69
-
36
+ exports.default = default_1;
70
37
  /**
71
38
  * @param t `babel.types`
72
39
  * @param importSpecifiers The "specifier" property of a `babel.types.ImportDeclaration` node
73
40
  * @returns true if the import declaration includes the identifier `Module`
74
41
  */
75
- function hasImportSpecifierOfIdentifierModule(t: typeof babel.types, importSpecifiers: babel.types.ImportDeclaration["specifiers"]): boolean {
42
+ function hasImportSpecifierOfIdentifierModule(t, importSpecifiers) {
76
43
  const specifier = importSpecifiers.find(specifier => {
77
44
  // Check if it is one of:
78
45
  // -> `import { <IMPORT_SPECIFIER_NODE> } from "core-fe";`
@@ -81,7 +48,6 @@ function hasImportSpecifierOfIdentifierModule(t: typeof babel.types, importSpeci
81
48
  const importedSpecifier = specifier.imported;
82
49
  return t.isIdentifier(importedSpecifier) && importedSpecifier.name === "Module";
83
50
  }
84
-
85
51
  // Check if it is:
86
52
  // -> `import * as <IMPORT_NAMESPACE_SPECIFIER_NODE> from "core-fe";`
87
53
  if (t.isImportNamespaceSpecifier(specifier)) {
@@ -89,8 +55,8 @@ function hasImportSpecifierOfIdentifierModule(t: typeof babel.types, importSpeci
89
55
  // Maybe enforce "core-fe" should not be imported with a namespace with an ESLint rule?
90
56
  return true;
91
57
  }
92
-
93
58
  return false;
94
59
  });
95
60
  return specifier !== undefined;
96
61
  }
62
+ //# sourceMappingURL=core-fe-hmr-babel-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-fe-hmr-babel-plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin.ts"],"names":[],"mappings":";;AAMA;;;;;;GAMG;AACH,mBAAyB,EAAC,KAAK,EAAE,CAAC,EAAe;IAC7C,OAAO;QACH,OAAO,EAAE;YACL,iBAAiB,CAAC,IAAI,EAAE,KAAK;gBACzB,IAAI,KAAK,CAAC,gCAAgC,EAAE;oBACxC,OAAO;iBACV;gBAED,MAAM,EACF,IAAI,EAAE,EACF,MAAM,EAAE,EAAC,KAAK,EAAE,YAAY,EAAC,EAC7B,UAAU,EAAE,gBAAgB,GAC/B,GACJ,GAAG,IAAI,CAAC;gBAET,IAAI,YAAY,KAAK,SAAS,EAAE;oBAC5B,OAAO;iBACV;gBAED,IAAI,CAAC,oCAAoC,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAE;oBAC5D,OAAO;iBACV;gBAED,4EAA4E;gBAC5E,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAyC,CAAC;gBAExH,kBAAkB;gBAClB,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CACvC,CAAC,CAAC,gBAAgB,CACd,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EACtB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CACtB,EACD,CAAC,CAAC,mBAAmB,CACjB,CAAC,CAAC,cAAc,CACZ,CAAC,CAAC,gBAAgB,CACd,CAAC,CAAC,gBAAgB,CACd,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EACtB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CACtB,EACD,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAC1B,EACD,EAAE,CACL,CACJ,CACJ,CAAC;gBAEF,uEAAuE;gBACvE,WAAW,CAAC,aAAa,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;gBAEzD,0EAA0E;gBAC1E,KAAK,CAAC,gCAAgC,GAAG,IAAI,CAAC;YAClD,CAAC;SACJ;KACJ,CAAC;AACN,CAAC;AAtDD,4BAsDC;AAED;;;;GAIG;AACH,SAAS,oCAAoC,CAAC,CAAqB,EAAE,gBAA6D;IAC9H,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAChD,yBAAyB;QACzB,0DAA0D;QAC1D,gFAAgF;QAChF,IAAI,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE;YAChC,MAAM,iBAAiB,GAAG,SAAS,CAAC,QAAQ,CAAC;YAC7C,OAAO,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,IAAI,KAAK,QAAQ,CAAC;SACnF;QAED,kBAAkB;QAClB,qEAAqE;QACrE,IAAI,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC,EAAE;YACzC,oFAAoF;YACpF,uFAAuF;YACvF,OAAO,IAAI,CAAC;SACf;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,KAAK,SAAS,CAAC;AACnC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type webpack from "webpack";
2
+ /**
3
+ * Handles dependency requests to image assets (".png", ".jpeg", ".jpg", ".gif", ".svg")
4
+ * by inlining as images as DataURL,
5
+ * or emitting as separate files if file size is too large.
6
+ *
7
+ * @see https://webpack.js.org/guides/asset-modules/
8
+ */
9
+ export declare function imageRule(): webpack.RuleSetRule;
@@ -1,6 +1,7 @@
1
- import type webpack from "webpack";
2
- import {RegExpUtil} from "./RegExpUtil";
3
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.imageRule = void 0;
4
+ const RegExpUtil_1 = require("./RegExpUtil");
4
5
  /**
5
6
  * Handles dependency requests to image assets (".png", ".jpeg", ".jpg", ".gif", ".svg")
6
7
  * by inlining as images as DataURL,
@@ -8,9 +9,9 @@ import {RegExpUtil} from "./RegExpUtil";
8
9
  *
9
10
  * @see https://webpack.js.org/guides/asset-modules/
10
11
  */
11
- export function imageRule(): webpack.RuleSetRule {
12
+ function imageRule() {
12
13
  return {
13
- test: RegExpUtil.fileExtension(".png", ".jpeg", ".jpg", ".gif", ".svg"),
14
+ test: RegExpUtil_1.RegExpUtil.fileExtension(".png", ".jpeg", ".jpg", ".gif", ".svg"),
14
15
  type: "asset",
15
16
  generator: {
16
17
  filename: "static/img/[name].[hash:8][ext][query]",
@@ -22,3 +23,5 @@ export function imageRule(): webpack.RuleSetRule {
22
23
  },
23
24
  };
24
25
  }
26
+ exports.imageRule = imageRule;
27
+ //# sourceMappingURL=image.rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/image.rule.ts"],"names":[],"mappings":";;;AACA,6CAAwC;AAExC;;;;;;GAMG;AACH,SAAgB,SAAS;IACrB,OAAO;QACH,IAAI,EAAE,uBAAU,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QACvE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACP,QAAQ,EAAE,wCAAwC;SACrD;QACD,MAAM,EAAE;YACJ,gBAAgB,EAAE;gBACd,OAAO,EAAE,IAAI;aAChB;SACJ;KACJ,CAAC;AACN,CAAC;AAbD,8BAaC"}
@@ -0,0 +1,13 @@
1
+ import { imageRule } from "./image.rule";
2
+ import { otherRule } from "./other.rule";
3
+ import { stylesheetRule } from "./stylesheet.rule";
4
+ import { tsRule } from "./ts.rule";
5
+ /**
6
+ * Static factories to create `webpack.config#modules.rules` items.
7
+ */
8
+ export declare class Rule {
9
+ static readonly image: typeof imageRule;
10
+ static readonly other: typeof otherRule;
11
+ static readonly ts: typeof tsRule;
12
+ static readonly stylesheet: typeof stylesheetRule;
13
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rule = void 0;
4
+ const image_rule_1 = require("./image.rule");
5
+ const other_rule_1 = require("./other.rule");
6
+ const stylesheet_rule_1 = require("./stylesheet.rule");
7
+ const ts_rule_1 = require("./ts.rule");
8
+ /**
9
+ * Static factories to create `webpack.config#modules.rules` items.
10
+ */
11
+ class Rule {
12
+ }
13
+ exports.Rule = Rule;
14
+ Rule.image = image_rule_1.imageRule;
15
+ Rule.other = other_rule_1.otherRule;
16
+ Rule.ts = ts_rule_1.tsRule;
17
+ Rule.stylesheet = stylesheet_rule_1.stylesheetRule;
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,6CAAuC;AACvC,uDAAiD;AACjD,uCAAiC;AAEjC;;GAEG;AACH,MAAa,IAAI;;AAAjB,oBAQC;AAPmB,UAAK,GAAG,sBAAS,CAAC;AAElB,UAAK,GAAG,sBAAS,CAAC;AAElB,OAAE,GAAG,gBAAM,CAAC;AAEZ,eAAU,GAAG,gCAAc,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type webpack from "webpack";
2
+ interface OtherRuleDeps {
3
+ extraExtensionsForOtherRule: string[];
4
+ }
5
+ /**
6
+ * Handles dependency requests to file assets
7
+ * by emitting as separate files.
8
+ *
9
+ * @see https://webpack.js.org/guides/asset-modules/
10
+ */
11
+ export declare function otherRule({ extraExtensionsForOtherRule }: OtherRuleDeps): webpack.RuleSetRule;
12
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.otherRule = void 0;
4
+ const Constant_1 = require("../../Constant");
5
+ const RegExpUtil_1 = require("./RegExpUtil");
6
+ /**
7
+ * Handles dependency requests to file assets
8
+ * by emitting as separate files.
9
+ *
10
+ * @see https://webpack.js.org/guides/asset-modules/
11
+ */
12
+ function otherRule({ extraExtensionsForOtherRule }) {
13
+ return {
14
+ test: RegExpUtil_1.RegExpUtil.fileExtension(".ico", ...Constant_1.Constant.mediaExtensions, ...Constant_1.Constant.fontExtensions, ...extraExtensionsForOtherRule),
15
+ type: "asset",
16
+ generator: {
17
+ filename: "static/other/[name].[hash:8][ext][query]",
18
+ },
19
+ };
20
+ }
21
+ exports.otherRule = otherRule;
22
+ //# sourceMappingURL=other.rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"other.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/other.rule.ts"],"names":[],"mappings":";;;AACA,6CAAwC;AACxC,6CAAwC;AAMxC;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,EAAC,2BAA2B,EAAgB;IAClE,OAAO;QACH,IAAI,EAAE,uBAAU,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,mBAAQ,CAAC,eAAe,EAAE,GAAG,mBAAQ,CAAC,cAAc,EAAE,GAAG,2BAA2B,CAAC;QAC/H,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACP,QAAQ,EAAE,0CAA0C;SACvD;KACJ,CAAC;AACN,CAAC;AARD,8BAQC"}
@@ -0,0 +1,17 @@
1
+ import type webpack from "webpack";
2
+ interface StylesheetRuleDeps {
3
+ minimize: boolean;
4
+ }
5
+ /**
6
+ * Handles dependency requests to stylesheet assets (".css", ".less")
7
+ * with `minimize: true` by `lessc` -> transform to js module -> inject to DOM as <style> tag,
8
+ * or with `minimize: false` by `lessc` -> `autoprefixer` with `postcss` -> transform to js module -> extract to stylesheet
9
+ *
10
+ * @see https://webpack.js.org/loaders/css-loader/
11
+ * @see https://webpack.js.org/loaders/less-loader/
12
+ * @see https://webpack.js.org/plugins/mini-css-extract-plugin/
13
+ * @see https://webpack.js.org/loaders/postcss-loader/
14
+ * @see https://webpack.js.org/loaders/style-loader/
15
+ */
16
+ export declare function stylesheetRule({ minimize }: StylesheetRuleDeps): webpack.RuleSetRule;
17
+ export {};
@@ -1,12 +1,12 @@
1
- import MiniCssExtractPlugin from "mini-css-extract-plugin";
2
- import type webpack from "webpack";
3
- import {RegExpUtil} from "./RegExpUtil";
4
-
5
- interface StylesheetRuleDeps {
6
- minimize: boolean;
7
- }
8
-
9
- function cssLoader(importLoaders: number): webpack.RuleSetUseItem {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.stylesheetRule = void 0;
7
+ const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
8
+ const RegExpUtil_1 = require("./RegExpUtil");
9
+ function cssLoader(importLoaders) {
10
10
  return {
11
11
  loader: require.resolve("css-loader"),
12
12
  options: {
@@ -14,8 +14,7 @@ function cssLoader(importLoaders: number): webpack.RuleSetUseItem {
14
14
  },
15
15
  };
16
16
  }
17
-
18
- function lessLoader(): webpack.RuleSetUseItem {
17
+ function lessLoader() {
19
18
  return {
20
19
  loader: require.resolve("less-loader"),
21
20
  options: {
@@ -25,14 +24,12 @@ function lessLoader(): webpack.RuleSetUseItem {
25
24
  },
26
25
  };
27
26
  }
28
-
29
- function miniCssExtractPluginLoader(): webpack.RuleSetUseItem {
27
+ function miniCssExtractPluginLoader() {
30
28
  return {
31
- loader: require.resolve(MiniCssExtractPlugin.loader),
29
+ loader: require.resolve(mini_css_extract_plugin_1.default.loader),
32
30
  };
33
31
  }
34
-
35
- function postcssLoader(): webpack.RuleSetUseItem {
32
+ function postcssLoader() {
36
33
  return {
37
34
  loader: require.resolve("postcss-loader"),
38
35
  options: {
@@ -45,13 +42,11 @@ function postcssLoader(): webpack.RuleSetUseItem {
45
42
  },
46
43
  };
47
44
  }
48
-
49
- function styleLoader(): webpack.RuleSetUseItem {
45
+ function styleLoader() {
50
46
  return {
51
47
  loader: require.resolve("style-loader"),
52
48
  };
53
49
  }
54
-
55
50
  /**
56
51
  * Handles dependency requests to stylesheet assets (".css", ".less")
57
52
  * with `minimize: true` by `lessc` -> transform to js module -> inject to DOM as <style> tag,
@@ -63,24 +58,23 @@ function styleLoader(): webpack.RuleSetUseItem {
63
58
  * @see https://webpack.js.org/loaders/postcss-loader/
64
59
  * @see https://webpack.js.org/loaders/style-loader/
65
60
  */
66
- export function stylesheetRule({minimize}: StylesheetRuleDeps): webpack.RuleSetRule {
67
- const use: webpack.RuleSetUseItem[] = minimize
61
+ function stylesheetRule({ minimize }) {
62
+ const use = minimize
68
63
  ? [
69
- miniCssExtractPluginLoader(),
70
- cssLoader(2),
71
- postcssLoader(),
72
- lessLoader(),
73
- // prettier-format-preserve
74
- ]
64
+ miniCssExtractPluginLoader(),
65
+ cssLoader(2),
66
+ postcssLoader(),
67
+ lessLoader(),
68
+ // prettier-format-preserve
69
+ ]
75
70
  : [
76
- styleLoader(),
77
- cssLoader(1),
78
- lessLoader(),
79
- // prettier-format-preserve
80
- ];
81
-
71
+ styleLoader(),
72
+ cssLoader(1),
73
+ lessLoader(),
74
+ // prettier-format-preserve
75
+ ];
82
76
  return {
83
- test: RegExpUtil.fileExtension(".css", ".less"),
77
+ test: RegExpUtil_1.RegExpUtil.fileExtension(".css", ".less"),
84
78
  use,
85
79
  // Declare all css/less imports as side effects (not to be considered
86
80
  // as dead code), regardless of the containing package claims to be
@@ -90,3 +84,5 @@ export function stylesheetRule({minimize}: StylesheetRuleDeps): webpack.RuleSetR
90
84
  sideEffects: true,
91
85
  };
92
86
  }
87
+ exports.stylesheetRule = stylesheetRule;
88
+ //# sourceMappingURL=stylesheet.rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stylesheet.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/stylesheet.rule.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA2D;AAE3D,6CAAwC;AAMxC,SAAS,SAAS,CAAC,aAAqB;IACpC,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;QACrC,OAAO,EAAE;YACL,aAAa;SAChB;KACJ,CAAC;AACN,CAAC;AAED,SAAS,UAAU;IACf,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC;QACtC,OAAO,EAAE;YACL,WAAW,EAAE;gBACT,iBAAiB,EAAE,IAAI;aAC1B;SACJ;KACJ,CAAC;AACN,CAAC;AAED,SAAS,0BAA0B;IAC/B,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,iCAAoB,CAAC,MAAM,CAAC;KACvD,CAAC;AACN,CAAC;AAED,SAAS,aAAa;IAClB,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACzC,OAAO,EAAE;YACL,cAAc,EAAE;gBACZ,OAAO,EAAE;oBACL,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;oBACjC,2BAA2B;iBAC9B;aACJ;SACJ;KACJ,CAAC;AACN,CAAC;AAED,SAAS,WAAW;IAChB,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;KAC1C,CAAC;AACN,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,cAAc,CAAC,EAAC,QAAQ,EAAqB;IACzD,MAAM,GAAG,GAA6B,QAAQ;QAC1C,CAAC,CAAC;YACI,0BAA0B,EAAE;YAC5B,SAAS,CAAC,CAAC,CAAC;YACZ,aAAa,EAAE;YACf,UAAU,EAAE;YACZ,2BAA2B;SAC9B;QACH,CAAC,CAAC;YACI,WAAW,EAAE;YACb,SAAS,CAAC,CAAC,CAAC;YACZ,UAAU,EAAE;YACZ,2BAA2B;SAC9B,CAAC;IAER,OAAO;QACH,IAAI,EAAE,uBAAU,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC;QAC/C,GAAG;QACH,qEAAqE;QACrE,mEAAmE;QACnE,uDAAuD;QACvD,sEAAsE;QACtE,sDAAsD;QACtD,WAAW,EAAE,IAAI;KACpB,CAAC;AACN,CAAC;AA1BD,wCA0BC"}
@@ -0,0 +1,18 @@
1
+ import type webpack from "webpack";
2
+ interface Deps {
3
+ tsconfigFilepath: string;
4
+ fastRefresh: boolean;
5
+ }
6
+ /**
7
+ * Handles dependency requests to typescript files
8
+ * by compiling with `tsc`.
9
+ *
10
+ * To enable react fast refresh, set `withReactFastRefreshBabelPlugin` to true,
11
+ * this requires "@pmmmwh/react-refresh-webpack-plugin" webpack plugin to work,
12
+ * and should not be used in production.
13
+ *
14
+ * @see https://github.com/TypeStrong/ts-loader
15
+ * @see https://github.com/pmmmwh/react-refresh-webpack-plugin
16
+ */
17
+ export declare function tsRule({ tsconfigFilepath, fastRefresh }: Deps): webpack.RuleSetRule;
18
+ export {};
@@ -1,12 +1,11 @@
1
- import path from "path";
2
- import type webpack from "webpack";
3
- import {RegExpUtil} from "./RegExpUtil";
4
-
5
- interface Deps {
6
- tsconfigFilepath: string;
7
- fastRefresh: boolean;
8
- }
9
-
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.tsRule = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const RegExpUtil_1 = require("./RegExpUtil");
10
9
  /**
11
10
  * Handles dependency requests to typescript files
12
11
  * by compiling with `tsc`.
@@ -18,16 +17,15 @@ interface Deps {
18
17
  * @see https://github.com/TypeStrong/ts-loader
19
18
  * @see https://github.com/pmmmwh/react-refresh-webpack-plugin
20
19
  */
21
- export function tsRule({tsconfigFilepath, fastRefresh}: Deps): webpack.RuleSetRule {
22
- const babelLoader: webpack.RuleSetUseItem = {
20
+ function tsRule({ tsconfigFilepath, fastRefresh }) {
21
+ const babelLoader = {
23
22
  loader: require.resolve("babel-loader"),
24
23
  options: {
25
- plugins: [require.resolve(path.join(__dirname, "./core-fe-hmr-babel-plugin")), require.resolve("react-refresh/babel")],
24
+ plugins: [require.resolve(path_1.default.join(__dirname, "./core-fe-hmr-babel-plugin")), require.resolve("react-refresh/babel")],
26
25
  },
27
26
  };
28
-
29
27
  // TODO/Alvis: Check whether ts-loader can be replaced by babel loader
30
- const tsLoader: webpack.RuleSetUseItem = {
28
+ const tsLoader = {
31
29
  loader: require.resolve("ts-loader"),
32
30
  options: {
33
31
  colors: false,
@@ -40,8 +38,7 @@ export function tsRule({tsconfigFilepath, fastRefresh}: Deps): webpack.RuleSetRu
40
38
  transpileOnly: true,
41
39
  },
42
40
  };
43
-
44
- const swcLoader: webpack.RuleSetUseItem = {
41
+ const swcLoader = {
45
42
  loader: require.resolve("swc-loader"),
46
43
  options: {
47
44
  jsc: {
@@ -60,9 +57,10 @@ export function tsRule({tsconfigFilepath, fastRefresh}: Deps): webpack.RuleSetRu
60
57
  },
61
58
  },
62
59
  };
63
-
64
60
  return {
65
- test: RegExpUtil.fileExtension(".ts", ".tsx"),
61
+ test: RegExpUtil_1.RegExpUtil.fileExtension(".ts", ".tsx"),
66
62
  use: fastRefresh ? [babelLoader, tsLoader] : [swcLoader],
67
63
  };
68
64
  }
65
+ exports.tsRule = tsRule;
66
+ //# sourceMappingURL=ts.rule.js.map