vite-plugin-taro 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. package/README.en.md +19 -11
  2. package/README.md +19 -11
  3. package/package.json +3 -3
package/README.en.md CHANGED
@@ -17,7 +17,7 @@ Live demo: <https://sep2.github.io/vite-plugin-taro>. See [Sample app](https://g
17
17
  - **Battle-tested Taro foundation** Use the full set of Taro APIs and components instead of reinventing cross-platform primitives.
18
18
  - **Tailwind ready** Built-in Tailwind CSS v4 support for both WeChat Mini Program and H5 styles.
19
19
  - **Conditional compilation** Use Taro-style `#ifdef` / `#ifndef` / `#if` blocks to split code and styles by `wx` / `h5` target.
20
- - **Type-friendly** Import Taro capabilities consistently through `virtual:taro/api` and `virtual:taro/components`, with TypeScript type support.
20
+ - **Type-friendly** The project supports TypeScript all the way.
21
21
  - **WeChat Skyline** Support WeChat Mini Program output with Skyline rendering mode.
22
22
 
23
23
  ## Quick start
@@ -74,7 +74,24 @@ npm run preview:h5
74
74
  npm run typecheck
75
75
  ```
76
76
 
77
- For existing apps or custom project layouts, follow the manual setup below.
77
+ ### 5. Use Taro virtual modules
78
+
79
+ Use these imports in app code:
80
+
81
+ ```tsx
82
+ import Taro from 'virtual:taro/api'
83
+ import { Text, View } from 'virtual:taro/components'
84
+ ```
85
+
86
+ | Import | Use |
87
+ | --- | --- |
88
+ | `virtual:taro/components` | Taro React components such as `View`, `Text`, `Button`, `Image`, and `ScrollView`. |
89
+ | `virtual:taro/api` | Taro APIs and hooks such as `Taro.navigateTo`, `Taro.getWindowInfo`, and `Taro.useLaunch`. |
90
+
91
+ Usage is the same as Taro itself; see the [Taro website](https://docs.taro.zone) for component and API details.
92
+
93
+ You no longer need to install `@tarojs/*` packages; application code should not import from `@tarojs/*`.
94
+
78
95
 
79
96
  ## Manual setup for existing apps
80
97
 
@@ -238,15 +255,6 @@ export default function IndexPage() {
238
255
  }
239
256
  ```
240
257
 
241
- Use these imports in app code:
242
-
243
- | Import | Use |
244
- | --- | --- |
245
- | `virtual:taro/components` | Taro React components such as `View`, `Text`, `Button`, `Image`, and `ScrollView`. |
246
- | `virtual:taro/api` | Taro APIs and hooks such as `Taro.navigateTo`, `Taro.getWindowInfo`, and `Taro.useLaunch`. |
247
-
248
- Do not import `@tarojs/*` packages directly in application code. Direct `@tarojs/*` usage is forbidden and unsupported by this plugin because it can bypass target-specific runtime aliases and H5 API transforms. Use `virtual:taro/api` and `virtual:taro/components` only.
249
-
250
258
  ### 5. Add the H5 HTML shell
251
259
 
252
260
  For H5, keep a normal Vite `index.html` with an `#app` mount node. The plugin injects the generated Taro H5 entry automatically, so you do not need a normal Vite `src/main.tsx` script.
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  - **依托成熟 Taro 能力** 复用久经实战检验的 Taro API 和组件,完整使用 Taro 跨端能力。
18
18
  - **Tailwind 就绪** 内置 Tailwind CSS v4 支持,微信小程序与 H5 样式开箱即用。
19
19
  - **条件编译** 支持 Taro 风格 `#ifdef` / `#ifndef` / `#if`,可按 `wx` / `h5` 裁剪代码和样式。
20
- - **类型友好** 通过 `virtual:taro/api` 和 `virtual:taro/components` 统一导入 Taro 能力,并提供 TypeScript 类型支持。
20
+ - **类型友好** 项目全链路支持 TypeScript
21
21
  - **微信 Skyline** 支持微信小程序 Skyline 渲染模式输出。
22
22
 
23
23
  ## 快速开始
@@ -74,7 +74,24 @@ npm run preview:h5
74
74
  npm run typecheck
75
75
  ```
76
76
 
77
- 已有应用或自定义项目结构,请继续阅读下面的手动接入步骤。
77
+ ### 5. 使用 Taro 虚拟模块
78
+
79
+ 应用代码请使用这些导入:
80
+
81
+ ```tsx
82
+ import Taro from 'virtual:taro/api'
83
+ import { Text, View } from 'virtual:taro/components'
84
+ ```
85
+
86
+ | 导入 | 用途 |
87
+ | --- | --- |
88
+ | `virtual:taro/components` | Taro React 组件,例如 `View`、`Text`、`Button`、`Image` 和 `ScrollView`。 |
89
+ | `virtual:taro/api` | Taro API 和 hooks,例如 `Taro.navigateTo`、`Taro.getWindowInfo` 和 `Taro.useLaunch`。 |
90
+
91
+ 用法与 Taro 本身一致;组件和 API 的具体用法请参考 [Taro 官网](https://docs.taro.zone)。
92
+
93
+ 你不再需要安装 `@tarojs/*` 包;应用代码也不要从 `@tarojs/*` 导入。
94
+
78
95
 
79
96
  ## 手动接入已有应用
80
97
 
@@ -238,15 +255,6 @@ export default function IndexPage() {
238
255
  }
239
256
  ```
240
257
 
241
- 应用代码请使用这些导入:
242
-
243
- | 导入 | 用途 |
244
- | --- | --- |
245
- | `virtual:taro/components` | Taro React 组件,例如 `View`、`Text`、`Button`、`Image` 和 `ScrollView`。 |
246
- | `virtual:taro/api` | Taro API 和 hooks,例如 `Taro.navigateTo`、`Taro.getWindowInfo` 和 `Taro.useLaunch`。 |
247
-
248
- 不要在应用代码中直接导入 `@tarojs/*` 包。此插件禁止且不支持直接使用 `@tarojs/*`,因为这可能绕过目标特定的运行时别名和 H5 API 转换。请只使用 `virtual:taro/api` 和 `virtual:taro/components`。
249
-
250
258
  ### 5. 添加 H5 HTML 外壳
251
259
 
252
260
  对于 H5,请保留一个普通的 Vite `index.html`,并包含 `#app` 挂载节点。插件会自动注入生成的 Taro H5 入口,因此你不需要普通 Vite 的 `src/main.tsx` 脚本。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-taro",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "author": "sep2",
5
5
  "description": "Vite 8 plugin for building one React/Taro codebase for WeChat Mini Program and H5 targets.",
6
6
  "type": "module",
@@ -64,8 +64,8 @@
64
64
  "babel-plugin-transform-taroapi": "^4.2.0",
65
65
  "tailwindcss": "^4.3.1",
66
66
  "weapp-tailwindcss": "^5.0.13",
67
- "@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.1.3",
68
- "@tarojs/react": "npm:vite-plugin-taro-react@0.1.3"
67
+ "@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.1.4",
68
+ "@tarojs/react": "npm:vite-plugin-taro-react@0.1.4"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "react": "^19.0.0",