@shuvi/service 2.0.0-dev.11 → 2.0.0-dev.13

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.
@@ -41,6 +41,7 @@ const tsCheckerRspackPlugin_1 = __importStar(require("@shuvi/toolpack/lib/utils/
41
41
  const formatWebpackMessages_1 = __importDefault(require("@shuvi/toolpack/lib/utils/formatWebpackMessages"));
42
42
  const logger_1 = __importDefault(require("@shuvi/utils/logger"));
43
43
  const util_1 = require("util");
44
+ const path = __importStar(require("path"));
44
45
  const webpack_1 = require("@shuvi/toolpack/lib/webpack");
45
46
  const config_1 = require("@shuvi/toolpack/lib/webpack/config");
46
47
  const constants_1 = require("@shuvi/shared/constants");
@@ -74,23 +75,19 @@ class RspackBundler {
74
75
  if (this._inited) {
75
76
  return;
76
77
  }
77
- /**
78
- * @unsupported DynamicDll is not supported in Rspack.
79
- * TODO: Implement DLL support if/when Rspack supports it.
80
- */
81
- // let dynamicDll: DynamicDll | undefined;
82
- // if (this._options.preBundle) {
83
- // dynamicDll = new DynamicDll({
84
- // cacheDir: path.join(this._cliContext.paths.cacheDir, 'dll'),
85
- // rootDir: this._cliContext.paths.rootDir,
86
- // exclude: [/react-refresh/],
87
- // resolveWebpackModule(module) {
88
- // return resolveRspackModule(module);
89
- // }
90
- // });
91
- // this._devMiddlewares.push(dynamicDll.middleware);
92
- // }
93
- this._compiler = yield this._getRspackCompiler( /*dynamicDll*/);
78
+ let dynamicDll;
79
+ if (this._options.preBundle) {
80
+ dynamicDll = new webpack_1.RspackDynamicDll({
81
+ cacheDir: path.join(this._cliContext.paths.cacheDir, 'dll'),
82
+ rootDir: this._cliContext.paths.rootDir,
83
+ exclude: [/react-refresh/],
84
+ resolveRspackModule(module) {
85
+ return (0, webpack_1.resolveRspackModule)(module);
86
+ }
87
+ });
88
+ this._devMiddlewares.push(dynamicDll.middleware);
89
+ }
90
+ this._compiler = yield this._getRspackCompiler(dynamicDll);
94
91
  this._inited = true;
95
92
  });
96
93
  }
