swico 2.0.0-beta.9 → 2.0.0

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/README.md CHANGED
@@ -7,15 +7,15 @@ Swico,发音近似于“斯威扣”。
7
7
 
8
8
  ## 主要特性
9
9
 
10
- - 构建工具基于Webpack5,并配合esbuild-loader和swc-loader提升编译构建速率。
10
+ - 构建工具基于Rspack 1.x,基于Rust多线程驱动,显著提升编译性能。
11
11
 
12
12
  - 提供Vue3和React18两种开发模板选择,默认集成TypeScript5。同时最大化统一这两种模板的开发API。
13
13
 
14
- - 提供可配置化路由方案,基于React-Router6和Vue-Router4进行二次封装,支持路由嵌套,懒加载,动态参数,装饰校验等功能。
14
+ - 提供可配置化路由方案,基于React-Router7和Vue-Router4进行二次封装,支持路由嵌套,懒加载,动态参数,装饰校验等功能。
15
15
 
16
- - 内置ESLint + Prettier + Husky三大前端编码风格以及代码提交规范约束插件,保证代码风格统一以及 Git 提交规范。
16
+ - 内置支持ESLint / Prettier / Husky等编码风格以及代码提交规范约束功能配置,保证代码风格统一以及 Git 提交规范。
17
17
 
18
- - 提供配置文件可对部分项目配置进行修改扩展,例如Alias映射,本地请求代理等。
18
+ - 提供配置文件可按需对架构配置进行修改扩展,例如Alias映射,本地请求代理等。
19
19
 
20
20
 
21
21
  官方文档:[SWICO 官方文档](https://scw1997.github.io/swico-docs)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "2.0.0-beta.9",
3
+ "version": "2.0.0",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -10,9 +10,7 @@
10
10
  "ecmascript",
11
11
  "react",
12
12
  "vue",
13
- "cli",
14
13
  "swico",
15
- "template",
16
14
  "rspack"
17
15
  ],
18
16
  "bin": {
@@ -21,7 +19,8 @@
21
19
  "scripts": {
22
20
  "compile": "tsc && ts-node ./src/task.ts",
23
21
  "publish:offical": "npm run compile && cd ./dist && npm publish",
24
- "publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta"
22
+ "publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta",
23
+ "lint:fix": "eslint --fix src/**/*.{js,jsx,ts,tsx} "
25
24
  },
26
25
  "repository": {
27
26
  "type": "git",
@@ -30,48 +29,52 @@
30
29
  "author": "scw",
31
30
  "license": "ISC",
32
31
  "dependencies": {
33
- "@rspack/core": "1.3.4",
34
- "@rspack/dev-server": "^1.1.1",
35
- "@vue/compiler-sfc": "3.4.14",
32
+ "@rspack/dev-server": "1.1.1",
33
+ "@vue/compiler-sfc": "3.5.13",
36
34
  "autoprefixer": "10.3.7",
37
35
  "chalk": "4.1.2",
38
36
  "chokidar": "3.6.0",
39
37
  "commander": "12.0.0",
40
38
  "cross-spawn": "7.0.5",
41
- "css-loader": "6.3.0",
42
- "eslint-webpack-plugin": "4.0.0",
39
+ "css-loader": "7.1.2",
40
+ "eslint-rspack-plugin": "4.2.1",
43
41
  "fs-extra": "11.3.0",
44
- "html-loader": "5.0.0",
45
- "less": "4.1.2",
42
+ "html-loader": "5.1.0",
43
+ "less": "4.3.0",
46
44
  "less-loader": "12.2.0",
47
45
  "ora": "5.4.1",
48
46
  "portfinder": "1.0.32",
49
47
  "postcss-loader": "8.1.0",
50
48
  "postcss-preset-env": "9.3.0",
51
49
  "qs": "6.13.0",
52
- "react-router-dom": "6.23.0",
53
- "sass-embedded": "^1.86.3",
50
+ "react-router": "7.5.0",
51
+ "sass-embedded": "1.86.3",
54
52
  "sass-loader": "16.0.5",
55
53
  "style-loader": "3.3.0",
56
- "ts-checker-rspack-plugin": "^1.1.1",
54
+ "ts-checker-rspack-plugin": "1.1.1",
57
55
  "ts-node": "10.9.1",
58
56
  "vue-loader": "17.4.2",
59
- "vue-router": "^4.2.5",
57
+ "vue-router": "4.5.0",
60
58
  "vue-style-loader": "4.1.3",
61
59
  "webpack-bundle-analyzer": "4.9.1",
62
- "webpack-merge": "^6.0.1",
63
- "webpackbar": "^7.0.0"
60
+ "webpack-merge": "6.0.1"
64
61
  },
65
62
  "devDependencies": {
63
+ "@rspack/core": "1.3.5",
64
+ "@eslint/js": "9.24.0",
66
65
  "@types/node": "22.13.10",
67
- "@types/react": "18.2.79",
68
- "@types/react-dom": "18.2.25",
69
- "@typescript-eslint/eslint-plugin": "6.19.0",
70
- "@typescript-eslint/parser": "6.19.0",
71
- "eslint": "8.48.0",
72
- "react": "~18.2.0",
73
- "react-dom": "~18.2.0",
74
- "typescript": "5.3.3",
75
- "vue": "~3.4.14"
66
+ "@types/react": "19.1.0",
67
+ "@types/react-dom": "19.1.0",
68
+ "eslint": "9.24.0",
69
+ "globals": "16.0.0",
70
+ "prettier": "3.5.3",
71
+ "react": "~19.1.0",
72
+ "react-dom": "~19.1.0",
73
+ "typescript": "5.8.3",
74
+ "typescript-eslint": "8.30.1",
75
+ "vue": "~3.5.13"
76
+ },
77
+ "engines": {
78
+ "node": ">=20.0.0"
76
79
  }
77
80
  }
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 (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
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
  };
@@ -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");
@@ -33,6 +34,7 @@ function default_1() {
33
34
  templateType
34
35
  });
