vite-plugin-taro 0.5.14 → 0.6.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/dist/node/plugins/client/client-taro.d.ts +2 -2
- package/dist/node/plugins/conditional/conditional-directives.d.ts +2 -2
- package/dist/node/plugins/h5/plugins.d.ts +2 -2
- package/dist/node/plugins/h5/resolver/module-resolver.d.ts +2 -2
- package/dist/node/plugins/h5/transform-app.d.ts +2 -2
- package/dist/node/plugins/h5/transform-app.js +2 -2
- package/dist/node/plugins/wx/dev/create-style-capture.d.ts +16 -4
- package/dist/node/plugins/wx/dev/create-style-capture.js +101 -53
- package/dist/node/plugins/wx/dev/dev-host.d.ts +2 -2
- package/dist/node/plugins/wx/dev/dev-host.js +13 -3
- package/dist/node/plugins/wx/dev/plugins.d.ts +2 -2
- package/dist/node/plugins/wx/dev/wx-dev-options.d.ts +2 -2
- package/dist/node/plugins/wx/output/files.d.ts +2 -2
- package/dist/node/plugins/wx/output/json.d.ts +3 -3
- package/dist/node/plugins/wx/output/json.js +1 -1
- package/dist/node/plugins/wx/output/templates.d.ts +2 -2
- package/dist/node/plugins/wx/plugins.d.ts +2 -2
- package/dist/node/plugins/wx/render/transport.js +1 -1
- package/dist/node/plugins/wx/resolve/resolver.d.ts +2 -2
- package/dist/node/plugins/wx/resolve/specialize-bootstrap.d.ts +2 -2
- package/dist/node/plugins/wx/resolve/specialize-bootstrap.js +1 -1
- package/dist/node/plugins/wx/resolve/specialize-page-capsule.d.ts +2 -2
- package/dist/node/plugins/wx/resolve/specialize-page-capsule.js +2 -2
- package/dist/node/utils/project-config.d.ts +2 -2
- package/dist/node/vpt.d.ts +4 -0
- package/dist/node/{vite-plugin.js → vpt.js} +1 -1
- package/dist/options.d.ts +65 -13
- package/dist/runtime/h5/app.js +2 -2
- package/dist/runtime/wx/amphibious/bootstrap.js +1 -1
- package/dist/runtime/wx/amphibious/transport.js +1 -1
- package/dist/runtime/wx/capsule/page.js +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/package.json +3 -3
- package/src/node/plugins/client/client-taro.ts +3 -3
- package/src/node/plugins/conditional/conditional-directives.ts +3 -3
- package/src/node/plugins/h5/plugins.ts +3 -3
- package/src/node/plugins/h5/resolver/module-resolver.ts +2 -2
- package/src/node/plugins/h5/transform-app.ts +5 -5
- package/src/node/plugins/wx/dev/create-style-capture.ts +126 -57
- package/src/node/plugins/wx/dev/dev-host.ts +16 -5
- package/src/node/plugins/wx/dev/plugins.ts +2 -5
- package/src/node/plugins/wx/dev/wx-dev-options.ts +2 -2
- package/src/node/plugins/wx/output/files.ts +2 -2
- package/src/node/plugins/wx/output/json.ts +8 -8
- package/src/node/plugins/wx/output/templates.ts +3 -3
- package/src/node/plugins/wx/plugins.ts +3 -3
- package/src/node/plugins/wx/render/transport.ts +1 -1
- package/src/node/plugins/wx/resolve/resolver.ts +5 -5
- package/src/node/plugins/wx/resolve/specialize-bootstrap.ts +3 -3
- package/src/node/plugins/wx/resolve/specialize-page-capsule.ts +4 -4
- package/src/node/utils/project-config.ts +2 -2
- package/src/node/{vite-plugin.ts → vpt.ts} +2 -2
- package/src/options.ts +71 -13
- package/src/runtime/h5/app.ts +4 -4
- package/src/runtime/wx/amphibious/bootstrap.ts +2 -2
- package/src/runtime/wx/amphibious/transport.ts +2 -4
- package/src/runtime/wx/capsule/page.ts +3 -8
- package/src/vite.ts +2 -2
- package/dist/node/vite-plugin.d.ts +0 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Plugin } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptTarget } from '../../../options.ts';
|
|
3
3
|
/** Public facade used by transformed application API imports. */
|
|
4
4
|
export declare const clientTaroApiId = "virtual:taro/api";
|
|
5
5
|
/** Creates the shared Taro facade backed by the selected target's API implementation. */
|
|
6
|
-
export declare function createClientTaroPlugin(target:
|
|
6
|
+
export declare function createClientTaroPlugin(target: VptTarget): Plugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptTarget } from '../../../options.ts';
|
|
3
3
|
/** Creates source-level target conditional handling shared by H5 and WX. */
|
|
4
|
-
export declare function createConditionalDirectivePlugin(target:
|
|
4
|
+
export declare function createConditionalDirectivePlugin(target: VptTarget): Plugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginOption } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../options.ts';
|
|
3
3
|
/** Creates the plugins that own the H5 target. */
|
|
4
|
-
export declare function createH5TargetPlugins(options:
|
|
4
|
+
export declare function createH5TargetPlugins(options: VptOptions): PluginOption[];
|
|
5
5
|
/**
|
|
6
6
|
* Coarse source prefilter for the upstream Taro API transform.
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VptOptions } from '../../../../options.ts';
|
|
2
2
|
/** Creates H5 application module resolution and specialization. */
|
|
3
|
-
export declare function createModuleResolver(options:
|
|
3
|
+
export declare function createModuleResolver(options: VptOptions): {
|
|
4
4
|
resolveId({ id, projectRoot }: {
|
|
5
5
|
id: string;
|
|
6
6
|
projectRoot: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VptOptions } from '../../../options.ts';
|
|
2
2
|
import { type AstTransformResult } from '../../utils/transform.ts';
|
|
3
3
|
/** Specializes the physical H5 App for one configured project. */
|
|
4
4
|
export declare function transformH5App({ code, id, options, projectRoot, sourcemap }: {
|
|
5
5
|
code: string;
|
|
6
6
|
id: string;
|
|
7
|
-
options:
|
|
7
|
+
options: VptOptions;
|
|
8
8
|
projectRoot: string;
|
|
9
9
|
sourcemap?: boolean;
|
|
10
10
|
}): Promise<AstTransformResult>;
|
|
@@ -2,8 +2,8 @@ import { types } from '@babel/core';
|
|
|
2
2
|
import { createPageComponentImportPath } from '../../utils/modules.js';
|
|
3
3
|
import { createAppConfig } from '../../utils/project-config.js';
|
|
4
4
|
import { replaceWithAst } from '../../utils/transform.js';
|
|
5
|
-
const appConfigPlaceholder = '
|
|
6
|
-
const routesPlaceholder = '
|
|
5
|
+
const appConfigPlaceholder = '__VPT_H5_APP_CONFIG__';
|
|
6
|
+
const routesPlaceholder = '__VPT_H5_ROUTES__';
|
|
7
7
|
/** Specializes the physical H5 App for one configured project. */
|
|
8
8
|
export async function transformH5App({ code, id, options, projectRoot, sourcemap = true }) {
|
|
9
9
|
const transformed = await replaceWithAst(code, id, {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { GetModuleInfo, Plugin } from 'rolldown';
|
|
2
|
+
/** Final CSS extracted from Vite's transformed style module, before the shared WX compatibility pass. */
|
|
2
3
|
type ProcessedStyle = Readonly<{
|
|
3
4
|
css: string;
|
|
5
|
+
/** Marks roots whose generated utilities must be refreshed when JavaScript changes Tailwind candidates. */
|
|
4
6
|
isTailwindRoot: boolean;
|
|
5
7
|
}>;
|
|
8
|
+
/** Minimal structural view of DevEngine output; style reconciliation does not own chunks or other asset metadata. */
|
|
6
9
|
type CompleteOutputFile = Readonly<{
|
|
7
10
|
type: 'asset';
|
|
8
11
|
fileName: string;
|
|
@@ -20,10 +23,19 @@ export type StyleCaptureAction = Readonly<{
|
|
|
20
23
|
style: ProcessedStyle;
|
|
21
24
|
}>;
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
26
|
+
* Captures final Vite CSS and composes the graph projection with its durable WXSS publisher.
|
|
24
27
|
*
|
|
25
|
-
* Rolldown remains authoritative for topology
|
|
26
|
-
*
|
|
28
|
+
* Rolldown remains authoritative for topology. Plugin hooks emit typed actions so the host serializes capture mutations with
|
|
29
|
+
* output and HMR publication; the projection and publisher below each own only one mutable concern.
|
|
30
|
+
*
|
|
31
|
+
* Complete-build path:
|
|
32
|
+
* final transform captures → DevEngine output write → graph reconciliation → App build rotation
|
|
33
|
+
*
|
|
34
|
+
* Incremental path:
|
|
35
|
+
* final transform captures → optional Tailwind root refresh → graph rendering → WXSS write → JavaScript patch publication
|
|
36
|
+
*
|
|
37
|
+
* Both paths render the same ordered App/Page graph projection. This prevents complete builds and HMR from implementing two
|
|
38
|
+
* subtly different CSS ownership policies, while keeping physical byte equality and atomic writes out of graph state.
|
|
27
39
|
*/
|
|
28
40
|
export declare function createStyleCapture({ applicationEntryIds, outDir, emit, transformTailwindRoot }: {
|
|
29
41
|
applicationEntryIds: readonly string[];
|
|
@@ -33,10 +45,10 @@ export declare function createStyleCapture({ applicationEntryIds, outDir, emit,
|
|
|
33
45
|
code: string;
|
|
34
46
|
}> | null>;
|
|
35
47
|
}): Readonly<{
|
|
36
|
-
bindOutput: (output: readonly CompleteOutputFile[]) => void;
|
|
37
48
|
captureGraph: (reader: GetModuleInfo) => void;
|
|
38
49
|
captureStyle: (id: string, style: ProcessedStyle) => void;
|
|
39
50
|
plugin: Plugin;
|
|
40
51
|
publishChanged: (changedIds: readonly string[]) => Promise<void>;
|
|
52
|
+
reconcileComplete: (output: readonly CompleteOutputFile[]) => Promise<void>;
|
|
41
53
|
}>;
|
|
42
54
|
export {};
|
|
@@ -4,50 +4,39 @@ import { transformWxStyle } from '../styles/transform-wx-style.js';
|
|
|
4
4
|
import { composeGraphStyleCss, createGraphStylePlan, createTailwindSidecarId, extractViteCss, isGlobalStyleRequest } from '../styles/utils.js';
|
|
5
5
|
import { globalWxssFileName, writeHmrFile } from './hmr-files.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Captures final Vite CSS and composes the graph projection with its durable WXSS publisher.
|
|
8
8
|
*
|
|
9
|
-
* Rolldown remains authoritative for topology
|
|
10
|
-
*
|
|
9
|
+
* Rolldown remains authoritative for topology. Plugin hooks emit typed actions so the host serializes capture mutations with
|
|
10
|
+
* output and HMR publication; the projection and publisher below each own only one mutable concern.
|
|
11
|
+
*
|
|
12
|
+
* Complete-build path:
|
|
13
|
+
* final transform captures → DevEngine output write → graph reconciliation → App build rotation
|
|
14
|
+
*
|
|
15
|
+
* Incremental path:
|
|
16
|
+
* final transform captures → optional Tailwind root refresh → graph rendering → WXSS write → JavaScript patch publication
|
|
17
|
+
*
|
|
18
|
+
* Both paths render the same ordered App/Page graph projection. This prevents complete builds and HMR from implementing two
|
|
19
|
+
* subtly different CSS ownership policies, while keeping physical byte equality and atomic writes out of graph state.
|
|
11
20
|
*/
|
|
12
21
|
export function createStyleCapture({ applicationEntryIds, outDir, emit, transformTailwindRoot }) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
let getModuleInfo;
|
|
20
|
-
/*
|
|
21
|
-
* This mutable Map is the CSS projection Rolldown does not retain: successful final transform hooks replace one module's
|
|
22
|
-
* processed bytes, failed transforms intentionally leave its last valid generation, and a successful multi-root Tailwind
|
|
23
|
-
* refresh commits all replacements only after every sibling resolves. Entries are not deleted when topology changes because
|
|
24
|
-
* reachability comes from the live graph plan; eager deletion would need a duplicate reverse graph and could remove CSS still
|
|
25
|
-
* shared by another App/Page root. Its size is bounded by style module identities seen during this server lifecycle.
|
|
26
|
-
*/
|
|
27
|
-
const processedStyles = new Map();
|
|
28
|
-
/*
|
|
29
|
-
* This mutable value mirrors the WXSS bytes currently durable on disk. It has one owner but two real transition sources:
|
|
30
|
-
*
|
|
31
|
-
* 1. DevEngine physically writes complete output before onOutput, so bindOutput only observes and adopts that external
|
|
32
|
-
* commit. An omitted asset means DevEngine preserved the existing file and this value must remain unchanged.
|
|
33
|
-
* 2. Incremental HMR is physically written by this host, so publishChanged advances the value only after its atomic write
|
|
34
|
-
* succeeds (or after byte equality proves no write was needed).
|
|
35
|
-
*
|
|
36
|
-
* Combining these operations behind one generic update event would still require branching between “observe an existing
|
|
37
|
-
* write” and “perform a new write”, while hiding their different durability boundaries. A genuine single path would require
|
|
38
|
-
* preventing DevEngine from writing complete WXSS and transferring that entire output responsibility to the host, adding
|
|
39
|
-
* asset interception and ordering machinery. The two explicit methods are therefore the smallest accurate state model.
|
|
40
|
-
*/
|
|
41
|
-
let publishedWxss;
|
|
22
|
+
const projection = createStyleProjection({
|
|
23
|
+
applicationEntryIds: applicationEntryIds,
|
|
24
|
+
transformTailwindRoot: transformTailwindRoot
|
|
25
|
+
});
|
|
26
|
+
const publication = createStylePublication(outDir);
|
|
42
27
|
const plugin = {
|
|
43
28
|
name: 'vpt:wx-dev-style-capture',
|
|
44
29
|
buildStart() {
|
|
30
|
+
// Capture a live reader rather than a graph snapshot. Rolldown updates the capability as imports change, and a later
|
|
31
|
+
// complete generation replaces it through the host action queue before that generation can publish output.
|
|
45
32
|
emit({ kind: 'capture-graph', getModuleInfo: (moduleId) => this.getModuleInfo(moduleId) });
|
|
46
33
|
},
|
|
47
34
|
transform(code, id) {
|
|
48
35
|
if (!isGlobalStyleRequest(id)) {
|
|
49
36
|
return;
|
|
50
37
|
}
|
|
38
|
+
// This host plugin runs after Vite's CSS transform, so `code` is the JavaScript wrapper containing final PostCSS and
|
|
39
|
+
// CSS-Module output. Capturing source CSS instead would lose generated class names and framework transformations.
|
|
51
40
|
const css = extractViteCss(code, id);
|
|
52
41
|
emit({
|
|
53
42
|
kind: 'capture-style',
|
|
@@ -60,48 +49,107 @@ export function createStyleCapture({ applicationEntryIds, outDir, emit, transfor
|
|
|
60
49
|
}
|
|
61
50
|
};
|
|
62
51
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
captureGraph: projection.captureGraph,
|
|
53
|
+
captureStyle: projection.captureStyle,
|
|
54
|
+
plugin: plugin,
|
|
55
|
+
async publishChanged(changedIds) {
|
|
56
|
+
// A CSS edit already carries updated processed bytes. Any non-CSS edit can alter both imports and Tailwind class
|
|
57
|
+
// candidates, so it requires a fresh graph plan and Tailwind-root generation even when no .css ID changed directly.
|
|
58
|
+
const styleChanged = changedIds.some(isGlobalStyleRequest);
|
|
59
|
+
const candidatesChanged = changedIds.some((id) => !isCSSRequest(id));
|
|
60
|
+
if (!styleChanged && !candidatesChanged) {
|
|
61
|
+
return;
|
|
71
62
|
}
|
|
63
|
+
await publication.publish(await projection.render(candidatesChanged));
|
|
72
64
|
},
|
|
65
|
+
async reconcileComplete(output) {
|
|
66
|
+
// Bundled development can omit CSS Modules from the compiler asset even with cssCodeSplit disabled. Observe the
|
|
67
|
+
// physical output first, then reconcile the same graph projection used by incremental HMR before App rotation.
|
|
68
|
+
publication.observeOutput(output);
|
|
69
|
+
await publication.publish(await projection.render(false));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Owns the live graph capability and final transformed bytes for every observed style module.
|
|
75
|
+
*
|
|
76
|
+
* Rendering is O(V + E + C): graph planning visits each reachable module and edge once, then composition and WX conversion
|
|
77
|
+
* process C CSS bytes once. The only persistent memory is one processed byte string per style identity observed by the server.
|
|
78
|
+
*/
|
|
79
|
+
function createStyleProjection({ applicationEntryIds, transformTailwindRoot }) {
|
|
80
|
+
/*
|
|
81
|
+
* This mutable capability is rebound by buildStart for each complete generation. Rolldown keeps the function live across
|
|
82
|
+
* incremental graph edits, so rendering uses authoritative topology without maintaining a shadow graph.
|
|
83
|
+
*/
|
|
84
|
+
let getModuleInfo;
|
|
85
|
+
/*
|
|
86
|
+
* This mutable projection stores final CSS bytes that Rolldown does not retain. Successful transforms replace one entry;
|
|
87
|
+
* unreachable entries can remain because every render filters them through the current graph plan. Its size is bounded by
|
|
88
|
+
* style module identities observed during this server lifecycle.
|
|
89
|
+
*/
|
|
90
|
+
const processedStyles = new Map();
|
|
91
|
+
return {
|
|
73
92
|
captureGraph(reader) {
|
|
74
93
|
getModuleInfo = reader;
|
|
75
94
|
},
|
|
76
95
|
captureStyle(id, style) {
|
|
77
96
|
processedStyles.set(id, style);
|
|
78
97
|
},
|
|
79
|
-
|
|
80
|
-
async publishChanged(changedIds) {
|
|
81
|
-
const styleChanged = changedIds.some(isGlobalStyleRequest);
|
|
82
|
-
const candidatesChanged = changedIds.some((id) => !isCSSRequest(id));
|
|
83
|
-
if (!styleChanged && !candidatesChanged) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
98
|
+
async render(refreshTailwind) {
|
|
86
99
|
if (!getModuleInfo) {
|
|
87
|
-
throw new Error('WX style graph is unavailable before
|
|
100
|
+
throw new Error('WX style graph is unavailable before publication');
|
|
88
101
|
}
|
|
89
|
-
//
|
|
102
|
+
// App first and configured Pages afterward define one deterministic global cascade. The plan also removes stale map
|
|
103
|
+
// entries implicitly: styles no longer reachable from these roots never enter composition.
|
|
90
104
|
const styleIds = createGraphStylePlan(applicationEntryIds, getModuleInfo, (styleId) => processedStyles.has(styleId));
|
|
91
|
-
if (
|
|
105
|
+
if (refreshTailwind) {
|
|
92
106
|
await refreshTailwindStyles(styleIds, processedStyles, transformTailwindRoot);
|
|
93
107
|
}
|
|
108
|
+
// Compose browser-facing transformed CSS first, then run one whole-file WX pass. Transforming modules independently
|
|
109
|
+
// would change cross-module cascade behavior and duplicate compatibility work.
|
|
94
110
|
const css = composeGraphStyleCss(styleIds, (styleId) => requireProcessedStyle(processedStyles, styleId).css);
|
|
95
|
-
|
|
111
|
+
return (await transformWxStyle(css)).css;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Owns the physical WXSS frontier independently from graph capture and rendering.
|
|
117
|
+
*
|
|
118
|
+
* DevEngine writes complete output itself; incremental HMR does not. Observing complete output before publishing the projection
|
|
119
|
+
* gives both writers one byte frontier, so equality avoids redundant filesystem notifications without pretending the host owns
|
|
120
|
+
* the compiler's write transaction.
|
|
121
|
+
*/
|
|
122
|
+
function createStylePublication(outDir) {
|
|
123
|
+
/*
|
|
124
|
+
* This mutable value mirrors bytes durable on disk. Complete output adopts the compiler's external write before graph
|
|
125
|
+
* reconciliation; host publication advances it only after an atomic write succeeds or byte equality proves none is needed.
|
|
126
|
+
*/
|
|
127
|
+
let publishedWxss;
|
|
128
|
+
return {
|
|
129
|
+
observeOutput(output) {
|
|
130
|
+
// Missing WXSS means DevEngine intentionally reused the existing physical asset. Do not reset the frontier: doing so
|
|
131
|
+
// would force an identical rewrite and a spurious DevTools style event on every omitted complete generation.
|
|
132
|
+
const style = output.find((file) => file.type === 'asset' && file.fileName === globalWxssFileName);
|
|
133
|
+
if (style) {
|
|
134
|
+
publishedWxss = typeof style.source === 'string' ? style.source : new TextDecoder().decode(style.source);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
async publish(wxss) {
|
|
96
138
|
if (wxss !== publishedWxss) {
|
|
139
|
+
// writeHmrFile uses atomic replacement; advance the frontier only after durability so a failed write leaves the
|
|
140
|
+
// last known physical generation available for the next reconciliation attempt.
|
|
97
141
|
await writeHmrFile(outDir, globalWxssFileName, wxss);
|
|
98
142
|
}
|
|
99
|
-
// HMR is the second physical writer; advance the frontier only after its atomic write succeeds or was unnecessary.
|
|
100
143
|
publishedWxss = wxss;
|
|
101
144
|
}
|
|
102
145
|
};
|
|
103
146
|
}
|
|
104
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Regenerates all reachable Tailwind roots and commits the cache only when every transform succeeds.
|
|
149
|
+
*
|
|
150
|
+
* Roots run concurrently because they are independent derivations of the same candidate generation. Results remain local until
|
|
151
|
+
* Promise.all fulfills; one failed root therefore preserves every prior root together instead of publishing a mixed generation.
|
|
152
|
+
*/
|
|
105
153
|
async function refreshTailwindStyles(styleIds, processedStyles, transformRoot) {
|
|
106
154
|
const roots = styleIds.filter((styleId) => requireProcessedStyle(processedStyles, styleId).isTailwindRoot);
|
|
107
155
|
const refreshedStyles = await Promise.all(roots.map(async (rootId) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ViteDevServer } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../../options.ts';
|
|
3
3
|
export type WxDevHost = Readonly<{
|
|
4
4
|
close: () => Promise<void>;
|
|
5
5
|
}>;
|
|
@@ -14,6 +14,6 @@ export type WxDevHost = Readonly<{
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function createWxDevHost({ server, options, applicationEntryIds }: {
|
|
16
16
|
server: ViteDevServer;
|
|
17
|
-
options:
|
|
17
|
+
options: VptOptions;
|
|
18
18
|
applicationEntryIds: readonly string[];
|
|
19
19
|
}): Promise<WxDevHost>;
|
|
@@ -11,7 +11,7 @@ import { PatchPublisher } from './patch-publisher.js';
|
|
|
11
11
|
import { createRuntimeReportsStream } from './runtime-reports.js';
|
|
12
12
|
import { installWxDevOptions, requireSingleOutput } from './wx-dev-options.js';
|
|
13
13
|
/** One short trailing-edge window absorbs editor bursts before style preparation and physical Page notification. */
|
|
14
|
-
const hmrSettleMilliseconds =
|
|
14
|
+
const hmrSettleMilliseconds = 16;
|
|
15
15
|
/**
|
|
16
16
|
* Creates the wx dev host: the adapter that owns the physical Rolldown DevEngine (created
|
|
17
17
|
* with dev(...)) and the patch publisher, and replaces Vite's bundledDev.listen so the
|
|
@@ -163,12 +163,22 @@ export async function createWxDevHost({ server, options, applicationEntryIds })
|
|
|
163
163
|
logWxError(server.config.logger, 'wx dev build failed', action.result);
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
return rotateBuildSession();
|
|
166
|
+
return reconcileCompleteOutput(action.result.output);
|
|
168
167
|
case 'listening':
|
|
169
168
|
return rotateBuildSession();
|
|
170
169
|
}
|
|
171
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Reconciles graph-complete styles before rotating the App-visible build identity.
|
|
173
|
+
*
|
|
174
|
+
* DevEngine has already written its compiler asset when onOutput fires, but bundled development may have omitted CSS Modules
|
|
175
|
+
* from that asset. Awaiting reconciliation inside the serialized reducer guarantees the subsequent app.wxss rotation—the
|
|
176
|
+
* event that refreshes DevTools—can only expose a generation whose global WXSS already represents the complete App/Page graph.
|
|
177
|
+
*/
|
|
178
|
+
async function reconcileCompleteOutput(output) {
|
|
179
|
+
await styleCapture.reconcileComplete(output);
|
|
180
|
+
await rotateBuildSession();
|
|
181
|
+
}
|
|
172
182
|
/** Applies one runtime receipt to the active physical patch history. */
|
|
173
183
|
function processReport(report) {
|
|
174
184
|
// Delayed reports from older builds must never prune the live build's cumulative patch history.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PluginOption } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../../options.ts';
|
|
3
3
|
/** Selects the sole Vite environment that owns the physical Mini Program development project. */
|
|
4
4
|
export declare function isWxClientEnvironment(environment: Readonly<{
|
|
5
5
|
name: string;
|
|
@@ -11,7 +11,7 @@ export declare function isWxClientEnvironment(environment: Readonly<{
|
|
|
11
11
|
* The ordered application entries cross this configuration boundary unchanged so the host can compose global CSS without
|
|
12
12
|
* reconstructing the resolver's App/Page ownership policy from unrelated Rolldown shell and transport entries.
|
|
13
13
|
*/
|
|
14
|
-
export declare function createWxDevelopmentPlugin(options:
|
|
14
|
+
export declare function createWxDevelopmentPlugin(options: VptOptions, applicationEntryIds: readonly string[]): PluginOption[];
|
|
15
15
|
/**
|
|
16
16
|
* Transfers development ownership of `app.wxss` from complete output to the dev host.
|
|
17
17
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InputOptions, OutputOptions, Plugin } from 'rolldown';
|
|
2
2
|
import { type DevEngine } from 'rolldown/experimental';
|
|
3
3
|
import type { ViteDevServer } from 'vite';
|
|
4
|
-
import type {
|
|
4
|
+
import type { VptOptions } from '../../../../options.ts';
|
|
5
5
|
type BundledDevRolldownOptions = InputOptions & {
|
|
6
6
|
experimental?: {
|
|
7
7
|
[key: string]: unknown;
|
|
@@ -22,7 +22,7 @@ export type BundledDev = {
|
|
|
22
22
|
export declare function installWxDevOptions({ bundledDev, server, options, hostPlugins }: {
|
|
23
23
|
bundledDev: BundledDev;
|
|
24
24
|
server: ViteDevServer;
|
|
25
|
-
options:
|
|
25
|
+
options: VptOptions;
|
|
26
26
|
hostPlugins: Plugin[];
|
|
27
27
|
}): void;
|
|
28
28
|
/** Returns the configured output after rejecting states unsupported by the physical WX engine. */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Rolldown } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../../options.ts';
|
|
3
3
|
import type { GeneratedSubpackage } from '../placement/placer.ts';
|
|
4
4
|
/** Creates every compiler-owned WX file derived from the final Rolldown bundle. */
|
|
5
5
|
export declare function createOutputFiles({ bundle, options, subpackages, getModuleInfo }: {
|
|
6
6
|
bundle: Rolldown.OutputBundle;
|
|
7
|
-
options:
|
|
7
|
+
options: VptOptions;
|
|
8
8
|
subpackages: readonly GeneratedSubpackage[];
|
|
9
9
|
getModuleInfo: (moduleId: string) => {
|
|
10
10
|
meta: Rolldown.CustomPluginOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Rolldown } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptJsonObject, VptOptions } from '../../../../options.ts';
|
|
3
3
|
import type { GeneratedSubpackage } from '../placement/placer.ts';
|
|
4
4
|
/** Creates every configured native JSON asset. */
|
|
5
5
|
export declare function createJsonAssets({ options, subpackages, nativeComponents }: {
|
|
6
|
-
options:
|
|
6
|
+
options: VptOptions;
|
|
7
7
|
subpackages: readonly GeneratedSubpackage[];
|
|
8
8
|
nativeComponents: readonly {
|
|
9
9
|
name: string;
|
|
@@ -11,4 +11,4 @@ export declare function createJsonAssets({ options, subpackages, nativeComponent
|
|
|
11
11
|
}[];
|
|
12
12
|
}): Rolldown.EmittedAsset[];
|
|
13
13
|
/** Serializes one native JSON object with stable formatting. */
|
|
14
|
-
export declare function renderJson(value:
|
|
14
|
+
export declare function renderJson(value: VptJsonObject): string;
|
|
@@ -13,7 +13,7 @@ export function createJsonAssets({ options, subpackages, nativeComponents }) {
|
|
|
13
13
|
...(options.projectPrivateConfigJson
|
|
14
14
|
? [createJsonAsset('project.private.config.json', options.projectPrivateConfigJson)]
|
|
15
15
|
: []),
|
|
16
|
-
createJsonAsset('sitemap.json', options.sitemapJson)
|
|
16
|
+
...(options.sitemapJson ? [createJsonAsset('sitemap.json', options.sitemapJson)] : [])
|
|
17
17
|
];
|
|
18
18
|
}
|
|
19
19
|
/** Creates Page JSON with generated Taro and native component registrations. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Rolldown } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../../options.ts';
|
|
3
3
|
/** Creates Taro's shared WeChat templates and native WXML/WXSS companions for every Page. */
|
|
4
|
-
export declare function createTemplateAssets(bundle: Rolldown.OutputBundle, options:
|
|
4
|
+
export declare function createTemplateAssets(bundle: Rolldown.OutputBundle, options: VptOptions, nativeComponents: readonly {
|
|
5
5
|
name: string;
|
|
6
6
|
fields: readonly string[];
|
|
7
7
|
}[]): Rolldown.EmittedAsset[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PluginOption } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../options.ts';
|
|
3
3
|
/** Creates the complete plugin set for the wx target. */
|
|
4
|
-
export declare function createWxTargetPlugins(options:
|
|
4
|
+
export declare function createWxTargetPlugins(options: VptOptions): PluginOption[];
|
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { types } from '@babel/core';
|
|
3
3
|
import { replaceWithAst } from '../../../utils/transform.js';
|
|
4
4
|
import { getWxExecutionKind } from '../module.js';
|
|
5
|
-
const transportPlaceholder = '
|
|
5
|
+
const transportPlaceholder = '__VPT_TRANSPORT__';
|
|
6
6
|
const moduleIdParameter = 'moduleId';
|
|
7
7
|
const exportBindingParameter = 'exportBinding';
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VptOptions } from '../../../../options.ts';
|
|
2
2
|
/** Creates the resolver and source specializer for the wx module graph. */
|
|
3
|
-
export declare function createResolver(options:
|
|
3
|
+
export declare function createResolver(options: VptOptions): {
|
|
4
4
|
resolveId(id: string, importer: string | undefined, projectRoot: string): string | undefined;
|
|
5
5
|
specialize(code: string, id: string, sourcemap?: boolean): Promise<import("../../../utils/transform.ts").AstTransformResult> | undefined;
|
|
6
6
|
applicationEntryIds: string[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VptJsonObject } from '../../../../options.ts';
|
|
2
2
|
import { type AstTransformResult } from '../../../utils/transform.ts';
|
|
3
3
|
/** Specializes the amphibious bootstrap with the shared App configuration. */
|
|
4
4
|
export declare function specializeBootstrap({ code, id, appConfig, sourcemap }: {
|
|
5
5
|
code: string;
|
|
6
6
|
id: string;
|
|
7
|
-
appConfig:
|
|
7
|
+
appConfig: VptJsonObject;
|
|
8
8
|
sourcemap?: boolean;
|
|
9
9
|
}): Promise<AstTransformResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { types } from '@babel/core';
|
|
2
2
|
import { replaceWithAst } from '../../../utils/transform.js';
|
|
3
|
-
const appConfigPlaceholder = '
|
|
3
|
+
const appConfigPlaceholder = '__VPT_APP_CONFIG__';
|
|
4
4
|
/** Specializes the amphibious bootstrap with the shared App configuration. */
|
|
5
5
|
export function specializeBootstrap({ code, id, appConfig, sourcemap = true }) {
|
|
6
6
|
return replaceWithAst(code, id, {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VptPageOption } from '../../../../options.ts';
|
|
2
2
|
import { type AstTransformResult } from '../../../utils/transform.ts';
|
|
3
3
|
/** Specializes the Page capsule for one configured route. */
|
|
4
4
|
export declare function specializePageCapsule({ code, id, page, sourcemap }: {
|
|
5
5
|
code: string;
|
|
6
6
|
id: string;
|
|
7
|
-
page:
|
|
7
|
+
page: VptPageOption;
|
|
8
8
|
sourcemap?: boolean;
|
|
9
9
|
}): Promise<AstTransformResult>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { types } from '@babel/core';
|
|
2
2
|
import { replaceWithAst } from '../../../utils/transform.js';
|
|
3
|
-
const pagePathPlaceholder = '
|
|
4
|
-
const pageConfigPlaceholder = '
|
|
3
|
+
const pagePathPlaceholder = '__VPT_PAGE_PATH__';
|
|
4
|
+
const pageConfigPlaceholder = '__VPT_PAGE_CONFIG__';
|
|
5
5
|
/** Specializes the Page capsule for one configured route. */
|
|
6
6
|
export function specializePageCapsule({ code, id, page, sourcemap = true }) {
|
|
7
7
|
return replaceWithAst(code, id, {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VptJsonObject, VptOptions } from '../../options.ts';
|
|
2
2
|
/** Creates shared App configuration with configured Page order as the authoritative value. */
|
|
3
|
-
export declare function createAppConfig(options:
|
|
3
|
+
export declare function createAppConfig(options: VptOptions): VptJsonObject;
|
|
@@ -4,7 +4,7 @@ import { createConditionalDirectivePlugin } from './plugins/conditional/conditio
|
|
|
4
4
|
import { createH5TargetPlugins } from './plugins/h5/plugins.js';
|
|
5
5
|
import { createWxTargetPlugins } from './plugins/wx/plugins.js';
|
|
6
6
|
/** Creates the Vite plugins for one Taro target. */
|
|
7
|
-
export default function
|
|
7
|
+
export default function vpt(options) {
|
|
8
8
|
return [
|
|
9
9
|
createConditionalDirectivePlugin(options.target),
|
|
10
10
|
createClientTaroPlugin(options.target),
|