swico 3.0.0-beta.3 → 3.0.0-beta.5
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/package.json +3 -1
- package/src/command/build.js +4 -7
- package/src/command/start.js +7 -0
- package/src/index.d.ts +2 -3
- package/src/index.react.d.ts +2 -2
- package/src/index.vue.d.ts +1 -1
- package/src/main-config/index.d.ts +6 -7
- package/src/main-config/index.js +1 -1
- package/src/rsbuild-config/config.dev.js +6 -0
- package/src/rsbuild-config/config.prod.js +15 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"author": "scw",
|
|
45
45
|
"license": "ISC",
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"@esctn/vue-tsc-api": "^1.0.1",
|
|
47
48
|
"@rsbuild/plugin-basic-ssl": "^1.2.2",
|
|
48
49
|
"@rsbuild/plugin-eslint": "^1.3.0",
|
|
49
50
|
"@rsbuild/plugin-less": "^1.6.2",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"@rsbuild/plugin-sass": "^1.5.1",
|
|
52
53
|
"@rsbuild/plugin-type-check": "^1.3.4",
|
|
53
54
|
"@rsbuild/plugin-vue": "^1.2.7",
|
|
55
|
+
"@rsdoctor/rspack-plugin": "^1.5.7",
|
|
54
56
|
"chalk": "4.1.2",
|
|
55
57
|
"chokidar": "3.6.0",
|
|
56
58
|
"commander": "12.0.0",
|
package/src/command/build.js
CHANGED
|
@@ -18,7 +18,6 @@ const main_config_1 = require("../main-config");
|
|
|
18
18
|
const utils_1 = require("../utils");
|
|
19
19
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
20
20
|
const core_1 = require("@rsbuild/core");
|
|
21
|
-
const isAnalyze = process.env.ANALYZE === 'true';
|
|
22
21
|
function default_1() {
|
|
23
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
23
|
process.env.SWICO_ENV = 'prod';
|
|
@@ -34,12 +33,7 @@ function default_1() {
|
|
|
34
33
|
templateType
|
|
35
34
|
});
|
|
36
35
|
const rsbuild = yield (0, core_1.createRsbuild)({ config: buildConfig });
|
|
37
|
-
|
|
38
|
-
if (isAnalyze) {
|
|
39
|
-
yield rsbuild.preview();
|
|
40
|
-
}
|
|
41
|
-
utils_1.toast.info('Building...');
|
|
42
|
-
const now = Date.now();
|
|
36
|
+
let now;
|
|
43
37
|
rsbuild.onAfterBuild(({ stats }) => {
|
|
44
38
|
if (stats.hasErrors()) {
|
|
45
39
|
const info = stats.toJson({ all: true });
|
|
@@ -53,5 +47,8 @@ function default_1() {
|
|
|
53
47
|
const duration = Date.now() - now;
|
|
54
48
|
utils_1.toast.success(`Build complete in ${(duration / 1000).toFixed(2)}s`);
|
|
55
49
|
});
|
|
50
|
+
utils_1.toast.info('Building...');
|
|
51
|
+
now = Date.now();
|
|
52
|
+
yield rsbuild.build();
|
|
56
53
|
});
|
|
57
54
|
}
|
package/src/command/start.js
CHANGED
|
@@ -138,6 +138,13 @@ function start() {
|
|
|
138
138
|
(SWICO_DEV_RESTART === 'true' && newRouterBase !== SWICO_DEV_ROUTER_BASE)) {
|
|
139
139
|
utils_1.toast.info(`Project is running at:${chalk_1.default.hex('#29abe0')(`${customConfig.dev.https ? 'https' : 'http'}://localhost:${rsbuild.context.devServer.port}${newRouterBase}`)}`);
|
|
140
140
|
}
|
|
141
|
+
const proxyConfig = startConfig.server.proxy;
|
|
142
|
+
if (proxyConfig &&
|
|
143
|
+
(Array.isArray(proxyConfig)
|
|
144
|
+
? proxyConfig.length > 0
|
|
145
|
+
: Object.keys(proxyConfig).length > 0)) {
|
|
146
|
+
utils_1.toast.info('Proxy service is enabled');
|
|
147
|
+
}
|
|
141
148
|
currentRouterBase = newRouterBase;
|
|
142
149
|
}
|
|
143
150
|
catch (e) {
|
package/src/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { GlobalDataType
|
|
1
|
+
import { GlobalDataType } from './main-config';
|
|
2
2
|
import { UseLocationType, UseNavType } from './typings/global-type';
|
|
3
3
|
import { App } from 'vue';
|
|
4
4
|
import { Router } from 'vue-router';
|
|
5
5
|
export type CustomConfigType = GlobalDataType['customConfig'];
|
|
6
|
-
export type
|
|
6
|
+
export type { ConfigRoutesItemType, GlobalSwicoConfigType, GlobalDataType, ConfigRouterType } from './main-config';
|
|
7
7
|
export type * from './typings/global-type';
|
|
8
|
-
export type { GlobalSwicoConfigType };
|
|
9
8
|
export { history } from './mock-history';
|
|
10
9
|
declare let Outlet: any, Link: any, useLocation: UseLocationType, useNav: UseNavType;
|
|
11
10
|
export { Outlet, Link, useLocation, useNav };
|
package/src/index.react.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { GlobalDataType } from './main-config';
|
|
|
2
2
|
import { CSSProperties, FC, ReactNode } from 'react';
|
|
3
3
|
import { SwicoHistoryOptionType } from './typings/global-type';
|
|
4
4
|
import { useLocation, useNav } from './template-root/.swico-react/hooks';
|
|
5
|
-
export type CustomConfigType = GlobalDataType['customConfig'];
|
|
6
5
|
export type * from './typings/global-type';
|
|
7
|
-
export type
|
|
6
|
+
export type { ConfigRoutesItemType, GlobalSwicoConfigType, GlobalDataType, ConfigRouterType } from './main-config';
|
|
7
|
+
export type CustomConfigType = GlobalDataType['customConfig'];
|
|
8
8
|
interface LinkPropsType {
|
|
9
9
|
replace?: boolean;
|
|
10
10
|
to: string | number | SwicoHistoryOptionType;
|
package/src/index.vue.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { RouterView } from 'vue-router';
|
|
|
8
8
|
export { useLocation, useNav };
|
|
9
9
|
export { history } from './mock-history';
|
|
10
10
|
export type * from './typings/global-type';
|
|
11
|
-
export type
|
|
11
|
+
export type { ConfigRoutesItemType, GlobalSwicoConfigType, GlobalDataType, ConfigRouterType } from './main-config';
|
|
12
12
|
export declare const Outlet: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
13
13
|
interface LinkPropsType {
|
|
14
14
|
replace?: boolean;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ProxyOptions, RsbuildPlugin, RsbuildPlugins, Rspack } from '@rsbuild/core';
|
|
2
|
+
import { Falsy } from '@rsbuild/core/dist-types/types';
|
|
1
3
|
export type ConfigRoutesItemType = {
|
|
2
4
|
component?: string;
|
|
3
5
|
children?: ConfigRoutesItemType[];
|
|
@@ -15,19 +17,16 @@ export type ConfigRouterType = {
|
|
|
15
17
|
};
|
|
16
18
|
export interface GlobalSwicoConfigType {
|
|
17
19
|
template: 'react' | 'vue';
|
|
18
|
-
plugins?:
|
|
20
|
+
plugins?: (RsbuildPlugin | Falsy | Promise<RsbuildPlugin | Falsy | RsbuildPlugins> | RsbuildPlugins)[];
|
|
19
21
|
publicPath?: string;
|
|
20
22
|
console?: boolean;
|
|
21
23
|
define?: Record<string, any>;
|
|
22
24
|
alias?: Record<string, any>;
|
|
23
|
-
proxy?:
|
|
25
|
+
proxy?: ProxyOptions[] | Record<string, string | ProxyOptions>;
|
|
24
26
|
https?: boolean;
|
|
25
27
|
responseHeaders?: Record<string, any>;
|
|
26
|
-
copy?:
|
|
27
|
-
|
|
28
|
-
to: string;
|
|
29
|
-
}>;
|
|
30
|
-
devtool?: string;
|
|
28
|
+
copy?: Rspack.CopyRspackPluginOptions | Rspack.CopyRspackPluginOptions['patterns'];
|
|
29
|
+
devtool?: Rspack.Configuration['devtool'];
|
|
31
30
|
externals?: any;
|
|
32
31
|
router?: ConfigRouterType;
|
|
33
32
|
}
|
package/src/main-config/index.js
CHANGED
|
@@ -61,7 +61,7 @@ const getFormatRouter = (projectPath, routes, templateType) => {
|
|
|
61
61
|
component: component
|
|
62
62
|
? `()=>import('${projectPath}/src/pages/${component}${templateType === 'vue' ? '.vue' : ''}')`
|
|
63
63
|
: undefined,
|
|
64
|
-
name
|
|
64
|
+
name: `decorator-outlet-${name}`,
|
|
65
65
|
redirect,
|
|
66
66
|
children: children ? children === null || children === void 0 ? void 0 : children.map((item) => _main(item)) : undefined
|
|
67
67
|
}
|
|
@@ -73,6 +73,9 @@ function default_1(options) {
|
|
|
73
73
|
proxy: (_g = (_f = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _f === void 0 ? void 0 : _f.proxy) !== null && _g !== void 0 ? _g : main_config_1.initConfig.proxy,
|
|
74
74
|
open: false
|
|
75
75
|
},
|
|
76
|
+
performance: {
|
|
77
|
+
buildCache: true
|
|
78
|
+
},
|
|
76
79
|
dev: {
|
|
77
80
|
client: {
|
|
78
81
|
overlay: false,
|
|
@@ -101,6 +104,9 @@ function default_1(options) {
|
|
|
101
104
|
error: (message) => {
|
|
102
105
|
utils_1.toast.error(message, { title: 'TypeScript errors' });
|
|
103
106
|
}
|
|
107
|
+
},
|
|
108
|
+
typescript: {
|
|
109
|
+
typescriptPath: templateType === 'vue' ? '@esctn/vue-tsc-api' : undefined
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
}),
|
|
@@ -45,6 +45,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.default = default_1;
|
|
46
46
|
const main_config_1 = require("../main-config");
|
|
47
47
|
const core_1 = require("@rsbuild/core");
|
|
48
|
+
const rspack_plugin_1 = require("@rsdoctor/rspack-plugin");
|
|
49
|
+
const isAnalyze = process.env.ANALYZE === 'true';
|
|
48
50
|
function default_1(options) {
|
|
49
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
52
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -55,7 +57,7 @@ function default_1(options) {
|
|
|
55
57
|
const copyConfig = (_d = (_c = customConfig.prod) === null || _c === void 0 ? void 0 : _c.copy) !== null && _d !== void 0 ? _d : main_config_1.initConfig.copy;
|
|
56
58
|
return (0, core_1.mergeRsbuildConfig)(baseConfig, {
|
|
57
59
|
output: {
|
|
58
|
-
copy: copyConfig
|
|
60
|
+
copy: copyConfig,
|
|
59
61
|
sourceMap: {
|
|
60
62
|
js: (_f = (_e = customConfig.prod.devtool) !== null && _e !== void 0 ? _e : customConfig.base.devtool) !== null && _f !== void 0 ? _f : false,
|
|
61
63
|
css: false,
|
|
@@ -63,9 +65,20 @@ function default_1(options) {
|
|
|
63
65
|
}
|
|
64
66
|
},
|
|
65
67
|
performance: {
|
|
66
|
-
removeConsole: !consoleAvailable
|
|
68
|
+
removeConsole: !consoleAvailable,
|
|
69
|
+
performance: {
|
|
70
|
+
buildCache: true
|
|
71
|
+
}
|
|
67
72
|
},
|
|
68
73
|
mode: 'production',
|
|
74
|
+
tools: {
|
|
75
|
+
rspack: {
|
|
76
|
+
plugins: [
|
|
77
|
+
isAnalyze &&
|
|
78
|
+
new rspack_plugin_1.RsdoctorRspackPlugin({})
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
},
|
|
69
82
|
plugins: [...((_h = (_g = customConfig.prod) === null || _g === void 0 ? void 0 : _g.plugins) !== null && _h !== void 0 ? _h : [])]
|
|
70
83
|
});
|
|
71
84
|
});
|