35
36
  const compiler = (0, core_1.rspack)(buildConfig);
37
+ tools_1.toast.info('Building...');
36
38
  compiler.run((err, stats) => {
37
39
  if (err) {
38
40
  tools_1.toast.error(err.stack || err.toString());
@@ -46,8 +48,7 @@ function default_1() {
46
48
  if (stats.hasWarnings()) {
47
49
  tools_1.toast.warning(info.warnings.map((item) => item.stack || item.message));
48
50
  }
49
- tools_1.toast.success('Build complete');
51
+ tools_1.toast.success(`Build complete ${(info === null || info === void 0 ? void 0 : info.time) ? `in ${(info.time / 1000).toFixed(2)}s` : ''}`);
50
52
  });
51
53
  });
52
54
  }
53
- exports.default = default_1;
@@ -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,7 +29,7 @@ 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, '/.eslintrc')], {
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,
@@ -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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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 eslint_webpack_plugin_1 = __importDefault(require("eslint-webpack-plugin"));
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' }));
@@ -52,11 +63,8 @@ function default_1(options) {
52
63
  mode: 'development',
53
64
  stats: 'none',
54
65
  devtool: templateType === 'vue'
55
- ? customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'cheap-module-source-map'
56
- : customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'eval-cheap-module-source-map',
57
- optimization: {
58
- runtimeChunk: 'single'
59
- },
66
+ ? (customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'cheap-module-source-map')
67
+ : (customDevtool !== null && customDevtool !== void 0 ? customDevtool : 'eval-cheap-module-source-map'),
60
68
  devServer: {
61
69
  historyApiFallback: {
62
70
  index: `${baseConfig.output.publicPath}index.html`
@@ -85,13 +93,15 @@ function default_1(options) {
85
93
  }
86
94
  },
87
95
  typescript: {
96
+ memoryLimit: 15000,
88
97
  diagnosticOptions: {
89
98
  semantic: true,
90
99
  syntactic: true
91
100
  }
92
101
  }
93
102
  }),
94
- new eslint_webpack_plugin_1.default({
103
+ new eslint_rspack_plugin_1.default({
104
+ configType: 'flat',
95
105
  context: path_1.default.join(projectPath, '/src'),
96
106
  failOnError: false,
97
107
  failOnWarning: true,
@@ -104,4 +114,3 @@ function default_1(options) {
104
114
  });
105
115
  });
106
116
  }
107
- exports.default = default_1;
@@ -112,7 +112,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
112
112
  extensions: string[];
113
113
  alias: {
114
114
  '@': string;
115
- 'react-router-dom': string;
115
+ 'react-router': string;
116
116
  qs: string;
117
117
  };
118
118
  };
