@umijs/bundler-webpack 4.0.0-beta.8 → 4.0.0-canary-20240513.3
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.
- package/client/client/client.js +255 -167
- package/client/constants.d.ts +15 -0
- package/client/constants.js +30 -12
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +87 -86
- package/compiled/autoprefixer/browserslist/index.d.ts +33 -7
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/package.json +1 -1
- package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
- package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
- package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
- package/compiled/autoprefixer/postcss/lib/node.d.ts +38 -4
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +6 -5
- package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
- package/compiled/babel-loader/index.js +8 -2
- package/compiled/babel-loader/package.json +1 -1
- package/compiled/copy-webpack-plugin/939.index.js +1171 -0
- package/compiled/copy-webpack-plugin/index.js +16 -10
- package/compiled/copy-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
- package/compiled/css-minimizer-webpack-plugin/minify.js +23 -22
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +305 -54
- package/compiled/cssnano/index.js +12 -11
- package/compiled/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/file-loader/index.js +3 -0
- package/compiled/file-loader/package.json +1 -0
- package/compiled/less-loader/index.js +1 -1
- package/compiled/less-loader/package.json +1 -1
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -46
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +10 -6
- package/compiled/mini-css-extract-plugin/index.js +10669 -10348
- package/compiled/mini-css-extract-plugin/loader.js +159 -100
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +88 -44
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/sass-loader/sass.default.dart.js +4 -0
- package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
- package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
- package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
- package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
- package/compiled/schema-utils/declarations/validate.d.ts +4 -4
- package/compiled/schema-utils/index.js +8 -2
- package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/style-loader/index.js +1 -1
- package/compiled/stylus-loader/LICENSE +20 -0
- package/compiled/stylus-loader/index.js +44 -0
- package/compiled/stylus-loader/package.json +1 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
- package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser/index.js +1 -1
- package/compiled/terser/package.json +1 -1
- package/compiled/terser/tools/terser.d.ts +6 -3
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser-webpack-plugin/index.js +1390 -3693
- package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
- package/compiled/terser-webpack-plugin/minify.js +10 -3
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +186 -152
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +20 -24
- package/compiled/terser-webpack-plugin/utils.js +153 -34
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicEvaluatedExpression.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/ExternalsPlugin.js +1 -0
- package/compiled/webpack/FetchCompileAsyncWasmPlugin.js +1 -0
- package/compiled/webpack/FetchCompileWasmPlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/LimitChunkCountPlugin.js +1 -0
- package/compiled/webpack/NodeTargetPlugin.js +1 -0
- package/compiled/webpack/NodeTemplatePlugin.js +1 -0
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/StringXor.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/WebWorkerTemplatePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +15 -1
- package/compiled/webpack/index.js +26404 -10329
- package/compiled/webpack/json-schema/index.d.ts +8 -1
- package/compiled/webpack/lazy-compilation-node.js +10 -0
- package/compiled/webpack/lazy-compilation-web.js +9 -0
- package/compiled/webpack/types.d.ts +823 -287
- package/compiled/webpack-5-chain/index.js +1 -1
- package/compiled/webpack-5-chain/package.json +1 -1
- package/compiled/webpack-5-chain/types/index.d.ts +76 -20
- package/compiled/webpack-bundle-analyzer/index.js +7 -6
- package/compiled/webpack-bundle-analyzer/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
- package/compiled/webpack-dev-middleware/index.js +12 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/{tapable → webpack-manifest-plugin}/LICENSE +2 -2
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- package/compiled/webpack-sources/index.js +1 -1
- package/compiled/{express → webpackbar}/LICENSE +1 -5
- package/compiled/webpackbar/dist/index.d.ts +121 -0
- package/compiled/webpackbar/index.js +7 -0
- package/compiled/webpackbar/package.json +1 -0
- package/compiled/ws/LICENSE +13 -12
- package/compiled/ws/index.d.ts +74 -35
- package/compiled/ws/index.js +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/build.d.ts +8 -3
- package/dist/build.js +147 -68
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +84 -81
- package/dist/config/_sampleFeature.js +33 -20
- package/dist/config/assetRules.js +46 -55
- package/dist/config/bundleAnalyzerPlugin.js +41 -28
- package/dist/config/compressPlugin.js +125 -74
- package/dist/config/config.d.ts +11 -2
- package/dist/config/config.js +235 -172
- package/dist/config/copyPlugin.js +61 -47
- package/dist/config/cssRules.js +162 -95
- package/dist/config/definePlugin.d.ts +2 -0
- package/dist/config/definePlugin.js +59 -39
- package/dist/config/detectCssModulesInDependence.d.ts +10 -0
- package/dist/config/detectCssModulesInDependence.js +151 -0
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +191 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +82 -0
- package/dist/config/fastRefreshPlugin.js +46 -31
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +49 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
- package/dist/config/ignorePlugin.js +38 -25
- package/dist/config/javaScriptRules.d.ts +2 -0
- package/dist/config/javaScriptRules.js +186 -150
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +40 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +52 -31
- package/dist/config/nodePolyfill.js +49 -32
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +38 -0
- package/dist/config/progressPlugin.js +50 -24
- package/dist/config/purgecssWebpackPlugin.js +41 -30
- package/dist/config/speedMeasureWebpackPlugin.js +56 -31
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +98 -0
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +68 -54
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +59 -15
- package/dist/dev.d.ts +23 -3
- package/dist/dev.js +198 -81
- package/dist/index.d.ts +6 -2
- package/dist/index.js +31 -15
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +84 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +149 -0
- package/dist/parcelCSS.d.ts +2 -0
- package/dist/parcelCSS.js +39 -0
- package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
- package/dist/plugins/EsbuildMinifyFix.js +136 -0
- package/dist/plugins/ProgressPlugin.js +68 -43
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
- package/dist/plugins/_SamplePlugin.d.ts +1 -1
- package/dist/plugins/_SamplePlugin.js +37 -14
- package/dist/requireHook.js +44 -27
- package/dist/schema.d.ts +4 -3
- package/dist/schema.js +175 -69
- package/dist/server/server.d.ts +4 -3
- package/dist/server/server.js +219 -154
- package/dist/server/ws.d.ts +8 -3
- package/dist/server/ws.js +72 -38
- package/dist/swcPlugins/autoCSSModules.d.ts +11 -2
- package/dist/swcPlugins/autoCSSModules.js +60 -32
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +32 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +56 -0
- package/dist/types.d.ts +53 -9
- package/dist/types.js +61 -29
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +65 -39
- package/dist/utils/formatWebpackMessages.js +119 -91
- package/dist/utils/getEsBuildTarget.d.ts +7 -0
- package/dist/utils/getEsBuildTarget.js +46 -0
- package/dist/utils/pkgUpContainsName.d.ts +1 -0
- package/dist/utils/pkgUpContainsName.js +50 -0
- package/package.json +89 -81
- package/compiled/@svgr/webpack/.svgo.yml +0 -75
- package/compiled/@svgr/webpack/LICENSE +0 -7
- package/compiled/@svgr/webpack/index.js +0 -343
- package/compiled/@svgr/webpack/package.json +0 -1
- package/compiled/css-loader/api.js +0 -102
- package/compiled/css-loader/getUrl.js +0 -29
- package/compiled/css-loader/index.js +0 -2
- package/compiled/css-loader/noSourceMaps.js +0 -5
- package/compiled/css-loader/package.json +0 -1
- package/compiled/css-loader/sourceMaps.js +0 -22
- package/compiled/express/body-parser/index.d.ts +0 -104
- package/compiled/express/connect/index.d.ts +0 -93
- package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
- package/compiled/express/index.d.ts +0 -133
- package/compiled/express/index.js +0 -338
- package/compiled/express/mime/index.d.ts +0 -35
- package/compiled/express/package.json +0 -1
- package/compiled/express/qs/index.d.ts +0 -62
- package/compiled/express/range-parser/index.d.ts +0 -35
- package/compiled/express/serve-static/index.d.ts +0 -108
- package/compiled/http-proxy-middleware/LICENSE +0 -22
- package/compiled/http-proxy-middleware/dist/index.d.ts +0 -4
- package/compiled/http-proxy-middleware/dist/types.d.ts +0 -54
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +0 -226
- package/compiled/http-proxy-middleware/index.js +0 -66
- package/compiled/http-proxy-middleware/package.json +0 -1
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- package/compiled/react-refresh/index.js +0 -19
- package/compiled/swc-loader/LICENSE +0 -25
- package/compiled/swc-loader/index.js +0 -1
- package/compiled/swc-loader/package.json +0 -1
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/dist/build.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/client.d.ts.map +0 -1
- package/dist/client/client.js +0 -239
- package/dist/config/_sampleFeature.d.ts.map +0 -1
- package/dist/config/assetRules.d.ts.map +0 -1
- package/dist/config/bundleAnalyzerPlugin.d.ts.map +0 -1
- package/dist/config/compressPlugin.d.ts.map +0 -1
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/copyPlugin.d.ts.map +0 -1
- package/dist/config/cssRules.d.ts.map +0 -1
- package/dist/config/definePlugin.d.ts.map +0 -1
- package/dist/config/fastRefreshPlugin.d.ts.map +0 -1
- package/dist/config/ignorePlugin.d.ts.map +0 -1
- package/dist/config/javaScriptRules.d.ts.map +0 -1
- package/dist/config/miniCSSExtractPlugin.d.ts.map +0 -1
- package/dist/config/nodePolyfill.d.ts.map +0 -1
- package/dist/config/progressPlugin.d.ts.map +0 -1
- package/dist/config/purgecssWebpackPlugin.d.ts.map +0 -1
- package/dist/config/speedMeasureWebpackPlugin.d.ts.map +0 -1
- package/dist/config/svgRules.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/dev.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts.map +0 -1
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
- package/dist/plugins/ProgressPlugin.d.ts.map +0 -1
- package/dist/plugins/_SamplePlugin.d.ts.map +0 -1
- package/dist/requireHook.d.ts.map +0 -1
- package/dist/schema.d.ts.map +0 -1
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/ws.d.ts.map +0 -1
- package/dist/swcPlugins/autoCSSModules.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/browsersList.d.ts.map +0 -1
- package/dist/utils/depMatch.d.ts.map +0 -1
- package/dist/utils/formatWebpackMessages.d.ts.map +0 -1
- /package/{dist → client}/client/client.d.ts +0 -0
- /package/compiled/{css-loader → file-loader}/LICENSE +0 -0
package/dist/server/server.js
CHANGED
|
@@ -1,158 +1,223 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
13
18
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
const port = opts.port || 8000;
|
|
151
|
-
server.listen(port, () => {
|
|
152
|
-
const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
|
|
153
|
-
utils_1.logger.ready(`App listening at http://${host}:${port}`);
|
|
154
|
-
});
|
|
155
|
-
return server;
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/server/server.ts
|
|
30
|
+
var server_exports = {};
|
|
31
|
+
__export(server_exports, {
|
|
32
|
+
createServer: () => createServer
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(server_exports);
|
|
35
|
+
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
36
|
+
var import_express = __toESM(require("@umijs/bundler-utils/compiled/express"));
|
|
37
|
+
var import_webpack = __toESM(require("@umijs/bundler-webpack/compiled/webpack"));
|
|
38
|
+
var import_utils = require("@umijs/utils");
|
|
39
|
+
var import_cors = __toESM(require("cors"));
|
|
40
|
+
var import_fs = require("fs");
|
|
41
|
+
var import_http = __toESM(require("http"));
|
|
42
|
+
var import_path = require("path");
|
|
43
|
+
var import_constants = require("../constants");
|
|
44
|
+
var import_ws = require("./ws");
|
|
45
|
+
async function createServer(opts) {
|
|
46
|
+
const { webpackConfig, userConfig } = opts;
|
|
47
|
+
const { proxy } = userConfig;
|
|
48
|
+
const app = (0, import_express.default)();
|
|
49
|
+
let ws;
|
|
50
|
+
app.use(
|
|
51
|
+
(0, import_cors.default)({
|
|
52
|
+
origin: true,
|
|
53
|
+
methods: ["GET", "HEAD", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"],
|
|
54
|
+
credentials: true
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
if (process.env.UMI_DEV_SERVER_COMPRESS !== "none") {
|
|
58
|
+
app.use(require("@umijs/bundler-webpack/compiled/compression")());
|
|
59
|
+
}
|
|
60
|
+
app.use((req, res, next) => {
|
|
61
|
+
const file = req.path;
|
|
62
|
+
const filePath = (0, import_path.join)(opts.cwd, file);
|
|
63
|
+
const ext = (0, import_path.extname)(filePath);
|
|
64
|
+
if (ext === ".js" && (0, import_fs.existsSync)(filePath)) {
|
|
65
|
+
import_utils.logger.info(
|
|
66
|
+
"[dev]",
|
|
67
|
+
`${file} is responded with ${filePath}, remove it to use original file`
|
|
68
|
+
);
|
|
69
|
+
res.sendFile(filePath);
|
|
70
|
+
} else {
|
|
71
|
+
next();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (opts.onBeforeMiddleware) {
|
|
75
|
+
opts.onBeforeMiddleware(app);
|
|
76
|
+
}
|
|
77
|
+
(opts.beforeMiddlewares || []).forEach((m) => app.use(m));
|
|
78
|
+
const configs = Array.isArray(webpackConfig) ? webpackConfig : [webpackConfig];
|
|
79
|
+
const progresses = [];
|
|
80
|
+
if (opts.onProgress) {
|
|
81
|
+
configs.forEach((config) => {
|
|
82
|
+
const progress = {
|
|
83
|
+
percent: 0,
|
|
84
|
+
status: "waiting",
|
|
85
|
+
details: []
|
|
86
|
+
};
|
|
87
|
+
progresses.push(progress);
|
|
88
|
+
config.plugins.push(
|
|
89
|
+
new import_webpack.default.ProgressPlugin((percent, msg, ...details) => {
|
|
90
|
+
progress.percent = percent;
|
|
91
|
+
progress.status = msg;
|
|
92
|
+
progress.details = details;
|
|
93
|
+
opts.onProgress({ progresses });
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const compiler = (0, import_webpack.default)(configs);
|
|
99
|
+
const webpackDevMiddleware = require("@umijs/bundler-webpack/compiled/webpack-dev-middleware");
|
|
100
|
+
const compilerMiddleware = webpackDevMiddleware(compiler, {
|
|
101
|
+
publicPath: userConfig.publicPath || "/",
|
|
102
|
+
writeToDisk: userConfig.writeToDisk,
|
|
103
|
+
stats: "none"
|
|
104
|
+
// watchOptions: { ignored }
|
|
105
|
+
});
|
|
106
|
+
app.use(compilerMiddleware);
|
|
107
|
+
let stats;
|
|
108
|
+
let isFirstCompile = true;
|
|
109
|
+
compiler.compilers.forEach(addHooks);
|
|
110
|
+
function addHooks(compiler2) {
|
|
111
|
+
compiler2.hooks.invalid.tap("server", () => {
|
|
112
|
+
sendMessage(import_constants.MESSAGE_TYPE.invalid);
|
|
113
|
+
});
|
|
114
|
+
compiler2.hooks.done.tap("server", (_stats) => {
|
|
115
|
+
var _a;
|
|
116
|
+
stats = _stats;
|
|
117
|
+
sendStats(getStats(stats));
|
|
118
|
+
(_a = opts.onDevCompileDone) == null ? void 0 : _a.call(opts, {
|
|
119
|
+
stats,
|
|
120
|
+
isFirstCompile,
|
|
121
|
+
ws,
|
|
122
|
+
time: stats.endTime - stats.startTime
|
|
123
|
+
});
|
|
124
|
+
isFirstCompile = false;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function sendStats(stats2, force, sender) {
|
|
128
|
+
const shouldEmit = !force && stats2 && (!stats2.errors || stats2.errors.length === 0) && (!stats2.warnings || stats2.warnings.length === 0) && stats2.assets && stats2.assets.every((asset) => !asset.emitted);
|
|
129
|
+
if (shouldEmit) {
|
|
130
|
+
sendMessage(import_constants.MESSAGE_TYPE.stillOk, null, sender);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
sendMessage(import_constants.MESSAGE_TYPE.hash, stats2.hash, sender);
|
|
134
|
+
if (stats2.errors && stats2.errors.length > 0 || stats2.warnings && stats2.warnings.length > 0) {
|
|
135
|
+
if (stats2.warnings && stats2.warnings.length > 0) {
|
|
136
|
+
sendMessage(import_constants.MESSAGE_TYPE.warnings, stats2.warnings, sender);
|
|
137
|
+
}
|
|
138
|
+
if (stats2.errors && stats2.errors.length > 0) {
|
|
139
|
+
sendMessage(import_constants.MESSAGE_TYPE.errors, stats2.errors, sender);
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
sendMessage(import_constants.MESSAGE_TYPE.ok, null, sender);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function getStats(stats2) {
|
|
146
|
+
return stats2.toJson({
|
|
147
|
+
all: false,
|
|
148
|
+
hash: true,
|
|
149
|
+
assets: true,
|
|
150
|
+
warnings: true,
|
|
151
|
+
errors: true,
|
|
152
|
+
errorDetails: false
|
|
156
153
|
});
|
|
154
|
+
}
|
|
155
|
+
function sendMessage(type, data, sender) {
|
|
156
|
+
var _a;
|
|
157
|
+
(_a = sender || ws) == null ? void 0 : _a.send(JSON.stringify({ type, data }));
|
|
158
|
+
}
|
|
159
|
+
if (proxy) {
|
|
160
|
+
(0, import_bundler_utils.createProxy)(proxy, app);
|
|
161
|
+
}
|
|
162
|
+
(opts.afterMiddlewares || []).forEach((m) => {
|
|
163
|
+
app.use(m.toString().includes(`{ compiler }`) ? m({ compiler }) : m);
|
|
164
|
+
});
|
|
165
|
+
app.use(
|
|
166
|
+
require("@umijs/bundler-webpack/compiled/connect-history-api-fallback")({
|
|
167
|
+
index: "/"
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
app.use("/__umi_ping", (_, res) => {
|
|
171
|
+
res.end("pong");
|
|
172
|
+
});
|
|
173
|
+
app.get("/", (_req, res, next) => {
|
|
174
|
+
res.set("Content-Type", "text/html");
|
|
175
|
+
const htmlPath = (0, import_path.join)(opts.cwd, "index.html");
|
|
176
|
+
if ((0, import_fs.existsSync)(htmlPath)) {
|
|
177
|
+
(0, import_fs.createReadStream)(htmlPath).on("error", next).pipe(res);
|
|
178
|
+
} else {
|
|
179
|
+
next();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
let server;
|
|
183
|
+
if (userConfig.https) {
|
|
184
|
+
const httpsOpts = userConfig.https;
|
|
185
|
+
if (!httpsOpts.hosts) {
|
|
186
|
+
httpsOpts.hosts = import_utils.lodash.uniq(
|
|
187
|
+
[
|
|
188
|
+
...httpsOpts.hosts || [],
|
|
189
|
+
// always add localhost, 127.0.0.1, ip and host
|
|
190
|
+
"127.0.0.1",
|
|
191
|
+
"localhost",
|
|
192
|
+
opts.ip,
|
|
193
|
+
opts.host !== "0.0.0.0" && opts.host
|
|
194
|
+
].filter(Boolean)
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
server = await (0, import_bundler_utils.createHttpsServer)(app, httpsOpts);
|
|
198
|
+
} else {
|
|
199
|
+
server = import_http.default.createServer(app);
|
|
200
|
+
}
|
|
201
|
+
if (!server) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
ws = (0, import_ws.createWebSocketServer)(server);
|
|
205
|
+
ws.wss.on("connection", (socket) => {
|
|
206
|
+
if (stats) {
|
|
207
|
+
sendStats(getStats(stats), false, socket);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
const protocol = userConfig.https ? "https:" : "http:";
|
|
211
|
+
const port = opts.port || 8e3;
|
|
212
|
+
server.listen(port, () => {
|
|
213
|
+
const banner = (0, import_utils.getDevBanner)(protocol, opts.host, port);
|
|
214
|
+
console.log(banner.before);
|
|
215
|
+
import_utils.logger.ready(banner.main);
|
|
216
|
+
console.log(banner.after);
|
|
217
|
+
});
|
|
218
|
+
return server;
|
|
157
219
|
}
|
|
158
|
-
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
createServer
|
|
223
|
+
});
|
package/dist/server/ws.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import type { SpdyServer as Server } from '@umijs/bundler-utils';
|
|
5
|
+
import { Server as HttpServer } from 'http';
|
|
6
|
+
import { Http2Server } from 'http2';
|
|
7
|
+
import { Server as HttpsServer } from 'https';
|
|
3
8
|
import WebSocket from '../../compiled/ws';
|
|
4
|
-
export declare function createWebSocketServer(server: Server): {
|
|
9
|
+
export declare function createWebSocketServer(server: HttpServer | HttpsServer | Http2Server | Server): {
|
|
5
10
|
send(message: string): void;
|
|
6
|
-
wss: WebSocket.Server
|
|
11
|
+
wss: WebSocket.Server<WebSocket.WebSocket>;
|
|
7
12
|
close(): void;
|
|
8
13
|
};
|
package/dist/server/ws.js
CHANGED
|
@@ -1,42 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
10
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/server/ws.ts
|
|
30
|
+
var ws_exports = {};
|
|
31
|
+
__export(ws_exports, {
|
|
32
|
+
createWebSocketServer: () => createWebSocketServer
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ws_exports);
|
|
35
|
+
var import_utils = require("@umijs/utils");
|
|
36
|
+
var import_ws = __toESM(require("../../compiled/ws"));
|
|
9
37
|
function createWebSocketServer(server) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
const wss = new import_ws.default.Server({
|
|
39
|
+
noServer: true
|
|
40
|
+
});
|
|
41
|
+
server.on("upgrade", (req, socket, head) => {
|
|
42
|
+
if (req.headers["sec-websocket-protocol"] === "webpack-hmr") {
|
|
43
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
44
|
+
wss.emit("connection", ws, req);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
wss.on("connection", (socket) => {
|
|
49
|
+
socket.send(JSON.stringify({ type: "connected" }));
|
|
50
|
+
});
|
|
51
|
+
wss.on("error", (e) => {
|
|
52
|
+
if (e.code !== "EADDRINUSE") {
|
|
53
|
+
console.error(
|
|
54
|
+
import_utils.chalk.red(`WebSocket server error:
|
|
55
|
+
${e.stack || e.message}`)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
send(message) {
|
|
61
|
+
wss.clients.forEach((client) => {
|
|
62
|
+
if (client.readyState === import_ws.default.OPEN) {
|
|
63
|
+
client.send(message);
|
|
26
64
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
wss,
|
|
37
|
-
close() {
|
|
38
|
-
wss.close();
|
|
39
|
-
},
|
|
40
|
-
};
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
wss,
|
|
68
|
+
close() {
|
|
69
|
+
wss.close();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
41
72
|
}
|
|
42
|
-
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
createWebSocketServer
|
|
76
|
+
});
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { ImportDeclaration,
|
|
1
|
+
import type { ImportDeclaration, ModuleItem, TsType } from '@swc/core';
|
|
2
2
|
import Visitor from '@swc/core/Visitor';
|
|
3
3
|
declare class AutoCSSModule extends Visitor {
|
|
4
4
|
visitTsType(expression: TsType): TsType;
|
|
5
|
+
/**
|
|
6
|
+
* call path:
|
|
7
|
+
* visitProgram -> visitModule -> visitModuleItems -> visitModuleItem -> visitImportDeclaration
|
|
8
|
+
* @see https://github.com/swc-project/swc/blob/main/node-swc/src/Visitor.ts#L189
|
|
9
|
+
*/
|
|
10
|
+
visitModuleItem(n: ModuleItem): ImportDeclaration | import("@swc/core").ExportDeclaration | import("@swc/core").ExportNamedDeclaration | import("@swc/core").ExportDefaultDeclaration | import("@swc/core").ExportDefaultExpression | import("@swc/core").ExportAllDeclaration | import("@swc/core").TsImportEqualsDeclaration | import("@swc/core").TsExportAssignment | import("@swc/core").TsNamespaceExportDeclaration | import("@swc/core").BlockStatement | import("@swc/core").EmptyStatement | import("@swc/core").DebuggerStatement | import("@swc/core").WithStatement | import("@swc/core").ReturnStatement | import("@swc/core").LabeledStatement | import("@swc/core").BreakStatement | import("@swc/core").ContinueStatement | import("@swc/core").IfStatement | import("@swc/core").SwitchStatement | import("@swc/core").ThrowStatement | import("@swc/core").TryStatement | import("@swc/core").WhileStatement | import("@swc/core").DoWhileStatement | import("@swc/core").ForStatement | import("@swc/core").ForInStatement | import("@swc/core").ForOfStatement | import("@swc/core").ClassDeclaration | import("@swc/core").FunctionDeclaration | import("@swc/core").VariableDeclaration | import("@swc/core").TsInterfaceDeclaration | import("@swc/core").TsTypeAliasDeclaration | import("@swc/core").TsEnumDeclaration | import("@swc/core").TsModuleDeclaration | import("@swc/core").ExpressionStatement;
|
|
5
11
|
visitImportDeclaration(expression: ImportDeclaration): ImportDeclaration;
|
|
6
|
-
visitVariableDeclaration(expression: VariableDeclaration): VariableDeclaration;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Swc will not support js plugin in the future.
|
|
15
|
+
* See https://github.com/swc-project/website/commit/fde42ad5371c1a16ca9729fe17bcfd3489841ac1
|
|
16
|
+
*/
|
|
8
17
|
export default AutoCSSModule;
|
|
@@ -1,35 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
10
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/swcPlugins/autoCSSModules.ts
|
|
30
|
+
var autoCSSModules_exports = {};
|
|
31
|
+
__export(autoCSSModules_exports, {
|
|
32
|
+
default: () => autoCSSModules_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(autoCSSModules_exports);
|
|
35
|
+
var import_Visitor = __toESM(require("@swc/core/Visitor"));
|
|
36
|
+
var import_utils = require("@umijs/utils");
|
|
37
|
+
var import_changeImportFromString = require("./changeImportFromString");
|
|
38
|
+
var AutoCSSModule = class extends import_Visitor.default {
|
|
39
|
+
visitTsType(expression) {
|
|
40
|
+
return expression;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* call path:
|
|
44
|
+
* visitProgram -> visitModule -> visitModuleItems -> visitModuleItem -> visitImportDeclaration
|
|
45
|
+
* @see https://github.com/swc-project/swc/blob/main/node-swc/src/Visitor.ts#L189
|
|
46
|
+
*/
|
|
47
|
+
visitModuleItem(n) {
|
|
48
|
+
if (n.type === "ImportDeclaration") {
|
|
49
|
+
return this.visitImportDeclaration(n);
|
|
20
50
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
CSS_EXT_NAMES.includes((0, path_1.extname)(declarations[0].init.argument.arguments[0].expression.value))) {
|
|
30
|
-
declarations[0].init.argument.arguments[0].expression.value = `${declarations[0].init.argument.arguments[0].expression.value}?modules`;
|
|
31
|
-
}
|
|
32
|
-
return expression;
|
|
51
|
+
return n;
|
|
52
|
+
}
|
|
53
|
+
visitImportDeclaration(expression) {
|
|
54
|
+
const { specifiers, source } = expression;
|
|
55
|
+
const { value } = source;
|
|
56
|
+
if (specifiers.length && (0, import_utils.isStyleFile)({ filename: value })) {
|
|
57
|
+
const newImportFrom = `${value}?modules`;
|
|
58
|
+
(0, import_changeImportFromString.changeImportFromString)(expression, newImportFrom);
|
|
33
59
|
}
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
return expression;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var autoCSSModules_default = AutoCSSModule;
|