@shuvi/service 1.0.62 → 2.0.0-dev.6
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/lib/bundler/bundler.d.ts +2 -2
- package/lib/bundler/bundler.js +65 -43
- package/lib/bundler/config.d.ts +2 -2
- package/lib/bundler/config.js +2 -2
- package/lib/bundler/runCompiler.d.ts +3 -3
- package/lib/core/api.js +27 -19
- package/lib/core/plugin.d.ts +2 -2
- package/lib/core/pluginTypes.d.ts +15 -10
- package/lib/server/shuviDevServer.js +30 -15
- package/package.json +9 -9
package/lib/bundler/bundler.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RemoveListenerCallback } from '@shuvi/utils/events';
|
|
2
|
-
import { Compiler as
|
|
2
|
+
import { Compiler as RspackCompiler } from '@shuvi/toolpack/lib/webpack';
|
|
3
3
|
import { Server } from '../server';
|
|
4
4
|
import { IPluginContext } from '../core';
|
|
5
5
|
import { Target } from '../core/plugin';
|
|
@@ -24,7 +24,7 @@ export interface Bundler {
|
|
|
24
24
|
onBuildDone(cb: FinishedCallback): RemoveListenerCallback;
|
|
25
25
|
onTypeCheckingDone(cb: FinishedCallback): RemoveListenerCallback;
|
|
26
26
|
applyDevMiddlewares(server: Server): void;
|
|
27
|
-
getSubCompiler(name: string):
|
|
27
|
+
getSubCompiler(name: string): RspackCompiler | undefined;
|
|
28
28
|
resolveTargetConfig(): Promise<Target[]>;
|
|
29
29
|
}
|
|
30
30
|
export interface CompilerStats {
|
package/lib/bundler/bundler.js
CHANGED
|
@@ -36,9 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.getBundler = getBundler;
|
|
39
|
-
const path_1 = __importDefault(require("path"));
|
|
40
39
|
const events_1 = require("@shuvi/utils/events");
|
|
41
|
-
const
|
|
40
|
+
const tsCheckerRspackPlugin_1 = __importStar(require("@shuvi/toolpack/lib/utils/tsCheckerRspackPlugin"));
|
|
42
41
|
const formatWebpackMessages_1 = __importDefault(require("@shuvi/toolpack/lib/utils/formatWebpackMessages"));
|
|
43
42
|
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
44
43
|
const util_1 = require("util");
|
|
@@ -56,7 +55,7 @@ const defaultBundleOptions = {
|
|
|
56
55
|
ignoreTypeScriptErrors: false
|
|
57
56
|
};
|
|
58
57
|
const hasEntry = (chain) => chain.entryPoints.values().length > 0;
|
|
59
|
-
class
|
|
58
|
+
class RspackBundler {
|
|
60
59
|
constructor(options, cliContext) {
|
|
61
60
|
this._targets = [];
|
|
62
61
|
this._buildEvent = (0, events_1.createEvent)();
|
|
@@ -75,19 +74,23 @@ class WebpackBundler {
|
|
|
75
74
|
if (this._inited) {
|
|
76
75
|
return;
|
|
77
76
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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*/);
|
|
91
94
|
this._inited = true;
|
|
92
95
|
});
|
|
93
96
|
}
|
|
@@ -114,6 +117,7 @@ class WebpackBundler {
|
|
|
114
117
|
return this._watching;
|
|
115
118
|
}
|
|
116
119
|
this._targets.forEach(({ name }) => {
|
|
120
|
+
console.debug(`[rspack][watch] setupListenersForTarget ${name}`);
|
|
117
121
|
if (name === constants_1.BUNDLER_TARGET_CLIENT) {
|
|
118
122
|
this._setupListenersForTarget(name, {
|
|
119
123
|
typeChecking: true
|
|
@@ -125,10 +129,21 @@ class WebpackBundler {
|
|
|
125
129
|
});
|
|
126
130
|
}
|
|
127
131
|
});
|
|
128
|
-
|
|
132
|
+
/**
|
|
133
|
+
* TODO
|
|
134
|
+
*/
|
|
135
|
+
// const webpackWatching = this._compiler.watch(
|
|
136
|
+
// this._compiler.compilers.map(
|
|
137
|
+
// childCompiler => childCompiler.options.watchOptions || {}
|
|
138
|
+
// ),
|
|
139
|
+
// () => {
|
|
140
|
+
// // do nothing
|
|
141
|
+
// }
|
|
142
|
+
// );
|
|
143
|
+
const rspackWatching = this._compiler.watch(this._compiler.compilers[0].options.watchOptions || {}, () => {
|
|
129
144
|
// do nothing
|
|
130
145
|
});
|
|
131
|
-
this._watching.set(
|
|
146
|
+
this._watching.set(rspackWatching);
|
|
132
147
|
return this._watching;
|
|
133
148
|
}
|
|
134
149
|
build() {
|
|
@@ -137,7 +152,7 @@ class WebpackBundler {
|
|
|
137
152
|
if (this._options.ignoreTypeScriptErrors) {
|
|
138
153
|
logger_1.default.info('Skipping validation of types');
|
|
139
154
|
this._compiler.compilers.forEach(compiler => {
|
|
140
|
-
|
|
155
|
+
tsCheckerRspackPlugin_1.default.getCompilerHooks(compiler).issues.tap('afterTypeScriptCheck', (issues) => issues.filter(msg => msg.severity !== 'error'));
|
|
141
156
|
});
|
|
142
157
|
}
|
|
143
158
|
return (0, runCompiler_1.runCompiler)(compiler);
|
|
@@ -151,21 +166,22 @@ class WebpackBundler {
|
|
|
151
166
|
get targets() {
|
|
152
167
|
return this._targets;
|
|
153
168
|
}
|
|
154
|
-
|
|
169
|
+
_getRspackCompiler( /*dynamicDll?: DynamicDll | null*/) {
|
|
155
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
171
|
if (!this._compiler) {
|
|
157
172
|
this._targets = yield this._getTargets();
|
|
158
|
-
if (dynamicDll) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
// if (dynamicDll) {
|
|
174
|
+
// this._compiler = rspack(
|
|
175
|
+
// this._targets.map(({ config }) => {
|
|
176
|
+
// if (config.target === 'node') {
|
|
177
|
+
// return config;
|
|
178
|
+
// }
|
|
179
|
+
// return dynamicDll.modifyWebpack(config);
|
|
180
|
+
// })
|
|
181
|
+
// );
|
|
182
|
+
// } else {
|
|
183
|
+
this._compiler = (0, webpack_1.rspack)(this._targets.map(t => t.config));
|
|
184
|
+
// }
|
|
169
185
|
let isFirstSuccessfulCompile = true;
|
|
170
186
|
this._compiler.hooks.done.tap('done', (stats) => __awaiter(this, void 0, void 0, function* () {
|
|
171
187
|
const warnings = [];
|
|
@@ -173,6 +189,7 @@ class WebpackBundler {
|
|
|
173
189
|
this._isCompiling = false;
|
|
174
190
|
let timeMessage = '';
|
|
175
191
|
if (this._startTime) {
|
|
192
|
+
// @ts-ignore exists ts error
|
|
176
193
|
const time = performance.now() - this._startTime;
|
|
177
194
|
this._startTime = 0;
|
|
178
195
|
timeMessage =
|
|
@@ -235,15 +252,15 @@ class WebpackBundler {
|
|
|
235
252
|
tsMessagesPromise = undefined;
|
|
236
253
|
isInvalid = true;
|
|
237
254
|
});
|
|
238
|
-
const useTypeScript = !!((_a = compiler.options.plugins) === null || _a === void 0 ? void 0 : _a.find(plugin => plugin instanceof
|
|
255
|
+
const useTypeScript = !!((_a = compiler.options.plugins) === null || _a === void 0 ? void 0 : _a.find(plugin => plugin instanceof tsCheckerRspackPlugin_1.default));
|
|
239
256
|
if (options.typeChecking && useTypeScript) {
|
|
240
|
-
const typescriptFormatter = (0,
|
|
257
|
+
const typescriptFormatter = (0, tsCheckerRspackPlugin_1.createCodeFrameFormatter)({});
|
|
241
258
|
compiler.hooks.beforeCompile.tap('beforeCompile', () => {
|
|
242
259
|
tsMessagesPromise = new Promise(resolve => {
|
|
243
260
|
tsMessagesResolver = msgs => resolve(msgs);
|
|
244
261
|
});
|
|
245
262
|
});
|
|
246
|
-
|
|
263
|
+
tsCheckerRspackPlugin_1.default.getCompilerHooks(compiler).issues.tap('afterTypeScriptCheck', (issues) => {
|
|
247
264
|
const format = (message) => {
|
|
248
265
|
const file = (message.file || '').replace(/\\/g, '/');
|
|
249
266
|
const formatted = typescriptFormatter(message);
|
|
@@ -263,10 +280,11 @@ class WebpackBundler {
|
|
|
263
280
|
}
|
|
264
281
|
compiler.hooks.invalid.tap('invalid', () => {
|
|
265
282
|
if (this._startTime === null) {
|
|
283
|
+
// @ts-ignore exists ts error
|
|
266
284
|
this._startTime = performance.now();
|
|
267
285
|
}
|
|
268
286
|
});
|
|
269
|
-
// "done" event fires when
|
|
287
|
+
// "done" event fires when Rspack has finished recompiling the bundle.
|
|
270
288
|
// Whether or not you have warnings or errors, you will get this event.
|
|
271
289
|
compiler.hooks.done.tap('done', (stats) => __awaiter(this, void 0, void 0, function* () {
|
|
272
290
|
var _a, _b;
|
|
@@ -276,7 +294,7 @@ class WebpackBundler {
|
|
|
276
294
|
return;
|
|
277
295
|
}
|
|
278
296
|
isInvalid = false;
|
|
279
|
-
// We have switched off the default
|
|
297
|
+
// We have switched off the default Rspack output in DevServer
|
|
280
298
|
// options so we are going to "massage" the warnings and errors and present
|
|
281
299
|
// them in a readable focused way.
|
|
282
300
|
// We only construct the warnings and errors for speed:
|
|
@@ -359,23 +377,27 @@ class WebpackBundler {
|
|
|
359
377
|
const extraTargets = (yield this._cliContext.pluginRunner.addExtraTarget({
|
|
360
378
|
createConfig: this._createConfig.bind(this),
|
|
361
379
|
mode: this._cliContext.mode,
|
|
362
|
-
webpack: webpack_1.
|
|
380
|
+
webpack: webpack_1.rspack
|
|
363
381
|
})).filter(Boolean);
|
|
364
382
|
buildTargets.push(...extraTargets);
|
|
365
|
-
const
|
|
383
|
+
const defaultRspackHelpers = { addExternals: config_1.addExternals };
|
|
366
384
|
for (const buildTarget of buildTargets) {
|
|
367
385
|
let { chain, name } = buildTarget;
|
|
368
386
|
// modify config by api hooks
|
|
369
387
|
chain = yield this._cliContext.pluginRunner.configWebpack(chain, {
|
|
370
388
|
name,
|
|
371
389
|
mode: this._cliContext.mode,
|
|
372
|
-
helpers:
|
|
373
|
-
|
|
390
|
+
helpers: defaultRspackHelpers,
|
|
391
|
+
/**
|
|
392
|
+
* @deprecated use rspack instead
|
|
393
|
+
*/
|
|
394
|
+
webpack: webpack_1.rspack,
|
|
395
|
+
rspack: webpack_1.rspack,
|
|
374
396
|
resolveWebpackModule(path) {
|
|
375
|
-
return (0, webpack_1.
|
|
397
|
+
return (0, webpack_1.resolveRspackModule)(path);
|
|
376
398
|
}
|
|
377
399
|
});
|
|
378
|
-
(0, config_1.
|
|
400
|
+
(0, config_1.checkRspackExternals)(chain);
|
|
379
401
|
if (hasEntry(chain)) {
|
|
380
402
|
const chainConfig = chain.toConfig();
|
|
381
403
|
logger_1.default.debug(`${name} Config`);
|
|
@@ -397,7 +419,7 @@ function getBundler(ctx) {
|
|
|
397
419
|
if (ctx.mode !== 'development') {
|
|
398
420
|
options.preBundle = false;
|
|
399
421
|
}
|
|
400
|
-
const bundler = new
|
|
422
|
+
const bundler = new RspackBundler(options, ctx);
|
|
401
423
|
yield bundler.init();
|
|
402
424
|
return bundler;
|
|
403
425
|
}
|
package/lib/bundler/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RspackChain } from '@shuvi/toolpack/lib/webpack/config';
|
|
2
2
|
import { IPluginContext } from '../core';
|
|
3
3
|
export interface IWebpackEntry {
|
|
4
4
|
[x: string]: string | string[];
|
|
@@ -10,4 +10,4 @@ export interface IWebpackConfigOptions {
|
|
|
10
10
|
include?: string[];
|
|
11
11
|
outputDir?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function createWebpackConfig({ mode, assetPublicPath, paths, config }: IPluginContext, { ...opts }: IWebpackConfigOptions):
|
|
13
|
+
export declare function createWebpackConfig({ mode, assetPublicPath, paths, config }: IPluginContext, { ...opts }: IWebpackConfigOptions): RspackChain;
|
package/lib/bundler/config.js
CHANGED
|
@@ -38,7 +38,7 @@ function createWebpackConfig({ mode, assetPublicPath, paths, config }, _a) {
|
|
|
38
38
|
const jsConfig = (0, typescript_1.getJavaScriptInfo)();
|
|
39
39
|
const compiler = Object.assign(Object.assign({}, config.compiler), { modularizeImports: experimental.modularizeImports, swcPlugins: experimental.swcPlugins, experimentalDecorators: Boolean((_b = jsConfig === null || jsConfig === void 0 ? void 0 : jsConfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.experimentalDecorators), emitDecoratorMetadata: Boolean((_c = jsConfig === null || jsConfig === void 0 ? void 0 : jsConfig.compilerOptions) === null || _c === void 0 ? void 0 : _c.emitDecoratorMetadata) });
|
|
40
40
|
if (opts.node) {
|
|
41
|
-
chain = (0, config_1.
|
|
41
|
+
chain = (0, config_1.createNodeRspackChain)({
|
|
42
42
|
name,
|
|
43
43
|
dev,
|
|
44
44
|
projectRoot,
|
|
@@ -54,7 +54,7 @@ function createWebpackConfig({ mode, assetPublicPath, paths, config }, _a) {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
chain = (0, config_1.
|
|
57
|
+
chain = (0, config_1.createBrowserRspackChain)({
|
|
58
58
|
name,
|
|
59
59
|
dev,
|
|
60
60
|
projectRoot,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Compiler, MultiCompiler } from '@shuvi/toolpack/lib/webpack';
|
|
2
|
-
import
|
|
2
|
+
import * as Rspack from '@shuvi/toolpack/lib/webpack';
|
|
3
3
|
export type BundlerResult = {
|
|
4
|
-
errors:
|
|
5
|
-
warnings:
|
|
4
|
+
errors: Rspack.StatsError[];
|
|
5
|
+
warnings: Rspack.StatsError[];
|
|
6
6
|
};
|
|
7
7
|
export declare function runCompiler(compiler: Compiler | MultiCompiler): Promise<BundlerResult>;
|
package/lib/core/api.js
CHANGED
|
@@ -52,7 +52,11 @@ 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
|
-
|
|
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';
|
|
56
60
|
const config_2 = require("../config");
|
|
57
61
|
const ServiceModes = ['development', 'production'];
|
|
58
62
|
class Api {
|
|
@@ -139,24 +143,28 @@ class Api {
|
|
|
139
143
|
return config;
|
|
140
144
|
}
|
|
141
145
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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*/);
|
|
160
168
|
// 2. init user plugins
|
|
161
169
|
const userPlugins = (0, getPlugins_1.getPlugins)(this._cwd, {
|
|
162
170
|
presets: this._presets,
|
package/lib/core/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IPluginInstance, IPluginHandlers } from '@shuvi/hook';
|
|
2
2
|
import { FileOptionWithId } from '../project/index';
|
|
3
|
-
import { ExtraTargetAssistant, ConfigWebpackAssistant, TargetChain, BundlerDoneExtra, BundlerTargetDoneExtra, RuntimeService, Resources, AddRuntimeFileUtils,
|
|
3
|
+
import { ExtraTargetAssistant, ConfigWebpackAssistant, TargetChain, BundlerDoneExtra, BundlerTargetDoneExtra, RuntimeService, Resources, AddRuntimeFileUtils, RspackChainType } from './pluginTypes';
|
|
4
4
|
import { ShuviConfig, IPluginContext, CustomCorePluginHooks } from './apiTypes';
|
|
5
5
|
declare const builtinPluginHooks: {
|
|
6
6
|
extendConfig: import("@shuvi/hook").SyncWaterfallHook<ShuviConfig, void>;
|
|
@@ -9,7 +9,7 @@ declare const builtinPluginHooks: {
|
|
|
9
9
|
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
10
10
|
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<BundlerDoneExtra, void, void>;
|
|
11
11
|
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<BundlerTargetDoneExtra, void, void>;
|
|
12
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<
|
|
12
|
+
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<RspackChainType, ConfigWebpackAssistant>;
|
|
13
13
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<ExtraTargetAssistant, void, TargetChain>;
|
|
14
14
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, Resources | Resources[]>;
|
|
15
15
|
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, AddRuntimeFileUtils, FileOptionWithId<any, any> | FileOptionWithId<any, any>[]>;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { RequestListener } from 'http';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import { RspackChain } from '@shuvi/toolpack/lib/webpack';
|
|
3
|
+
import * as Rspack from '@shuvi/toolpack/lib/webpack';
|
|
4
|
+
import { rspack, Configuration } from '@shuvi/toolpack/lib/webpack';
|
|
5
|
+
import { IWebpackHelpers } from '@shuvi/toolpack/lib/webpack/types.rspack';
|
|
5
6
|
import { defineFile, FileBuilder } from '../project/index';
|
|
6
7
|
import { IWebpackConfigOptions } from '../bundler/config';
|
|
7
8
|
import { IServiceMode } from './apiTypes';
|
|
8
9
|
export type ExtraTargetAssistant = {
|
|
9
|
-
createConfig(options: IWebpackConfigOptions):
|
|
10
|
+
createConfig(options: IWebpackConfigOptions): RspackChain;
|
|
10
11
|
mode: IServiceMode;
|
|
11
|
-
webpack: typeof
|
|
12
|
+
webpack: typeof rspack;
|
|
12
13
|
};
|
|
13
14
|
export type ConfigWebpackAssistant = {
|
|
14
15
|
name: string;
|
|
15
16
|
mode: IServiceMode;
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated use rspack instead
|
|
19
|
+
*/
|
|
20
|
+
webpack: typeof rspack;
|
|
21
|
+
rspack: typeof rspack;
|
|
17
22
|
/**
|
|
18
23
|
* require webpack interal module
|
|
19
24
|
* eg. resolveWebpackModule('webpack/lib/dependencies/ConstDependency')
|
|
@@ -23,7 +28,7 @@ export type ConfigWebpackAssistant = {
|
|
|
23
28
|
};
|
|
24
29
|
export interface TargetChain {
|
|
25
30
|
name: string;
|
|
26
|
-
chain:
|
|
31
|
+
chain: RspackChain;
|
|
27
32
|
}
|
|
28
33
|
export interface Target {
|
|
29
34
|
name: string;
|
|
@@ -31,12 +36,12 @@ export interface Target {
|
|
|
31
36
|
}
|
|
32
37
|
export type BundlerDoneExtra = {
|
|
33
38
|
first: boolean;
|
|
34
|
-
stats:
|
|
39
|
+
stats: Rspack.MultiStats;
|
|
35
40
|
};
|
|
36
41
|
export type BundlerTargetDoneExtra = {
|
|
37
42
|
first: boolean;
|
|
38
43
|
name: string;
|
|
39
|
-
stats:
|
|
44
|
+
stats: Rspack.Stats;
|
|
40
45
|
};
|
|
41
46
|
export type RuntimeService = {
|
|
42
47
|
source: string;
|
|
@@ -48,7 +53,7 @@ export type AddRuntimeFileUtils = {
|
|
|
48
53
|
defineFile: typeof defineFile;
|
|
49
54
|
getContent: FileBuilder<any>['getContent'];
|
|
50
55
|
};
|
|
51
|
-
export interface
|
|
56
|
+
export interface RspackChainType extends RspackChain {
|
|
52
57
|
}
|
|
53
58
|
export type AfterBuildOptions = {
|
|
54
59
|
requestHandler: RequestListener;
|
|
@@ -171,24 +171,39 @@ class ShuviDevServer extends shuviServer_1.ShuviServer {
|
|
|
171
171
|
(0, env_1.loadDotenvConfig)({ rootDir, forceReloadEnv: true });
|
|
172
172
|
}
|
|
173
173
|
configs.forEach(({ config }) => {
|
|
174
|
-
var _a
|
|
174
|
+
var _a;
|
|
175
175
|
if (tsconfigChange) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
176
|
+
/**
|
|
177
|
+
* @unsupported Rspack does not support resolve.plugins array like webpack.
|
|
178
|
+
* TODO: Handle this after Rspack support is available.
|
|
179
|
+
* For now, we'll use Rspack's built-in tsConfig support instead.
|
|
180
|
+
*/
|
|
181
|
+
// config.resolve?.plugins?.forEach((plugin: any) => {
|
|
182
|
+
// // look for the JsConfigPathsPlugin and update with the latest paths/baseUrl config
|
|
183
|
+
// if (plugin && plugin.jsConfigPlugin && parseJsConfig) {
|
|
184
|
+
// const { resolvedBaseUrl, compilerOptions } = parseJsConfig;
|
|
185
|
+
// if (compilerOptions.paths && resolvedBaseUrl) {
|
|
186
|
+
// Object.keys(plugin.paths).forEach(key => {
|
|
187
|
+
// delete plugin.paths[key];
|
|
188
|
+
// });
|
|
189
|
+
// plugin.paths = { ...compilerOptions.paths };
|
|
190
|
+
// plugin.resolvedBaseUrl = resolvedBaseUrl;
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
193
|
+
// });
|
|
194
|
+
// Use Rspack's built-in tsConfig support
|
|
195
|
+
if (parseJsConfig && config.resolve) {
|
|
196
|
+
/**
|
|
197
|
+
* @TODO
|
|
198
|
+
* @unsupported Rspack's tsConfig type is not fully compatible with ParsedJsConfig.
|
|
199
|
+
* TODO: Update when Rspack provides proper TypeScript configuration support.
|
|
200
|
+
*/
|
|
201
|
+
// @ts-expect-error wrong!!
|
|
202
|
+
config.resolve.tsConfig = parseJsConfig;
|
|
203
|
+
}
|
|
189
204
|
}
|
|
190
205
|
if (envChange) {
|
|
191
|
-
(
|
|
206
|
+
(_a = config.plugins) === null || _a === void 0 ? void 0 : _a.forEach((plugin) => {
|
|
192
207
|
// we look for the DefinePlugin definitions so we can
|
|
193
208
|
// update them on the active compilers
|
|
194
209
|
if (plugin &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/service",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-dev.6",
|
|
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": "
|
|
33
|
-
"@shuvi/router": "
|
|
34
|
-
"@shuvi/runtime": "
|
|
35
|
-
"@shuvi/shared": "
|
|
36
|
-
"@shuvi/toolpack": "
|
|
37
|
-
"@shuvi/utils": "
|
|
38
|
-
"@shuvi/error-overlay": "
|
|
39
|
-
"@shuvi/reporters": "
|
|
32
|
+
"@shuvi/hook": "2.0.0-dev.6",
|
|
33
|
+
"@shuvi/router": "2.0.0-dev.6",
|
|
34
|
+
"@shuvi/runtime": "2.0.0-dev.6",
|
|
35
|
+
"@shuvi/shared": "2.0.0-dev.6",
|
|
36
|
+
"@shuvi/toolpack": "2.0.0-dev.6",
|
|
37
|
+
"@shuvi/utils": "2.0.0-dev.6",
|
|
38
|
+
"@shuvi/error-overlay": "2.0.0-dev.6",
|
|
39
|
+
"@shuvi/reporters": "2.0.0-dev.6",
|
|
40
40
|
"commander": "5.1.0",
|
|
41
41
|
"comment-json": "4.2.2",
|
|
42
42
|
"cross-spawn": "7.0.3",
|