vite-plugin-taro 0.5.7 → 0.5.9
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/wx/dev/empty-output-directory.d.ts +2 -0
- package/dist/node/plugins/wx/dev/empty-output-directory.js +7 -0
- package/dist/node/plugins/wx/dev/wx-dev-options.js +8 -7
- package/dist/node/plugins/wx/plugins.js +2 -2
- package/dist/runtime/wx/dev/dev-runtime.js +1 -1
- package/package.json +3 -3
- package/src/node/plugins/wx/dev/empty-output-directory.ts +8 -0
- package/src/node/plugins/wx/dev/wx-dev-options.ts +8 -7
- package/src/node/plugins/wx/plugins.ts +2 -2
- package/src/runtime/wx/dev/dev-runtime.ts +4 -4
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/** Creates the one startup cleanup allowed before Rolldown begins tracking incremental output in memory. */
|
|
2
|
+
export declare function createInitialOutputDirectoryCleaner(directory: string): () => Promise<void>;
|
|
1
3
|
/** Empties an output directory without replacing the directory itself or deleting Git metadata. */
|
|
2
4
|
export declare function emptyOutputDirectory(directory: string): Promise<void>;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { once } from '../../../utils/once.js';
|
|
4
|
+
/** Creates the one startup cleanup allowed before Rolldown begins tracking incremental output in memory. */
|
|
5
|
+
export function createInitialOutputDirectoryCleaner(directory) {
|
|
6
|
+
// Later full builds suppress byte-identical emitted assets. Clearing again would delete those files behind Rolldown's
|
|
7
|
+
// output cache, so the writer would correctly emit no bytes and leave the physical Mini Program incomplete.
|
|
8
|
+
return once(() => emptyOutputDirectory(directory));
|
|
9
|
+
}
|
|
3
10
|
/** Empties an output directory without replacing the directory itself or deleting Git metadata. */
|
|
4
11
|
export async function emptyOutputDirectory(directory) {
|
|
5
12
|
await fs.mkdir(directory, { recursive: true });
|
|
@@ -5,7 +5,7 @@ import { once } from '../../../utils/once.js';
|
|
|
5
5
|
import { resolvePackageFile } from '../../../utils/packages.js';
|
|
6
6
|
import { appShellFileName } from '../module.js';
|
|
7
7
|
import { createWxDevMode } from './create-wx-dev-mode.js';
|
|
8
|
-
import {
|
|
8
|
+
import { createInitialOutputDirectoryCleaner } from './empty-output-directory.js';
|
|
9
9
|
/** Installs the physical WX output and runtime conventions over Vite's browser-oriented bundled-development options. */
|
|
10
10
|
export function installWxDevOptions({ bundledDev, server, options }) {
|
|
11
11
|
// The buildEnd hook and its one-shot result belong to the same abstraction. Consumers can await startup without receiving
|
|
@@ -42,13 +42,14 @@ export function installWxDevOptions({ bundledDev, server, options }) {
|
|
|
42
42
|
});
|
|
43
43
|
rolldownOptions.experimental ??= {};
|
|
44
44
|
rolldownOptions.experimental.devMode = createWxDevMode(rolldownOptions.experimental.devMode, await bundleRuntimeSource());
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
const initializeOutputDirectory = createInitialOutputDirectoryCleaner(server.config.build.outDir);
|
|
46
|
+
const initializeOutputDirectoryPlugin = {
|
|
47
|
+
name: 'vpt:wx-initialize-output-directory',
|
|
47
48
|
renderStart: {
|
|
48
49
|
order: 'pre',
|
|
49
|
-
// DevEngine bypasses Vite's build-only output preparation.
|
|
50
|
-
//
|
|
51
|
-
handler:
|
|
50
|
+
// DevEngine bypasses Vite's build-only output preparation. Remove stale startup contents once, before
|
|
51
|
+
// Rolldown starts treating its in-memory incremental output as authoritative for later complete builds.
|
|
52
|
+
handler: initializeOutputDirectory
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
55
|
const reportInitialBuildPlugin = {
|
|
@@ -56,7 +57,7 @@ export function installWxDevOptions({ bundledDev, server, options }) {
|
|
|
56
57
|
buildEnd: settleInitialBuild
|
|
57
58
|
};
|
|
58
59
|
rolldownOptions.plugins = [
|
|
59
|
-
|
|
60
|
+
initializeOutputDirectoryPlugin,
|
|
60
61
|
rolldownOptions.plugins,
|
|
61
62
|
reportInitialBuildPlugin,
|
|
62
63
|
createViteReporter(server)
|
|
@@ -104,8 +104,8 @@ function createWxPlugin(options) {
|
|
|
104
104
|
generateBundle: {
|
|
105
105
|
/*
|
|
106
106
|
* This hook is registered after createCssPlugins() and shares hook-level `order: 'post'` with the adapted
|
|
107
|
-
* upstream hooks and VPT style finalizer. Registration order therefore guarantees that
|
|
108
|
-
* before native Page/component companions are emitted. Without this order, the
|
|
107
|
+
* upstream hooks and VPT style finalizer. Registration order therefore guarantees that the imported global
|
|
108
|
+
* stylesheet is complete before native Page/component companions are emitted. Without this order, the finalizer could consume
|
|
109
109
|
* incomplete Tailwind output or mistake native WXSS companions for additional compiler styles.
|
|
110
110
|
*/
|
|
111
111
|
order: 'post',
|
|
@@ -278,7 +278,7 @@ class WxDevRuntime extends DevRuntime {
|
|
|
278
278
|
/**
|
|
279
279
|
* Folds one cumulative physical patch file into a single logical HMR update.
|
|
280
280
|
*
|
|
281
|
-
* `hmr/patches.js` can contain several unacknowledged
|
|
281
|
+
* `hmr/patches.js` can contain several unacknowledged application patches and can be required by several Page shells. The
|
|
282
282
|
* runtime must therefore ignore replayed sequences, reject a missing sequence, and move directly from the currently live
|
|
283
283
|
* module generation to the latest published generation without rendering intermediate generations.
|
|
284
284
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
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",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"rolldown": "1.2.3",
|
|
76
76
|
"tailwindcss": "^4.3.3",
|
|
77
77
|
"weapp-tailwindcss": "^5.2.11",
|
|
78
|
-
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.5.
|
|
79
|
-
"@tarojs/react": "npm:vite-plugin-taro-react@0.5.
|
|
78
|
+
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.5.9",
|
|
79
|
+
"@tarojs/react": "npm:vite-plugin-taro-react@0.5.9"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"react": "^19.0.0",
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
+
import { once } from '../../../utils/once.ts'
|
|
4
|
+
|
|
5
|
+
/** Creates the one startup cleanup allowed before Rolldown begins tracking incremental output in memory. */
|
|
6
|
+
export function createInitialOutputDirectoryCleaner(directory: string): () => Promise<void> {
|
|
7
|
+
// Later full builds suppress byte-identical emitted assets. Clearing again would delete those files behind Rolldown's
|
|
8
|
+
// output cache, so the writer would correctly emit no bytes and leave the physical Mini Program incomplete.
|
|
9
|
+
return once(() => emptyOutputDirectory(directory))
|
|
10
|
+
}
|
|
3
11
|
|
|
4
12
|
/** Empties an output directory without replacing the directory itself or deleting Git metadata. */
|
|
5
13
|
export async function emptyOutputDirectory(directory: string): Promise<void> {
|
|
@@ -8,7 +8,7 @@ import { once } from '../../../utils/once.ts'
|
|
|
8
8
|
import { resolvePackageFile } from '../../../utils/packages.ts'
|
|
9
9
|
import { appShellFileName } from '../module.ts'
|
|
10
10
|
import { createWxDevMode } from './create-wx-dev-mode.ts'
|
|
11
|
-
import {
|
|
11
|
+
import { createInitialOutputDirectoryCleaner } from './empty-output-directory.ts'
|
|
12
12
|
|
|
13
13
|
export type BundledDevRolldownOptions = InputOptions & {
|
|
14
14
|
experimental?: {
|
|
@@ -77,13 +77,14 @@ export function installWxDevOptions({
|
|
|
77
77
|
await bundleRuntimeSource()
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
const
|
|
81
|
-
|
|
80
|
+
const initializeOutputDirectory = createInitialOutputDirectoryCleaner(server.config.build.outDir)
|
|
81
|
+
const initializeOutputDirectoryPlugin: Plugin = {
|
|
82
|
+
name: 'vpt:wx-initialize-output-directory',
|
|
82
83
|
renderStart: {
|
|
83
84
|
order: 'pre',
|
|
84
|
-
// DevEngine bypasses Vite's build-only output preparation.
|
|
85
|
-
//
|
|
86
|
-
handler:
|
|
85
|
+
// DevEngine bypasses Vite's build-only output preparation. Remove stale startup contents once, before
|
|
86
|
+
// Rolldown starts treating its in-memory incremental output as authoritative for later complete builds.
|
|
87
|
+
handler: initializeOutputDirectory
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -93,7 +94,7 @@ export function installWxDevOptions({
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
rolldownOptions.plugins = [
|
|
96
|
-
|
|
97
|
+
initializeOutputDirectoryPlugin,
|
|
97
98
|
rolldownOptions.plugins,
|
|
98
99
|
reportInitialBuildPlugin,
|
|
99
100
|
createViteReporter(server)
|
|
@@ -128,8 +128,8 @@ function createWxPlugin(options: VitePluginTaroOptions): Plugin {
|
|
|
128
128
|
generateBundle: {
|
|
129
129
|
/*
|
|
130
130
|
* This hook is registered after createCssPlugins() and shares hook-level `order: 'post'` with the adapted
|
|
131
|
-
* upstream hooks and VPT style finalizer. Registration order therefore guarantees that
|
|
132
|
-
* before native Page/component companions are emitted. Without this order, the
|
|
131
|
+
* upstream hooks and VPT style finalizer. Registration order therefore guarantees that the imported global
|
|
132
|
+
* stylesheet is complete before native Page/component companions are emitted. Without this order, the finalizer could consume
|
|
133
133
|
* incomplete Tailwind output or mistake native WXSS companions for additional compiler styles.
|
|
134
134
|
*/
|
|
135
135
|
order: 'post',
|
|
@@ -26,8 +26,8 @@ type HmrSession = {
|
|
|
26
26
|
/** Fixed control URL discovered from the Vite server that produced this full build. */
|
|
27
27
|
readonly endpoint: string
|
|
28
28
|
/**
|
|
29
|
-
* Highest contiguous
|
|
30
|
-
*
|
|
29
|
+
* Highest contiguous application sequence whose factories, graph propagation, and accept callbacks all succeeded.
|
|
30
|
+
* Host-filtered native asset updates consume no sequence. Replayed Page shells read this watermark; it advances only
|
|
31
31
|
* after an atomic batch succeeds and resets only with a new App heap.
|
|
32
32
|
*/
|
|
33
33
|
appliedSeq: number
|
|
@@ -39,7 +39,7 @@ type PatchPayload = Readonly<{
|
|
|
39
39
|
patches: readonly PatchProgram[]
|
|
40
40
|
}>
|
|
41
41
|
|
|
42
|
-
/** One patch: its
|
|
42
|
+
/** One patch: its physical application sequence, changed module ids, and Rolldown factory program. */
|
|
43
43
|
type PatchProgram = Readonly<{
|
|
44
44
|
seq: number
|
|
45
45
|
/** Stable ids of the changed modules; the sync apply walks the graph from these. */
|
|
@@ -415,7 +415,7 @@ class WxDevRuntime extends DevRuntime {
|
|
|
415
415
|
/**
|
|
416
416
|
* Folds one cumulative physical patch file into a single logical HMR update.
|
|
417
417
|
*
|
|
418
|
-
* `hmr/patches.js` can contain several unacknowledged
|
|
418
|
+
* `hmr/patches.js` can contain several unacknowledged application patches and can be required by several Page shells. The
|
|
419
419
|
* runtime must therefore ignore replayed sequences, reject a missing sequence, and move directly from the currently live
|
|
420
420
|
* module generation to the latest published generation without rendering intermediate generations.
|
|
421
421
|
*
|