@fibrae/semi-next 0.3.0 → 0.3.1

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/LICENSE CHANGED
@@ -20,65 +20,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
20
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  SOFTWARE.
23
-
24
- The code implementation of the external library is referenced by DouyinFe are:
25
-
26
- - animate.css
27
-
28
- The MIT License (MIT)
29
-
30
- Copyright (c) 2020 Daniel Eden
31
-
32
- Permission is hereby granted, free of charge, to any person obtaining a copy
33
- of this software and associated documentation files (the "Software"), to deal
34
- in the Software without restriction, including without limitation the rights
35
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
- copies of the Software, and to permit persons to whom the Software is
37
- furnished to do so, subject to the following conditions:
38
-
39
- The above copyright notice and this permission notice shall be included in all
40
- copies or substantial portions of the Software.
41
-
42
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
- SOFTWARE.
49
-
50
- - Ant Design
51
- MIT LICENSE
52
-
53
- Copyright (c) 2015-present Ant UED, https://xtech.antfin.com/
54
-
55
- Permission is hereby granted, free of charge, to any person obtaining
56
- a copy of this software and associated documentation files (the
57
- "Software"), to deal in the Software without restriction, including
58
- without limitation the rights to use, copy, modify, merge, publish,
59
- distribute, sublicense, and/or sell copies of the Software, and to
60
- permit persons to whom the Software is furnished to do so, subject to
61
- the following conditions:
62
-
63
- The above copyright notice and this permission notice shall be
64
- included in all copies or substantial portions of the Software.
65
-
66
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
67
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
68
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
69
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
70
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
71
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
72
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73
-
74
- - rc-tree
75
-
76
- MIT LICENSE
77
-
78
- Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
79
-
80
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
81
-
82
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
83
-
84
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,47 @@
1
1
  # @fibrae/semi-next
2
2
 
3
- Semi Design Next 的 Next.js 构建插件,给使用 Semi React 组件包的 Next.js 应用用。Semi 的组件 JS 会导入自己的 `.css`;插件让这些导入在 Turbopack、Pages Router 与自定义前缀下也能构建和服务端渲染。包名中的 next 指 Next.js。
3
+ [简体中文](README.zh-CN.md)
4
4
 
5
- ## 何时需要
5
+ The Next.js build plugin of Semi Design Next, for Next.js applications that use the Semi React component packages. Semi's component JS imports its own `.css`, and the plugin makes those imports build and server-render under Turbopack, the Pages Router and custom prefixes. The `next` in the package name refers to Next.js.
6
6
 
7
- | 场景 | 写法 |
8
- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
9
- | App Router,`next dev --webpack`、`next build --webpack` | 不需要本插件,装 `@fibrae/semi-ui-react` 即可 |
10
- | Next.js 16 默认的 Turbopack、Pages Router,或两种 Router 混用 | `semiNext()`,样式无需另外导入 |
11
- | 自定义类名前缀 | `semiNext({ prefixCls: 'my', omitCss: true })`,再导入一次 `semi-build-scss --prefix my` 生成的样式表 |
7
+ ## When you need it
12
8
 
13
- ## 安装
9
+ | Scenario | Setup |
10
+ | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
11
+ | App Router, `next dev --webpack`, `next build --webpack` | No plugin needed, just install `@fibrae/semi-ui-react` |
12
+ | Next.js 16 default Turbopack, the Pages Router, or both Routers mixed | `semiNext()`, with no separate style import |
13
+ | Custom class prefix | `semiNext({ prefixCls: 'my', omitCss: true })`, and import the stylesheet generated by `semi-build-scss --prefix my` once |
14
+
15
+ ## Installation
14
16
 
15
17
  ```shell
16
18
  pnpm add -D @fibrae/semi-next
17
19
  ```
18
20
 
19
- 仅提供 ESM。依赖 [`@fibrae/semi-webpack-plugin`](../semi-webpack/README.md);`next` 由应用自带。
21
+ Ships ESM only. Depends on [`@fibrae/semi-webpack-plugin`](../semi-webpack/README.md); the application brings its own `next`.
20
22
 
