swico 2.0.0-beta.2 → 2.0.0-beta.20
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 +32 -32
- 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 -4
- package/src/config/rspack.base.react.js +23 -21
- package/src/config/rspack.base.vue.d.ts +35 -37
- package/src/config/rspack.base.vue.js +35 -137
- package/src/config/rspack.prod.js +27 -14
- 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.20",
|
|
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,52 @@
|
|
|
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
|
-
"eslint-plugin
|
|
45
|
-
"eslint-plugin-react-hooks": "4.3.0",
|
|
46
|
-
"eslint-plugin-vue": "9.19.2",
|
|
47
|
-
"eslint-webpack-plugin": "4.0.0",
|
|
42
|
+
"css-loader": "7.1.2",
|
|
43
|
+
"eslint-rspack-plugin": "4.2.1",
|
|
48
44
|
"fs-extra": "11.3.0",
|
|
49
|
-
"html-loader": "5.
|
|
50
|
-
"less": "4.
|
|
45
|
+
"html-loader": "5.1.0",
|
|
46
|
+
"less": "4.3.0",
|
|
51
47
|
"less-loader": "12.2.0",
|
|
52
48
|
"ora": "5.4.1",
|
|
53
49
|
"portfinder": "1.0.32",
|
|
54
50
|
"postcss-loader": "8.1.0",
|
|
55
51
|
"postcss-preset-env": "9.3.0",
|
|
56
52
|
"qs": "6.13.0",
|
|
57
|
-
"react-router
|
|
58
|
-
"sass": "1.
|
|
59
|
-
"sass-loader": "
|
|
53
|
+
"react-router": "7.5.0",
|
|
54
|
+
"sass-embedded": "1.86.3",
|
|
55
|
+
"sass-loader": "16.0.5",
|
|
60
56
|
"style-loader": "3.3.0",
|
|
61
|
-
"ts-checker-rspack-plugin": "
|
|
57
|
+
"ts-checker-rspack-plugin": "1.1.1",
|
|
62
58
|
"ts-node": "10.9.1",
|
|
63
59
|
"vue-loader": "17.4.2",
|
|
64
|
-
"vue-router": "
|
|
65
|
-
"vue-style-loader": "4.1.3",
|
|
60
|
+
"vue-router": "4.5.0",
|
|
66
61
|
"webpack-bundle-analyzer": "4.9.1",
|
|
67
|
-
"webpack-merge": "
|
|
68
|
-
"webpackbar": "
|
|
62
|
+
"webpack-merge": "6.0.1",
|
|
63
|
+
"webpackbar": "7.0.0"
|
|
69
64
|
},
|
|
70
65
|
"devDependencies": {
|
|
66
|
+
"@eslint/js": "9.24.0",
|
|
71
67
|
"@types/node": "22.13.10",
|
|
72
|
-
"@types/react": "
|
|
73
|
-
"@types/react-dom": "
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"react": "~
|
|
78
|
-
"react-dom": "~
|
|
79
|
-
"typescript": "5.
|
|
80
|
-
"
|
|
68
|
+
"@types/react": "19.1.0",
|
|
69
|
+
"@types/react-dom": "19.1.0",
|
|
70
|
+
"eslint": "9.24.0",
|
|
71
|
+
"globals": "16.0.0",
|
|
72
|
+
"prettier": "3.5.3",
|
|
73
|
+
"react": "~19.1.0",
|
|
74
|
+
"react-dom": "~19.1.0",
|
|
75
|
+
"typescript": "5.8.3",
|
|
76
|
+
"typescript-eslint": "8.30.1",
|
|
77
|
+
"vue": "~3.5.13"
|
|
78
|
+
},
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=20.0.0"
|
|
81
81
|
}
|
|
82
82
|
}
|
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;
|
|
@@ -12,10 +15,12 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
12
15
|
css: boolean;
|
|
13
16
|
};
|
|
14
17
|
target: string[];
|
|
15
|
-
cache: {
|
|
16
|
-
type: string;
|
|
17
|
-
};
|
|
18
18
|
module: {
|
|
19
|
+
parser: {
|
|
20
|
+
'css/auto': {
|
|
21
|
+
namedExports: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
19
24
|
rules: ({
|
|
20
25
|
test: RegExp;
|
|
21
26
|
exclude: RegExp;
|
|
@@ -55,6 +60,28 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
55
60
|
})[];
|
|
56
61
|
generator?: undefined;
|
|
57
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;
|
|
58
85
|
} | {
|
|
59
86
|
test: RegExp;
|
|
60
87
|
type: string;
|
|
@@ -85,7 +112,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
85
112
|
extensions: string[];
|
|
86
113
|
alias: {
|
|
87
114
|
'@': string;
|
|
88
|
-
'react-router
|
|
115
|
+
'react-router': string;
|
|
89
116
|
qs: string;
|
|
90
117
|
};
|
|
91
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,11 +57,13 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
53
57
|
experiments: {
|
|
54
58
|
css: true
|
|
55
59
|
},
|
|
56
|
-
target: ['web', '
|
|
57
|
-
cache: {
|
|
58
|
-
type: 'filesystem'
|
|
59
|
-
},
|
|
60
|
+
target: ['web', 'es2015'],
|
|
60
61
|
module: {
|
|
62
|
+
parser: {
|
|
63
|
+
'css/auto': {
|
|
64
|
+
namedExports: false
|
|
65
|
+
}
|
|
66
|
+
},
|
|
61
67
|
rules: [
|
|
62
68
|
{
|
|
63
69
|
test: /\.(tsx|ts|jsx)$/,
|
|
@@ -92,7 +98,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
92
98
|
test: /\.css$/,
|
|
93
99
|
type: 'css/auto',
|
|
94
100
|
use: [
|
|
95
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
96
101
|
cssLoader,
|
|
97
102
|
{
|
|
98
103
|
loader: postcssLoader,
|
|
@@ -108,8 +113,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
108
113
|
test: /\.less$/,
|
|
109
114
|
type: 'css/auto',
|
|
110
115
|
use: [
|
|
111
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
112
|
-
cssLoader,
|
|
113
116
|
{
|
|
114
117
|
loader: postcssLoader,
|
|
115
118
|
options: {
|
|
@@ -125,8 +128,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
125
128
|
test: /\.scss$/,
|
|
126
129
|
type: 'css/auto',
|
|
127
130
|
use: [
|
|
128
|
-
core_1.rspack.CssExtractRspackPlugin.loader,
|
|
129
|
-
cssLoader,
|
|
130
131
|
{
|
|
131
132
|
loader: postcssLoader,
|
|
132
133
|
options: {
|
|
@@ -135,7 +136,13 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
},
|
|
138
|
-
|
|
139
|
+
{
|
|
140
|
+
loader: sassLoader,
|
|
141
|
+
options: {
|
|
142
|
+
api: 'modern-compiler',
|
|
143
|
+
implementation: require.resolve('sass-embedded')
|
|
144
|
+
}
|
|
145
|
+
}
|
|
139
146
|
]
|
|
140
147
|
},
|
|
141
148
|
{
|
|
@@ -166,7 +173,7 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
166
173
|
},
|
|
167
174
|
resolve: {
|
|
168
175
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
169
|
-
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())
|
|
170
177
|
},
|
|
171
178
|
externals: customConfig.base.externals,
|
|
172
179
|
plugins: [
|
|
@@ -181,13 +188,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
181
188
|
},
|
|
182
189
|
hash: true
|
|
183
190
|
}),
|
|
184
|
-
new core_1.rspack.CssExtractRspackPlugin({
|
|
185
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
186
|
-
ignoreOrder: true
|
|
187
|
-
}),
|
|
188
191
|
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
189
192
|
]
|
|
190
193
|
};
|
|
191
194
|
});
|
|
192
195
|
}
|
|
193
|
-
exports.default = default_1;
|
|
@@ -4,15 +4,23 @@ 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;
|
|
10
13
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: string;
|
|
14
|
+
experiments: {
|
|
15
|
+
css: boolean;
|
|
14
16
|
};
|
|
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
|
loader: string;
|
|
@@ -45,58 +53,48 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
|
|
|
45
53
|
} | {
|
|
46
54
|
oneOf: ({
|
|
47
55
|
test: RegExp;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
localIdentName: string;
|
|
55
|
-
};
|
|
56
|
-
postcssOptions?: undefined;
|
|
57
|
-
};
|
|
58
|
-
} | {
|
|
59
|
-
loader: string;
|
|
60
|
-
options: {
|
|
61
|
-
postcssOptions: {
|
|
62
|
-
plugins: string[][];
|
|
63
|
-
};
|
|
64
|
-
modules?: undefined;
|
|
65
|
-
};
|
|
66
|
-
})[];
|
|
67
|
-
} | {
|
|
68
|
-
use: (string | {
|
|
69
|
-
loader: string;
|
|
70
|
-
options: {
|
|
71
|
-
postcssOptions: {
|
|
72
|
-
plugins: string[][];
|
|
73
|
-
};
|
|
56
|
+
type: string;
|
|
57
|
+
use: (string | {
|
|
58
|
+
loader: string;
|
|
59
|
+
options: {
|
|
60
|
+
postcssOptions: {
|
|
61
|
+
plugins: string[][];
|
|
74
62
|
};
|
|
75
|
-
}
|
|
76
|
-
resourceQuery?: undefined;
|
|
63
|
+
};
|
|
77
64
|
})[];
|
|
78
|
-
type?: undefined;
|
|
79
|
-
generator?: undefined;
|
|
80
65
|
loader?: undefined;
|
|
66
|
+
generator?: undefined;
|
|
67
|
+
} | {
|
|
68
|
+
test: RegExp;
|
|
69
|
+
type: string;
|
|
70
|
+
loader: string;
|
|
71
|
+
use: {
|
|
72
|
+
loader: string;
|
|
73
|
+
options: {
|
|
74
|
+
api: string;
|
|
75
|
+
implementation: string;
|
|
76
|
+
};
|
|
77
|
+
}[];
|
|
78
|
+
generator?: undefined;
|
|
81
79
|
} | {
|
|
82
80
|
test: RegExp;
|
|
83
81
|
type: string;
|
|
84
82
|
generator: {
|
|
85
83
|
filename: string;
|
|
86
84
|
};
|
|
87
|
-
|
|
85
|
+
use?: undefined;
|
|
88
86
|
loader?: undefined;
|
|
89
87
|
} | {
|
|
90
88
|
test: RegExp;
|
|
91
89
|
type: string;
|
|
92
|
-
|
|
93
|
-
generator?: undefined;
|
|
90
|
+
use?: undefined;
|
|
94
91
|
loader?: undefined;
|
|
92
|
+
generator?: undefined;
|
|
95
93
|
} | {
|
|
96
94
|
test: RegExp;
|
|
97
95
|
loader: string;
|
|
98
|
-
oneOf?: undefined;
|
|
99
96
|
type?: undefined;
|
|
97
|
+
use?: undefined;
|
|
100
98
|
generator?: undefined;
|
|
101
99
|
})[];
|
|
102
100
|
test?: undefined;
|
|
@@ -12,18 +12,17 @@ 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");
|
|
18
19
|
const core_1 = require("@rspack/core");
|
|
19
|
-
const vueStyleLoader = require.resolve('vue-style-loader');
|
|
20
|
-
const cssLoader = require.resolve('css-loader');
|
|
21
20
|
const lessLoader = require.resolve('less-loader');
|
|
22
21
|
const sassLoader = require.resolve('sass-loader');
|
|
23
22
|
const postcssLoader = require.resolve('postcss-loader');
|
|
24
|
-
function default_1(
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
function default_1(_a) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
25
|
+
var _b, _c, _d;
|
|
27
26
|
const customBaseConfig = customConfig.base;
|
|
28
27
|
const getCustomAliasConfig = () => {
|
|
29
28
|
const { alias } = customBaseConfig || {};
|
|
@@ -36,9 +35,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
36
35
|
return custAliasConfig;
|
|
37
36
|
};
|
|
38
37
|
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
39
|
-
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;
|
|
40
39
|
const basicPlugins = [];
|
|
41
|
-
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 : {};
|
|
42
41
|
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
43
42
|
if (Object.keys(formatObj).length !== 0) {
|
|
44
43
|
basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
|
|
@@ -48,15 +47,23 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
48
47
|
output: {
|
|
49
48
|
path: path_1.default.join(projectPath, '/dist'),
|
|
50
49
|
filename: 'js/[name].[chunkhash].js',
|
|
51
|
-
|
|
50
|
+
chunkFilename: 'js/[name].[chunkhash].js',
|
|
51
|
+
cssFilename: 'css/[id].css',
|
|
52
|
+
cssChunkFilename: 'css/[id].css',
|
|
53
|
+
assetModuleFilename: 'assets/[name]_[id][ext]',
|
|
52
54
|
publicPath,
|
|
53
55
|
clean: true
|
|
54
56
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
type: 'filesystem'
|
|
57
|
+
experiments: {
|
|
58
|
+
css: true
|
|
58
59
|
},
|
|
60
|
+
target: ['web', 'es5'],
|
|
59
61
|
module: {
|
|
62
|
+
parser: {
|
|
63
|
+
'css/auto': {
|
|
64
|
+
namedExports: false
|
|
65
|
+
}
|
|
66
|
+
},
|
|
60
67
|
rules: [
|
|
61
68
|
{
|
|
62
69
|
test: /\.vue$/,
|
|
@@ -88,136 +95,32 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
88
95
|
},
|
|
89
96
|
{
|
|
90
97
|
oneOf: [
|
|
91
|
-
{
|
|
92
|
-
test: /\.css$/,
|
|
93
|
-
oneOf: [
|
|
94
|
-
{
|
|
95
|
-
resourceQuery: /module/,
|
|
96
|
-
use: [
|
|
97
|
-
vueStyleLoader,
|
|
98
|
-
{
|
|
99
|
-
loader: cssLoader,
|
|
100
|
-
options: {
|
|
101
|
-
modules: {
|
|
102
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
loader: postcssLoader,
|
|
108
|
-
options: {
|
|
109
|
-
postcssOptions: {
|
|
110
|
-
plugins: [['autoprefixer']]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
use: [
|
|
118
|
-
env === 'dev'
|
|
119
|
-
? vueStyleLoader
|
|
120
|
-
: core_1.CssExtractRspackPlugin.loader,
|
|
121
|
-
cssLoader,
|
|
122
|
-
{
|
|
123
|
-
loader: postcssLoader,
|
|
124
|
-
options: {
|
|
125
|
-
postcssOptions: {
|
|
126
|
-
plugins: [['autoprefixer']]
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
98
|
{
|
|
135
99
|
test: /\.less$/,
|
|
136
|
-
|
|
100
|
+
type: 'css',
|
|
101
|
+
use: [
|
|
137
102
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
modules: {
|
|
145
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
loader: postcssLoader,
|
|
151
|
-
options: {
|
|
152
|
-
postcssOptions: {
|
|
153
|
-
plugins: [['autoprefixer']]
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
lessLoader
|
|
158
|
-
]
|
|
103
|
+
loader: postcssLoader,
|
|
104
|
+
options: {
|
|
105
|
+
postcssOptions: {
|
|
106
|
+
plugins: [['autoprefixer']]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
159
109
|
},
|
|
160
|
-
|
|
161
|
-
use: [
|
|
162
|
-
env === 'dev'
|
|
163
|
-
? vueStyleLoader
|
|
164
|
-
: core_1.CssExtractRspackPlugin.loader,
|
|
165
|
-
cssLoader,
|
|
166
|
-
{
|
|
167
|
-
loader: postcssLoader,
|
|
168
|
-
options: {
|
|
169
|
-
postcssOptions: {
|
|
170
|
-
plugins: [['autoprefixer']]
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
lessLoader
|
|
175
|
-
]
|
|
176
|
-
}
|
|
110
|
+
lessLoader
|
|
177
111
|
]
|
|
178
112
|
},
|
|
179
113
|
{
|
|
180
114
|
test: /\.scss$/,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
use: [
|
|
185
|
-
vueStyleLoader,
|
|
186
|
-
{
|
|
187
|
-
loader: cssLoader,
|
|
188
|
-
options: {
|
|
189
|
-
modules: {
|
|
190
|
-
localIdentName: 'moduleStyle_[local]_[contenthash:8]'
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
loader: postcssLoader,
|
|
196
|
-
options: {
|
|
197
|
-
postcssOptions: {
|
|
198
|
-
plugins: [['autoprefixer']]
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
sassLoader
|
|
203
|
-
]
|
|
204
|
-
},
|
|
115
|
+
type: 'css',
|
|
116
|
+
loader: sassLoader,
|
|
117
|
+
use: [
|
|
205
118
|
{
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
{
|
|
212
|
-
loader: postcssLoader,
|
|
213
|
-
options: {
|
|
214
|
-
postcssOptions: {
|
|
215
|
-
plugins: [['autoprefixer']]
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
sassLoader
|
|
220
|
-
]
|
|
119
|
+
loader: sassLoader,
|
|
120
|
+
options: {
|
|
121
|
+
api: 'modern-compiler',
|
|
122
|
+
implementation: require.resolve('sass-embedded')
|
|
123
|
+
}
|
|
221
124
|
}
|
|
222
125
|
]
|
|
223
126
|
},
|
|
@@ -270,13 +173,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
270
173
|
},
|
|
271
174
|
hash: true
|
|
272
175
|
}),
|
|
273
|
-
new core_1.CssExtractRspackPlugin({
|
|
274
|
-
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
275
|
-
ignoreOrder: true
|
|
276
|
-
}),
|
|
277
176
|
...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
|
|
278
177
|
]
|
|
279
178
|
};
|
|
280
179
|
});
|
|
281
180
|
}
|
|
282
|
-
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"));
|
|
@@ -46,16 +57,19 @@ const core_1 = require("@rspack/core");
|
|
|
46
57
|
const BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
47
58
|
const isAnalyze = process.env.ANALYZE === 'true';
|
|
48
59
|
function default_1(options) {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
50
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
var _a, _b, _c, _d, _e;
|
|
51
62
|
const { projectPath, customConfig, templateType } = options;
|
|
52
|
-
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './
|
|
63
|
+
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
53
64
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'prod' }));
|
|
54
|
-
const consoleAvailable = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.console) !== null && _b !== void 0 ? _b : config_1.initConfig.console;
|
|
55
65
|
const isPublicDirExist = yield fs_extra_1.default.exists(path_1.default.join(projectPath, '/public'));
|
|
56
|
-
const copyConfig = (
|
|
57
|
-
const customDevtool = (
|
|
66
|
+
const copyConfig = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.copy) !== null && _b !== void 0 ? _b : config_1.initConfig.copy;
|
|
67
|
+
const customDevtool = (_c = customConfig.prod.devtool) !== null && _c !== void 0 ? _c : customConfig.base.devtool;
|
|
58
68
|
return (0, webpack_merge_1.merge)(baseConfig, {
|
|
69
|
+
output: {
|
|
70
|
+
cssFilename: 'css/[name].[contenthash].css',
|
|
71
|
+
cssChunkFilename: 'css/[name].[contenthash].css'
|
|
72
|
+
},
|
|
59
73
|
performance: {
|
|
60
74
|
hints: false
|
|
61
75
|
},
|
|
@@ -115,9 +129,8 @@ function default_1(options) {
|
|
|
115
129
|
color: tools_1.colorConfig.theme,
|
|
116
130
|
profile: false
|
|
117
131
|
}),
|
|
118
|
-
...((
|
|
132
|
+
...((_e = (_d = customConfig.prod) === null || _d === void 0 ? void 0 : _d.plugins) !== null && _e !== void 0 ? _e : [])
|
|
119
133
|
]
|
|
120
134
|
});
|
|
121
135
|
});
|
|
122
136
|
}
|
|
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)}`);
|