@@ -12,16 +12,16 @@ 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");
18
- const cssLoader = require.resolve('css-loader');
19
19
  const lessLoader = require.resolve('less-loader');
20
20
  const sassLoader = require.resolve('sass-loader');
21
21
  const postcssLoader = require.resolve('postcss-loader');
22
- function default_1({ projectPath, entryPath, env, customConfig }) {
23
- var _a, _b, _c;
24
- return __awaiter(this, void 0, void 0, function* () {
22
+ function default_1(_a) {
23
+ return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
24
+ var _b, _c, _d;
25
25
  const customBaseConfig = customConfig.base;
26
26
  const getCustomAliasConfig = () => {
27
27
  const { alias } = customBaseConfig || {};
@@ -34,9 +34,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
34
34
  return custAliasConfig;
35
35
  };
36
36
  const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
37
- const routerBase = ((_a = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _a === void 0 ? void 0 : _a.base) || config_1.initConfig.router.base;
37
+ 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
38
  const basicPlugins = [];
39
- const defineConfigData = (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _b === void 0 ? void 0 : _b.define) !== null && _c !== void 0 ? _c : {};
39
+ 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
40
  const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
41
41
  if (Object.keys(formatObj).length !== 0) {
42
42
  basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
@@ -47,8 +47,8 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
47
47
  path: path_1.default.join(projectPath, '/dist'),
48
48
  filename: 'js/[name].[chunkhash].js',
49
49
  chunkFilename: 'js/[name].[chunkhash].js',
50
- cssFilename: 'css/[name].[contenthash].css',
51
- cssChunkFilename: 'css/[name].[contenthash].css',
50
+ cssFilename: 'css/[id].css',
51
+ cssChunkFilename: 'css/[id].css',
52
52
  assetModuleFilename: 'assets/[name]_[chunkhash][ext]',
53
53
  publicPath,
54
54
  clean: true
@@ -97,7 +97,6 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
97
97
  test: /\.css$/,
98
98
  type: 'css/auto',
99
99
  use: [
100
- cssLoader,
101
100
  {
102
101
  loader: postcssLoader,
103
102
  options: {
@@ -172,7 +171,7 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
172
171
  },
173
172
  resolve: {
174
173
  extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
175
- alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router-dom': path_1.default.dirname(require.resolve('react-router-dom')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
174
+ 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())
176
175
  },
177
176
  externals: customConfig.base.externals,
178
177
  plugins: [
@@ -192,4 +191,3 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
192
191
  };
193
192
  });
194
193
  }
195
- exports.default = default_1;
@@ -11,16 +11,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
11
11
  publicPath: string;
12
12
  clean: boolean;
13
13
  };
14
- experiments: {
15
- css: boolean;
16
- };
17
14
  target: string[];
18
15
  module: {
19
- parser: {
20
- 'css/auto': {
21
- namedExports: boolean;
22
- };
23
- };
24
16
  rules: ({
25
17
  test: RegExp;
26
18
  loader: string;
@@ -30,6 +22,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
30
22
  };
31
23
  use?: undefined;
32
24
  oneOf?: undefined;
25
+ type?: undefined;
26
+ generator?: undefined;
33
27
  } | {
34
28
  test: RegExp;
35
29
  exclude: RegExp;
@@ -50,48 +44,79 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
50
44
  loader?: undefined;
51
45
  options?: undefined;
52
46
  oneOf?: undefined;
47
+ type?: undefined;
48
+ generator?: undefined;
53
49
  } | {
54
- oneOf: ({
55
- test: RegExp;
56
- type: string;
57
- loader: string;
58
- options?: undefined;
59
- generator?: undefined;
60
- } | {
61
- test: RegExp;
62
- type: string;
63
- loader: string;
64
- options: {
65
- api: string;
66
- implementation: string;
67
- };
68
- generator?: undefined;
69
- } | {
70
- test: RegExp;
71
- type: string;
72
- generator: {
73
- filename: string;
74
- };
75
- loader?: undefined;
76
- options?: undefined;
77
- } | {
78
- test: RegExp;
79
- type: string;
80
- loader?: undefined;
81
- options?: undefined;
82
- generator?: undefined;
83
- } | {
50
+ oneOf: {
84
51
  test: RegExp;
85
- loader: string;
86
- type?: undefined;
87
- options?: undefined;
88
- generator?: undefined;
89
- })[];
52
+ oneOf: ({
53
+ resourceQuery: RegExp;
54
+ use: (string | {
55
+ loader: string;
56
+ options: {
57
+ modules: {
58
+ localIdentName: string;
59
+ namedExport: boolean;
60
+ };
61
+ postcssOptions?: undefined;
62
+ };
63
+ } | {
64
+ loader: string;
65
+ options: {
66
+ postcssOptions: {
67
+ plugins: string[][];
68
+ };
69
+ modules?: undefined;
70
+ };
71
+ })[];
72
+ } | {
73
+ use: (string | {
74
+ loader: string;
75
+ options: {
76
+ postcssOptions: {
77
+ plugins: string[][];
78
+ };
79
+ };
80
+ })[];
81
+ resourceQuery?: undefined;
82
+ })[];
83
+ }[];
90
84
  test?: undefined;
91
85
  loader?: undefined;
92
86
  exclude?: undefined;
93
87
  options?: undefined;
94
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;
95
120
  })[];
96
121
  };
97
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({ projectPath, entryPath, env, customConfig }) {
25
- var _a, _b, _c;
26
- return __awaiter(this, void 0, void 0, function* () {
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,12 +37,12 @@ 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 = ((_a = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _a === void 0 ? void 0 : _a.base) || config_1.initConfig.router.base;
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 = (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _b === void 0 ? void 0 : _b.define) !== null && _c !== void 0 ? _c : {};
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.rspack.DefinePlugin(formatObj));
45
+ basicPlugins.push(new core_1.DefinePlugin(formatObj));
45
46
  }
46
47
  return {
47
48
  entry: entryPath,
@@ -49,22 +50,14 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
49
50
  path: path_1.default.join(projectPath, '/dist'),
50
51
  filename: 'js/[name].[chunkhash].js',
51
52
  chunkFilename: 'js/[name].[chunkhash].js',
52
- cssFilename: 'css/[name].[contenthash].css',
53
- cssChunkFilename: 'css/[name].[contenthash].css',
53
+ cssFilename: 'css/[id].css',
54
+ cssChunkFilename: 'css/[id].css',
54
55
  assetModuleFilename: 'assets/[name]_[id][ext]',
55
56
  publicPath,
56
57
  clean: true
57
58
  },
58
- experiments: {
59
- css: true
60
- },
61
59
  target: ['web', 'es5'],
62
60
  module: {
63
- parser: {
64
- 'css/auto': {
65
- namedExports: false
66
- }
67
- },
68
61
  rules: [
69
62
  {
70
63
  test: /\.vue$/,
@@ -97,42 +90,164 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
97
90
  {
98
91
  oneOf: [
99
92
  {
100
- test: /\.less$/,
101
- type: 'css',
102
- loader: lessLoader
103
- },
104
- {
105
- test: /\.scss$/,
106
- type: 'css',
107
- loader: sassLoader,
108
- options: {
109
- api: 'modern-compiler',
110
- implementation: require.resolve('sass-embedded')
111
- }
112
- },
113
- {
114
- test: /\.(jpg|png|gif|webp|bmp|jpeg|svg)$/,
115
- type: 'asset',
116
- generator: {
117
- filename: 'images/[name]_[contenthash][ext]'
118
- }
119
- },
120
- {
121
- test: /\.(otf|eot|woff2?|ttf)$/i,
122
- type: 'asset',
123
- generator: {
124
- filename: 'fonts/[name]_[contenthash][ext]'
125
- }
93
+ test: /\.css$/,
94
+ oneOf: [
95
+ {
96
+ resourceQuery: /module/,
97
+ use: [
98
+ vueStyleLoader,
99
+ {
100
+ loader: cssLoader,
101
+ options: {
102
+ modules: {
103
+ localIdentName: 'moduleStyle_[local]_[contenthash:8]',
104
+ namedExport: false
105
+ }
106
+ }
107
+ },
108
+ {
109
+ loader: postcssLoader,
110
+ options: {
111
+ postcssOptions: {
112
+ plugins: [['autoprefixer']]
113
+ }
114
+ }
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ use: [
120
+ env === 'dev'
121
+ ? vueStyleLoader
122
+ : core_1.CssExtractRspackPlugin.loader,
123
+ cssLoader,
124
+ {
125
+ loader: postcssLoader,
126
+ options: {
127
+ postcssOptions: {
128
+ plugins: [['autoprefixer']]
129
+ }
130
+ }
131
+ }
132
+ ]
133
+ }
134
+ ]
126
135
  },
127
136
  {
128
- test: /\.(txt|xml)$/i,
129
- type: 'asset/source'
137
+ test: /\.less$/,
138
+ oneOf: [
139
+ {
140
+ resourceQuery: /module/,
141
+ use: [
142
+ vueStyleLoader,
143
+ {
144
+ loader: cssLoader,
145
+ options: {
146
+ modules: {
147
+ localIdentName: 'moduleStyle_[local]_[contenthash:8]',
148
+ namedExport: false
149
+ }
150
+ }
151
+ },
152
+ {
153
+ loader: postcssLoader,
154
+ options: {
155
+ postcssOptions: {
156
+ plugins: [['autoprefixer']]
157
+ }
158
+ }
159
+ },
160
+ lessLoader
161
+ ]
162
+ },
163
+ {
164
+ use: [
165
+ env === 'dev'
166
+ ? vueStyleLoader
167
+ : core_1.CssExtractRspackPlugin.loader,
168
+ cssLoader,
169
+ {
170
+ loader: postcssLoader,
171
+ options: {
172
+ postcssOptions: {
173
+ plugins: [['autoprefixer']]
174
+ }
175
+ }
176
+ },
177
+ lessLoader
178
+ ]
179
+ }
180
+ ]
130
181
  },
131
182
  {
132
- test: /\.html$/,
133
- loader: require.resolve('html-loader')
183
+ test: /\.scss$/,
184
+ oneOf: [
185
+ {
186
+ resourceQuery: /module/,
187
+ use: [
188
+ vueStyleLoader,
189
+ {
190
+ loader: cssLoader,
191
+ options: {
192
+ modules: {
193
+ localIdentName: 'moduleStyle_[local]_[contenthash:8]',
194
+ namedExport: false
195
+ }
196
+ }
197
+ },
198
+ {
199
+ loader: postcssLoader,
200
+ options: {
201
+ postcssOptions: {
202
+ plugins: [['autoprefixer']]
203
+ }
204
+ }
205
+ },
206
+ sassLoader
207
+ ]
208
+ },
209
+ {
210
+ use: [
211
+ env === 'dev'
212
+ ? vueStyleLoader
213
+ : core_1.CssExtractRspackPlugin.loader,
214
+ cssLoader,
215
+ {
216
+ loader: postcssLoader,
217
+ options: {
218
+ postcssOptions: {
219
+ plugins: [['autoprefixer']]
220
+ }
221
+ }
222
+ },
223
+ sassLoader
224
+ ]
225
+ }
226
+ ]
134
227
  }
135
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')
136
251
  }
137
252
  ]
138
253
  },
@@ -143,13 +258,17 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
143
258
  externals: customConfig.base.externals,
144
259
  plugins: [
145
260
  ...basicPlugins,
261
+ new core_1.CssExtractRspackPlugin({
262
+ filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
263
+ ignoreOrder: true
264
+ }),
146
265
  new vue_loader_1.VueLoaderPlugin(),
147
- new core_1.rspack.DefinePlugin({
266
+ new core_1.DefinePlugin({
148
267
  __VUE_OPTIONS_API__: true,
149
268
  __VUE_PROD_DEVTOOLS__: false,
150
269
  __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
151
270
  }),
152
- new core_1.rspack.HtmlRspackPlugin({
271
+ new core_1.HtmlRspackPlugin({
153
272
  template: path_1.default.join(projectPath, '/src/index.ejs'),
154
273
  filename: 'index.html',
155
274
  minify: true,
@@ -164,4 +283,3 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
164
283
  };
165
284
  });
166
285
  }
167
- 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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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,26 +45,30 @@ 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"));
41
52
  const config_1 = require("../utils/config");
42
53
  const webpack_merge_1 = require("webpack-merge");
43
- const webpackbar_1 = __importDefault(require("webpackbar"));
44
- const tools_1 = require("../utils/tools");
45
54
  const core_1 = require("@rspack/core");
46
55
  const BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
47
56
  const isAnalyze = process.env.ANALYZE === 'true';
48
57
  function default_1(options) {
49
- var _a, _b, _c, _d, _e;
50
58
  return __awaiter(this, void 0, void 0, function* () {
59
+ var _a, _b, _c, _d, _e, _f, _g;
51
60
  const { projectPath, customConfig, templateType } = options;
52
61
  const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
53
62
  const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'prod' }));
63
+ const consoleAvailable = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.console) !== null && _b !== void 0 ? _b : config_1.initConfig.console;
54
64
  const isPublicDirExist = yield fs_extra_1.default.exists(path_1.default.join(projectPath, '/public'));
55
- const copyConfig = (_b = (_a = customConfig.prod) === null || _a === void 0 ? void 0 : _a.copy) !== null && _b !== void 0 ? _b : config_1.initConfig.copy;
56
- const customDevtool = (_c = customConfig.prod.devtool) !== null && _c !== void 0 ? _c : customConfig.base.devtool;
65
+ const copyConfig = (_d = (_c = customConfig.prod) === null || _c === void 0 ? void 0 : _c.copy) !== null && _d !== void 0 ? _d : config_1.initConfig.copy;
66
+ const customDevtool = (_e = customConfig.prod.devtool) !== null && _e !== void 0 ? _e : customConfig.base.devtool;
57
67
  return (0, webpack_merge_1.merge)(baseConfig, {
68
+ output: {
69
+ cssFilename: 'css/[name].[contenthash].css',
70
+ cssChunkFilename: 'css/[name].[contenthash].css'
71
+ },
58
72
  performance: {
59
73
  hints: false
60
74
  },
@@ -63,24 +77,22 @@ function default_1(options) {
63
77
  optimization: {
64
78
  runtimeChunk: true,
65
79
  minimize: true,
66
- splitChunks: {
67
- chunks: 'all',
68
- cacheGroups: {
69
- vendors: {
70
- test: /[\\/]node_modules[\\/]/,
71
- priority: -10,
72
- chunks: 'all',
73
- reuseExistingChunk: true
74
- },
75
- commons: {
76
- minSize: 0,
77
- minChunks: 2,
78
- priority: -20,
79
- chunks: 'all',
80
- reuseExistingChunk: true
80
+ minimizer: [
81
+ new core_1.rspack.SwcJsMinimizerRspackPlugin({
82
+ minimizerOptions: {
83
+ minify: true,
84
+ mangle: true,
85
+ compress: {
86
+ passes: 2,
87
+ drop_console: !consoleAvailable
88
+ },
89
+ format: {
90
+ comments: false
91
+ }
81
92
  }
82
- }
83
- }
93
+ }),
94
+ new core_1.rspack.LightningCssMinimizerRspackPlugin({})
95
+ ]
84
96
  },
85
97
  plugins: [
86
98
  ...(isPublicDirExist || copyConfig.length > 0
@@ -109,14 +121,8 @@ function default_1(options) {
109
121
  })
110
122
  ]
111
123
  : []),
112
- new webpackbar_1.default({
113
- name: 'Swico',
114
- color: tools_1.colorConfig.theme,
115
- profile: false
116
- }),
117
- ...((_e = (_d = customConfig.prod) === null || _d === void 0 ? void 0 : _d.plugins) !== null && _e !== void 0 ? _e : [])
124
+ ...((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : [])
118
125
  ]
119
126
  });
120
127
  });
121
128
  }
122
- exports.default = default_1;
@@ -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-dom';
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 interface DefineGlobalConfigType {
22
- }
21
+ export type DefineGlobalConfigType = object;
23
22
  export declare const defineGlobal: (config: DefineGlobalConfigType) => DefineGlobalConfigType;
@@ -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 react_router_dom_1 = require("react-router-dom");
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(react_router_dom_1.Link, { replace, to, style, className }, children);
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 react_router_dom_2 = require("react-router-dom");
12
- Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_dom_2.Outlet; } });
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; } });
@@ -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
- }, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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 react_router_dom_1 = require("react-router-dom");
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(react_router_dom_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_dom_1.Outlet, null)),
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' ? react_router_dom_1.createHashRouter : react_router_dom_1.createBrowserRouter)(routeList, {
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(react_router_dom_1.RouterProvider, { router: router });
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 react_router_dom_1 = require("react-router-dom");
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, react_router_dom_1.useLocation)();
13
- const params = (0, react_router_dom_1.useParams)();
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, react_router_dom_1.useNavigate)();
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").ExtractPropTypes<{}>>, {}, {}>;
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").ExtractPropTypes<{}>>, {}, {}>;
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 react_router_dom_1 = require("react-router-dom");
6
+ const react_router_1 = require("react-router");
7
7
  const react_1 = __importDefault(require("react"));