21
- ## 使用
23
+ ## Usage
22
24
 
23
- ### Turbopack 与 Pages Router
25
+ ### Turbopack and the Pages Router
24
26
 
25
27
  ```js
26
28
  // next.config.mjs
27
29
  import semiNext from '@fibrae/semi-next';
28
30
 
29
31
  export default semiNext()({
30
- // 你的 Next.js 配置
32
+ // your Next.js config
31
33
  });
32
34
  ```
33
35
 
34
- 组件按需带出自己的样式,不导入 `styles.css`。`semiNext(options)` 返回 `(nextConfig) => nextConfig`,在你的配置上:
36
+ Components bring their own styles on demand, so do not import `styles.css`. `semiNext(options)` returns `(nextConfig) => nextConfig`, and on your config it:
35
37
 
36
- - 把 `@fibrae/semi-ui-react`、`@fibrae/semi-ai-react`、`@fibrae/semi-icons-react`、`@fibrae/semi-illustrations-react` 合并进 `transpilePackages`:Pages Router 的服务端用 Node 直接加载 `node_modules`,而 Node 不能导入 `.css`。
37
- - 加 `turbopack.rules`:`omitCss`、`prefixCls` 时给 Semi 的 JS 挂对应 loader。你已有的其他规则保留;与插件同 glob 的规则(`*.js`)抛错,请改用别的 glob。
38
- - 加 `webpack()`:`--webpack` 下按选项挂 `SemiWebpackPlugin`,再调用你原有的 `webpack` 函数;不传选项时不挂插件,Next 直接处理组件导入的 `.css`。
38
+ - Merges `@fibrae/semi-ui-react`, `@fibrae/semi-ai-react`, `@fibrae/semi-icons-react` and `@fibrae/semi-illustrations-react` into `transpilePackages`. The Pages Router server loads `node_modules` directly with Node, and Node cannot import `.css`.
39
+ - Adds `turbopack.rules`: with `omitCss` or `prefixCls`, it attaches the matching loader to Semi's JS. Your other rules stay. A rule on the same glob as the plugin (`*.js`) throws, so use a different glob.
40
+ - Adds `webpack()`: under `--webpack`, it attaches `SemiWebpackPlugin` according to the options, then calls your original `webpack` function. With no options it attaches no plugin, and Next handles the `.css` imported by components directly.
39
41
 
40
- Next.js 16 在 Turbopack 下遇到只有 `webpack` 键的配置会报错退出,所以两个键总是一起返回。
42
+ Next.js 16 exits with an error under Turbopack when the config has only a `webpack` key, so both keys are always returned together.
41
43
 
42
- ### 自定义前缀
44
+ ### Custom prefix
43
45
 
44
46
  ```js
45
47
  // next.config.mjs
@@ -48,36 +50,36 @@ import semiNext from '@fibrae/semi-next';
48
50
  export default semiNext({ prefixCls: 'my', omitCss: true })({});
49
51
  ```
50
52
 
51
- `omitCss` 去掉 Semi 包内的 `.css` 导入,`prefixCls` 改写 Semi JS 里的类名前缀。样式改由一份带同样前缀的完整样式表提供,用 [`@fibrae/semi-scss-compile`](../semi-scss-compile/README.md) 生成后在根 layout(Pages Router 为 `pages/_app`)导入一次:
53
+ `omitCss` removes the `.css` imports inside Semi packages, and `prefixCls` rewrites the class prefix in Semi's JS. Styles then come from a full stylesheet with the same prefix. Generate it with [`@fibrae/semi-scss-compile`](../semi-scss-compile/README.md) and import it once in the root layout (`pages/_app` for the Pages Router):
52
54
 
53
55
  ```shell
54
56
  pnpm add -D @fibrae/semi-scss-compile
55
57
  semi-build-scss --prefix my -o app/semi-my.css --min
56
- # 使用 @fibrae/semi-ai-react 时另装 -D @fibrae/semi-ai-foundation,在 app/semi-my.css 之后导入
58
+ # with @fibrae/semi-ai-react, also install -D @fibrae/semi-ai-foundation and import after app/semi-my.css
57
59
  semi-build-scss --ai node_modules/@fibrae/semi-ai-foundation/dist -o app/semi-ai-my.css --min --prefix my
58
60
  ```
