vite-plugin-taro 0.7.0 → 0.7.1-beta.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/client.d.ts +2 -2
- package/dist/index.js +148 -123
- package/dist/node/plugins/h5/plugins.d.ts +2483 -1
- package/dist/node/plugins/mini/dev/react-refresh.d.ts +20 -15
- package/dist/node/plugins/mini/skeleton/platform/create-wx-template.d.ts +3 -0
- package/dist/node/plugins/mini/skeleton/platform/create-zfb-template.d.ts +3 -0
- package/dist/node/plugins/mini/skeleton/recursive-merge.d.ts +9 -0
- package/dist/node/utils/assert-runtime-versions.d.ts +3 -0
- package/dist/runtime/client/taro/api.d.ts +2 -2
- package/dist/runtime/client/taro/api.js +3 -3
- package/dist/runtime/client/taro/component.d.ts +1 -1
- package/dist/runtime/client/taro/component.js +2 -1
- package/dist/runtime/h5/taro-runtime.d.ts +6 -5
- package/dist/runtime/h5/taro-runtime.js +6 -5
- package/dist/runtime/mini/capsule/page.d.ts +1 -1
- package/dist/runtime/mini/capsule/taro-runtime.d.ts +3 -3
- package/dist/runtime/mini/capsule/taro-runtime.js +4 -4
- package/package.json +5 -12
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { type Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the serve-only Oxc substitution for React's free DevTools-hook references.
|
|
4
|
+
*
|
|
5
|
+
* Bundled Vite folds `define` into its existing native Oxc transform. Oxc rewrites only free references, preserving explicit
|
|
6
|
+
* members, property keys, string contents, and shadowed bindings without an all-module plugin filter or a second AST parse.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMiniReactRefreshDefines(isDevelopment: boolean): Record<string, string>;
|
|
2
9
|
/**
|
|
3
10
|
* Creates the serve-only React Refresh adaptation transforms for a Mini Program target.
|
|
4
11
|
*
|
|
@@ -9,16 +16,22 @@ import { type Plugin } from 'vite';
|
|
|
9
16
|
* and injects its renderer hook at module evaluation, replacing the missing HTML preamble.
|
|
10
17
|
* - React Reconciler is selected by exact physical ID. Its renderer injection receives a static dependency on the refresh
|
|
11
18
|
* runtime, so hook installation cannot race renderer initialization during cold startup.
|
|
12
|
-
* - React-family modules are selected by the reserved free DevTools-hook identifier. Their expression references are rewritten
|
|
13
|
-
* as explicit `globalThis` members; an AST visitor edits only those identifier ranges after the filter admits the module.
|
|
14
|
-
* - Refresh boundaries are selected by Vite's generated `$RefreshReg$` guard. The AST transform removes only that web-preamble
|
|
15
|
-
* assertion because each boundary already owns local wrappers over the imported refresh runtime.
|
|
16
19
|
*
|
|
17
|
-
* These adaptations deliberately remain serve-only plugin transforms rather than target-wide
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
+
* These adaptations deliberately remain serve-only plugin transforms rather than target-wide production behavior. Reconciler's
|
|
21
|
+
* static refresh dependency establishes hook installation order. The Mini config lowers React's free DevTools-hook protocol with
|
|
22
|
+
* a serve-only native Oxc define. A filtered post-transform removes the browser-preamble assertion before both complete chunk
|
|
23
|
+
* rendering and incremental factory generation. Removing it only during renderChunk leaves HMR patches unadapted.
|
|
20
24
|
*/
|
|
21
25
|
export declare function createMiniReactRefreshTransforms(): Plugin[];
|
|
26
|
+
/**
|
|
27
|
+
* Removes only the generated browser assertion at the shared module-transform boundary.
|
|
28
|
+
* The native hook filter avoids parsing nonmatching modules. Matching modules cost O(n) time and memory; unchanged modules
|
|
29
|
+
* reuse the bundler's transform cache. Refresh registration and unrelated window expressions remain untouched.
|
|
30
|
+
*/
|
|
31
|
+
export declare function removeRefreshPreambleGuard({ code, id }: {
|
|
32
|
+
code: string;
|
|
33
|
+
id: string;
|
|
34
|
+
}): import("../../../utils/transform.ts").AstTransformResult;
|
|
22
35
|
/** Makes renderer hook injection statically depend on the refresh runtime. */
|
|
23
36
|
export declare function injectReactRefreshRendererDependency(code: string): {
|
|
24
37
|
code: string;
|
|
@@ -28,11 +41,3 @@ export declare function transformRefreshRuntime({ code, id }: {
|
|
|
28
41
|
code: string;
|
|
29
42
|
id: string;
|
|
30
43
|
}): import("../../../utils/transform.ts").AstTransformResult;
|
|
31
|
-
export declare function transformReactDevtoolsHook({ code, id }: {
|
|
32
|
-
code: string;
|
|
33
|
-
id: string;
|
|
34
|
-
}): import("../../../utils/transform.ts").AstTransformResult;
|
|
35
|
-
export declare function removeRefreshPreambleGuard({ code, id }: {
|
|
36
|
-
code: string;
|
|
37
|
-
id: string;
|
|
38
|
-
}): import("../../../utils/transform.ts").AstTransformResult;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type MergeRecord = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Recursively merges sources into the retained target used by Taro's template generator.
|
|
4
|
+
*
|
|
5
|
+
* The target and its existing nested records are intentionally mutated because Taro retains their references. Matching arrays
|
|
6
|
+
* are concatenated, matching records are merged recursively, and all other source values replace their target values.
|
|
7
|
+
*/
|
|
8
|
+
export declare function recursiveMerge<T extends MergeRecord>(target: T, ...sources: ReadonlyArray<MergeRecord | undefined>): T;
|
|
9
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import taro from '
|
|
2
|
-
export * from '
|
|
1
|
+
import taro from 'vite-plugin-taro-runtime/taro';
|
|
2
|
+
export * from 'vite-plugin-taro-runtime/taro';
|
|
3
3
|
export default taro;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* This physical module is the shared facade, not the generic Taro implementation. Its own
|
|
2
|
+
* This physical module is the shared facade, not the generic Taro implementation. Its own `vite-plugin-taro-runtime/taro` request is
|
|
3
3
|
* resolved by the client plugin to the selected platform APIs, while application requests resolve back to this facade.
|
|
4
4
|
* React's API loader then extends this same object with framework lifecycle hooks.
|
|
5
5
|
*/
|
|
6
|
-
import taro from '
|
|
6
|
+
import taro from 'vite-plugin-taro-runtime/taro';
|
|
7
7
|
// Re-export platform APIs while preserving object identity for the framework loader's lifecycle assignments.
|
|
8
8
|
// @ts-expect-error @tarojs/taro uses export= types while Rolldown exposes its runtime properties as named exports.
|
|
9
|
-
export * from '
|
|
9
|
+
export * from 'vite-plugin-taro-runtime/taro';
|
|
10
10
|
export default taro;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from 'vite-plugin-taro-runtime/components';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// The compiler maps this typed component slot to the active H5 or Mini implementation.
|
|
2
|
+
export * from 'vite-plugin-taro-runtime/components';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/** biome-ignore-all assist/source/organizeImports: keep runtime side effect order */
|
|
1
2
|
/** Runtime exports consumed by the generated H5 entry. */
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
export { createReactApp } from '
|
|
5
|
-
export { createHashHistory, createRouter, handleAppMount } from '
|
|
6
|
-
export { window } from '
|
|
3
|
+
import 'vite-plugin-taro-runtime/components/global.css';
|
|
4
|
+
import 'vite-plugin-taro-runtime/components/dist/taro-components/taro-components.css';
|
|
5
|
+
export { createReactApp } from 'vite-plugin-taro-runtime/plugin-framework-react/runtime';
|
|
6
|
+
export { createHashHistory, createRouter, handleAppMount } from 'vite-plugin-taro-runtime/router';
|
|
7
|
+
export { window } from 'vite-plugin-taro-runtime/runtime/h5';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/** biome-ignore-all assist/source/organizeImports: keep runtime side effect order */
|
|
1
2
|
/** Runtime exports consumed by the generated H5 entry. */
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
export { createReactApp } from '
|
|
5
|
-
export { createHashHistory, createRouter, handleAppMount } from '
|
|
6
|
-
export { window } from '
|
|
3
|
+
import 'vite-plugin-taro-runtime/components/global.css';
|
|
4
|
+
import 'vite-plugin-taro-runtime/components/dist/taro-components/taro-components.css';
|
|
5
|
+
export { createReactApp } from 'vite-plugin-taro-runtime/plugin-framework-react/runtime';
|
|
6
|
+
export { createHashHistory, createRouter, handleAppMount } from 'vite-plugin-taro-runtime/router';
|
|
7
|
+
export { window } from 'vite-plugin-taro-runtime/runtime/h5';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** biome-ignore-all assist/source/organizeImports: keep side effect order */
|
|
2
2
|
/** Taro runtime exports shared by the App, Page, and generated recursive component capsules. */
|
|
3
3
|
import '\0vpt:taro-platform-runtime';
|
|
4
|
-
export { createReactApp } from '
|
|
5
|
-
export { default as ReactDOM } from '
|
|
6
|
-
export { createPageConfig, createRecursiveComponentConfig } from '
|
|
4
|
+
export { createReactApp } from 'vite-plugin-taro-runtime/plugin-framework-react/runtime';
|
|
5
|
+
export { default as ReactDOM } from 'vite-plugin-taro-runtime/react';
|
|
6
|
+
export { createPageConfig, createRecursiveComponentConfig } from 'vite-plugin-taro-runtime/runtime/mini';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
/** Taro runtime exports shared by the App, Page, and generated recursive component capsules. */
|
|
3
3
|
// @ts-expect-error: The active Mini contract resolves its Taro platform initialization module.
|
|
4
4
|
import '\0vpt:taro-platform-runtime';
|
|
5
|
-
export { createReactApp } from '
|
|
6
|
-
export { default as ReactDOM } from '
|
|
7
|
-
export { createPageConfig, createRecursiveComponentConfig } from '
|
|
8
|
-
import { customWrapperCache } from '
|
|
5
|
+
export { createReactApp } from 'vite-plugin-taro-runtime/plugin-framework-react/runtime';
|
|
6
|
+
export { default as ReactDOM } from 'vite-plugin-taro-runtime/react';
|
|
7
|
+
export { createPageConfig, createRecursiveComponentConfig } from 'vite-plugin-taro-runtime/runtime/mini';
|
|
8
|
+
import { customWrapperCache } from 'vite-plugin-taro-runtime/runtime/mini';
|
|
9
9
|
// DevTools HMR runs in the bootstrap chunk, so publish the application graph's cache once on the language global.
|
|
10
10
|
if (process.env.NODE_ENV === 'development') {
|
|
11
11
|
Reflect.set(globalThis, Symbol.for('customWrapperCache'), customWrapperCache);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-beta.1",
|
|
4
4
|
"author": "sep2",
|
|
5
5
|
"description": "Vite 8 plugin for building one React/Taro codebase for WeChat, Alipay, and H5 targets.",
|
|
6
6
|
"type": "module",
|
|
@@ -57,21 +57,14 @@
|
|
|
57
57
|
"@tailwindcss/node": "4.3.3",
|
|
58
58
|
"@tailwindcss/oxide": "4.3.3",
|
|
59
59
|
"@tailwindcss/vite": "4.3.3",
|
|
60
|
-
"@tarojs/
|
|
61
|
-
"@tarojs/helper": "4.2.1",
|
|
62
|
-
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.7.0",
|
|
63
|
-
"@tarojs/plugin-platform-alipay": "4.2.1",
|
|
64
|
-
"@tarojs/plugin-platform-h5": "4.2.1",
|
|
65
|
-
"@tarojs/plugin-platform-weapp": "4.2.1",
|
|
66
|
-
"@tarojs/react": "npm:vite-plugin-taro-react@0.7.0",
|
|
67
|
-
"@tarojs/router": "4.2.1",
|
|
68
|
-
"@tarojs/runtime": "npm:vite-plugin-taro-runtime@0.7.0",
|
|
69
|
-
"@tarojs/taro": "4.2.1",
|
|
60
|
+
"@tarojs/shared": "4.2.1",
|
|
70
61
|
"@vitejs/plugin-react": "^6.1.1",
|
|
62
|
+
"babel-plugin-transform-taroapi": "4.2.1",
|
|
71
63
|
"react-reconciler": "0.33.0",
|
|
72
64
|
"rolldown": "1.2.7",
|
|
73
65
|
"sval": "0.6.12",
|
|
74
|
-
"tailwindcss": "^4.3.3"
|
|
66
|
+
"tailwindcss": "^4.3.3",
|
|
67
|
+
"vite-plugin-taro-runtime": "0.7.1-beta.1"
|
|
75
68
|
},
|
|
76
69
|
"peerDependencies": {
|
|
77
70
|
"react": "^19.0.0",
|