8
- exports.default = () => react_1.default.createElement(react_router_dom_1.Outlet, null);
8
+ exports.default = () => react_1.default.createElement(react_router_1.Outlet, null);
@@ -20,7 +20,7 @@ export interface GlobalSwicoConfigType {
20
20
  console?: boolean;
21
21
  define?: Record<string, any>;
22
22
  alias?: Record<string, any>;
23
- proxy?: Record<string, any>;
23
+ proxy?: Array<Record<string, any>>;
24
24
  https?: boolean;
25
25
  copy?: Array<string | {
26
26
  from: string;
@@ -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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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) {
@@ -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['routes'], templateType: any) => any[];
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;
@@ -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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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) {
@@ -181,7 +191,6 @@ const initIndexFile = () => __awaiter(void 0, void 0, void 0, function* () {
181
191
  .replaceAll('\\', '/');
182
192
  if (fileText.includes(`require("${formatHooksPath}");`)) {
183
193
  fileText = fileText.replaceAll(`require("${formatHooksPath}");`, 'require("./project-path/.swico-react/react-hooks");');
184
- yield fs_extra_1.default.writeFile(targetPath, fileText);
185
194
  }
186
195
  const formatDevHistoryPath = path_1.default
187
196
  .resolve(projectPath, './.swico/.dev/history')
@@ -191,11 +200,10 @@ const initIndexFile = () => __awaiter(void 0, void 0, void 0, function* () {
191
200
  .replaceAll('\\', '/');
192
201
  if (fileText.includes(`require("${formatDevHistoryPath}");`)) {
193
202
  fileText = fileText.replaceAll(`require("${formatDevHistoryPath}");`, 'require("./mock-history");');
194
- yield fs_extra_1.default.writeFile(targetPath, fileText);
195
203
  }
196
204
  else if (fileText.includes(`require("${formatProdHistoryPath}");`)) {
197
205
  fileText = fileText.replaceAll(`require("${formatProdHistoryPath}");`, 'require("./mock-history");');
198
- yield fs_extra_1.default.writeFile(targetPath, fileText);
199
206
  }
207
+ yield fs_extra_1.default.writeFile(targetPath, fileText);
200
208
  });
201
209
  exports.initIndexFile = initIndexFile;