59
61
 
60
- `prefixCls` 必须配 `omitCss: true`,否则读取配置时抛错(Turbopack 不能重编译 Semi 的 SCSS,`--webpack` 下重编译会与 Next 自己的样式规则冲突)。
62
+ `prefixCls` requires `omitCss: true`, or reading the config throws (Turbopack cannot recompile Semi's SCSS, and under `--webpack` recompiling conflicts with Next's own style rules).
61
63
 
62
- ## 选项
64
+ ## Options
63
65
 
64
- 选项即 [`@fibrae/semi-webpack-plugin`](../semi-webpack/README.md) 的 `SemiWebpackPluginOptions`(本包导出别名类型 `SemiNextOptions`)。
66
+ The options are `SemiWebpackPluginOptions` from [`@fibrae/semi-webpack-plugin`](../semi-webpack/README.md) (this package exports the alias type `SemiNextOptions`).
65
67
 
66
- | 选项 | 类型 | 默认值 | 说明 |
67
- | ------------------------------------------------------------ | --------- | ------- | ---------------------------------------------------------------------------------- |
68
- | `omitCss` | `boolean` | `false` | 去掉 Semi 包内的 `.css` 导入,样式改由应用导入的完整样式表提供。 |
69
- | `prefixCls` | `string` | `semi` | 类名前缀,必须与所导入样式表的前缀一致。必须配 `omitCss: true`。 |
70
- | `cssLayer`、`extractCssOptions`、`overrideStylesheetLoaders` | - | - | 重编译 SCSS 的选项,只在 `--webpack` 下传给 webpack 插件;Turbopack 下传入即抛错。 |
68
+ | Option | Type | Default | Description |
69
+ | ------------------------------------------------------------ | --------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
70
+ | `omitCss` | `boolean` | `false` | Removes the `.css` imports inside Semi packages. Styles come from a full stylesheet the application imports. |
71
+ | `prefixCls` | `string` | `semi` | Class prefix, which must match the prefix of the imported stylesheet. Requires `omitCss: true`. |
72
+ | `cssLayer`, `extractCssOptions`, `overrideStylesheetLoaders` | - | - | SCSS recompile options, passed to the webpack plugin only under `--webpack`. Passing them under Turbopack throws. |
71
73
 
72
- 插件判断打包器靠 Next 在读取 `next.config` 前设置的 `process.env.TURBOPACK`:默认打包器为 `auto`,`--turbopack` 为 `1`,`--webpack` 与 `next start` 下未设置。
74
+ The plugin detects the bundler through `process.env.TURBOPACK`, which Next sets before reading `next.config`: `auto` for the default bundler, `1` for `--turbopack`, and unset for `--webpack` and `next start`.
73
75
 
74
- 已知限制:Next.js 16.4.3 的 `--webpack` 下,`cssLayer` 触发的 webpack 插件重编译 SCSS 与 Next 自己的样式规则冲突,构建报 `Invalid generator object`;`extractCssOptions`、`overrideStylesheetLoaders` 未验证。
76
+ Known limitation: under `--webpack` on Next.js 16.4.3, the webpack plugin's SCSS recompile triggered by `cssLayer` conflicts with Next's own style rules, and the build reports `Invalid generator object`. `extractCssOptions` and `overrideStylesheetLoaders` are unverified.
75
77
 
76
- Turbopack 的 `*.css` 规则不改变模块类型,应用自己的 `*.module.css` 仍按 CSS Modules 处理。
78
+ The Turbopack `*.css` rule does not change the module type, so your own `*.module.css` files still work as CSS Modules.
77
79
 
78
- ## 开发
80
+ ## Development
79
81
 