@@ -167,22 +164,21 @@ class RspackBundler {
167
164
  get targets() {
168
165
  return this._targets;
169
166
  }
170
- _getRspackCompiler( /*dynamicDll?: DynamicDll | null*/) {
167
+ _getRspackCompiler(dynamicDll) {
171
168
  return __awaiter(this, void 0, void 0, function* () {
172
169
  if (!this._compiler) {
173
170
  this._targets = yield this._getTargets();
174
- // if (dynamicDll) {
175
- // this._compiler = rspack(
176
- // this._targets.map(({ config }) => {
177
- // if (config.target === 'node') {
178
- // return config;
179
- // }
180
- // return dynamicDll.modifyWebpack(config);
181
- // })
182
- // );
183
- // } else {
184
- this._compiler = (0, webpack_1.rspack)(this._targets.map(t => t.config));
185
- // }
171
+ if (dynamicDll) {
172
+ this._compiler = (0, webpack_1.rspack)(this._targets.map(({ config }) => {
173
+ if (config.target === 'node') {
174
+ return config;
175
+ }
176
+ return dynamicDll.modifyRspack(config);
177
+ }));
178
+ }
179
+ else {
180
+ this._compiler = (0, webpack_1.rspack)(this._targets.map(t => t.config));
181
+ }
186
182
  let isFirstSuccessfulCompile = true;
187
183
  this._compiler.hooks.done.tap('done', (stats) => __awaiter(this, void 0, void 0, function* () {
188
184
  const warnings = [];
@@ -207,6 +203,13 @@ class RspackBundler {
207
203
  warnings.push(...(statsData.warnings || []));
208
204
  errors.push(...(statsData.errors || []));
209
205
  });
206
+ if (warnings.length > 0) {
207
+ console.warn('warnings', warnings);
208
+ }
209
+ if (errors.length > 0) {
210
+ console.log('errors', errors);
211
+ process.exit(1);
212
+ }
210
213
  const isSuccessful = !warnings.length && !errors.length;
211
214
  if (isSuccessful) {
212
215
  if (!isFirstSuccessfulCompile) {
package/lib/core/api.js CHANGED
@@ -52,11 +52,7 @@ const plugin_1 = require("./plugin");
52
52
  const config_1 = require("./config");
53
53
  const paths_1 = require("./paths");
54
54
  const getPlugins_1 = require("./getPlugins");
55
- /**
56
- * @unsupported Rspack does not support WebpackWatchWaitForFileBuilderPlugin directly.
57
- * TODO: Implement equivalent Rspack plugin or use Rspack's built-in watching capabilities.
58
- */
59
- // import WebpackWatchWaitForFileBuilderPlugin from '../lib/webpack-watch-wait-for-file-builder-plugin';
55
+ const webpack_watch_wait_for_file_builder_plugin_1 = __importDefault(require("../lib/webpack-watch-wait-for-file-builder-plugin"));
60
56
  const config_2 = require("../config");
61
57
  const ServiceModes = ['development', 'production'];
62
58
  class Api {
@@ -143,28 +139,24 @@ class Api {
143
139
  return config;
144
140
  }
145
141
  });
146
- /**
147
- * @unsupported Rspack does not support WebpackWatchWaitForFileBuilderPlugin directly.
148
- * TODO: Implement equivalent Rspack plugin or use Rspack's built-in watching capabilities.
149
- */
150
- // const rspackWaitPlugin = createPlugin({
151
- // configRspack: config => {
152
- // if (this.mode === 'development') {
153
- // config
154
- // .plugin('rspack-watch-wait-for-file-builder-plugin')
155
- // .use(RspackWatchWaitForFileBuilderPlugin, [
156
- // {
157
- // onBuildStart: this._projectBuilder.onBuildStart,
158
- // onBuildEnd: this._projectBuilder.onBuildEnd,
159
- // onInvalid: this._projectBuilder.onInvalid,
160
- // isDependency: this._projectBuilder.isDependency
161
- // }
162
- // ]);
163
- // }
164
- // return config;
165
- // }
166
- // });
167
- usePlugin(addIncludeToSwcLoader /*, rspackWaitPlugin*/);
142
+ const webpackWaitPlugin = createPlugin({
143
+ configWebpack: config => {
144
+ if (this.mode === 'development') {
145
+ config
146
+ .plugin('webpack-watch-wait-for-file-builder-plugin')
147
+ .use(webpack_watch_wait_for_file_builder_plugin_1.default, [
148
+ {
149
+ onBuildStart: this._projectBuilder.onBuildStart,
150
+ onBuildEnd: this._projectBuilder.onBuildEnd,
151
+ onInvalid: this._projectBuilder.onInvalid,
152
+ isDependency: this._projectBuilder.isDependency
153
+ }
154
+ ]);
155
+ }
156
+ return config;
157
+ }
158
+ });
159
+ usePlugin(addIncludeToSwcLoader, webpackWaitPlugin);
168
160
  // 2. init user plugins
169
161
  const userPlugins = (0, getPlugins_1.getPlugins)(this._cwd, {
170
162
  presets: this._presets,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/service",
3
- "version": "2.0.0-dev.11",
3
+ "version": "2.0.0-dev.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -29,14 +29,14 @@
29
29
  "@babel/generator": "7.14.5",
30
30
  "@babel/parser": "7.14.7",
31
31
  "@babel/traverse": "7.14.7",
32
- "@shuvi/hook": "2.0.0-dev.11",
33
- "@shuvi/router": "2.0.0-dev.11",
34
- "@shuvi/runtime": "2.0.0-dev.11",
35
- "@shuvi/shared": "2.0.0-dev.11",
36
- "@shuvi/toolpack": "2.0.0-dev.11",
37
- "@shuvi/utils": "2.0.0-dev.11",
38
- "@shuvi/error-overlay": "2.0.0-dev.11",
39
- "@shuvi/reporters": "2.0.0-dev.11",
32
+ "@shuvi/hook": "2.0.0-dev.13",
33
+ "@shuvi/router": "2.0.0-dev.13",
34
+ "@shuvi/runtime": "2.0.0-dev.13",
35
+ "@shuvi/shared": "2.0.0-dev.13",
36
+ "@shuvi/toolpack": "2.0.0-dev.13",
37
+ "@shuvi/utils": "2.0.0-dev.13",
38
+ "@shuvi/error-overlay": "2.0.0-dev.13",
39
+ "@shuvi/reporters": "2.0.0-dev.13",
40
40
  "commander": "5.1.0",
41
41
  "comment-json": "4.2.2",
42
42
  "cross-spawn": "7.0.3",