@lark-apaas/miaoda-presets 0.1.0-alpha.1 → 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,11 @@ const eslint_1 = __importDefault(require("./recommend/eslint"));
13
13
  const importPlugin = require('eslint-plugin-import');
14
14
  function createEslintConfig() {
15
15
  return typescript_eslint_1.default.config({ ignores: ['dist', 'node_modules', 'build'] }, {
16
- extends: [js_1.default.configs.recommended, eslint_1.default, ...typescript_eslint_1.default.configs.recommended],
16
+ extends: [
17
+ js_1.default.configs.recommended,
18
+ ...typescript_eslint_1.default.configs.recommended,
19
+ eslint_1.default,
20
+ ],
17
21
  files: ['src/**/*.{ts,tsx}'],
18
22
  languageOptions: {
19
23
  ecmaVersion: 2020,
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable no-undef */
2
3
  /**
3
4
  * play-render 使用的 umd-loader
4
5
  */
@@ -58,11 +59,10 @@ function loadScriptsWithDeps() {
58
59
  // Create loading promise for this script
59
60
  const loadingPromise = Promise.all(
60
61
  // Map dependencies to promises
61
- script.deps.map((dep) => loadWithDeps(dep)))
62
- .then(() => {
63
- // After all dependencies are loaded, load this script
64
- return loadScript(script.src);
65
- })
62
+ script.deps.map(dep => loadWithDeps(dep)))
63
+ .then(() =>
64
+ // After all dependencies are loaded, load this script
65
+ loadScript(script.src))
66
66
  .then(() => {
67
67
  // Mark as loaded after successful load
68
68
  loaded.add(name);
@@ -73,7 +73,7 @@ function loadScriptsWithDeps() {
73
73
  return loadingPromise;
74
74
  }
75
75
  // Load all scripts
76
- return Promise.all(Object.keys(scripts).map((name) => loadWithDeps(name)));
76
+ return Promise.all(Object.keys(scripts).map(name => loadWithDeps(name)));
77
77
  }
78
78
  // Start loading all scripts
79
79
  window.__FEISUDA_SCRIPTS_LOADED__ = loadScriptsWithDeps();
@@ -24,5 +24,12 @@ exports.default = {
24
24
  // Import 相关检查
25
25
  'import/no-unresolved': 'error', // 检查导入路径是否存在
26
26
  'import/named': 'error', // 检查命名导入是否存在
27
+ 'no-restricted-syntax': [
28
+ 'error',
29
+ {
30
+ selector: "CallExpression[callee.object.name='console'][callee.property.name=/^(log|warn|info|debug|trace)$/]",
31
+ message: 'Avoid using console.log, console.warn, etc. Use `@byted/spark-framework/logger` instead.',
32
+ },
33
+ ],
27
34
  },
28
35
  };
@@ -59,7 +59,7 @@ function createRecommendRspackConfig(options) {
59
59
  runtime: 'automatic',
60
60
  ...(isDev
61
61
  ? {
62
- importSource: path_1.default.dirname(require.resolve('@apaas-ai/miaoda-inspector-jsx-runtime')),
62
+ importSource: path_1.default.dirname(require.resolve('@lark-apaas/miaoda-inspector-jsx-runtime')),
63
63
  }
64
64
  : {}),
65
65
  development: isDev,
@@ -69,7 +69,9 @@ function createRecommendRspackConfig(options) {
69
69
  },
70
70
  },
71
71
  },
72
- ...(isDev ? [require.resolve('@apaas-ai/miaoda-inspector-babel-plugin')] : []),
72
+ ...(isDev
73
+ ? [require.resolve('@lark-apaas/miaoda-inspector-babel-plugin')]
74
+ : []),
73
75
  ],
74
76
  },
75
77
  ],
@@ -94,7 +96,7 @@ function createRecommendRspackConfig(options) {
94
96
  maxChunks: 1,
95
97
  }),
96
98
  ],
