@hsu-react/ui 2.3.0 → 2.4.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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 给消费方 webpack 配置用的工具。**构建期模块,不要从应用代码里引**
3
+ * —— 它不依赖 React,也不该进运行时产物。
4
+ *
5
+ * ```js
6
+ * // webpack.config.js(CJS)
7
+ * const { excludeNodeModulesExceptHsuUi } = require("@hsu-react/ui/lib/build/webpack");
8
+ *
9
+ * { test: /\.scss$/, exclude: excludeNodeModulesExceptHsuUi, use: [...] }
10
+ * ```
11
+ */
12
+ /**
13
+ * 判断一个模块路径「是否该被 loader 排除」:node_modules 一律排除,但放行本库。
14
+ *
15
+ * ## 为什么需要它
16
+ *
17
+ * 本库的 es / lib 产物里带着**未编译的 `.module.scss`** 和图片资源,要由消费方自己的
18
+ * loader 处理(这样 CSS Module 的类名哈希、`getLocalIdent` 等策略才由消费方说了算)。
19
+ * 于是每个 webpack 项目都得在 scss / 图片规则上开一个「排除 node_modules,但放行
20
+ * @hsu-react/ui」的例外。
21
+ *
22
+ * ## 为什么不能用正则
23
+ *
24
+ * 手写的版本几乎都是 `/node_modules\/(?!@hsu-react\/ui\/)/`。它只看**第一个**
25
+ * node_modules 后面跟着什么——扁平安装(yarn / npm)下确实是 `@hsu-react/ui/`,
26
+ * 但 pnpm 的真实路径是
27
+ *
28
+ * ```
29
+ * node_modules/.pnpm/@hsu-react+ui@<版本>/node_modules/@hsu-react/ui/es/...
30
+ * ```
31
+ *
32
+ * 跟着的是 `.pnpm/`,否定前瞻立刻失败,本库的 scss 与图片会被**全部排除**,
33
+ * 报「no loaders are configured to process this file」。这个坑在四个下游项目里
34
+ * 各踩过一次,所以把判定收进库里导出,消费方引用而不是各抄一份。
35
+ *
36
+ * 改按「整条路径里有没有 @hsu-react/ui」判断,扁平与嵌套两种布局都成立;
37
+ * 路径分隔符同时接受 `/` 与 `\`,Windows 下同样有效。
38
+ */
39
+ export declare const excludeNodeModulesExceptHsuUi: (modulePath: string) => boolean;
40
+ export default excludeNodeModulesExceptHsuUi;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * 给消费方 webpack 配置用的工具。**构建期模块,不要从应用代码里引**
3
+ * —— 它不依赖 React,也不该进运行时产物。
4
+ *
5
+ * ```js
6
+ * // webpack.config.js(CJS)
7
+ * const { excludeNodeModulesExceptHsuUi } = require("@hsu-react/ui/lib/build/webpack");
8
+ *
9
+ * { test: /\.scss$/, exclude: excludeNodeModulesExceptHsuUi, use: [...] }
10
+ * ```
11
+ */
12
+
13
+ /**
14
+ * 判断一个模块路径「是否该被 loader 排除」:node_modules 一律排除,但放行本库。
15
+ *
16
+ * ## 为什么需要它
17
+ *
18
+ * 本库的 es / lib 产物里带着**未编译的 `.module.scss`** 和图片资源,要由消费方自己的
19
+ * loader 处理(这样 CSS Module 的类名哈希、`getLocalIdent` 等策略才由消费方说了算)。
20
+ * 于是每个 webpack 项目都得在 scss / 图片规则上开一个「排除 node_modules,但放行
21
+ * @hsu-react/ui」的例外。
22
+ *
23
+ * ## 为什么不能用正则
24
+ *
25
+ * 手写的版本几乎都是 `/node_modules\/(?!@hsu-react\/ui\/)/`。它只看**第一个**
26
+ * node_modules 后面跟着什么——扁平安装(yarn / npm)下确实是 `@hsu-react/ui/`,
27
+ * 但 pnpm 的真实路径是
28
+ *
29
+ * ```
30
+ * node_modules/.pnpm/@hsu-react+ui@<版本>/node_modules/@hsu-react/ui/es/...
31
+ * ```
32
+ *
33
+ * 跟着的是 `.pnpm/`,否定前瞻立刻失败,本库的 scss 与图片会被**全部排除**,
34
+ * 报「no loaders are configured to process this file」。这个坑在四个下游项目里
35
+ * 各踩过一次,所以把判定收进库里导出,消费方引用而不是各抄一份。
36
+ *
37
+ * 改按「整条路径里有没有 @hsu-react/ui」判断,扁平与嵌套两种布局都成立;
38
+ * 路径分隔符同时接受 `/` 与 `\`,Windows 下同样有效。
39
+ */
40
+ export var excludeNodeModulesExceptHsuUi = function excludeNodeModulesExceptHsuUi(modulePath) {
41
+ return /node_modules/.test(modulePath) && !/@hsu-react[\\/]ui[\\/]/.test(modulePath);
42
+ };
43
+ export default excludeNodeModulesExceptHsuUi;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 给消费方 webpack 配置用的工具。**构建期模块,不要从应用代码里引**
3
+ * —— 它不依赖 React,也不该进运行时产物。
4
+ *
5
+ * ```js
6
+ * // webpack.config.js(CJS)
7
+ * const { excludeNodeModulesExceptHsuUi } = require("@hsu-react/ui/lib/build/webpack");
8
+ *
9
+ * { test: /\.scss$/, exclude: excludeNodeModulesExceptHsuUi, use: [...] }
10
+ * ```
11
+ */
12
+ /**
13
+ * 判断一个模块路径「是否该被 loader 排除」:node_modules 一律排除,但放行本库。
14
+ *
15
+ * ## 为什么需要它
16
+ *
17
+ * 本库的 es / lib 产物里带着**未编译的 `.module.scss`** 和图片资源,要由消费方自己的
18
+ * loader 处理(这样 CSS Module 的类名哈希、`getLocalIdent` 等策略才由消费方说了算)。
19
+ * 于是每个 webpack 项目都得在 scss / 图片规则上开一个「排除 node_modules,但放行
20
+ * @hsu-react/ui」的例外。
21
+ *
22
+ * ## 为什么不能用正则
23
+ *
24
+ * 手写的版本几乎都是 `/node_modules\/(?!@hsu-react\/ui\/)/`。它只看**第一个**
25
+ * node_modules 后面跟着什么——扁平安装(yarn / npm)下确实是 `@hsu-react/ui/`,
26
+ * 但 pnpm 的真实路径是
27
+ *
28
+ * ```
29
+ * node_modules/.pnpm/@hsu-react+ui@<版本>/node_modules/@hsu-react/ui/es/...
30
+ * ```
31
+ *
32
+ * 跟着的是 `.pnpm/`,否定前瞻立刻失败,本库的 scss 与图片会被**全部排除**,
33
+ * 报「no loaders are configured to process this file」。这个坑在四个下游项目里
34
+ * 各踩过一次,所以把判定收进库里导出,消费方引用而不是各抄一份。
35
+ *
36
+ * 改按「整条路径里有没有 @hsu-react/ui」判断,扁平与嵌套两种布局都成立;
37
+ * 路径分隔符同时接受 `/` 与 `\`,Windows 下同样有效。
38
+ */
39
+ export declare const excludeNodeModulesExceptHsuUi: (modulePath: string) => boolean;
40
+ export default excludeNodeModulesExceptHsuUi;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.excludeNodeModulesExceptHsuUi = exports.default = void 0;
7
+ /**
8
+ * 给消费方 webpack 配置用的工具。**构建期模块,不要从应用代码里引**
9
+ * —— 它不依赖 React,也不该进运行时产物。
10
+ *
11
+ * ```js
12
+ * // webpack.config.js(CJS)
13
+ * const { excludeNodeModulesExceptHsuUi } = require("@hsu-react/ui/lib/build/webpack");
14
+ *
15
+ * { test: /\.scss$/, exclude: excludeNodeModulesExceptHsuUi, use: [...] }
16
+ * ```
17
+ */
18
+
19
+ /**
20
+ * 判断一个模块路径「是否该被 loader 排除」:node_modules 一律排除,但放行本库。
21
+ *
22
+ * ## 为什么需要它
23
+ *
24
+ * 本库的 es / lib 产物里带着**未编译的 `.module.scss`** 和图片资源,要由消费方自己的
25
+ * loader 处理(这样 CSS Module 的类名哈希、`getLocalIdent` 等策略才由消费方说了算)。
26
+ * 于是每个 webpack 项目都得在 scss / 图片规则上开一个「排除 node_modules,但放行
27
+ * @hsu-react/ui」的例外。
28
+ *
29
+ * ## 为什么不能用正则
30
+ *
31
+ * 手写的版本几乎都是 `/node_modules\/(?!@hsu-react\/ui\/)/`。它只看**第一个**
32
+ * node_modules 后面跟着什么——扁平安装(yarn / npm)下确实是 `@hsu-react/ui/`,
33
+ * 但 pnpm 的真实路径是
34
+ *
35
+ * ```
36
+ * node_modules/.pnpm/@hsu-react+ui@<版本>/node_modules/@hsu-react/ui/es/...
37
+ * ```
38
+ *
39
+ * 跟着的是 `.pnpm/`,否定前瞻立刻失败,本库的 scss 与图片会被**全部排除**,
40
+ * 报「no loaders are configured to process this file」。这个坑在四个下游项目里
41
+ * 各踩过一次,所以把判定收进库里导出,消费方引用而不是各抄一份。
42
+ *
43
+ * 改按「整条路径里有没有 @hsu-react/ui」判断,扁平与嵌套两种布局都成立;
44
+ * 路径分隔符同时接受 `/` 与 `\`,Windows 下同样有效。
45
+ */
46
+ const excludeNodeModulesExceptHsuUi = modulePath => /node_modules/.test(modulePath) && !/@hsu-react[\\/]ui[\\/]/.test(modulePath);
47
+ exports.excludeNodeModulesExceptHsuUi = excludeNodeModulesExceptHsuUi;
48
+ var _default = exports.default = excludeNodeModulesExceptHsuUi;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsu-react/ui",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "一套基于 React + Ant Design 的中后台业务组件库",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,8 +41,8 @@
41
41
  "dev": "dumi dev",
