@weapp-tailwindcss/lynx 0.3.19 → 0.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.
package/README.md CHANGED
@@ -13,11 +13,12 @@ pnpm add @weapp-tailwindcss/lynx tailwindcss
13
13
  ## Configure
14
14
 
15
15
  ```ts
16
+ import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
16
17
  import { defineConfig } from '@lynx-js/rspeedy'
17
18
  import { pluginLynxTailwindcss } from '@weapp-tailwindcss/lynx'
18
19
 
19
20
  export default defineConfig({
20
- plugins: [pluginLynxTailwindcss()],
21
+ plugins: [pluginReactLynx(), pluginLynxTailwindcss()],
21
22
  })
22
23
  ```
23
24
 
@@ -34,6 +35,10 @@ Import Tailwind CSS 4 from the application CSS entry and point `@source` at the
34
35
 
35
36
  `pluginLynxTailwindcss` fixes `platform` to `'lynx'`, sets `generator.target` to `'web'`, and enables Lynx-compatible output. Tailwind CSS 4 theme variables are resolved at build time, while application-defined dynamic variables remain unchanged.
36
37
 
38
+ Recursive variables require Lynx runtime 3.6 or later and the exposed template API from ReactLynx plugin 0.12.4 or later. Older builders must be upgraded; native behavior is currently tested on the pinned 4.0.1 matrix.
39
+
40
+ Before template encoding, the plugin defaults `enableCSSInlineVariables` to `true` through the ReactLynx builder’s exposed template hooks. This selects native recursive variable resolution for nested Tailwind utility variables while preserving explicit page configuration and dynamic CSS dependencies. Register `pluginReactLynx()` alongside this plugin; a missing template API is a build error. This does not change the target SDK or guarantee native support for each CSS property.
41
+
37
42
  See the [ReactLynx / Rspeedy configuration reference](https://tw.weapp.dev/docs/config/react-lynx) for the `generator`, `rspack`, CSS loader, and encoder options.
38
43
 
39
44
  The current integration supports ReactLynx + Rspeedy and Tailwind CSS 4. It does not cover Rspeedy Web output, non-React Lynx frameworks, or React Native-style runtime style mapping.
package/README.zh-CN.md CHANGED
@@ -14,11 +14,12 @@ pnpm add @weapp-tailwindcss/lynx tailwindcss
14
14
 
15
15
  ```ts
16
16
  // lynx.config.ts
17
+ import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
17
18
  import { defineConfig } from '@lynx-js/rspeedy'
18
19
  import { pluginLynxTailwindcss } from '@weapp-tailwindcss/lynx'
19
20
 
20
21
  export default defineConfig({
21
- plugins: [pluginLynxTailwindcss()],
22
+ plugins: [pluginReactLynx(), pluginLynxTailwindcss()],
22
23
  })
23
24
  ```
24
25
 
@@ -35,6 +36,10 @@ export default defineConfig({
35
36
 
36
37
  `pluginLynxTailwindcss` 固定使用 `platform: 'lynx'`、`generator.target: 'web'` 与 Lynx 原生兼容输出。Tailwind v4 theme 变量会在构建期静态化,确保 `bg-sky-500`、`p-6`、`text-lg` 等标准 utility 能进入 Lynx 原生样式表;应用自行定义的动态 CSS 变量保持不变。
37
38
 
39
+ 递归变量路径要求 Lynx runtime 3.6 以上,以及 ReactLynx 插件 0.12.4 以上公开的模板 API;更旧的构建器需要升级。源码支持边界不等于设备验收,当前原生测试仍使用固定 4.0.1 矩阵。
40
+
41
+ 插件在模板编码前,通过 ReactLynx 构建器公开的 hook 将未配置的 `enableCSSInlineVariables` 默认设为 `true`,使嵌套 utility 变量进入原生递归解析路径;保留显式页面配置与动态 CSS 依赖。需要同时注册 `pluginReactLynx()`,缺少模板 API 时明确构建失败。此设置不改变目标 SDK,也不代表所有 CSS 属性已通过原生验收。
42
+
38
43
  完整的 `generator`、`rspack`、CSS loader 和 encoder 配置项见 [ReactLynx / Rspeedy 配置参考](https://tw.weapp.dev/zh-cn/docs/config/react-lynx)。
39
44
 
40
45
  当前集成支持 ReactLynx + Rspeedy 与 Tailwind CSS v4;不覆盖 Rspeedy Web 输出、非 React Lynx 框架或 React Native 风格的运行时样式映射。
package/dist/index.cjs CHANGED
@@ -1,5 +1,24 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let weapp_tailwindcss_rspack = require("weapp-tailwindcss/rspack");
3
+ //#region src/css-variables.ts
4
+ /** 通过模板编码生命周期启用原生递归变量解析,保留显式配置及动态依赖。 */
5
+ var LynxCssVariablesPlugin = class {
6
+ templatePlugin;
7
+ constructor(templatePlugin) {
8
+ this.templatePlugin = templatePlugin;
9
+ }
10
+ apply(compiler) {
11
+ const name = "weapp-tailwindcss:lynx-css-variables";
12
+ compiler.hooks.thisCompilation.tap(name, (compilation) => {
13
+ this.templatePlugin.getLynxTemplatePluginHooks(compilation).beforeEncode.tap(name, (args) => {
14
+ const config = args.encodeData.sourceContent.config;
15
+ if (config.enableCSSInlineVariables === void 0) config.enableCSSInlineVariables = true;
16
+ return args;
17
+ });
18
+ });
19
+ }
20
+ };
21
+ //#endregion
3
22
  //#region src/index.ts
4
23
  const PLUGIN_NAME = "weapp-tailwindcss:lynx";
5
24
  function normalizeOptions(options) {
@@ -54,7 +73,10 @@ function pluginLynxTailwindcss(options = {}) {
54
73
  setup(api) {
55
74
  const rsbuildApi = api;
56
75
  rsbuildApi.modifyBundlerChain((chain) => {
76
+ const templatePlugin = rsbuildApi.useExposed?.(Symbol.for("LynxTemplatePlugin"))?.LynxTemplatePlugin;
77
+ if (!templatePlugin?.getLynxTemplatePluginHooks) throw new Error("Lynx 模板编码 hook 不可用;请注册或升级 ReactLynx 构建插件(至少 0.12.4),确认其提供 LynxTemplatePlugin API。");
57
78
  chain.plugin(PLUGIN_NAME).use(weapp_tailwindcss_rspack.WeappTailwindcss, [normalizedOptions]);
79
+ chain.plugin(`${PLUGIN_NAME}:css-variables`).use(LynxCssVariablesPlugin, [templatePlugin]);
58
80
  return chain;
59
81
  });
60
82
  rsbuildApi.modifyRspackConfig((config) => (0, weapp_tailwindcss_rspack.patchRspackConfig)(config, normalizeRspackOptions(options.rspack)));
package/dist/index.js CHANGED
@@ -1,4 +1,23 @@
1
1
  import { WeappTailwindcss, patchRspackConfig } from "weapp-tailwindcss/rspack";
2
+ //#region src/css-variables.ts
3
+ /** 通过模板编码生命周期启用原生递归变量解析,保留显式配置及动态依赖。 */
4
+ var LynxCssVariablesPlugin = class {
5
+ templatePlugin;
6
+ constructor(templatePlugin) {
7
+ this.templatePlugin = templatePlugin;
8
+ }
9
+ apply(compiler) {
10
+ const name = "weapp-tailwindcss:lynx-css-variables";
11
+ compiler.hooks.thisCompilation.tap(name, (compilation) => {
12
+ this.templatePlugin.getLynxTemplatePluginHooks(compilation).beforeEncode.tap(name, (args) => {
13
+ const config = args.encodeData.sourceContent.config;
14
+ if (config.enableCSSInlineVariables === void 0) config.enableCSSInlineVariables = true;
15
+ return args;
16
+ });
17
+ });
18
+ }
19
+ };
20
+ //#endregion
2
21
  //#region src/index.ts
3
22
  const PLUGIN_NAME = "weapp-tailwindcss:lynx";
4
23
  function normalizeOptions(options) {
@@ -53,7 +72,10 @@ function pluginLynxTailwindcss(options = {}) {
53
72
  setup(api) {
54
73
  const rsbuildApi = api;
55
74
  rsbuildApi.modifyBundlerChain((chain) => {
75
+ const templatePlugin = rsbuildApi.useExposed?.(Symbol.for("LynxTemplatePlugin"))?.LynxTemplatePlugin;
76
+ if (!templatePlugin?.getLynxTemplatePluginHooks) throw new Error("Lynx 模板编码 hook 不可用;请注册或升级 ReactLynx 构建插件(至少 0.12.4),确认其提供 LynxTemplatePlugin API。");
56
77
  chain.plugin(PLUGIN_NAME).use(WeappTailwindcss, [normalizedOptions]);
78
+ chain.plugin(`${PLUGIN_NAME}:css-variables`).use(LynxCssVariablesPlugin, [templatePlugin]);
57
79
  return chain;
58
80
  });
59
81
  rsbuildApi.modifyRspackConfig((config) => patchRspackConfig(config, normalizeRspackOptions(options.rspack)));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/lynx",
3
3
  "type": "module",
4
- "version": "0.3.19",
4
+ "version": "0.4.0",
5
5
  "description": "Tailwind CSS integration for ReactLynx and Rspeedy cross-platform builds. 面向 ReactLynx 与 Rspeedy 跨端构建的 Tailwind CSS 集成。",
6
6
  "license": "MIT",
7
7
  "homepage": "https://tw.weapp.dev/docs/quick-start/frameworks/lynx",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/sonofmagic/weapp-tailwindcss.git",
10
+ "url": "git+https://github.com/weapp-tailwindcss/weapp-tailwindcss.git",
11
11
  "directory": "packages/lynx"
12
12
  },
13
13
  "sideEffects": false,
@@ -44,12 +44,12 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
- "weapp-tailwindcss": "5.5.10"
47
+ "weapp-tailwindcss": "5.5.12"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@lynx-js/rspeedy": "^0.18.0",
51
51
  "tailwindcss": "^4.3.3",
52
- "vitest": "~5.0.1"
52
+ "vitest": "~5.0.3"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsdown",