@shuvi/service 2.0.0-dev.12 → 2.0.0-dev.14

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 = [];
@@ -208,10 +204,16 @@ class RspackBundler {
208
204
  errors.push(...(statsData.errors || []));
209
205
  });
210
206
  if (warnings.length > 0) {
211
- console.warn('warnings', warnings);
207
+ warnings.forEach(warning => {
208
+ console.warn('warning message', warning.message);
209
+ console.warn('warning file', warning.file);
210
+ });
212
211
  }
213
212
  if (errors.length > 0) {
214
- console.log('errors', errors);
213
+ errors.forEach(error => {
214
+ console.error('error message', error.message);
215
+ console.error('error file', error.file);
216
+ });
215
217
  process.exit(1);
216
218
  }
217
219
  const isSuccessful = !warnings.length && !errors.length;
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.12",
3
+ "version": "2.0.0-dev.14",
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.12",
33
- "@shuvi/router": "2.0.0-dev.12",
34
- "@shuvi/runtime": "2.0.0-dev.12",
35
- "@shuvi/shared": "2.0.0-dev.12",
36
- "@shuvi/toolpack": "2.0.0-dev.12",
37
- "@shuvi/utils": "2.0.0-dev.12",
38
- "@shuvi/error-overlay": "2.0.0-dev.12",
39
- "@shuvi/reporters": "2.0.0-dev.12",
32
+ "@shuvi/hook": "2.0.0-dev.14",
33
+ "@shuvi/router": "2.0.0-dev.14",
34
+ "@shuvi/runtime": "2.0.0-dev.14",
35
+ "@shuvi/shared": "2.0.0-dev.14",
36
+ "@shuvi/toolpack": "2.0.0-dev.14",
37
+ "@shuvi/utils": "2.0.0-dev.14",
38
+ "@shuvi/error-overlay": "2.0.0-dev.14",
39
+ "@shuvi/reporters": "2.0.0-dev.14",
40
40
  "commander": "5.1.0",
41
41
  "comment-json": "4.2.2",
42
42
  "cross-spawn": "7.0.3",