@qse/edu-scripts 1.14.17 → 2.0.0

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 (92) hide show
  1. package/CHANGELOG.md +2 -483
  2. package/asset/rspack-dev-server-client.js +534 -0
  3. package/{src/asset → asset}/template/edu-scripts.override.js.tpl +2 -2
  4. package/{lib/asset → asset}/template/tailwind.config.js.tpl +1 -1
  5. package/babel.config.json +6 -0
  6. package/dist/cli.d.mts +1 -0
  7. package/dist/cli.mjs +1426 -0
  8. package/dist/index.d.mts +83 -0
  9. package/dist/index.mjs +13 -0
  10. package/eslint.config.mjs +3 -0
  11. package/{jest.config.js → jest.config.mjs} +8 -4
  12. package/package.json +52 -57
  13. package/src/{auto-refactor.js → auto-refactor.ts} +51 -59
  14. package/src/{build.js → build.ts} +22 -16
  15. package/src/{cli.js → cli.ts} +25 -21
  16. package/src/{commit-dist.js → commit-dist.ts} +28 -21
  17. package/src/config/paths.ts +52 -0
  18. package/src/config/plugins/mock-server/{index.js → index.ts} +30 -41
  19. package/src/config/plugins/{postcss-safe-area.js → postcss-safe-area.ts} +4 -2
  20. package/src/config/{webpackConfig.js → webpackConfig.ts} +152 -126
  21. package/src/config/{webpackDevServerConfig.js → webpackDevServerConfig.ts} +18 -18
  22. package/src/{deploy.js → deploy.ts} +36 -25
  23. package/src/{generator.js → generator.ts} +5 -14
  24. package/src/start.ts +52 -0
  25. package/src/utils/FileSizeReporter.ts +166 -0
  26. package/src/utils/{appConfig.js → appConfig.ts} +5 -4
  27. package/src/utils/{beforeStart.js → beforeStart.ts} +18 -29
  28. package/src/utils/{changeDeployVersion.js → changeDeployVersion.ts} +43 -48
  29. package/src/utils/defineConfig.ts +19 -36
  30. package/src/utils/{exec.js → exec.ts} +3 -3
  31. package/src/utils/{getConfig.js → getConfig.ts} +7 -5
  32. package/src/utils/getOverride.ts +32 -0
  33. package/src/utils/resolveModule.ts +3 -0
  34. package/tsconfig.json +3 -15
  35. package/tsdown.config.ts +5 -0
  36. package/docs/changelog.md +0 -5
  37. package/docs/debug.md +0 -17
  38. package/docs/deploy.md +0 -54
  39. package/docs/faq.md +0 -144
  40. package/docs/feat.md +0 -167
  41. package/docs/grayscale.md +0 -31
  42. package/docs/index.md +0 -5
  43. package/docs/mode.md +0 -42
  44. package/docs/override.md +0 -193
  45. package/docs/refactor-react-16.md +0 -37
  46. package/docs/refactor.md +0 -67
  47. package/docs/static.md +0 -24
  48. package/lib/asset/template/edu-scripts.override.js.tpl +0 -7
  49. package/lib/auto-refactor.js +0 -151
  50. package/lib/build.js +0 -59
  51. package/lib/cli.js +0 -66
  52. package/lib/commit-dist.js +0 -79
  53. package/lib/config/babel.dependencies.js +0 -79
  54. package/lib/config/babel.js +0 -107
  55. package/lib/config/paths.js +0 -36
  56. package/lib/config/plugins/babel-plugin-add-webpack-chunk-name.js +0 -31
  57. package/lib/config/plugins/mock-server/defineMock.d.ts +0 -6
  58. package/lib/config/plugins/mock-server/defineMock.js +0 -31
  59. package/lib/config/plugins/mock-server/index.js +0 -122
  60. package/lib/config/plugins/postcss-safe-area.js +0 -19
  61. package/lib/config/plugins/ws-utils-createSocketURL.js +0 -118
  62. package/lib/config/webpackConfig.js +0 -462
  63. package/lib/config/webpackDevServerConfig.js +0 -72
  64. package/lib/deploy.js +0 -143
  65. package/lib/generator.js +0 -50
  66. package/lib/index.d.ts +0 -2
  67. package/lib/index.js +0 -32
  68. package/lib/start.js +0 -36
  69. package/lib/utils/FileSizeReporter.js +0 -107
  70. package/lib/utils/appConfig.js +0 -32
  71. package/lib/utils/beforeStart.js +0 -62
  72. package/lib/utils/changeDeployVersion.js +0 -89
  73. package/lib/utils/defineConfig.d.ts +0 -93
  74. package/lib/utils/defineConfig.js +0 -31
  75. package/lib/utils/exec.js +0 -7
  76. package/lib/utils/getConfig.js +0 -20
  77. package/lib/utils/getOverride.js +0 -61
  78. package/src/asset/dll/libcommon3-manifest.json +0 -181
  79. package/src/asset/template/edu-app-env.d.ts.tpl +0 -20
  80. package/src/asset/template/tailwind.config.js.tpl +0 -11
  81. package/src/asset/template/tsconfig.json.tpl +0 -24
  82. package/src/config/babel.dependencies.js +0 -66
  83. package/src/config/babel.js +0 -94
  84. package/src/config/paths.js +0 -38
  85. package/src/config/plugins/babel-plugin-add-webpack-chunk-name.js +0 -55
  86. package/src/config/plugins/ws-utils-createSocketURL.js +0 -140
  87. package/src/start.js +0 -44
  88. package/src/utils/FileSizeReporter.js +0 -151
  89. package/src/utils/getOverride.js +0 -48
  90. /package/{lib/asset → asset}/dll/libcommon3-manifest.json +0 -0
  91. /package/{lib/asset → asset}/template/edu-app-env.d.ts.tpl +0 -0
  92. /package/{lib/asset → asset}/template/tsconfig.json.tpl +0 -0
