@shuvi/service 1.0.63 → 2.0.0-dev.10
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 +67 -44
- 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
|
}
|
|
@@ -125,10 +128,23 @@ class WebpackBundler {
|
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
});
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
/**
|
|
132
|
+
* TODO
|
|
133
|
+
*/
|
|
134
|
+
// const webpackWatching = this._compiler.watch(
|
|
135
|
+
// this._compiler.compilers.map(
|
|
136
|
+
// childCompiler => childCompiler.options.watchOptions || {}
|
|
137
|
+
// ),
|
|
138
|
+
// () => {
|
|
139
|
+
// // do nothing
|
|
140
|
+
// }
|
|
141
|
+
// );
|
|
142
|
+
const rspackWatching = this._compiler.watch(this._compiler.compilers[0].options.watchOptions || {}, (error, multiStats) => {
|
|
143
|
+
if (error) {
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
130
146
|
});
|
|
131
|
-
this._watching.set(
|
|
147
|
+
this._watching.set(rspackWatching);
|
|
132
148
|
return this._watching;
|
|
133
149
|
}
|
|
134
150
|
build() {
|
|
@@ -137,7 +153,7 @@ class WebpackBundler {
|
|
|
137
153
|
if (this._options.ignoreTypeScriptErrors) {
|
|
138
154
|
logger_1.default.info('Skipping validation of types');
|
|
139
155
|
this._compiler.compilers.forEach(compiler => {
|
|
140
|
-
|
|
156
|
+
tsCheckerRspackPlugin_1.default.getCompilerHooks(compiler).issues.tap('afterTypeScriptCheck', (issues) => issues.filter(msg => msg.severity !== 'error'));
|
|
141
157
|
});
|
|
142
158
|
}
|
|
143
159
|
return (0, runCompiler_1.runCompiler)(compiler);
|
|
@@ -151,21 +167,22 @@ class WebpackBundler {
|
|
|
151
167
|
get targets() {
|
|
152
168
|
return this._targets;
|
|
153
169
|
}
|
|
154
|
-
|
|
170
|
+
_getRspackCompiler( /*dynamicDll?: DynamicDll | null*/) {
|
|
155
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
172
|
if (!this._compiler) {
|
|
157
173
|
this._targets = yield this._getTargets();
|
|
158
|
-
if (dynamicDll) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
// }
|
|
169
186
|
let isFirstSuccessfulCompile = true;
|
|
170
187
|
this._compiler.hooks.done.tap('done', (stats) => __awaiter(this, void 0, void 0, function* () {
|
|
171
188
|
const warnings = [];
|
|
@@ -173,6 +190,7 @@ class WebpackBundler {
|
|
|
173
190
|
this._isCompiling = false;
|
|
174
191
|
let timeMessage = '';
|
|
175
192
|
if (this._startTime) {
|
|
193
|
+
// @ts-ignore exists ts error
|
|
176
194
|
const time = performance.now() - this._startTime;
|
|
177
195
|
this._startTime = 0;
|
|
178
196
|
timeMessage =
|
|
@@ -235,15 +253,15 @@ class WebpackBundler {
|
|
|
235
253
|
tsMessagesPromise = undefined;
|
|
236
254
|
isInvalid = true;
|
|
237
255
|
});
|
|
238
|
-
const useTypeScript = !!((_a = compiler.options.plugins) === null || _a === void 0 ? void 0 : _a.find(plugin => plugin instanceof
|
|
256
|
+
const useTypeScript = !!((_a = compiler.options.plugins) === null || _a === void 0 ? void 0 : _a.find(plugin => plugin instanceof tsCheckerRspackPlugin_1.default));
|
|
239
257
|
if (options.typeChecking && useTypeScript) {
|
|
240
|
-
const typescriptFormatter = (0,
|
|
258
|
+
const typescriptFormatter = (0, tsCheckerRspackPlugin_1.createCodeFrameFormatter)({});
|
|
241
259
|
compiler.hooks.beforeCompile.tap('beforeCompile', () => {
|
|
242
260
|
tsMessagesPromise = new Promise(resolve => {
|
|
243
261
|
tsMessagesResolver = msgs => resolve(msgs);
|
|
244
262
|
});
|
|
245
263
|
});
|
|
246
|
-
|
|
264
|
+
tsCheckerRspackPlugin_1.default.getCompilerHooks(compiler).issues.tap('afterTypeScriptCheck', (issues) => {
|
|
247
265
|
const format = (message) => {
|
|
248
266
|
const file = (message.file || '').replace(/\\/g, '/');
|
|
249
267
|
const formatted = typescriptFormatter(message);
|
|
@@ -263,10 +281,11 @@ class WebpackBundler {
|
|
|
263
281
|
}
|
|
264
282
|
compiler.hooks.invalid.tap('invalid', () => {
|
|
265
283
|
if (this._startTime === null) {
|
|
284
|
+
// @ts-ignore exists ts error
|
|
266
285
|
this._startTime = performance.now();
|
|
267
286
|
}
|
|
268
287
|
});
|
|
269
|
-
// "done" event fires when
|
|
288
|
+
// "done" event fires when Rspack has finished recompiling the bundle.
|
|
270
289
|
// Whether or not you have warnings or errors, you will get this event.
|
|
271
290
|
compiler.hooks.done.tap('done', (stats) => __awaiter(this, void 0, void 0, function* () {
|
|
272
291
|
var _a, _b;
|
|
@@ -276,7 +295,7 @@ class WebpackBundler {
|
|
|
276
295
|
return;
|
|
277
296
|
}
|
|
278
297
|
isInvalid = false;
|
|
279
|
-
// We have switched off the default
|
|
298
|
+
// We have switched off the default Rspack output in DevServer
|
|
280
299
|
// options so we are going to "massage" the warnings and errors and present
|
|
281
300
|
// them in a readable focused way.
|
|
282
301
|
// We only construct the warnings and errors for speed:
|
|
@@ -359,23 +378,27 @@ class WebpackBundler {
|
|
|
359
378
|
const extraTargets = (yield this._cliContext.pluginRunner.addExtraTarget({
|
|
360
379
|
createConfig: this._createConfig.bind(this),
|
|
361
380
|
mode: this._cliContext.mode,
|
|
362
|
-
webpack: webpack_1.
|
|
381
|
+
webpack: webpack_1.rspack
|
|
363
382
|
})).filter(Boolean);
|
|
364
383
|
buildTargets.push(...extraTargets);
|
|
365
|
-
const
|
|
384
|
+
const defaultRspackHelpers = { addExternals: config_1.addExternals };
|
|
366
385
|
for (const buildTarget of buildTargets) {
|
|
367
386
|
let { chain, name } = buildTarget;
|
|
368
387
|
// modify config by api hooks
|
|
369
388
|
chain = yield this._cliContext.pluginRunner.configWebpack(chain, {
|
|
370
389
|
name,
|
|
371
390
|
mode: this._cliContext.mode,
|
|
372
|
-
helpers:
|
|
373
|
-
|
|
391
|
+
helpers: defaultRspackHelpers,
|
|
392
|
+
/**
|
|
393
|
+
* @deprecated use rspack instead
|
|
394
|
+
*/
|
|
395
|
+
webpack: webpack_1.rspack,
|
|
396
|
+
rspack: webpack_1.rspack,
|
|
374
397
|
resolveWebpackModule(path) {
|
|
375
|
-
return (0, webpack_1.
|
|
398
|
+
return (0, webpack_1.resolveRspackModule)(path);
|
|
376
399
|
}
|
|
377
400
|
});
|
|
378
|
-
(0, config_1.
|
|
401
|
+
(0, config_1.checkRspackExternals)(chain);
|
|
379
402
|
if (hasEntry(chain)) {
|
|
380
403
|
const chainConfig = chain.toConfig();
|
|
381
404
|
logger_1.default.debug(`${name} Config`);
|
|
@@ -397,7 +420,7 @@ function getBundler(ctx) {
|
|
|
397
420
|
if (ctx.mode !== 'development') {
|
|
398
421
|
options.preBundle = false;
|
|
399
422
|
}
|
|
400
|
-
const bundler = new
|
|
423
|
+
const bundler = new RspackBundler(options, ctx);
|
|
401
424
|
yield bundler.init();
|
|
402
425
|
return bundler;
|
|
403
426
|
}
|
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.10",
|
|
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.10",
|
|
33
|
+
"@shuvi/router": "2.0.0-dev.10",
|
|
34
|
+
"@shuvi/runtime": "2.0.0-dev.10",
|
|
35
|
+
"@shuvi/shared": "2.0.0-dev.10",
|
|
36
|
+
"@shuvi/toolpack": "2.0.0-dev.10",
|
|
37
|
+
"@shuvi/utils": "2.0.0-dev.10",
|
|
38
|
+
"@shuvi/error-overlay": "2.0.0-dev.10",
|
|
39
|
+
"@shuvi/reporters": "2.0.0-dev.10",
|
|
40
40
|
"commander": "5.1.0",
|
|
41
41
|
"comment-json": "4.2.2",
|
|
42
42
|
"cross-spawn": "7.0.3",
|