80
- - `pnpm --filter @fibrae/semi-next build`:`vp pack` 构建。
81
- - `pnpm --filter @fibrae/semi-next test`:先构建,再用 `test/run.ts` 验证返回的 `transpilePackages`、`turbopack.rules`(loader 路径指向已发布文件,`*.css` 规则不带 `as` 以保留 CSS Modules)、`webpack()` 何时挂插件,以及 `prefixCls` 与 Turbopack 下的选项校验。
82
+ - `pnpm --filter @fibrae/semi-next build`: builds with `vp pack`.
83
+ - `pnpm --filter @fibrae/semi-next test`: builds first, then uses `test/run.ts` to verify the returned `transpilePackages` and `turbopack.rules` (loader paths point at published files, and the `*.css` rule has no `as`, which keeps CSS Modules), when `webpack()` attaches the plugin, and the option checks for `prefixCls` and Turbopack.
82
84
 
83
- 通用命令见根目录 [README.md](../../README.md) 的「常用命令」。
85
+ For general commands, see [CONTRIBUTING.md](../../CONTRIBUTING.md#常用命令) at the repository root.
@@ -0,0 +1,85 @@
1
+ # @fibrae/semi-next
2
+
3
+ [English](README.md)
4
+
5
+ Semi Design Next 的 Next.js 构建插件,给使用 Semi React 组件包的 Next.js 应用用。Semi 的组件 JS 会导入自己的 `.css`;插件让这些导入在 Turbopack、Pages Router 与自定义前缀下也能构建和服务端渲染。包名中的 next 指 Next.js。
6
+
7
+ ## 何时需要
8
+
9
+ | 场景 | 写法 |
10
+ | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
11
+ | App Router,`next dev --webpack`、`next build --webpack` | 不需要本插件,装 `@fibrae/semi-ui-react` 即可 |
12
+ | Next.js 16 默认的 Turbopack、Pages Router,或两种 Router 混用 | `semiNext()`,样式无需另外导入 |
13
+ | 自定义类名前缀 | `semiNext({ prefixCls: 'my', omitCss: true })`,再导入一次 `semi-build-scss --prefix my` 生成的样式表 |
14
+
15
+ ## 安装
16
+
17
+ ```shell
18
+ pnpm add -D @fibrae/semi-next
19
+ ```
20
+
21
+ 仅提供 ESM。依赖 [`@fibrae/semi-webpack-plugin`](../semi-webpack/README.zh-CN.md);`next` 由应用自带。
22
+
23
+ ## 使用
24
+
25
+ ### Turbopack 与 Pages Router
26
+
27
+ ```js
28
+ // next.config.mjs
29
+ import semiNext from '@fibrae/semi-next';
30
+
31
+ export default semiNext()({
32
+ // 你的 Next.js 配置
33
+ });
34
+ ```
35
+
36
+ 组件按需带出自己的样式,不导入 `styles.css`。`semiNext(options)` 返回 `(nextConfig) => nextConfig`,在你的配置上:
37
+
38
+ - 把 `@fibrae/semi-ui-react`、`@fibrae/semi-ai-react`、`@fibrae/semi-icons-react`、`@fibrae/semi-illustrations-react` 合并进 `transpilePackages`:Pages Router 的服务端用 Node 直接加载 `node_modules`,而 Node 不能导入 `.css`。
39
+ - 加 `turbopack.rules`:`omitCss`、`prefixCls` 时给 Semi 的 JS 挂对应 loader。你已有的其他规则保留;与插件同 glob 的规则(`*.js`)抛错,请改用别的 glob。
40
+ - 加 `webpack()`:`--webpack` 下按选项挂 `SemiWebpackPlugin`,再调用你原有的 `webpack` 函数;不传选项时不挂插件,Next 直接处理组件导入的 `.css`。
41
+
42
+ Next.js 16 在 Turbopack 下遇到只有 `webpack` 键的配置会报错退出,所以两个键总是一起返回。
43
+
44
+ ### 自定义前缀
45
+
46
+ ```js
47
+ // next.config.mjs
48
+ import semiNext from '@fibrae/semi-next';
49
+
50
+ export default semiNext({ prefixCls: 'my', omitCss: true })({});
51
+ ```
52
+
53
+ `omitCss` 去掉 Semi 包内的 `.css` 导入,`prefixCls` 改写 Semi JS 里的类名前缀。样式改由一份带同样前缀的完整样式表提供,用 [`@fibrae/semi-scss-compile`](../semi-scss-compile/README.zh-CN.md) 生成后在根 layout(Pages Router 为 `pages/_app`)导入一次:
54
+
55
+ ```shell
56
+ pnpm add -D @fibrae/semi-scss-compile
57
+ semi-build-scss --prefix my -o app/semi-my.css --min
58
+ # 使用 @fibrae/semi-ai-react 时另装 -D @fibrae/semi-ai-foundation,在 app/semi-my.css 之后导入
59
+ semi-build-scss --ai node_modules/@fibrae/semi-ai-foundation/dist -o app/semi-ai-my.css --min --prefix my
60
+ ```
61
+
62
+ `prefixCls` 必须配 `omitCss: true`,否则读取配置时抛错(Turbopack 不能重编译 Semi 的 SCSS,`--webpack` 下重编译会与 Next 自己的样式规则冲突)。
63
+
64
+ ## 选项
65
+
66
+ 选项即 [`@fibrae/semi-webpack-plugin`](../semi-webpack/README.zh-CN.md) 的 `SemiWebpackPluginOptions`(本包导出别名类型 `SemiNextOptions`)。
67
+
68
+ | 选项 | 类型 | 默认值 | 说明 |
69
+ | ------------------------------------------------------------ | --------- | ------- | ---------------------------------------------------------------------------------- |
70
+ | `omitCss` | `boolean` | `false` | 去掉 Semi 包内的 `.css` 导入,样式改由应用导入的完整样式表提供。 |
71
+ | `prefixCls` | `string` | `semi` | 类名前缀,必须与所导入样式表的前缀一致。必须配 `omitCss: true`。 |
72
+ | `cssLayer`、`extractCssOptions`、`overrideStylesheetLoaders` | - | - | 重编译 SCSS 的选项,只在 `--webpack` 下传给 webpack 插件;Turbopack 下传入即抛错。 |
73
+
74
+ 插件判断打包器靠 Next 在读取 `next.config` 前设置的 `process.env.TURBOPACK`:默认打包器为 `auto`,`--turbopack` 为 `1`,`--webpack` 与 `next start` 下未设置。
75
+
76
+ 已知限制:Next.js 16.4.3 的 `--webpack` 下,`cssLayer` 触发的 webpack 插件重编译 SCSS 与 Next 自己的样式规则冲突,构建报 `Invalid generator object`;`extractCssOptions`、`overrideStylesheetLoaders` 未验证。
77
+
78
+ Turbopack 的 `*.css` 规则不改变模块类型,应用自己的 `*.module.css` 仍按 CSS Modules 处理。
79
+
80
+ ## 开发
81
+
82
+ - `pnpm --filter @fibrae/semi-next build`:`vp pack` 构建。
83
+ - `pnpm --filter @fibrae/semi-next test`:先构建,再用 `test/run.ts` 验证返回的 `transpilePackages`、`turbopack.rules`(loader 路径指向已发布文件,`*.css` 规则不带 `as` 以保留 CSS Modules)、`webpack()` 何时挂插件,以及 `prefixCls` 与 Turbopack 下的选项校验。
84
+
85
+ 通用命令见根目录 [CONTRIBUTING.md](../../CONTRIBUTING.md#常用命令)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibrae/semi-next",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Plugin that support Semi Design Next in Next.js",
5
5
  "license": "MIT",
6
6
  "homepage": "https://semi-design-next.pages.dev",
@@ -25,10 +25,10 @@
25
25
  "typescript": "^6.0.3"
26
26
  },
27
27
  "dependencies": {
28
- "@fibrae/semi-webpack-plugin": "0.3.0"
28
+ "@fibrae/semi-webpack-plugin": "0.3.1"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "vp pack",
32
- "test": "vp pack && node test/run.ts"
32
+ "test": "node test/run.ts"
33
33
  }
34
34
  }