@@ -1,181 +0,0 @@
1
- {
2
- "name": "libcommon3_3b2812567db0aac08740",
3
- "content": {
4
- "react": { "id": 0 },
5
- "./node_modules/core-js/library/modules/_core.js": { "id": 1 },
6
- "./node_modules/core-js/library/modules/_global.js": { "id": 2 },
7
- "./node_modules/core-js/library/modules/_wks.js": { "id": 3 },
8
- "./node_modules/core-js/library/modules/_an-object.js": { "id": 4 },
9
- "./node_modules/core-js/library/modules/_descriptors.js": { "id": 5 },
10
- "./node_modules/react-keeper/utils/Util.js": { "id": 6 },
11
- "./node_modules/core-js/library/modules/_export.js": { "id": 7 },
12
- "./node_modules/core-js/library/modules/_object-dp.js": { "id": 8 },
13
- "./node_modules/core-js/library/modules/_is-object.js": { "id": 9 },
14
- "./node_modules/react-keeper/HistoryControl.js": { "id": 10 },
15
- "./node_modules/warning/browser.js": { "id": 11 },
16
- "./node_modules/vhistory/PathUtils.js": { "id": 12 },
17
- "./node_modules/core-js/library/modules/_hide.js": { "id": 13 },
18
- "./node_modules/core-js/library/modules/_has.js": { "id": 14 },
19
- "./node_modules/core-js/library/modules/_to-iobject.js": { "id": 15 },
20
- "./node_modules/core-js/library/modules/_fails.js": { "id": 16 },
21
- "./node_modules/prop-types/index.js": { "id": 17 },
22
- "./node_modules/react-keeper/utils/Logger.js": { "id": 18 },
23
- "./node_modules/vhistory/LocationUtils.js": { "id": 19 },
24
- "./node_modules/core-js/library/modules/_library.js": { "id": 20 },
25
- "./node_modules/core-js/library/modules/_ctx.js": { "id": 21 },
26
- "./node_modules/core-js/library/modules/_cof.js": { "id": 22 },
27
- "./node_modules/core-js/library/modules/_iterators.js": { "id": 23 },
28
- "./node_modules/invariant/browser.js": { "id": 24 },
29
- "./node_modules/vhistory/DOMUtils.js": { "id": 25 },
30
- "./node_modules/core-js/library/modules/_a-function.js": { "id": 26 },
31
- "./node_modules/core-js/library/modules/_uid.js": { "id": 27 },
32
- "./node_modules/core-js/library/modules/_property-desc.js": { "id": 28 },
33
- "./node_modules/core-js/library/modules/_set-to-string-tag.js": { "id": 29 },
34
- "./node_modules/core-js/library/modules/_object-keys.js": { "id": 30 },
35
- "./node_modules/core-js/library/modules/_object-pie.js": { "id": 31 },
36
- "./node_modules/core-js/library/modules/_to-object.js": { "id": 32 },
37
- "./node_modules/react-keeper/Router.js": { "id": 33 },
38
- "./node_modules/react-keeper/utils/CacheOfLinkControl.js": { "id": 34 },
39
- "./node_modules/vhistory/ExecutionEnvironment.js": { "id": 35 },
40
- "./node_modules/vhistory/BrowserProtocol.js": { "id": 36 },
41
- "./node_modules/vhistory/Actions.js": { "id": 37 },
42
- "./node_modules/vhistory/createHistory.js": { "id": 38 },
43
- "./node_modules/core-js/library/modules/_shared.js": { "id": 39 },
44
- "./node_modules/core-js/library/modules/_dom-create.js": { "id": 40 },
45
- "./node_modules/core-js/library/modules/_to-primitive.js": { "id": 41 },
46
- "./node_modules/core-js/library/modules/_to-integer.js": { "id": 42 },
47
- "./node_modules/core-js/library/modules/_wks-ext.js": { "id": 43 },
48
- "./node_modules/core-js/library/modules/_wks-define.js": { "id": 44 },
49
- "./node_modules/core-js/library/modules/_defined.js": { "id": 45 },
50
- "./node_modules/core-js/library/modules/_shared-key.js": { "id": 46 },
51
- "./node_modules/core-js/library/modules/_enum-bug-keys.js": { "id": 47 },
52
- "./node_modules/core-js/library/modules/_object-gops.js": { "id": 48 },
53
- "./node_modules/core-js/library/modules/_object-create.js": { "id": 49 },
54
- "./node_modules/core-js/library/modules/_object-gopd.js": { "id": 50 },
55
- "./node_modules/core-js/library/modules/_object-sap.js": { "id": 51 },
56
- "./node_modules/babel-runtime/helpers/typeof.js": { "id": 52 },
57
- "./node_modules/babel-runtime/core-js/object/define-property.js": { "id": 53 },
58
- "./node_modules/prop-types/lib/ReactPropTypesSecret.js": { "id": 54 },
59
- "./node_modules/react-keeper/InnerRouter.js": { "id": 55 },
60
- "./node_modules/react-keeper/RouteBase.js": { "id": 56 },
61
- "./node_modules/object-assign/index.js": { "id": 57 },
62
- "./node_modules/vhistory/DOMStateStorage.js": { "id": 58 },
63
- "./node_modules/vhistory/runTransitionHook.js": { "id": 59 },
64
- "./node_modules/vhistory/useBasename.js": { "id": 60 },
65
- "./node_modules/react-keeper/Link.js": { "id": 61 },
66
- "./node_modules/core-js/library/modules/_classof.js": { "id": 62 },
67
- "./node_modules/core-js/library/modules/_ie8-dom-define.js": { "id": 63 },
68
- "./node_modules/core-js/library/modules/_to-length.js": { "id": 64 },
69
- "./node_modules/core-js/library/modules/_task.js": { "id": 65 },
70
- "./node_modules/core-js/library/modules/_html.js": { "id": 66 },
71
- "./node_modules/core-js/library/modules/_new-promise-capability.js": { "id": 67 },
72
- "./node_modules/core-js/library/modules/es6.symbol.js": { "id": 68 },
73
- "./node_modules/core-js/library/modules/_redefine.js": { "id": 69 },
74
- "./node_modules/core-js/library/modules/_object-keys-internal.js": { "id": 70 },
75
- "./node_modules/core-js/library/modules/_iobject.js": { "id": 71 },
76
- "./node_modules/core-js/library/modules/_object-gopn.js": { "id": 72 },
77
- "./node_modules/core-js/library/fn/object/assign.js": { "id": 73 },
78
- "./node_modules/core-js/library/modules/es6.object.assign.js": { "id": 74 },
79
- "./node_modules/core-js/library/modules/_object-assign.js": { "id": 75 },
80
- "./node_modules/core-js/library/fn/object/define-property.js": { "id": 76 },
81
- "./node_modules/core-js/library/modules/es6.object.define-property.js": { "id": 77 },
82
- "./node_modules/core-js/library/fn/object/get-own-property-descriptor.js": { "id": 78 },
83
- "./node_modules/core-js/library/modules/es6.object.get-own-property-descriptor.js": {
84
- "id": 79
85
- },
86
- "./node_modules/core-js/library/fn/object/get-prototype-of.js": { "id": 80 },
87
- "./node_modules/core-js/library/modules/es6.object.get-prototype-of.js": { "id": 81 },
88
- "./node_modules/core-js/library/modules/_object-gpo.js": { "id": 82 },
89
- "./node_modules/prop-types/checkPropTypes.js": { "id": 83 },
90
- "./node_modules/core-js/library/modules/_iter-define.js": { "id": 84 },
91
- "./node_modules/babel-runtime/core-js/object/assign.js": { "id": 85 },
92
- "./node_modules/babel-runtime/core-js/object/get-own-property-descriptor.js": { "id": 86 },
93
- "./node_modules/babel-runtime/core-js/object/get-prototype-of.js": { "id": 87 },
94
- "./node_modules/process/browser.js": { "id": 88 },
95
- "./node_modules/refast/dist/index.js": { "id": 90 },
96
- "./node_modules/react-keeper/index.js": { "id": 91 },
97
- "./node_modules/react-keeper/HashRouter.js": { "id": 92 },
98
- "./node_modules/prop-types/factoryWithThrowingShims.js": { "id": 93 },
99
- "./node_modules/react-keeper/utils/functional.js": { "id": 94 },
100
- "./node_modules/create-react-class/index.js": { "id": 95 },
101
- "./node_modules/create-react-class/factory.js": { "id": 96 },
102
- "./node_modules/fbjs/lib/emptyObject.js": { "id": 97 },
103
- "./node_modules/fbjs/lib/invariant.js": { "id": 98 },
104
- "./node_modules/react-keeper/utils/RouteControl.js": { "id": 99 },
105
- "./node_modules/react-keeper/match/matchPath.js": { "id": 100 },
106
- "./node_modules/react-keeper/match/compilePattern.js": { "id": 101 },
107
- "./node_modules/vhistory/createHashHistory.js": { "id": 102 },
108
- "./node_modules/vhistory/HashProtocol.js": { "id": 103 },
109
- "./node_modules/vhistory/AsyncUtils.js": { "id": 104 },
110
- "./node_modules/react-keeper/BrowserRouter.js": { "id": 105 },
111
- "./node_modules/vhistory/createBrowserHistory.js": { "id": 106 },
112
- "./node_modules/vhistory/RefreshProtocol.js": { "id": 107 },
113
- "./node_modules/react-keeper/MemoryRouter.js": { "id": 108 },
114
- "./node_modules/vhistory/createMemoryHistory.js": { "id": 109 },
115
- "./node_modules/react-keeper/Route.js": { "id": 110 },
116
- "./node_modules/react-keeper/middleware/RouteIndex.js": { "id": 111 },
117
- "./node_modules/react-keeper/middleware/RouteCache.js": { "id": 112 },
118
- "react-dom": { "id": 113 },
119
- "./node_modules/react-keeper/utils/CacheOfTagControl.js": { "id": 114 },
120
- "./node_modules/react-keeper/middleware/RouteFilter.js": { "id": 115 },
121
- "./node_modules/react-keeper/middleware/RouteRedirect.js": { "id": 116 },
122
- "./node_modules/react-keeper/middleware/RouteMiss.js": { "id": 117 },
123
- "./node_modules/react-keeper/CacheLink.js": { "id": 118 },
124
- "./src/lib-common.js": { "id": 119 },
125
- "./node_modules/core-js/library/modules/es6.promise.js": { "id": 120 },
126
- "./node_modules/core-js/library/modules/_an-instance.js": { "id": 121 },
127
- "./node_modules/core-js/library/modules/_for-of.js": { "id": 122 },
128
- "./node_modules/core-js/library/modules/_iter-call.js": { "id": 123 },
129
- "./node_modules/core-js/library/modules/_is-array-iter.js": { "id": 124 },
130
- "./node_modules/core-js/library/modules/core.get-iterator-method.js": { "id": 125 },
131
- "./node_modules/core-js/library/modules/_species-constructor.js": { "id": 126 },
132
- "./node_modules/core-js/library/modules/_invoke.js": { "id": 127 },
133
- "./node_modules/core-js/library/modules/_microtask.js": { "id": 128 },
134
- "./node_modules/core-js/library/modules/_perform.js": { "id": 129 },
135
- "./node_modules/core-js/library/modules/_user-agent.js": { "id": 130 },
136
- "./node_modules/core-js/library/modules/_promise-resolve.js": { "id": 131 },
137
- "./node_modules/core-js/library/modules/_redefine-all.js": { "id": 132 },
138
- "./node_modules/core-js/library/modules/_set-species.js": { "id": 133 },
139
- "./node_modules/core-js/library/modules/_iter-detect.js": { "id": 134 },
140
- "./node_modules/core-js/library/modules/_meta.js": { "id": 135 },
141
- "./node_modules/core-js/library/modules/_enum-keys.js": { "id": 136 },
142
- "./node_modules/core-js/library/modules/_array-includes.js": { "id": 137 },
143
- "./node_modules/core-js/library/modules/_to-absolute-index.js": { "id": 138 },
144
- "./node_modules/core-js/library/modules/_is-array.js": { "id": 139 },
145
- "./node_modules/core-js/library/modules/_object-dps.js": { "id": 140 },
146
- "./node_modules/core-js/library/modules/_object-gopn-ext.js": { "id": 141 },
147
- "./node_modules/prop-types/factoryWithTypeCheckers.js": { "id": 142 },
148
- "./node_modules/react-is/index.js": { "id": 143 },
149
- "./node_modules/react-is/cjs/react-is.production.min.js": { "id": 144 },
150
- "./node_modules/regenerator-runtime/runtime.js": { "id": 145 },
151
- "./node_modules/babel-runtime/core-js/symbol/iterator.js": { "id": 146 },
152
- "./node_modules/core-js/library/fn/symbol/iterator.js": { "id": 147 },
153
- "./node_modules/core-js/library/modules/es6.string.iterator.js": { "id": 148 },
154
- "./node_modules/core-js/library/modules/_string-at.js": { "id": 149 },
155
- "./node_modules/core-js/library/modules/_iter-create.js": { "id": 150 },
156
- "./node_modules/core-js/library/modules/web.dom.iterable.js": { "id": 151 },
157
- "./node_modules/core-js/library/modules/es6.array.iterator.js": { "id": 152 },
158
- "./node_modules/core-js/library/modules/_add-to-unscopables.js": { "id": 153 },
159
- "./node_modules/core-js/library/modules/_iter-step.js": { "id": 154 },
160
- "./node_modules/babel-runtime/core-js/symbol.js": { "id": 155 },
161
- "./node_modules/core-js/library/fn/symbol/index.js": { "id": 156 },
162
- "./node_modules/core-js/library/modules/es6.object.to-string.js": { "id": 157 },
163
- "./node_modules/core-js/library/modules/es7.symbol.async-iterator.js": { "id": 158 },
164
- "./node_modules/core-js/library/modules/es7.symbol.observable.js": { "id": 159 },
165
- "./node_modules/babel-runtime/helpers/inherits.js": { "id": 160 },
166
- "./node_modules/babel-runtime/core-js/object/set-prototype-of.js": { "id": 161 },
167
- "./node_modules/core-js/library/fn/object/set-prototype-of.js": { "id": 162 },
168
- "./node_modules/core-js/library/modules/es6.object.set-prototype-of.js": { "id": 163 },
169
- "./node_modules/core-js/library/modules/_set-proto.js": { "id": 164 },
170
- "./node_modules/babel-runtime/core-js/object/create.js": { "id": 165 },
171
- "./node_modules/core-js/library/fn/object/create.js": { "id": 166 },
172
- "./node_modules/core-js/library/modules/es6.object.create.js": { "id": 167 },
173
- "./node_modules/babel-runtime/helpers/classCallCheck.js": { "id": 168 },
174
- "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js": { "id": 169 },
175
- "./node_modules/babel-runtime/helpers/createClass.js": { "id": 170 },
176
- "./node_modules/babel-runtime/helpers/extends.js": { "id": 171 },
177
- "./node_modules/babel-runtime/helpers/defineProperty.js": { "id": 172 },
178
- "./node_modules/babel-runtime/helpers/get.js": { "id": 173 },
179
- "./node_modules/performance-now/lib/performance-now.js": { "id": 176 }
180
- }
181
- }
@@ -1,20 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- /* eslint-disable import/first */
3
-
4
- /// <reference types="@qse/edu-scripts/app" />
5
-
6
- import '@qse/edu-login'
7
- declare module '@qse/edu-login' {
8
- interface IConfig {
9
- // 拓展 config
10
- }
11
-
12
- interface IUser {
13
- // 拓展 config.user
14
- }
15
- }
16
-
17
- declare global {
18
- interface Window {
19
- }
20
- }
@@ -1,11 +0,0 @@
1
- /** @type {import('tailwindcss').Config} */
2
- module.exports = {
3
- content: ['./src/**/*.{js,jsx,ts,tsx}'],
4
- theme: {
5
- extend: {},
6
- },
7
- plugins: [],
8
- corePlugins: {
9
- // preflight: false, // 预设样式,如果不需要可关闭
10
- },
11
- }
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "lib": ["dom", "dom.iterable", "esnext"],
5
- "jsx": "preserve",
6
- "experimentalDecorators": true,
7
- "module": "ESNext",
8
- "moduleResolution": "node",
9
- "baseUrl": "./",
10
- "paths": {
11
- "@/*": ["src/*"]
12
- },
13
- "allowJs": true,
14
- "noEmit": true,
15
- "allowSyntheticDefaultImports": true,
16
- "esModuleInterop": true,
17
- "forceConsistentCasingInFileNames": true,
18
- "strict": true,
19
- "useUnknownInCatchVariables": false,
20
- "skipLibCheck": true,
21
- "downlevelIteration": true,
22
- "resolveJsonModule": true
23
- }
24
- }
@@ -1,66 +0,0 @@
1
- const getOverride = require('../utils/getOverride')
2
-
3
- /**
4
- * @typedef {Object} Opts
5
- * @property {string} [modules]
6
- *
7
- * @param {Opts} [opts]
8
- * @return {*}
9
- */
10
- module.exports = function getBabelConfig(opts = {}) {
11
- const isDev = process.env.NODE_ENV === 'development'
12
-
13
- let config = {
14
- cacheDirectory: true,
15
- cacheCompression: false,
16
- babelrc: false,
17
- configFile: false,
18
- sourceType: 'unambiguous',
19
- compact: false,
20
- sourceMaps: isDev,
21
- inputSourceMap: isDev,
22
- presets: [
23
- [
24
- require.resolve('@babel/preset-env'),
25
- {
26
- modules: opts.modules,
27
- useBuiltIns: 'entry',
28
- corejs: 3,
29
- // Exclude transforms that make all code slower
30
- exclude: ['transform-typeof-symbol'],
31
- },
32
- ],
33
- ].filter(Boolean),
34
- plugins: [
35
- [
36
- require.resolve('@babel/plugin-transform-runtime'),
37
- {
38
- absoluteRuntime: true,
39
- corejs: false,
40
- helpers: true,
41
- // By default, babel assumes babel/runtime version 7.0.0-beta.0,
42
- // explicitly resolving to match the provided helper functions.
43
- // https://github.com/babel/babel/issues/10261
44
- version: require('@babel/runtime/package.json').version,
45
- regenerator: true,
46
- // // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
47
- // // We should turn this on once the lowest version of Node LTS
48
- // // supports ES Modules.
49
- // useESModules: true,
50
- },
51
- ],
52
- [
53
- require.resolve('babel-plugin-import'),
54
- { libraryName: 'lodash', libraryDirectory: '', camel2DashComponentName: false },
55
- 'lodash',
56
- ],
57
- ].filter(Boolean),
58
- }
59
-
60
- const override = getOverride()
61
- if (override.babel) {
62
- config = override.babel(config, 'node_modules') || config
63
- }
64
-
65
- return config
66
- }
@@ -1,94 +0,0 @@
1
- const fs = require('fs')
2
- const paths = require('./paths')
3
- const appConfig = require('../utils/appConfig')
4
- const getOverride = require('../utils/getOverride')
5
- const addWebpackChunkName = require('./plugins/babel-plugin-add-webpack-chunk-name')
6
- const hasJsxRuntime = (() => {
7
- try {
8
- require.resolve('react/jsx-runtime')
9
- return true && appConfig.single
10
- } catch (error) {
11
- return false
12
- }
13
- })()
14
-
15
- /**
16
- * @typedef {Object} Opts
17
- * @property {string} [modules]
18
- *
19
- * @param {Opts} [opts]
20
- * @return {*}
21
- */
22
- module.exports = function getBabelConfig(opts = {}) {
23
- const isTypeScriptEnabled = fs.existsSync(paths.tsconfig)
24
- const isDev = process.env.NODE_ENV === 'development'
25
-
26
- let config = {
27
- cacheDirectory: true,
28
- cacheCompression: false,
29
- compact: !isDev,
30
- babelrc: false,
31
- configFile: false,
32
- presets: [
33
- [
34
- require.resolve('@babel/preset-env'),
35
- {
36
- modules: opts.modules,
37
- useBuiltIns: 'entry',
38
- corejs: 3,
39
- // Exclude transforms that make all code slower
40
- exclude: ['transform-typeof-symbol'],
41
- },
42
- ],
43
- [
44
- require.resolve('@babel/preset-react'),
45
- {
46
- development: isDev,
47
- runtime: hasJsxRuntime ? 'automatic' : 'classic',
48
- useBuiltIns: !hasJsxRuntime,
49
- },
50
- ],
51
- isTypeScriptEnabled && require.resolve('@babel/preset-typescript'),
52
- ].filter(Boolean),
53
- plugins: [
54
- [
55
- require.resolve('@babel/plugin-transform-runtime'),
56
- {
57
- absoluteRuntime: true,
58
- corejs: false,
59
- helpers: true,
60
- // By default, babel assumes babel/runtime version 7.0.0-beta.0,
61
- // explicitly resolving to match the provided helper functions.
62
- // https://github.com/babel/babel/issues/10261
63
- version: require('@babel/runtime/package.json').version,
64
- regenerator: true,
65
- // // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
66
- // // We should turn this on once the lowest version of Node LTS
67
- // // supports ES Modules.
68
- // useESModules: true,
69
- },
70
- ],
71
- [
72
- require.resolve('babel-plugin-import'),
73
- { libraryName: 'lodash', libraryDirectory: '', camel2DashComponentName: false },
74
- 'lodash',
75
- ],
76
- isDev && require.resolve('react-refresh/babel'),
77
- addWebpackChunkName,
78
- ].filter(Boolean),
79
- }
80
-
81
- const override = getOverride()
82
- if (override.decorators) {
83
- config.presets[0][1].include = ['@babel/plugin-transform-class-properties'] // Force include: always transform
84
- config.plugins.push([
85
- require.resolve('@babel/plugin-proposal-decorators'),
86
- { version: 'legacy' },
87
- ])
88
- }
89
- if (override.babel) {
90
- config = override.babel(config, 'src') || config
91
- }
92
-
93
- return config
94
- }
@@ -1,38 +0,0 @@
1
- const path = require('path')
2
- const fs = require('fs')
3
- const glob = require('globby')
4
-
5
- function resolveApp(...filePath) {
6
- return path.resolve(process.cwd(), ...filePath)
7
- }
8
-
9
- function getExistPath(...paths) {
10
- for (const path of paths) {
11
- if (fs.existsSync(path)) {
12
- return path
13
- }
14
- }
15
- return paths[0]
16
- }
17
-
18
- const paths = {
19
- resolveApp,
20
- eduAppEnv: resolveApp('src', 'edu-app-env.d.ts'),
21
- dist: resolveApp('dist'),
22
- sshSftp: resolveApp('.sftprc.json'),
23
- nodeModules: resolveApp('node_modules'),
24
- tsconfig: resolveApp('tsconfig.json'),
25
- jsconfig: resolveApp('jsconfig.json'),
26
- package: resolveApp('package.json'),
27
- tailwind: resolveApp('tailwind.config.js'),
28
- indexJS: resolveApp('src', 'index.js'),
29
- pages: resolveApp('src', 'pages'),
30
- override: resolveApp('edu-scripts.override.js'),
31
- indexHTML: glob.sync('./public/*.html', { absolute: true }),
32
- src: resolveApp('src'),
33
- public: resolveApp('public'),
34
- static: resolveApp('public', 'static'),
35
- theme: getExistPath(resolveApp('theme.json'), resolveApp('theme.js')),
36
- mock: resolveApp('mock'),
37
- }
38
- module.exports = paths
@@ -1,55 +0,0 @@
1
- // Modified from `babel-plugin-dynamic-import-chunk-name` as it used a slightly
2
- // different naming system than what we wanted. Using the plugin and correcting
3
- // the names after the fact would be more effort than forking. Additionally, the
4
- // plugin does not have source code available online. While we're unlikely to run
5
- // into issues, having a way to create fixes ourselves would be beneficial.
6
- //
7
- // https://www.npmjs.im/babel-plugin-dynamic-import-chunk-name
8
- // MIT Licensed: https://www.runpkg.com/?babel-plugin-dynamic-import-chunk-name@1.0.0/LICENSE
9
-
10
- function removeTrailingIndex(string) {
11
- return string.split('_').length - 1 > 1 ? string.replace(/_index$/, '') : string
12
- }
13
-
14
- function convertToKebabCase(string) {
15
- return string.replace(/\s+/g, '_')
16
- }
17
-
18
- function getChunkName(filename) {
19
- filename = filename
20
- .split('/')
21
- .map((part) => part.replace(/\..*$/, '').replace(/[^a-zA-Z0-9-_/]/g, ''))
22
- .filter(Boolean)
23
- .map(convertToKebabCase)
24
- .join('_')
25
-
26
- return removeTrailingIndex(filename)
27
- }
28
-
29
- function hasComment(comment) {
30
- return comment && comment.value.replace(/\*+/g, '').trim().startsWith('webpackChunkName')
31
- }
32
-
33
- /**
34
- * @param {import('@babel/core')} babel
35
- * @returns {import('@babel/core').PluginObj}
36
- */
37
- function addWebpackChunkName({ types: t }) {
38
- return {
39
- name: 'webpack-chunk-name-comments',
40
- visitor: {
41
- Import(path) {
42
- const [arg] = path.parent.arguments
43
- if (!t.isStringLiteral(arg)) return
44
-
45
- const [comment] = arg.leadingComments || []
46
-
47
- if (!hasComment(comment)) {
48
- t.addComment(arg, 'leading', `webpackChunkName: "${getChunkName(arg.value)}"`)
49
- }
50
- },
51
- },
52
- }
53
- }
54
-
55
- module.exports = addWebpackChunkName
@@ -1,140 +0,0 @@
1
- /* eslint-disable no-restricted-globals */
2
-
3
- /**
4
- * @param {{ protocol?: string, auth?: string, hostname?: string, port?: string, pathname?: string, search?: string, hash?: string, slashes?: boolean }} objURL
5
- * @returns {string}
6
- */
7
- function format(objURL) {
8
- var protocol = objURL.protocol || ''
9
- if (protocol && protocol.substr(-1) !== ':') {
10
- protocol += ':'
11
- }
12
- var auth = objURL.auth || ''
13
- if (auth) {
14
- auth = encodeURIComponent(auth)
15
- auth = auth.replace(/%3A/i, ':')
16
- auth += '@'
17
- }
18
- var host = ''
19
- if (objURL.hostname) {
20
- host =
21
- auth +
22
- (objURL.hostname.indexOf(':') === -1 ? objURL.hostname : '['.concat(objURL.hostname, ']'))
23
- if (objURL.port) {
24
- host += ':'.concat(objURL.port)
25
- }
26
- }
27
- var pathname = objURL.pathname || ''
28
- if (objURL.slashes) {
29
- host = '//'.concat(host || '')
30
- if (pathname && pathname.charAt(0) !== '/') {
31
- pathname = '/'.concat(pathname)
32
- }
33
- } else if (!host) {
34
- host = ''
35
- }
36
- var search = objURL.search || ''
37
- if (search && search.charAt(0) !== '?') {
38
- search = '?'.concat(search)
39
- }
40
- var hash = objURL.hash || ''
41
- if (hash && hash.charAt(0) !== '#') {
42
- hash = '#'.concat(hash)
43
- }
44
- pathname = pathname.replace(
45
- /[?#]/g,
46
- /**
47
- * @param {string} match
48
- * @returns {string}
49
- */
50
- function (match) {
51
- return encodeURIComponent(match)
52
- }
53
- )
54
- search = search.replace('#', '%23')
55
- return ''.concat(protocol).concat(host).concat(pathname).concat(search).concat(hash)
56
- }
57
-
58
- /**
59
- * @param {URL & { fromCurrentScript?: boolean }} parsedURL
60
- * @returns {string}
61
- */
62
- function createSocketURL(parsedURL) {
63
- var hostname = parsedURL.hostname
64
-
65
- // Node.js module parses it as `::`
66
- // `new URL(urlString, [baseURLString])` parses it as '[::]'
67
- var isInAddrAny = hostname === '0.0.0.0' || hostname === '::' || hostname === '[::]'
68
-
69
- // why do we need this check?
70
- // hostname n/a for file protocol (example, when using electron, ionic)
71
- // see: https://github.com/webpack/webpack-dev-server/pull/384
72
- if (isInAddrAny && self.location.hostname && self.location.protocol.indexOf('http') === 0) {
73
- hostname = self.location.hostname
74
- }
75
- var socketURLProtocol = parsedURL.protocol || self.location.protocol
76
-
77
- // When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets.
78
- if (
79
- socketURLProtocol === 'auto:' ||
80
- (hostname && isInAddrAny && self.location.protocol === 'https:')
81
- ) {
82
- socketURLProtocol = self.location.protocol
83
- }
84
- socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, 'ws')
85
- var socketURLAuth = ''
86
-
87
- // `new URL(urlString, [baseURLstring])` doesn't have `auth` property
88
- // Parse authentication credentials in case we need them
89
- if (parsedURL.username) {
90
- socketURLAuth = parsedURL.username
91
-
92
- // Since HTTP basic authentication does not allow empty username,
93
- // we only include password if the username is not empty.
94
- if (parsedURL.password) {
95
- // Result: <username>:<password>
96
- socketURLAuth = socketURLAuth.concat(':', parsedURL.password)
97
- }
98
- }
99
-
100
- // In case the host is a raw IPv6 address, it can be enclosed in
101
- // the brackets as the brackets are needed in the final URL string.
102
- // Need to remove those as url.format blindly adds its own set of brackets
103
- // if the host string contains colons. That would lead to non-working
104
- // double brackets (e.g. [[::]]) host
105
- //
106
- // All of these web socket url params are optionally passed in through resourceQuery,
107
- // so we need to fall back to the default if they are not provided
108
- var socketURLHostname = (hostname || self.location.hostname || 'localhost').replace(
109
- /^\[(.*)\]$/,
110
- '$1'
111
- )
112
- var socketURLPort = parsedURL.port
113
- if (!socketURLPort || socketURLPort === '0') {
114
- socketURLPort = self.location.port
115
- }
116
-
117
- // If path is provided it'll be passed in via the resourceQuery as a
118
- // query param so it has to be parsed out of the querystring in order for the
119
- // client to open the socket to the correct location.
120
- var socketURLPathname = '/ws'
121
- if (parsedURL.pathname && !parsedURL.fromCurrentScript) {
122
- socketURLPathname = parsedURL.pathname
123
-
124
- if (hostname.indexOf('zhidianbao.cn') > -1 || hostname.indexOf('qsban.cn') > -1) {
125
- var ctx = self.location.pathname.split('/')[1]
126
- if (ctx) {
127
- socketURLPathname = '/' + ctx + socketURLPathname
128
- }
129
- }
130
- }
131
- return format({
132
- protocol: socketURLProtocol,
133
- auth: socketURLAuth,
134
- hostname: socketURLHostname,
135
- port: socketURLPort,
136
- pathname: socketURLPathname,
137
- slashes: true,
138
- })
139
- }
140
- export default createSocketURL