vite-plugin-taro 0.7.2 → 0.7.3-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/README.en.md +6 -0
- package/README.md +7 -0
- package/dist/index.js +168 -116
- package/dist/node/plugins/mini/dev/plugins.d.ts +2 -2
- package/dist/node/plugins/mini/dev/react-refresh.d.ts +10 -31
- package/dist/node/plugins/mini/mini-contract.d.ts +1 -1
- package/dist/node/plugins/mini/module/chunk-path.d.ts +1 -3
- package/dist/node/plugins/mini/module/module.d.ts +2 -2
- package/dist/node/plugins/mini/placer/placer.d.ts +5 -16
- package/dist/node/plugins/mini/styles/mini-html-base.d.ts +2 -0
- package/dist/node/plugins/mini/styles/plugins.d.ts +2 -2
- package/dist/node/plugins/mini/watch/create-mini-watch-plugin.d.ts +3 -0
- package/dist/node/utils/clean-output-files.d.ts +5 -0
- package/dist/runtime/mini/capsule/taro-runtime.d.ts +2 -1
- package/dist/runtime/mini/capsule/taro-runtime.js +6 -2
- package/package.json +16 -16
|
@@ -25,8 +25,8 @@ export declare function createMiniDevelopmentPlugin(contract: Pick<MiniContract,
|
|
|
25
25
|
* rebuild-mode transaction has completed;
|
|
26
26
|
* 3. let the host replace the wrapper again with the new marker, causing a second App reload.
|
|
27
27
|
*
|
|
28
|
-
* Deleting
|
|
29
|
-
*
|
|
28
|
+
* Deleting the in-memory bundle entry avoids both premature writes. Startup cleanup removes all physical files; live recovery
|
|
29
|
+
* builds do not clean, so their prior App stylesheet remains available. The host publishes the stylesheet once afterward.
|
|
30
30
|
* Patch modes first reset delivery and publish matching `hmr/info.js`; rebuild mode has no patch state and writes a fresh marker
|
|
31
31
|
* directly. Incremental HMR never enters this complete-output hook and changes only the imported global stylesheet; rewriting
|
|
32
32
|
* the App root would reload the heap while a JavaScript patch is awaiting acknowledgement. The serve-only plugin leaves
|
|
@@ -1,43 +1,22 @@
|
|
|
1
1
|
import { type Plugin } from 'vite';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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>;
|
|
9
|
-
/**
|
|
10
|
-
* Creates the serve-only React Refresh adaptation transforms for a Mini Program target.
|
|
11
|
-
*
|
|
12
|
-
* @vitejs/plugin-react assumes an HTML preamble and browser global scope; Mini Program hosts provide neither. Each
|
|
13
|
-
* transform owns one distinct compatibility boundary:
|
|
14
|
-
*
|
|
15
|
-
* - The refresh runtime is selected by exact ID. It rewrites only the two browser protocol globals that React Refresh evaluates
|
|
16
|
-
* and injects its renderer hook at module evaluation, replacing the missing HTML preamble.
|
|
17
|
-
* - React Reconciler is selected by exact physical ID. Its renderer injection receives a static dependency on the refresh
|
|
18
|
-
* runtime, so hook installation cannot race renderer initialization during cold startup.
|
|
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.
|
|
3
|
+
* Installs the missing HTML preamble inside the Refresh runtime. Boundary modules import that runtime before evaluating
|
|
4
|
+
* their preamble guards, including during incremental updates. Reconciler also imports it before registering its renderer.
|
|
5
|
+
* The shared Rolldown injection binds free `window` references to the same Taro window in the preamble and boundaries.
|
|
24
6
|
*/
|
|
25
7
|
export declare function createMiniReactRefreshTransforms(): Plugin[];
|
|
26
8
|
/**
|
|
27
|
-
*
|
|
28
|
-
* The
|
|
29
|
-
*
|
|
9
|
+
* Reproduces the browser preamble at runtime evaluation, after its declarations initialize.
|
|
10
|
+
* The renderer hook belongs to the real global used by Reconciler. The no-op registration and identity signature belong
|
|
11
|
+
* to the injected Taro window, satisfying upstream guards without replacing module-local Refresh registration.
|
|
12
|
+
* These shared protocol properties are initialized once per runtime module evaluation, not for each updated boundary.
|
|
30
13
|
*/
|
|
31
|
-
export declare function
|
|
14
|
+
export declare function transformRefreshRuntime(code: string): {
|
|
32
15
|
code: string;
|
|
33
|
-
|
|
34
|
-
}
|
|
16
|
+
map: null;
|
|
17
|
+
};
|
|
35
18
|
/** Makes renderer hook injection statically depend on the refresh runtime. */
|
|
36
19
|
export declare function injectReactRefreshRendererDependency(code: string): {
|
|
37
20
|
code: string;
|
|
38
21
|
map: null;
|
|
39
22
|
};
|
|
40
|
-
export declare function transformRefreshRuntime({ code, id }: {
|
|
41
|
-
code: string;
|
|
42
|
-
id: string;
|
|
43
|
-
}): import("../../../utils/transform.ts").AstTransformResult;
|
|
@@ -4,7 +4,7 @@ import type { VptJsonObject, VptOptions } from '../../../options.ts';
|
|
|
4
4
|
export type TaroContract = {
|
|
5
5
|
env: string;
|
|
6
6
|
componentsReactPath: string;
|
|
7
|
-
|
|
7
|
+
targetRuntimePath: string;
|
|
8
8
|
};
|
|
9
9
|
/** Physical runtime modules selected by one Mini Program target. */
|
|
10
10
|
export type RuntimeModulesContract = {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare const generatedChunkDirectory = "assets";
|
|
3
|
-
/** Projects one Rolldown-owned physical candidate path into the package-neutral SystemJS identity. */
|
|
1
|
+
/** Uses package-relative paths as logical IDs so source groups and runtime chunks share one namespace. */
|
|
4
2
|
export declare function toLogicalChunkId(physicalChunkId: string): string;
|
|
5
3
|
/** Resolves one relative Rolldown-generated import to its preliminary physical chunk path. */
|
|
6
4
|
export declare function resolvePhysicalChunkReference(importerChunkId: string, reference: string): string;
|
|
@@ -2,8 +2,8 @@ import type { Rolldown } from 'vite';
|
|
|
2
2
|
import type { RuntimeModulesContract } from '../mini-contract.ts';
|
|
3
3
|
/** Identifies Rolldown's generated helper module independently of its unstable output filename. */
|
|
4
4
|
export declare const rolldownRuntimeId = "\0rolldown/runtime.js";
|
|
5
|
-
/** Resolves the shared Taro facade's
|
|
6
|
-
export declare const
|
|
5
|
+
/** Resolves the shared Taro facade's target initialization side effect. */
|
|
6
|
+
export declare const taroTargetRuntimeId = "\0vpt:taro-target-runtime";
|
|
7
7
|
/** Redirects Vite's injected browser preload helper to the bootstrap identity loader. */
|
|
8
8
|
export declare const vitePreloadId = "\0vite/preload-helper.js";
|
|
9
9
|
/** Forces the native App shell entry to emit at the required root path. */
|
|
@@ -19,15 +19,15 @@ export type MiniPlacementPlugin = Plugin & Readonly<{
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function createPlacementRolldownOptions(classifyChunk: MiniModuleClassifier): {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Rolldown owns shared chunk names and collision handling. LTHP adds physical package prefixes
|
|
23
|
+
* to those names later without copying or replacing the chunks.
|
|
24
24
|
*/
|
|
25
25
|
output: {
|
|
26
26
|
/**
|
|
27
27
|
* React and Taro form one stable framework boundary shared by the App and every Page capsule. Keeping their complete
|
|
28
28
|
* dependency closure together prevents application edits from invalidating framework chunk identity and makes later
|
|
29
|
-
* development generations eligible to reuse the unchanged vendor.
|
|
30
|
-
*
|
|
29
|
+
* development generations eligible to reuse the unchanged vendor. Application code and other dependencies
|
|
30
|
+
* use Rolldown's automatic chunking without source-path groups or a blanket external vendor group.
|
|
31
31
|
*/
|
|
32
32
|
codeSplitting: {
|
|
33
33
|
groups: {
|
|
@@ -37,24 +37,13 @@ export declare function createPlacementRolldownOptions(classifyChunk: MiniModule
|
|
|
37
37
|
includeDependenciesRecursively: boolean;
|
|
38
38
|
}[];
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
41
|
-
* Native App/Page/Component shells are files addressed directly by the host and must retain the exact names configured
|
|
42
|
-
* in `input`, such as `app.js` and `pages/home/index.js`. Transport is excluded even though it is CommonJS:
|
|
43
|
-
* application chunks import its content-hashed path, so it belongs with hashed runtime/capsule entries. `[hash]`
|
|
44
|
-
* remains a Rolldown placeholder here and is resolved only after renderChunk transforms finish.
|
|
45
|
-
*/
|
|
40
|
+
/** Native shells retain their public routes; capsules live beside them and shared runtime entries live in common/. */
|
|
46
41
|
entryFileNames(chunk: Rolldown.PreRenderedChunk): string;
|
|
47
42
|
/**
|
|
48
43
|
* Leaves chunk identity and collision handling entirely to Rolldown. This package-neutral physical pattern deliberately
|
|
49
44
|
* contains no LTHP owner; generateBundle adds only the selected package root to the existing Rolldown filename.
|
|
50
45
|
*/
|
|
51
46
|
chunkFileNames: string;
|
|
52
|
-
/**
|
|
53
|
-
* Emits generic Rolldown assets under one collision-resistant hashed namespace. Native-component folders are not
|
|
54
|
-
* governed by this option: createNativeComponentOutput preserves their required relative filenames and relocates the
|
|
55
|
-
* complete folder beside its owning JavaScript chunk after LTHP finalization.
|
|
56
|
-
*/
|
|
57
|
-
assetFileNames: string;
|
|
58
47
|
};
|
|
59
48
|
/**
|
|
60
49
|
* Keeps every native entry's required exports while allowing Rolldown to add cross-chunk bindings created by natural code
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Native-ready display defaults for Taro's mapped HTML tags; all other styling belongs to the application. */
|
|
2
|
+
export declare const miniHtmlBase = "\n.h5-span,\n.h5-a {\n display: inline;\n}\n\n.h5-button,\n.h5-input,\n.h5-textarea,\n.h5-progress {\n display: inline-block;\n}\n\n.h5-template,\n.h5-datalist {\n display: none;\n}\n";
|
|
@@ -86,8 +86,8 @@ export type MiniStylePlugin = Plugin & Readonly<{
|
|
|
86
86
|
*
|
|
87
87
|
* The post-order `generateBundle` hook gathers all JavaScript chunks, finalizes them as one operation, and only then mutates the
|
|
88
88
|
* bundle. It assigns converted code, clears invalid source maps, removes Vite's intermediate browser stylesheet, and always
|
|
89
|
-
* emits the contract-selected global file
|
|
90
|
-
*
|
|
89
|
+
* emits the contract-selected global file, including the HTML compatibility base even when the application has no styles.
|
|
90
|
+
* Native output hooks run afterward and emit Page/component companion files independently.
|
|
91
91
|
*
|
|
92
92
|
* ### 5b. Development commit
|
|
93
93
|
*
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WeChat DevTools can retain stale file contents when output directories are deleted and recreated.
|
|
3
|
+
* Preserve every directory so its watcher stays attached, but unlink every file to invalidate cached contents.
|
|
4
|
+
*/
|
|
5
|
+
export declare function cleanOutputFiles(directory: string): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
-
import '\0vpt:taro-
|
|
3
|
+
import '\0vpt:taro-target-runtime';
|
|
4
|
+
import 'vite-plugin-taro-runtime/plugin-html/runtime';
|
|
4
5
|
export { createReactApp } from 'vite-plugin-taro-runtime/plugin-framework-react/runtime';
|
|
5
6
|
export { default as ReactDOM } from 'vite-plugin-taro-runtime/react';
|
|
6
7
|
export { createPageConfig, createRecursiveComponentConfig } from 'vite-plugin-taro-runtime/runtime/mini';
|
|
@@ -1,7 +1,11 @@
|
|
|
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
|
-
// @ts-expect-error: The active Mini contract resolves its Taro
|
|
4
|
-
import '\0vpt:taro-
|
|
3
|
+
// @ts-expect-error: The active Mini contract resolves its Taro target initialization module.
|
|
4
|
+
import '\0vpt:taro-target-runtime';
|
|
5
|
+
// Native templates cannot render HTML names directly. These upstream hooks translate div -> view, img -> image,
|
|
6
|
+
// href -> url and click -> tap, including later attribute removal and event-listener changes, not just first render.
|
|
7
|
+
// Keep registration in the shared runtime dependency, rather than App/Page bodies that execute again during HMR.
|
|
8
|
+
import 'vite-plugin-taro-runtime/plugin-html/runtime';
|
|
5
9
|
export { createReactApp } from 'vite-plugin-taro-runtime/plugin-framework-react/runtime';
|
|
6
10
|
export { default as ReactDOM } from 'vite-plugin-taro-runtime/react';
|
|
7
11
|
export { createPageConfig, createRecursiveComponentConfig } from 'vite-plugin-taro-runtime/runtime/mini';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3-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",
|
|
@@ -59,38 +59,38 @@
|
|
|
59
59
|
"@tailwindcss/vite": "4.3.3",
|
|
60
60
|
"@tarojs/shared": "4.2.1",
|
|
61
61
|
"@vitejs/plugin-react": "^6.1.1",
|
|
62
|
-
"react-reconciler": "0.
|
|
63
|
-
"rolldown": "1.2.
|
|
62
|
+
"react-reconciler": "0.34.0",
|
|
63
|
+
"rolldown": "1.2.8",
|
|
64
64
|
"sval": "0.6.12",
|
|
65
65
|
"tailwindcss": "^4.3.3",
|
|
66
|
-
"vite-plugin-taro-runtime": "0.7.
|
|
66
|
+
"vite-plugin-taro-runtime": "0.7.3-beta.1"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"react": "^19.
|
|
70
|
-
"react-dom": "^19.
|
|
71
|
-
"vite": "8.
|
|
69
|
+
"react": "^19.3.0",
|
|
70
|
+
"react-dom": "^19.3.0",
|
|
71
|
+
"vite": "8.3.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@babel/core": "^8.0.
|
|
75
|
-
"@babel/generator": "^8.0.
|
|
74
|
+
"@babel/core": "^8.0.5",
|
|
75
|
+
"@babel/generator": "^8.0.5",
|
|
76
76
|
"@babel/plugin-transform-dynamic-import": "^8.0.1",
|
|
77
77
|
"@babel/plugin-transform-modules-commonjs": "^8.0.1",
|
|
78
78
|
"@babel/plugin-transform-modules-systemjs": "^8.0.1",
|
|
79
|
-
"@babel/types": "^8.0.
|
|
80
|
-
"@oxc-project/types": "0.
|
|
79
|
+
"@babel/types": "^8.0.5",
|
|
80
|
+
"@oxc-project/types": "0.149.0",
|
|
81
81
|
"@tailwindcss-mangle/engine": "0.2.0",
|
|
82
|
-
"@types/node": "^26.
|
|
83
|
-
"@types/react": "^19.
|
|
84
|
-
"@types/react-dom": "^19.
|
|
82
|
+
"@types/node": "^26.5.1",
|
|
83
|
+
"@types/react": "^19.3.0",
|
|
84
|
+
"@types/react-dom": "^19.3.0",
|
|
85
85
|
"@types/react-refresh": "^0.14.7",
|
|
86
86
|
"@weapp-core/escape": "8.0.0",
|
|
87
|
-
"@weapp-tailwindcss/postcss": "3.
|
|
87
|
+
"@weapp-tailwindcss/postcss": "3.3.3",
|
|
88
88
|
"c8": "^12.0.0",
|
|
89
89
|
"oxc-walker": "1.1.1",
|
|
90
90
|
"picocolors": "^1.1.1",
|
|
91
91
|
"rxjs": "^7.8.2",
|
|
92
92
|
"typescript": "^7.0.2",
|
|
93
|
-
"vite": "8.
|
|
93
|
+
"vite": "8.3.0"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build": "node ../../scripts/sync-plugin-readme.ts && node ./scripts/build.ts",
|