97
- optimization: {
99
+ optimization: isDev ? {} : {
98
100
  moduleIds: 'deterministic',
99
101
  concatenateModules: true,
100
102
  minimize: true, // 对应vite的minify配置
@@ -41,7 +41,7 @@ function createRecommendTailwindConfig(options) {
41
41
  darkMode: 'class',
42
42
  content: [
43
43
  // 让 framework 里的 tailwind 生效
44
- path.join(path.dirname(require.resolve('@lark-apaas/client-core')), '/**/*.js'),
44
+ path.join(path.dirname(require.resolve('@lark-apaas/miaoda-toolkit')), '/**/*.js'),
45
45
  ],
46
46
  prefix: '',
47
47
  plugins: [],
@@ -8,13 +8,14 @@ const path_1 = __importDefault(require("path"));
8
8
  const core_1 = __importDefault(require("@rspack/core"));
9
9
  const rspack_1 = require("./recommend/rspack");
10
10
  const webpack_merge_1 = __importDefault(require("webpack-merge"));
11
+ // 妙搭template-v3使用的配置构造函数
11
12
  // eslint-disable-next-line max-lines-per-function
12
13
  function createRspackConfig(options) {
13
- const { enableReactRrefresh = false, isDev = true } = options;
14
- console.log('isDev:', isDev);
14
+ const { enableReactRrefresh = false, isDevBuildMode = true } = options;
15
+ console.log('isDevBuildMode:', isDevBuildMode);
15
16
  console.log('enableReactRrefresh:', enableReactRrefresh);
16
17
  // 构建外部依赖配置,对应vite的rollupOptions.external和globals
17
- const externals = isDev
18
+ const externals = isDevBuildMode
18
19
  ? {
19
20
  antd: 'antd',
20
21
  '@ant-design/icons': 'icons',
@@ -24,22 +25,27 @@ function createRspackConfig(options) {
24
25
  echarts: 'echarts',
25
26
  }
26
27
  : {};
27
- const recommendConfig = (0, rspack_1.createRecommendRspackConfig)({ enableReactRrefresh, isDev });
28
+ const recommendConfig = (0, rspack_1.createRecommendRspackConfig)({
29
+ enableReactRrefresh,
30
+ isDev: isDevBuildMode,
31
+ });
28
32
  return (0, webpack_merge_1.default)(recommendConfig, {
29
- mode: isDev ? 'development' : 'production',
33
+ mode: isDevBuildMode ? 'development' : 'production',
30
34
  entry: './src/index.tsx',
31
35
  output: {
32
36
  publicPath: '/',
33
37
  // path: path.resolve(__dirname, 'dist'),
34
38
  filename: 'assets/index.js',
35
39
  cssFilename: 'assets/index.css',
36
- assetModuleFilename: (pathData) => {
40
+ assetModuleFilename: pathData => {
37
41
  // 对应vite的assetFileNames逻辑
38
42
  const ext = path_1.default.extname(pathData.filename || '');
39
43
  if (ext === '.css') {
40
44
  return 'assets/index.css';
41
45
  }
42
- return pathData.filename ? `assets/${pathData.filename}` : 'assets/asset-[hash][ext]';
46
+ return pathData.filename
47
+ ? `assets/${pathData.filename}`
48
+ : 'assets/asset-[hash][ext]';
43
49
  },
44
50
  library: {
45
51
  type: 'self', // 对应vite的iife格式
@@ -55,7 +61,7 @@ function createRspackConfig(options) {
55
61
  },
56
62
  extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
57
63
  },
58
- devServer: isDev
64
+ devServer: isDevBuildMode
59
65
  ? undefined
60
66
  : {
61
67
  host: '::',
@@ -85,5 +91,46 @@ function createRspackConfig(options) {
85
91
  },
86
92
  }),
87
93
  ],
94
+ optimization: {
95
+ moduleIds: 'deterministic',
96
+ concatenateModules: true,
97
+ minimize: true, // 对应vite的minify配置
98
+ minimizer: [
99
+ new core_1.default.SwcJsMinimizerRspackPlugin({
100
+ minimizerOptions: {
101
+ // 保持不压缩
102
+ minify: !isDevBuildMode,
103
+ mangle: !isDevBuildMode,
104
+ format: {
105
+ beautify: isDevBuildMode,
106
+ comments: false,
107
+ },
108
+ compress: {
109
+ keep_classnames: true,
110
+ keep_fnames: true,
111
+ keep_fargs: !isDevBuildMode,
112
+ unused: true,
113
+ dead_code: true,
114
+ drop_debugger: true,
115
+ // FIXME: 先临时开始 console.log
116
+ // drop_console: !isDevBuildMode,
117
+ const_to_let: !isDevBuildMode,
118
+ booleans_as_integers: !isDevBuildMode,
119
+ booleans: !isDevBuildMode,
120
+ // maybe unsafe
121
+ reduce_funcs: !isDevBuildMode,
122
+ reduce_vars: !isDevBuildMode,
123
+ },
124
+ },
125
+ }),
126
+ new core_1.default.LightningCssMinimizerRspackPlugin(),
127
+ ],
128
+ sideEffects: true,
129
+ usedExports: true,
130
+ innerGraph: true,
131
+ providedExports: true,
132
+ mergeDuplicateChunks: true,
133
+ splitChunks: false, // 禁用代码分割,保持单文件输出
134
+ },
88
135
  });
89
136
  }
@@ -8,7 +8,9 @@ const webpack_merge_1 = __importDefault(require("webpack-merge"));
8
8
  const tailwind_1 = require("./recommend/tailwind");
9
9
  function createTailwindConfig(options) {
10
10
  const { isDevBuildMode = true } = options;
11
- const recommendConfig = (0, tailwind_1.createRecommendTailwindConfig)({ isDev: isDevBuildMode });
11
+ const recommendConfig = (0, tailwind_1.createRecommendTailwindConfig)({
12
+ isDev: isDevBuildMode,
13
+ });
12
14
  return (0, webpack_merge_1.default)(recommendConfig, {
13
15
  content: ['./src/**/*.{ts,tsx}'],
14
16
  });
package/package.json CHANGED
@@ -1,35 +1,19 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-presets",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.10",
4
4
  "files": [
5
5
  "lib"
6
6
  ],
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
- "scripts": {
11
- "build": "tsc && npm run copy:json",
12
- "copy:json": "cp -r src/*.json lib",
13
- "watch": "tsc --watch",
14
- "bump": "changeset version",
15
- "change": "changeset",
16
- "check": "biome check --write",
17
- "dev": "rslib build --watch",
18
- "format": "biome format --write",
19
- "storybook": "storybook dev",
20
- "test": "echo 0",
21
- "prepublishOnly": "npm run build"
22
- },
23
10
  "dependencies": {
24
- "@lark-apaas/miaoda-inspector-babel-plugin": "workspace:*",
25
- "@lark-apaas/miaoda-inspector-jsx-runtime": "workspace:*",
26
11
  "@babel/core": "^7.28.0",
27
12
  "@babel/parser": "^7.28.0",
28
13
  "@babel/traverse": "^7.28.0",
29
14
  "@babel/types": "^7.28.2",
30
15
  "@eslint/js": "^9.34.0",
31
16
  "@react-dev-inspector/middleware": "^2.0.1",
32
- "@rsdoctor/rspack-plugin": "^1.1.8",
33
17
  "@rspack/dev-server": "^1.1.3",
34
18
  "@rspack/plugin-react-refresh": "^1.4.3",
35
19
  "dayjs": "^1.11.14",
@@ -43,7 +27,9 @@
43
27
  "tsconfig-paths-webpack-plugin": "^4.2.0",
44
28
  "typescript-eslint": "^8.41.0",
45
29
  "webpack-merge": "^6.0.1",
46
- "tailwindcss": "^4.1.13"
30
+ "tailwindcss": "^4.1.13",
31
+ "@lark-apaas/miaoda-inspector-babel-plugin": "0.1.0-alpha.5",
32
+ "@lark-apaas/miaoda-inspector-jsx-runtime": "0.1.0-alpha.6"
47
33
  },
48
34
  "devDependencies": {
49
35
  "@biomejs/biome": "2.0.6",
@@ -57,5 +43,17 @@
57
43
  "peerDependencies": {
58
44
  "react": ">=16.14.0",
59
45
  "react-dom": ">=16.14.0"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc && npm run copy:json",
49
+ "copy:json": "cp -r src/*.json lib",
50
+ "watch": "tsc --watch",
51
+ "bump": "changeset version",
52
+ "change": "changeset",
53
+ "check": "biome check --write",
54
+ "dev": "rslib build --watch",
55
+ "format": "biome format --write",
56
+ "storybook": "storybook dev",
57
+ "test": "echo 0"
60
58
  }
61
- }
59
+ }