@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
@@ -1,21 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`core-fe-hmr-babel-plugin sanity test for some react component files 1`] = `
4
- "import React from \\"react\\";
5
- import { ReactUtil } from \\"@pinnacle0/util\\";
6
- export const Main = ReactUtil.memo(\\"Main\\", () => {
7
- return React.createElement(\\"div\\", {});
8
- });"
9
- `;
10
-
11
- exports[`core-fe-hmr-babel-plugin should ignore when non core-fe source files 1`] = `
12
- "import { Module } from \\"not-core-fe\\";
13
- import { Main } from \\"./component/Main\\";
14
- const initialState = {};
15
-
16
- class FeatureModule extends Module {}
17
-
18
- const featureModule = register(new FeatureModule(\\"feature\\", initialState));
19
- export const actions = featureModule.getActions();
20
- export const MainComponent = featureModule.attachLifecycle(Main);"
21
- `;
@@ -1,53 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`core-fe-hmr-babel-plugin works with \`import * as CoreFENamespace\` 1`] = `
4
- "import * as CoreFENamespace from \\"core-fe\\";
5
- import { Main } from \\"./component/Main\\";
6
- const initialState = {};
7
-
8
- class FeatureModule extends CoreFENamespace.Module {}
9
-
10
- const featureModule = register(new FeatureModule(\\"feature\\", initialState));
11
- export const actions = featureModule.getActions();
12
- export const MainComponent = featureModule.attachLifecycle(Main);
13
- if (module.hot) module.hot.decline();"
14
- `;
15
-
16
- exports[`core-fe-hmr-babel-plugin works with \`import {Module as CoreFEModule}\` 1`] = `
17
- "import { Module as CoreFEModule } from \\"core-fe\\";
18
- import { Main } from \\"./component/Main\\";
19
- const initialState = {};
20
-
21
- class FeatureModule extends CoreFEModule {}
22
-
23
- const featureModule = register(new FeatureModule(\\"feature\\", initialState));
24
- export const actions = featureModule.getActions();
25
- export const MainComponent = featureModule.attachLifecycle(Main);
26
- if (module.hot) module.hot.decline();"
27
- `;
28
-
29
- exports[`core-fe-hmr-babel-plugin works with \`import {Module}\` 1`] = `
30
- "import { Module } from \\"core-fe\\";
31
- import { Main } from \\"./component/Main\\";
32
- const initialState = {};
33
-
34
- class FeatureModule extends Module {}
35
-
36
- const featureModule = register(new FeatureModule(\\"feature\\", initialState));
37
- export const actions = featureModule.getActions();
38
- export const MainComponent = featureModule.attachLifecycle(Main);
39
- if (module.hot) module.hot.decline();"
40
- `;
41
-
42
- exports[`core-fe-hmr-babel-plugin works with \`import CoreFEDefault, {Module}\` 1`] = `
43
- "import CoreFEDefault, { Module } from \\"core-fe\\";
44
- import { Main } from \\"./component/Main\\";
45
- const initialState = {};
46
-
47
- class FeatureModule extends Module {}
48
-
49
- const featureModule = register(new FeatureModule(\\"feature\\", initialState));
50
- export const actions = featureModule.getActions();
51
- export const MainComponent = featureModule.attachLifecycle(Main);
52
- if (module.hot) module.hot.decline();"
53
- `;
@@ -1,36 +0,0 @@
1
- import * as babel from "@babel/core";
2
- import plugin from "@pinnacle0/webpack-util/src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin";
3
-
4
- describe("core-fe-hmr-babel-plugin", () => {
5
- test("should ignore when non core-fe source files", () => {
6
- const source = `
7
- import {Module} from "not-core-fe";
8
- import {Main} from "./component/Main";
9
-
10
- const initialState = {};
11
- class FeatureModule extends Module {}
12
-
13
- const featureModule = register(new FeatureModule("feature", initialState));
14
- export const actions = featureModule.getActions();
15
- export const MainComponent = featureModule.attachLifecycle(Main);
16
- `;
17
- const {code} = babel.transformSync(source, {plugins: [plugin]})!;
18
- expect(code).toMatchSnapshot();
19
- expect(code).not.toContain("if (module.hot) module.hot.decline();");
20
- });
21
-
22
- test("sanity test for some react component files", () => {
23
- const source = `
24
- import React from "react";
25
- import {ReactUtil} from "@pinnacle0/util";
26
-
27
- export const Main = ReactUtil.memo("Main", () => {
28
- return React.createElement("div", {});
29
- });
30
- `;
31
- const {code} = babel.transformSync(source, {plugins: [plugin]})!;
32
-
33
- expect(code).toMatchSnapshot();
34
- expect(code).not.toContain("if (module.hot) module.hot.decline();");
35
- });
36
- });
@@ -1,72 +0,0 @@
1
- import * as babel from "@babel/core";
2
- import plugin from "@pinnacle0/webpack-util/src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin";
3
-
4
- describe("core-fe-hmr-babel-plugin", () => {
5
- test("works with `import {Module}`", () => {
6
- const source = `
7
- import {Module} from "core-fe";
8
- import {Main} from "./component/Main";
9
-
10
- const initialState = {};
11
- class FeatureModule extends Module {}
12
-
13
- const featureModule = register(new FeatureModule("feature", initialState));
14
- export const actions = featureModule.getActions();
15
- export const MainComponent = featureModule.attachLifecycle(Main);
16
- `;
17
- const {code} = babel.transformSync(source, {plugins: [plugin]})!;
18
- expect(code).toMatchSnapshot();
19
- expect(code).toContain("if (module.hot) module.hot.decline();");
20
- });
21
-
22
- test("works with `import {Module as CoreFEModule}`", () => {
23
- const source = `
24
- import {Module as CoreFEModule} from "core-fe";
25
- import {Main} from "./component/Main";
26
-
27
- const initialState = {};
28
- class FeatureModule extends CoreFEModule {}
29
-
30
- const featureModule = register(new FeatureModule("feature", initialState));
31
- export const actions = featureModule.getActions();
32
- export const MainComponent = featureModule.attachLifecycle(Main);
33
- `;
34
- const {code} = babel.transformSync(source, {plugins: [plugin]})!;
35
- expect(code).toMatchSnapshot();
36
- expect(code).toContain("if (module.hot) module.hot.decline();");
37
- });
38
-
39
- test("works with `import CoreFEDefault, {Module}`", () => {
40
- const source = `
41
- import CoreFEDefault, {Module} from "core-fe";
42
- import {Main} from "./component/Main";
43
-
44
- const initialState = {};
45
- class FeatureModule extends Module {}
46
-
47
- const featureModule = register(new FeatureModule("feature", initialState));
48
- export const actions = featureModule.getActions();
49
- export const MainComponent = featureModule.attachLifecycle(Main);
50
- `;
51
- const {code} = babel.transformSync(source, {plugins: [plugin]})!;
52
- expect(code).toMatchSnapshot();
53
- expect(code).toContain("if (module.hot) module.hot.decline();");
54
- });
55
-
56
- test("works with `import * as CoreFENamespace`", () => {
57
- const source = `
58
- import * as CoreFENamespace from "core-fe";
59
- import {Main} from "./component/Main";
60
-
61
- const initialState = {};
62
- class FeatureModule extends CoreFENamespace.Module {}
63
-
64
- const featureModule = register(new FeatureModule("feature", initialState));
65
- export const actions = featureModule.getActions();
66
- export const MainComponent = featureModule.attachLifecycle(Main);
67
- `;
68
- const {code} = babel.transformSync(source, {plugins: [plugin]})!;
69
- expect(code).toMatchSnapshot();
70
- expect(code).toContain("if (module.hot) module.hot.decline();");
71
- });
72
- });
@@ -1,2 +0,0 @@
1
- const {a} = require("./script1");
2
- console.info(a);
@@ -1 +0,0 @@
1
- module.exports = {a: "123"};
@@ -1,58 +0,0 @@
1
- import path from "path";
2
- import fs from "fs";
3
- import webpack from "webpack";
4
- import HtmlWebpackPlugin from "html-webpack-plugin";
5
- import {ScriptTagCrossOriginPlugin} from "../../../src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin";
6
-
7
- const OUTPUT_DIR = path.join(__dirname, "./dist");
8
- type Entry = Omit<webpack.Configuration["entry"], "undefined">;
9
- const createConfig = (entry: Entry): webpack.Configuration => ({
10
- mode: "production",
11
- entry,
12
- output: {
13
- path: OUTPUT_DIR,
14
- },
15
- plugins: [
16
- new HtmlWebpackPlugin({
17
- filename: "index.html",
18
- }),
19
- new ScriptTagCrossOriginPlugin(),
20
- ],
21
- });
22
-
23
- describe("script-tag-crossorigin-plugin test: Add crossorigin='anonymous'", () => {
24
- beforeEach(done => {
25
- fs.rmSync(OUTPUT_DIR, {force: true, recursive: true});
26
- done();
27
- });
28
-
29
- const testPlugin = (entry: Entry, expectedResult: RegExp, done: () => void) => {
30
- const config: webpack.Configuration = createConfig(entry);
31
- webpack(config, error => {
32
- expect(error).toBeFalsy();
33
- const outputFile = fs.readFileSync(path.join(OUTPUT_DIR, "index.html"));
34
- expect(outputFile.toString()).toMatch(expectedResult);
35
- done();
36
- });
37
- };
38
-
39
- test("single entry script tag", done => {
40
- testPlugin(
41
- {
42
- main: path.join(__dirname, "./fixture/script.js"),
43
- },
44
- new RegExp('<script.+src.+\\main.js.+crossorigin="anonymous"', "gm"),
45
- done
46
- );
47
- });
48
- test("multiple entry script tag", done => {
49
- testPlugin(
50
- {
51
- main: path.join(__dirname, "./fixture/script.js"),
52
- second: path.join(__dirname, "./fixture/script.js"),
53
- },
54
- new RegExp('<script.+src.+\\main.js.+crossorigin="anonymous".*>.+<script.+src.+second\\.js.+crossorigin="anonymous"', "gm"),
55
- done
56
- );
57
- });
58
- });
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@pinnacle0/webpack-util-test-project",
3
- "license": "UNLICENSED",
4
- "private": true
5
- }
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "files": [],
3
- "include": [],
4
- "references": [
5
- {
6
- "path": "./config/tsconfig.script.json"
7
- },
8
- {
9
- "path": "./config/tsconfig.src.json"
10
- },
11
- {
12
- "path": "./config/tsconfig.test.json"
13
- }
14
- ]
15
- }