swico 2.0.0-beta.3 → 2.0.0-beta.30
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 +33 -31
- package/src/bin.js +17 -7
- package/src/command/build.js +1 -1
- package/src/command/start.js +5 -5
- package/src/config/rsbpack.dev.js +22 -11
- package/src/config/rspack.base.react.d.ts +31 -1
- package/src/config/rspack.base.react.js +23 -18
- package/src/config/rspack.base.vue.d.ts +41 -25
- package/src/config/rspack.base.vue.js +45 -39
- package/src/config/rspack.prod.js +33 -10
- package/src/index.react.d.ts +2 -3
- package/src/index.react.js +4 -4
- package/src/index.vue.d.ts +6 -4
- package/src/project-path/.swico-react/$env/history.js +1 -1
- package/src/project-path/.swico-react/$env/index.js +21 -11
- package/src/project-path/.swico-react/react-hooks.js +4 -4
- package/src/project-path/.swico-vue/Container.d.ts +1 -1
- package/src/project-path/src/layout/Layout.d.ts +1 -1
- package/src/project-path/src/layout/index.js +2 -2
- package/src/utils/config.js +17 -7
- package/src/utils/tools.d.ts +1 -1
- package/src/utils/tools.js +20 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.30",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"cli",
|
|
14
14
|
"swico",
|
|
15
15
|
"template",
|
|
16
|
-
"
|
|
16
|
+
"rspack"
|
|
17
17
|
],
|
|
18
18
|
"bin": {
|
|
19
19
|
"swico": "./src/bin.js"
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"compile": "tsc && ts-node ./src/task.ts",
|
|
23
23
|
"publish:offical": "npm run compile && cd ./dist && npm publish",
|
|
24
|
-
"publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta"
|
|
24
|
+
"publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta",
|
|
25
|
+
"lint:fix": "eslint --fix src/**/*.{js,jsx,ts,tsx} "
|
|
25
26
|
},
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
@@ -30,53 +31,54 @@
|
|
|
30
31
|
"author": "scw",
|
|
31
32
|
"license": "ISC",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@rspack/
|
|
35
|
-
"@
|
|
36
|
-
"@swc/core": "1.4.6",
|
|
37
|
-
"@vue/compiler-sfc": "3.4.14",
|
|
34
|
+
"@rspack/core": "1.3.5",
|
|
35
|
+
"@rspack/dev-server": "1.1.1",
|
|
36
|
+
"@vue/compiler-sfc": "3.5.13",
|
|
38
37
|
"autoprefixer": "10.3.7",
|
|
39
38
|
"chalk": "4.1.2",
|
|
40
39
|
"chokidar": "3.6.0",
|
|
41
40
|
"commander": "12.0.0",
|
|
42
41
|
"cross-spawn": "7.0.5",
|
|
43
|
-
"css-loader": "
|
|
44
|
-
"
|
|
45
|
-
"eslint-plugin
|
|
46
|
-
"eslint-plugin-vue": "9.19.2",
|
|
47
|
-
"eslint-webpack-plugin": "4.0.0",
|
|
42
|
+
"css-loader": "7.1.2",
|
|
43
|
+
"esbuild-loader": "4.3.0",
|
|
44
|
+
"eslint-rspack-plugin": "4.2.1",
|
|
48
45
|
"fs-extra": "11.3.0",
|
|
49
|
-
"html-loader": "5.
|
|
50
|
-
"less": "4.
|
|
46
|
+
"html-loader": "5.1.0",
|
|
47
|
+
"less": "4.3.0",
|
|
51
48
|
"less-loader": "12.2.0",
|
|
52
49
|
"ora": "5.4.1",
|
|
53
50
|
"portfinder": "1.0.32",
|
|
54
51
|
"postcss-loader": "8.1.0",
|
|
55
52
|
"postcss-preset-env": "9.3.0",
|
|
56
53
|
"qs": "6.13.0",
|
|
57
|
-
"react-router
|
|
58
|
-
"sass": "1.
|
|
59
|
-
"sass-loader": "
|
|
54
|
+
"react-router": "7.5.0",
|
|
55
|
+
"sass-embedded": "1.86.3",
|
|
56
|
+
"sass-loader": "16.0.5",
|
|
60
57
|
"style-loader": "3.3.0",
|
|
61
|
-
"ts-checker-rspack-plugin": "
|
|
58
|
+
"ts-checker-rspack-plugin": "1.1.1",
|
|
62
59
|
"ts-node": "10.9.1",
|
|
63
60
|
"vue-loader": "17.4.2",
|
|
64
|
-
"vue-router": "
|
|
61
|
+
"vue-router": "4.5.0",
|
|
65
62
|
"vue-style-loader": "4.1.3",
|
|
66
63
|
"webpack-bundle-analyzer": "4.9.1",
|
|
67
|
-
"webpack-merge": "
|
|
68
|
-
"webpackbar": "
|
|
64
|
+
"webpack-merge": "6.0.1",
|
|
65
|
+
"webpackbar": "7.0.0"
|
|
69
66
|
},
|
|
70
67
|
"devDependencies": {
|
|
68
|
+
"@eslint/js": "9.24.0",
|
|
71
69
|
"@types/node": "22.13.10",
|
|
72
|
-
"@types/react": "
|
|
73
|
-
"@types/react-dom": "
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"react": "~
|
|
78
|
-
"react-dom": "~
|
|
79
|
-
"typescript": "5.
|
|
80
|
-
"
|
|
70
|
+
"@types/react": "19.1.0",
|
|
71
|
+
"@types/react-dom": "19.1.0",
|
|
72
|
+
"eslint": "9.24.0",
|
|
73
|
+
"globals": "16.0.0",
|
|
74
|
+
"prettier": "3.5.3",
|
|
75
|
+
"react": "~19.1.0",
|
|
76
|
+
"react-dom": "~19.1.0",
|
|
77
|
+
"typescript": "5.8.3",
|
|
78
|
+
"typescript-eslint": "8.30.1",
|
|
79
|
+
"vue": "~3.5.13"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=20.0.0"
|
|
81
83
|
}
|
|
82
84
|
}
|
package/src/bin.js
CHANGED
|
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
16
16
|
}) : function(o, v) {
|
|
17
17
|
o["default"] = v;
|
|
18
18
|
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
26
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
38
|
};
|
package/src/command/build.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const rspack_prod_1 = __importDefault(require("../config/rspack.prod"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const tools_1 = require("../utils/tools");
|
|
@@ -50,4 +51,3 @@ function default_1() {
|
|
|
50
51
|
});
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
exports.default = default_1;
|
package/src/command/start.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = start;
|
|
15
16
|
const rsbpack_dev_1 = __importDefault(require("../config/rsbpack.dev"));
|
|
16
17
|
const tools_1 = require("../utils/tools");
|
|
17
18
|
const config_1 = require("../utils/config");
|
|
@@ -28,14 +29,14 @@ let currentPort, currentRouterBase = '/';
|
|
|
28
29
|
const handleWatch = (projectPath, devServer, env) => {
|
|
29
30
|
const envPath = env === 'dev' ? '/.dev/' : '/.prod/';
|
|
30
31
|
const configFilesWatcher = chokidar_1.default
|
|
31
|
-
.watch([path_1.default.join(projectPath, '/config/*.ts'), path_1.default.join(projectPath, '/.
|
|
32
|
+
.watch([path_1.default.join(projectPath, '/config/*.ts'), path_1.default.join(projectPath, '/.eslint.config.mjs')], {
|
|
32
33
|
interval: 500,
|
|
33
34
|
binaryInterval: 500,
|
|
34
35
|
ignoreInitial: true,
|
|
35
36
|
ignored: [path_1.default.join(projectPath, '/config/swico.prod.ts')]
|
|
36
37
|
})
|
|
37
38
|
.on('all', (path, stats) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
tools_1.toast.warning('
|
|
39
|
+
tools_1.toast.warning('Configuration files changed, restarting server...', {
|
|
39
40
|
inline: true
|
|
40
41
|
});
|
|
41
42
|
yield devServer.stop();
|
|
@@ -119,7 +120,7 @@ const createCompileListener = (compiler) => {
|
|
|
119
120
|
const warnings = info.warnings;
|
|
120
121
|
warnings.some((item) => {
|
|
121
122
|
const msg = item.message || item.stack;
|
|
122
|
-
if (msg.
|
|
123
|
+
if (msg.includes('[eslint]')) {
|
|
123
124
|
tools_1.toast.warning(msg, { title: 'ESLint errors' });
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
@@ -129,8 +130,8 @@ const createCompileListener = (compiler) => {
|
|
|
129
130
|
});
|
|
130
131
|
};
|
|
131
132
|
function start() {
|
|
132
|
-
var _a, _b, _c, _d, _e, _f;
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
134
135
|
process.env.SWICO_ENV = 'dev';
|
|
135
136
|
if (SWICO_RESTART !== 'true') {
|
|
136
137
|
console.log('\n');
|
|
@@ -168,4 +169,3 @@ function start() {
|
|
|
168
169
|
}
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
|
-
exports.default = start;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,15 +45,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.default = default_1;
|
|
38
49
|
const config_1 = require("../utils/config");
|
|
39
50
|
const path_1 = __importDefault(require("path"));
|
|
40
51
|
const webpack_merge_1 = require("webpack-merge");
|
|
41
|
-
const
|
|
52
|
+
const eslint_rspack_plugin_1 = __importDefault(require("eslint-rspack-plugin"));
|
|
42
53
|
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
43
54
|
const tools_1 = require("../utils/tools");
|
|
44
55
|
function default_1(options) {
|
|
45
|
-
var _a, _b, _c, _d, _e;
|
|
46
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c, _d, _e;
|
|
47
58
|
const { projectPath, customConfig, templateType, entryPath, env } = options;
|
|
48
59
|
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
49
60
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'dev' }));
|
|
@@ -88,7 +99,8 @@ function default_1(options) {
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
}),
|
|
91
|
-
new
|
|
102
|
+
new eslint_rspack_plugin_1.default({
|
|
103
|
+
configType: 'flat',
|
|
92
104
|
context: path_1.default.join(projectPath, '/src'),
|
|
93
105
|
failOnError: false,
|
|
94
106
|
failOnWarning: true,
|
|
@@ -101,4 +113,3 @@ function default_1(options) {
|
|
|
101
113
|
});
|
|
102
114
|
});
|
|
103
115
|
}
|
|
104
|
-
exports.default = default_1;
|
|
@@ -4,6 +4,9 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
6
6
|
filename: string;
|
|
7
|
+
chunkFilename: string;
|
|
8
|
+
cssFilename: string;
|
|
9
|
+
cssChunkFilename: string;
|
|
7
10
|
assetModuleFilename: string;
|
|
8
11
|
publicPath: string;
|
|
9
12
|
clean: boolean;
|
|
@@ -13,6 +16,11 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
13
16
|
};
|
|
14
17
|
target: string[];
|
|
15
18
|
module: {
|
|
19
|
+
parser: {
|
|
20
|
+
'css/auto': {
|
|
21
|
+
namedExports: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
16
24
|
rules: ({
|
|
17
25
|
test: RegExp;
|
|
18
26
|
exclude: RegExp;
|
|
@@ -52,6 +60,28 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
52
60
|
})[];
|
|
53
61
|
generator?: undefined;
|
|
54
62
|
loader?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
test: RegExp;
|
|
65
|
+
type: string;
|
|
66
|
+
use: ({
|
|
67
|
+
loader: string;
|
|
68
|
+
options: {
|
|
69
|
+
postcssOptions: {
|
|
70
|
+
plugins: string[][];
|
|
71
|
+
};
|
|
72
|
+
api?: undefined;
|
|
73
|
+
implementation?: undefined;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
loader: string;
|
|
77
|
+
options: {
|
|
78
|
+
api: string;
|
|
79
|
+
implementation: string;
|
|
80
|
+
postcssOptions?: undefined;
|
|
81
|
+
};
|
|
82
|
+
})[];
|
|
83
|
+
generator?: undefined;
|
|
84
|
+
loader?: undefined;
|
|
55
85
|
} | {
|
|
56
86
|
test: RegExp;
|
|
57
87
|
type: string;
|
|
@@ -82,7 +112,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
82
112
|
extensions: string[];
|
|
83
113
|
alias: {
|
|
84
114
|
'@': string;
|
|
85
|
-
'react-router
|
|
115
|
+
'react-router': string;
|
|
86
116
|
qs: string;
|
|
87
117
|
};
|
|
88
118
|
};
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const path_1 = __importDefault(require("path"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const core_1 = require("@rspack/core");
|
|
@@ -19,9 +20,9 @@ const cssLoader = require.resolve('css-loader');
|
|
|
19
20
|
const lessLoader = require.resolve('less-loader');
|
|
20
21
|
const sassLoader = require.resolve('sass-loader');
|
|
21
22
|
const postcssLoader = require.resolve('postcss-loader');
|
|
22
|
-
function default_1(
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
function default_1(_a) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
25
|
+
var _b, _c, _d;
|
|
25
26
|
const customBaseConfig = customConfig.base;
|
|
26
27
|
const getCustomAliasConfig = () => {
|
|
27
28
|
const { alias } = customBaseConfig || {};
|
|
@@ -34,9 +35,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
34
35
|
return custAliasConfig;
|
|
35
36
|
};
|
|
36
37
|
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
37
|
-
const routerBase = ((
|
|
38
|
+
const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
38
39
|
const basicPlugins = [];
|
|
39
|
-
const defineConfigData = (
|
|
40
|
+
const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
40
41
|
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
41
42
|
if (Object.keys(formatObj).length !== 0) {
|
|
42
43
|
basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
|
|
@@ -46,6 +47,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
46
47
|
output: {
|
|
47
48
|
path: path_1.default.join(projectPath, '/dist'),
|
|
48
49
|
filename: 'js/[name].[chunkhash].js',
|
|
50
|
+
chunkFilename: 'js/[name].[chunkhash].js',
|
|
51
|
+
cssFilename: 'css/[id].css',
|
|
52
|
+
cssChunkFilename: 'css/[id].css',
|
|
49
53
|
assetModuleFilename: 'assets/[name]_[chunkhash][ext]',
|
|
50
54
|
publicPath,
|
|
51
55
|
clean: true
|
|
@@ -53,8 +57,13 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
53
57
|
experiments: {
|
|
54
58
|
css: true
|
|
55
59
|
},
|
|
56
|
-
target: ['web', '
|
|
60
|
+
target: ['web', 'es2015'],
|
|
57
61
|
module: {
|
|
62
|
+
parser: {
|
|
63
|
+
'css/auto': {
|
|
64
|
+
namedExports: false
|
|
65
|
+
}
|
|
66
|
+
},
|
|
58
67
|
rules: [
|
|
59
68
|
{
|
|
60
69
|
test: /\.(tsx|ts|jsx)$/,
|
|
@@ -89,7 +98,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
89
98
|
test: /\.css$/,
|
|
90
99
|
type: 'css/auto',
|
|
91
100
|
use: [
|
|
92
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
93
101
|
cssLoader,
|
|
94
102
|
{
|
|
95
103
|
loader: postcssLoader,
|
|
@@ -105,8 +113,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
105
113
|
test: /\.less$/,
|
|
106
114
|
type: 'css/auto',
|
|
107
115
|
use: [
|
|
108
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
109
|
-
cssLoader,
|
|
110
116
|
{
|
|
111
117
|
loader: postcssLoader,
|
|
112
118
|
options: {
|
|
@@ -122,8 +128,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
122
128
|
test: /\.scss$/,
|
|
123
129
|
type: 'css/auto',
|
|
124
130
|
use: [
|
|
125
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
126
|
-
cssLoader,
|
|
127
131
|
{
|
|
128
132
|
loader: postcssLoader,
|
|
129
133
|
options: {
|
|
@@ -132,7 +136,13 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
},
|
|
135
|
-
|
|
139
|
+
{
|
|
140
|
+
loader: sassLoader,
|
|
141
|
+
options: {
|
|
142
|
+
api: 'modern-compiler',
|
|
143
|
+
implementation: require.resolve('sass-embedded')
|
|
144
|
+
}
|
|
145
|
+
}
|
|
136
146
|
]
|
|
137
147
|
},
|
|
138
148
|
{
|
|
@@ -163,7 +173,7 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
163
173
|
},
|
|
164
174
|
resolve: {
|
|
165
175
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
166
|
-
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router
|
|
176
|
+
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router': path_1.default.dirname(require.resolve('react-router')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
167
177
|
},
|
|
168
178
|
externals: customConfig.base.externals,
|
|
169
179
|
plugins: [
|
|
@@ -178,13 +188,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
178
188
|
},
|
|
179
189
|
hash: true
|
|
180
190
|
}),
|
|
181
|
-
new core_1.rspack.CssExtractRspackPlugin({
|
|
182
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
183
|
-
ignoreOrder: true
|
|
184
|
-
}),
|
|
185
191
|
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
186
192
|
]
|
|
187
193
|
};
|
|
188
194
|
});
|
|
189
195
|
}
|
|
190
|
-
exports.default = default_1;
|
|
@@ -4,6 +4,9 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
6
6
|
filename: string;
|
|
7
|
+
chunkFilename: string;
|
|
8
|
+
cssFilename: string;
|
|
9
|
+
cssChunkFilename: string;
|
|
7
10
|
assetModuleFilename: string;
|
|
8
11
|
publicPath: string;
|
|
9
12
|
clean: boolean;
|
|
@@ -19,6 +22,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
19
22
|
};
|
|
20
23
|
use?: undefined;
|
|
21
24
|
oneOf?: undefined;
|
|
25
|
+
type?: undefined;
|
|
26
|
+
generator?: undefined;
|
|
22
27
|
} | {
|
|
23
28
|
test: RegExp;
|
|
24
29
|
exclude: RegExp;
|
|
@@ -39,8 +44,10 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
39
44
|
loader?: undefined;
|
|
40
45
|
options?: undefined;
|
|
41
46
|
oneOf?: undefined;
|
|
47
|
+
type?: undefined;
|
|
48
|
+
generator?: undefined;
|
|
42
49
|
} | {
|
|
43
|
-
oneOf:
|
|
50
|
+
oneOf: {
|
|
44
51
|
test: RegExp;
|
|
45
52
|
oneOf: ({
|
|
46
53
|
resourceQuery: RegExp;
|
|
@@ -49,6 +56,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
49
56
|
options: {
|
|
50
57
|
modules: {
|
|
51
58
|
localIdentName: string;
|
|
59
|
+
namedExport: boolean;
|
|
52
60
|
};
|
|
53
61
|
postcssOptions?: undefined;
|
|
54
62
|
};
|
|
@@ -72,35 +80,43 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
72
80
|
})[];
|
|
73
81
|
resourceQuery?: undefined;
|
|
74
82
|
})[];
|
|
75
|
-
|
|
76
|
-
generator?: undefined;
|
|
77
|
-
loader?: undefined;
|
|
78
|
-
} | {
|
|
79
|
-
test: RegExp;
|
|
80
|
-
type: string;
|
|
81
|
-
generator: {
|
|
82
|
-
filename: string;
|
|
83
|
-
};
|
|
84
|
-
oneOf?: undefined;
|
|
85
|
-
loader?: undefined;
|
|
86
|
-
} | {
|
|
87
|
-
test: RegExp;
|
|
88
|
-
type: string;
|
|
89
|
-
oneOf?: undefined;
|
|
90
|
-
generator?: undefined;
|
|
91
|
-
loader?: undefined;
|
|
92
|
-
} | {
|
|
93
|
-
test: RegExp;
|
|
94
|
-
loader: string;
|
|
95
|
-
oneOf?: undefined;
|
|
96
|
-
type?: undefined;
|
|
97
|
-
generator?: undefined;
|
|
98
|
-
})[];
|
|
83
|
+
}[];
|
|
99
84
|
test?: undefined;
|
|
100
85
|
loader?: undefined;
|
|
101
86
|
exclude?: undefined;
|
|
102
87
|
options?: undefined;
|
|
103
88
|
use?: undefined;
|
|
89
|
+
type?: undefined;
|
|
90
|
+
generator?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
test: RegExp;
|
|
93
|
+
type: string;
|
|
94
|
+
generator: {
|
|
95
|
+
filename: string;
|
|
96
|
+
};
|
|
97
|
+
loader?: undefined;
|
|
98
|
+
exclude?: undefined;
|
|
99
|
+
options?: undefined;
|
|
100
|
+
use?: undefined;
|
|
101
|
+
oneOf?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
test: RegExp;
|
|
104
|
+
type: string;
|
|
105
|
+
loader?: undefined;
|
|
106
|
+
exclude?: undefined;
|
|
107
|
+
options?: undefined;
|
|
108
|
+
use?: undefined;
|
|
109
|
+
oneOf?: undefined;
|
|
110
|
+
generator?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
test: RegExp;
|
|
113
|
+
loader: string;
|
|
114
|
+
exclude?: undefined;
|
|
115
|
+
options?: undefined;
|
|
116
|
+
use?: undefined;
|
|
117
|
+
oneOf?: undefined;
|
|
118
|
+
type?: undefined;
|
|
119
|
+
generator?: undefined;
|
|
104
120
|
})[];
|
|
105
121
|
};
|
|
106
122
|
resolve: {
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const path_1 = __importDefault(require("path"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const vue_loader_1 = require("vue-loader");
|
|
@@ -21,9 +22,9 @@ const cssLoader = require.resolve('css-loader');
|
|
|
21
22
|
const lessLoader = require.resolve('less-loader');
|
|
22
23
|
const sassLoader = require.resolve('sass-loader');
|
|
23
24
|
const postcssLoader = require.resolve('postcss-loader');
|
|
24
|
-
function default_1(
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
function default_1(_a) {
|
|
26
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
27
|
+
var _b, _c, _d;
|
|
27
28
|
const customBaseConfig = customConfig.base;
|
|
28
29
|
const getCustomAliasConfig = () => {
|
|
29
30
|
const { alias } = customBaseConfig || {};
|
|
@@ -36,19 +37,22 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
36
37
|
return custAliasConfig;
|
|
37
38
|
};
|
|
38
39
|
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
39
|
-
const routerBase = ((
|
|
40
|
+
const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
40
41
|
const basicPlugins = [];
|
|
41
|
-
const defineConfigData = (
|
|
42
|
+
const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
42
43
|
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
43
44
|
if (Object.keys(formatObj).length !== 0) {
|
|
44
|
-
basicPlugins.push(new core_1.
|
|
45
|
+
basicPlugins.push(new core_1.DefinePlugin(formatObj));
|
|
45
46
|
}
|
|
46
47
|
return {
|
|
47
48
|
entry: entryPath,
|
|
48
49
|
output: {
|
|
49
50
|
path: path_1.default.join(projectPath, '/dist'),
|
|
50
51
|
filename: 'js/[name].[chunkhash].js',
|
|
51
|
-
|
|
52
|
+
chunkFilename: 'js/[name].[chunkhash].js',
|
|
53
|
+
cssFilename: 'css/[id].css',
|
|
54
|
+
cssChunkFilename: 'css/[id].css',
|
|
55
|
+
assetModuleFilename: 'assets/[name]_[id][ext]',
|
|
52
56
|
publicPath,
|
|
53
57
|
clean: true
|
|
54
58
|
},
|
|
@@ -96,7 +100,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
96
100
|
loader: cssLoader,
|
|
97
101
|
options: {
|
|
98
102
|
modules: {
|
|
99
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
103
|
+
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
104
|
+
namedExport: false
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
},
|
|
@@ -139,7 +144,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
139
144
|
loader: cssLoader,
|
|
140
145
|
options: {
|
|
141
146
|
modules: {
|
|
142
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
147
|
+
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
148
|
+
namedExport: false
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
151
|
},
|
|
@@ -184,7 +190,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
184
190
|
loader: cssLoader,
|
|
185
191
|
options: {
|
|
186
192
|
modules: {
|
|
187
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
193
|
+
localIdentName: 'moduleStyle_[local]_[contenthash:8]',
|
|
194
|
+
namedExport: false
|
|
188
195
|
}
|
|
189
196
|
}
|
|
190
197
|
},
|
|
@@ -217,30 +224,30 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
217
224
|
]
|
|
218
225
|
}
|
|
219
226
|
]
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
223
|
-
type: 'asset',
|
|
224
|
-
generator: {
|
|
225
|
-
filename: 'images/[name]_[contenthash][ext]'
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
230
|
-
type: 'asset',
|
|
231
|
-
generator: {
|
|
232
|
-
filename: 'fonts/[name]_[contenthash][ext]'
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
test: /\.(txt|xml)$/i,
|
|
237
|
-
type: 'asset/source'
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
test: /\.html$/,
|
|
241
|
-
loader: require.resolve('html-loader')
|
|
242
227
|
}
|
|
243
228
|
]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
|
|
232
|
+
type: 'asset',
|
|
233
|
+
generator: {
|
|
234
|
+
filename: 'images/[name]_[contenthash][ext]'
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
test: /\.(otf|eot|woff2?|ttf)$/i,
|
|
239
|
+
type: 'asset',
|
|
240
|
+
generator: {
|
|
241
|
+
filename: 'fonts/[name]_[contenthash][ext]'
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
test: /\.(txt|xml)$/i,
|
|
246
|
+
type: 'asset/source'
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
test: /\.html$/,
|
|
250
|
+
loader: require.resolve('html-loader')
|
|
244
251
|
}
|
|
245
252
|
]
|
|
246
253
|
},
|
|
@@ -251,13 +258,17 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
251
258
|
externals: customConfig.base.externals,
|
|
252
259
|
plugins: [
|
|
253
260
|
...basicPlugins,
|
|
261
|
+
new core_1.CssExtractRspackPlugin({
|
|
262
|
+
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
263
|
+
ignoreOrder: true
|
|
264
|
+
}),
|
|
254
265
|
new vue_loader_1.VueLoaderPlugin(),
|
|
255
|
-
new core_1.
|
|
266
|
+
new core_1.DefinePlugin({
|
|
256
267
|
__VUE_OPTIONS_API__: true,
|
|
257
268
|
__VUE_PROD_DEVTOOLS__: false,
|
|
258
269
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
|
|
259
270
|
}),
|
|
260
|
-
new core_1.
|
|
271
|
+
new core_1.HtmlRspackPlugin({
|
|
261
272
|
template: path_1.default.join(projectPath, '/src/index.ejs'),
|
|
262
273
|
filename: 'index.html',
|
|
263
274
|
minify: true,
|
|
@@ -267,13 +278,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
267
278
|
},
|
|
268
279
|
hash: true
|
|
269
280
|
}),
|
|
270
|
-
new core_1.CssExtractRspackPlugin({
|
|
271
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
272
|
-
ignoreOrder: true
|
|
273
|
-
}),
|
|
274
281
|
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
275
282
|
]
|
|
276
283
|
};
|
|
277
284
|
});
|
|
278
285
|
}
|
|
279
|
-
exports.default = default_1;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,6 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.default = default_1;
|
|
38
49
|
const webpack_bundle_analyzer_1 = __importDefault(require("webpack-bundle-analyzer"));
|
|
39
50
|
const path_1 = __importDefault(require("path"));
|
|
40
51
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -43,19 +54,24 @@ const webpack_merge_1 = require("webpack-merge");
|
|
|
43
54
|
const webpackbar_1 = __importDefault(require("webpackbar"));
|
|
44
55
|
const tools_1 = require("../utils/tools");
|
|
45
56
|
const core_1 = require("@rspack/core");
|
|
57
|
+
const esbuild_loader_1 = require("esbuild-loader");
|
|
46
58
|
const BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
47
59
|
const isAnalyze = process.env.ANALYZE === 'true';
|
|
48
60
|
function default_1(options) {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
50
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
63
|
const { projectPath, customConfig, templateType } = options;
|
|
52
|
-
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './
|
|
64
|
+
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
53
65
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'prod' }));
|
|
54
66
|
const consoleAvailable = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.console) !== null && _b !== void 0 ? _b : config_1.initConfig.console;
|
|
55
67
|
const isPublicDirExist = yield fs_extra_1.default.exists(path_1.default.join(projectPath, '/public'));
|
|
56
68
|
const copyConfig = (_d = (_c = customConfig.prod) === null || _c === void 0 ? void 0 : _c.copy) !== null && _d !== void 0 ? _d : config_1.initConfig.copy;
|
|
57
69
|
const customDevtool = (_e = customConfig.prod.devtool) !== null && _e !== void 0 ? _e : customConfig.base.devtool;
|
|
58
70
|
return (0, webpack_merge_1.merge)(baseConfig, {
|
|
71
|
+
output: {
|
|
72
|
+
cssFilename: 'css/[name].[contenthash].css',
|
|
73
|
+
cssChunkFilename: 'css/[name].[contenthash].css'
|
|
74
|
+
},
|
|
59
75
|
performance: {
|
|
60
76
|
hints: false
|
|
61
77
|
},
|
|
@@ -64,6 +80,14 @@ function default_1(options) {
|
|
|
64
80
|
optimization: {
|
|
65
81
|
runtimeChunk: true,
|
|
66
82
|
minimize: true,
|
|
83
|
+
minimizer: [
|
|
84
|
+
new esbuild_loader_1.EsbuildPlugin({
|
|
85
|
+
target: 'es2015',
|
|
86
|
+
css: true,
|
|
87
|
+
minify: true,
|
|
88
|
+
drop: [...(!consoleAvailable ? ['console'] : []), 'debugger']
|
|
89
|
+
})
|
|
90
|
+
],
|
|
67
91
|
splitChunks: {
|
|
68
92
|
chunks: 'all',
|
|
69
93
|
cacheGroups: {
|
|
@@ -120,4 +144,3 @@ function default_1(options) {
|
|
|
120
144
|
});
|
|
121
145
|
});
|
|
122
146
|
}
|
|
123
|
-
exports.default = default_1;
|
package/src/index.react.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const Link: FC<{
|
|
|
9
9
|
className?: string;
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
}>;
|
|
12
|
-
export { Outlet } from 'react-router
|
|
12
|
+
export { Outlet } from 'react-router';
|
|
13
13
|
export { useLocation, useNav } from './project-path/.swico-react/react-hooks';
|
|
14
14
|
export { history } from './mock-history';
|
|
15
15
|
export interface DefineSwicoConfigType {
|
|
@@ -18,6 +18,5 @@ export interface DefineSwicoConfigType {
|
|
|
18
18
|
(env: 'prod', config: CustomConfigType['prod']): any;
|
|
19
19
|
}
|
|
20
20
|
export declare const defineConfig: DefineSwicoConfigType;
|
|
21
|
-
export
|
|
22
|
-
}
|
|
21
|
+
export type DefineGlobalConfigType = object;
|
|
23
22
|
export declare const defineGlobal: (config: DefineGlobalConfigType) => DefineGlobalConfigType;
|
package/src/index.react.js
CHANGED
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.defineGlobal = exports.defineConfig = exports.history = exports.useNav = exports.useLocation = exports.Outlet = exports.Link = void 0;
|
|
7
|
-
const
|
|
7
|
+
const react_router_1 = require("react-router");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const Link = ({ replace, to, style, className, children }) => react_1.default.createElement(
|
|
9
|
+
const Link = ({ replace, to, style, className, children }) => react_1.default.createElement(react_router_1.Link, { replace, to, style, className }, children);
|
|
10
10
|
exports.Link = Link;
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return
|
|
11
|
+
var react_router_2 = require("react-router");
|
|
12
|
+
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_2.Outlet; } });
|
|
13
13
|
var react_hooks_1 = require("./project-path/.swico-react/react-hooks");
|
|
14
14
|
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_hooks_1.useLocation; } });
|
|
15
15
|
Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return react_hooks_1.useNav; } });
|
package/src/index.vue.d.ts
CHANGED
|
@@ -6,23 +6,25 @@ export { RouterView as Outlet } from 'vue-router';
|
|
|
6
6
|
export { useLocation, useNav } from './project-path/.swico-vue/vue-hooks';
|
|
7
7
|
export { history } from './mock-history';
|
|
8
8
|
export type { GlobalSwicoConfigType };
|
|
9
|
-
export declare const Link: import("vue").DefineComponent<{
|
|
9
|
+
export declare const Link: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
10
|
to: {
|
|
11
11
|
type: StringConstructor;
|
|
12
12
|
};
|
|
13
13
|
replace: {
|
|
14
14
|
type: BooleanConstructor;
|
|
15
15
|
};
|
|
16
|
-
}
|
|
16
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
17
|
to: {
|
|
18
18
|
type: StringConstructor;
|
|
19
19
|
};
|
|
20
20
|
replace: {
|
|
21
21
|
type: BooleanConstructor;
|
|
22
22
|
};
|
|
23
|
-
}
|
|
23
|
+
}>> & Readonly<{}>, {
|
|
24
24
|
replace: boolean;
|
|
25
|
-
}, {}
|
|
25
|
+
}, {}, {
|
|
26
|
+
RouterLink: import("vue-router")._RouterLinkI;
|
|
27
|
+
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
28
|
export interface DefineSwicoConfigType {
|
|
27
29
|
(env: 'base', config: CustomConfigType['base']): any;
|
|
28
30
|
(env: 'dev', config: CustomConfigType['dev']): any;
|
|
@@ -31,7 +31,7 @@ exports.compareURLPatterns = compareURLPatterns;
|
|
|
31
31
|
const interpolatePath = (pathTemplate, params) => {
|
|
32
32
|
const pathParts = pathTemplate.split('/');
|
|
33
33
|
const interpolatedParts = pathParts.map((part) => {
|
|
34
|
-
const paramMatch = part.match(
|
|
34
|
+
const paramMatch = part.match(/^:(.+)$/);
|
|
35
35
|
if (paramMatch) {
|
|
36
36
|
const paramName = paramMatch[1];
|
|
37
37
|
if (params[paramName]) {
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -29,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
39
|
exports.getChildrenRouteList = void 0;
|
|
30
40
|
const client_1 = require("react-dom/client");
|
|
31
41
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const
|
|
42
|
+
const react_router_1 = require("react-router");
|
|
33
43
|
const loading_1 = __importDefault(require("../loading"));
|
|
34
44
|
const history_1 = require("./history");
|
|
35
45
|
require("../../src/global");
|
|
@@ -57,7 +67,7 @@ const getChildrenRouteList = (childrenRoutes, ancPathKey) => {
|
|
|
57
67
|
const { component, path, children, redirect } = item;
|
|
58
68
|
const newAncPathKey = `${ancPathKey}-${path}`;
|
|
59
69
|
return {
|
|
60
|
-
element: redirect ? (react_1.default.createElement(
|
|
70
|
+
element: redirect ? (react_1.default.createElement(react_router_1.Navigate, { to: redirect, replace: true })) : component ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement(loading_1.default, null) }, (0, react_1.createElement)((0, react_1.lazy)(component)))) : (react_1.default.createElement(react_router_1.Outlet, null)),
|
|
61
71
|
key: newAncPathKey,
|
|
62
72
|
path: path.startsWith('/') ? path.slice(1) : path,
|
|
63
73
|
children: (0, exports.getChildrenRouteList)(children, newAncPathKey)
|
|
@@ -74,7 +84,7 @@ const App = () => {
|
|
|
74
84
|
children: (0, exports.getChildrenRouteList)(routes_1.default, '')
|
|
75
85
|
}
|
|
76
86
|
];
|
|
77
|
-
const router = (config_1.routerType === 'hash' ?
|
|
87
|
+
const router = (config_1.routerType === 'hash' ? react_router_1.createHashRouter : react_router_1.createBrowserRouter)(routeList, {
|
|
78
88
|
basename: config_1.routerBase
|
|
79
89
|
});
|
|
80
90
|
if (config_1.routerBase && config_1.routerBase !== '/') {
|
|
@@ -85,7 +95,7 @@ const App = () => {
|
|
|
85
95
|
(0, react_1.useLayoutEffect)(() => {
|
|
86
96
|
history_1.history = (0, history_1.getHistory)(router);
|
|
87
97
|
});
|
|
88
|
-
return react_1.default.createElement(
|
|
98
|
+
return react_1.default.createElement(react_router_1.RouterProvider, { router: router });
|
|
89
99
|
};
|
|
90
100
|
const root = (0, client_1.createRoot)(document.getElementById('root'));
|
|
91
101
|
root.render(react_1.default.createElement(App, null));
|
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useNav = exports.useLocation = void 0;
|
|
7
|
-
const
|
|
7
|
+
const react_router_1 = require("react-router");
|
|
8
8
|
const history_1 = require("./$env/history");
|
|
9
9
|
const qs_1 = __importDefault(require("qs"));
|
|
10
10
|
const useLocation = () => {
|
|
11
11
|
var _a;
|
|
12
|
-
const location = (0,
|
|
13
|
-
const params = (0,
|
|
12
|
+
const location = (0, react_router_1.useLocation)();
|
|
13
|
+
const params = (0, react_router_1.useParams)();
|
|
14
14
|
const { search, hash, pathname, state } = location;
|
|
15
15
|
const matchItem = history_1.pathNameList.find((item) => (Object.keys(params).length > 0 && (0, history_1.compareURLPatterns)(pathname, item.path)) ||
|
|
16
16
|
item.path === pathname);
|
|
@@ -39,7 +39,7 @@ const getFormatNavPath = (to) => {
|
|
|
39
39
|
return newPath;
|
|
40
40
|
};
|
|
41
41
|
const useNav = () => {
|
|
42
|
-
const navigate = (0,
|
|
42
|
+
const navigate = (0, react_router_1.useNavigate)();
|
|
43
43
|
const newNavigate = (to, options) => {
|
|
44
44
|
switch (typeof to) {
|
|
45
45
|
case 'string':
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
2
|
export default _default;
|
|
@@ -3,6 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const react_router_1 = require("react-router");
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
exports.default = () => react_1.default.createElement(
|
|
8
|
+
exports.default = () => react_1.default.createElement(react_router_1.Outlet, null);
|
package/src/utils/config.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigRouterType } from './config';
|
|
2
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
|
|
3
|
-
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType[
|
|
3
|
+
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType["routes"], templateType: any) => any[];
|
|
4
4
|
export declare const getPort: () => Promise<number>;
|
|
5
5
|
export declare const colorConfig: {
|
|
6
6
|
theme: string;
|
package/src/utils/tools.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -141,14 +151,14 @@ exports.toast = {
|
|
|
141
151
|
else {
|
|
142
152
|
if (Array.isArray(message)) {
|
|
143
153
|
if (message.length > 0) {
|
|
144
|
-
console.log(`${chalk_1.default.red.bold('error')} - ${title || '
|
|
154
|
+
console.log(`${chalk_1.default.red.bold('error')} - ${title || 'Swico errors'}:`);
|
|
145
155
|
}
|
|
146
156
|
message.forEach((item) => {
|
|
147
157
|
console.log(`> ${chalk_1.default.red.bold(item)}`);
|
|
148
158
|
});
|
|
149
159
|
}
|
|
150
160
|
else if (message) {
|
|
151
|
-
console.log(`${chalk_1.default.red.bold('error')} - ${title || '
|
|
161
|
+
console.log(`${chalk_1.default.red.bold('error')} - ${title || 'Swico errors'}:`);
|
|
152
162
|
console.log(`> ${chalk_1.default.red.bold(message)}`);
|
|
153
163
|
}
|
|
154
164
|
}
|
|
@@ -160,7 +170,7 @@ exports.toast = {
|
|
|
160
170
|
console.log(`${chalk_1.default.hex(color).bold('warning')} - ${message}`);
|
|
161
171
|
}
|
|
162
172
|
else {
|
|
163
|
-
console.log(`${chalk_1.default.hex(color).bold('warning')} - ${title || '
|
|
173
|
+
console.log(`${chalk_1.default.hex(color).bold('warning')} - ${title || ' Swico warnings'}:`);
|
|
164
174
|
if (Array.isArray(message)) {
|
|
165
175
|
message.forEach((item) => {
|
|
166
176
|
console.log(`> ${chalk_1.default.hex(color).bold(item)}`);
|