42
42
  "docs:build": "dumi build",
43
43
  "docs:preview": "dumi preview",
44
- "build": "node scripts/clean-dist.cjs && node scripts/gen-tokens-scss.cjs && father build && node scripts/check-heavy-deps.cjs",
45
- "prepublishOnly": "node scripts/clean-dist.cjs && node scripts/gen-tokens-scss.cjs --check && father build && node scripts/check-heavy-deps.cjs",
44
+ "build": "node scripts/clean-dist.cjs && node scripts/gen-tokens-scss.cjs && father build && node scripts/mark-cjs.cjs && node scripts/check-heavy-deps.cjs",
45
+ "prepublishOnly": "node scripts/clean-dist.cjs && node scripts/gen-tokens-scss.cjs --check && father build && node scripts/mark-cjs.cjs && node scripts/check-heavy-deps.cjs",
46
46
  "check:deps": "node scripts/check-heavy-deps.cjs",
47
47
  "tokens": "node scripts/gen-tokens-scss.cjs",
48
48
  "check:tokens": "node scripts/gen-tokens-scss.cjs --check"
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 给消费方 webpack 配置用的工具。**构建期模块,不要从应用代码里引**
3
+ * —— 它不依赖 React,也不该进运行时产物。
4
+ *
5
+ * ```js
6
+ * // webpack.config.js(CJS)
7
+ * const { excludeNodeModulesExceptHsuUi } = require("@hsu-react/ui/lib/build/webpack");
8
+ *
9
+ * { test: /\.scss$/, exclude: excludeNodeModulesExceptHsuUi, use: [...] }
10
+ * ```
11
+ */
12
+
13
+ /**
14
+ * 判断一个模块路径「是否该被 loader 排除」:node_modules 一律排除,但放行本库。
15
+ *
16
+ * ## 为什么需要它
17
+ *
18
+ * 本库的 es / lib 产物里带着**未编译的 `.module.scss`** 和图片资源,要由消费方自己的
19
+ * loader 处理(这样 CSS Module 的类名哈希、`getLocalIdent` 等策略才由消费方说了算)。
20
+ * 于是每个 webpack 项目都得在 scss / 图片规则上开一个「排除 node_modules,但放行
21
+ * @hsu-react/ui」的例外。
22
+ *
23
+ * ## 为什么不能用正则
24
+ *
25
+ * 手写的版本几乎都是 `/node_modules\/(?!@hsu-react\/ui\/)/`。它只看**第一个**
26
+ * node_modules 后面跟着什么——扁平安装(yarn / npm)下确实是 `@hsu-react/ui/`,
27
+ * 但 pnpm 的真实路径是
28
+ *
29
+ * ```
30
+ * node_modules/.pnpm/@hsu-react+ui@<版本>/node_modules/@hsu-react/ui/es/...
31
+ * ```
32
+ *
33
+ * 跟着的是 `.pnpm/`,否定前瞻立刻失败,本库的 scss 与图片会被**全部排除**,
34
+ * 报「no loaders are configured to process this file」。这个坑在四个下游项目里
35
+ * 各踩过一次,所以把判定收进库里导出,消费方引用而不是各抄一份。
36
+ *
37
+ * 改按「整条路径里有没有 @hsu-react/ui」判断,扁平与嵌套两种布局都成立;
38
+ * 路径分隔符同时接受 `/` 与 `\`,Windows 下同样有效。
39
+ */
40
+ export const excludeNodeModulesExceptHsuUi = (modulePath: string): boolean =>
41
+ /node_modules/.test(modulePath) &&
42
+ !/@hsu-react[\\/]ui[\\/]/.test(modulePath);
43
+
44
+ export default excludeNodeModulesExceptHsuUi;