vite-plugin-taro 0.6.2 → 0.6.5
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 +8 -3
- package/README.md +8 -3
- package/dist/node/plugins/wx/dev/dev-host.d.ts +5 -4
- package/dist/node/plugins/wx/dev/dev-host.js +19 -43
- package/dist/node/plugins/wx/dev/plugins.d.ts +6 -15
- package/dist/node/plugins/wx/dev/plugins.js +16 -70
- package/dist/node/plugins/wx/dev/react-refresh.d.ts +9 -3
- package/dist/node/plugins/wx/dev/react-refresh.js +35 -7
- package/dist/node/plugins/wx/dev/wx-dev-options.d.ts +2 -3
- package/dist/node/plugins/wx/dev/wx-dev-options.js +6 -7
- package/dist/node/plugins/wx/plugins.js +5 -11
- package/dist/node/plugins/wx/resolve/resolver.js +4 -4
- package/dist/node/plugins/wx/resolve/{specialize-bootstrap.d.ts → specialize-app-capsule.d.ts} +2 -2
- package/dist/node/plugins/wx/resolve/{specialize-bootstrap.js → specialize-app-capsule.js} +2 -2
- package/dist/node/plugins/wx/styles/plugins.d.ts +141 -3
- package/dist/node/plugins/wx/styles/plugins.js +401 -89
- package/dist/node/utils/vite.d.ts +4 -14
- package/dist/node/utils/vite.js +7 -40
- package/dist/runtime/wx/amphibious/bootstrap.d.ts +0 -2
- package/dist/runtime/wx/amphibious/bootstrap.js +0 -2
- package/dist/runtime/wx/capsule/app.d.ts +2 -2
- package/dist/runtime/wx/capsule/app.js +2 -2
- package/dist/runtime/wx/dev/dev-runtime.js +55 -79
- package/package.json +4 -3
- package/src/node/plugins/wx/dev/dev-host.ts +22 -44
- package/src/node/plugins/wx/dev/plugins.ts +17 -73
- package/src/node/plugins/wx/dev/react-refresh.ts +36 -7
- package/src/node/plugins/wx/dev/wx-dev-options.ts +7 -10
- package/src/node/plugins/wx/plugins.ts +5 -11
- package/src/node/plugins/wx/resolve/resolver.ts +4 -4
- package/src/node/plugins/wx/resolve/{specialize-bootstrap.ts → specialize-app-capsule.ts} +2 -2
- package/src/node/plugins/wx/styles/plugins.ts +518 -93
- package/src/node/utils/vite.ts +13 -58
- package/src/runtime/wx/amphibious/bootstrap.ts +0 -5
- package/src/runtime/wx/capsule/app.ts +5 -2
- package/src/runtime/wx/dev/dev-runtime.ts +71 -120
- package/src/runtime/wx/wechat.d.ts +1 -2
- package/dist/node/plugins/wx/dev/create-style-capture.d.ts +0 -54
- package/dist/node/plugins/wx/dev/create-style-capture.js +0 -173
- package/dist/node/plugins/wx/styles/transform-wx-style.d.ts +0 -8
- package/dist/node/plugins/wx/styles/transform-wx-style.js +0 -9
- package/dist/node/plugins/wx/styles/utils.d.ts +0 -39
- package/dist/node/plugins/wx/styles/utils.js +0 -95
- package/src/node/plugins/wx/dev/create-style-capture.ts +0 -248
- package/src/node/plugins/wx/styles/transform-wx-style.ts +0 -11
- package/src/node/plugins/wx/styles/utils.ts +0 -119
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import type { InputOptions, OutputOptions
|
|
2
|
+
import type { InputOptions, OutputOptions } from 'rolldown'
|
|
3
3
|
import { build } from 'rolldown'
|
|
4
4
|
import { type DevEngine, viteReporterPlugin } from 'rolldown/experimental'
|
|
5
5
|
import type { ViteDevServer } from 'vite'
|
|
@@ -30,13 +30,11 @@ export type BundledDev = {
|
|
|
30
30
|
export function installWxDevOptions({
|
|
31
31
|
bundledDev,
|
|
32
32
|
server,
|
|
33
|
-
options
|
|
34
|
-
hostPlugins
|
|
33
|
+
options
|
|
35
34
|
}: {
|
|
36
35
|
bundledDev: BundledDev
|
|
37
36
|
server: ViteDevServer
|
|
38
37
|
options: VptOptions
|
|
39
|
-
hostPlugins: Plugin[]
|
|
40
38
|
}): void {
|
|
41
39
|
/*
|
|
42
40
|
* Vite owns this mutable adapter method and calls it later when constructing DevEngine. Replacing that one seam preserves
|
|
@@ -113,10 +111,10 @@ export function installWxDevOptions({
|
|
|
113
111
|
|
|
114
112
|
/*
|
|
115
113
|
* The plugin list is mutable configuration consumed once by this engine generation. Replace the top-level reference with
|
|
116
|
-
* an ordered composite rather than pushing into Vite's potentially shared nested array
|
|
117
|
-
*
|
|
114
|
+
* an ordered composite rather than pushing into Vite's potentially shared nested array; the reporter observes final output
|
|
115
|
+
* without mutating Vite's retained input list.
|
|
118
116
|
*/
|
|
119
|
-
rolldownOptions.plugins = [rolldownOptions.plugins,
|
|
117
|
+
rolldownOptions.plugins = [rolldownOptions.plugins, createViteReporter(server)]
|
|
120
118
|
disableViteOxcSourcemap(rolldownOptions.plugins)
|
|
121
119
|
|
|
122
120
|
return rolldownOptions
|
|
@@ -145,7 +143,7 @@ function ensureSingleOutput(rolldownOptions: BundledDevRolldownOptions): OutputO
|
|
|
145
143
|
/**
|
|
146
144
|
* Prepends entry banners after Rolldown's analysis so their native requires remain physical dependencies rather than chunk
|
|
147
145
|
* graph edges. The App initializes the runtime identity, while every Page explicitly applies the watched patch data before its
|
|
148
|
-
*
|
|
146
|
+
* native Page registration.
|
|
149
147
|
*/
|
|
150
148
|
function createEntryBanner(pageFiles: ReadonlySet<string>): (chunk: { name: string; fileName: string }) => string {
|
|
151
149
|
return (chunk) => {
|
|
@@ -154,8 +152,7 @@ function createEntryBanner(pageFiles: ReadonlySet<string>): (chunk: { name: stri
|
|
|
154
152
|
}
|
|
155
153
|
if (pageFiles.has(chunk.name)) {
|
|
156
154
|
const patchesPath = path.posix.relative(path.posix.dirname(chunk.fileName), 'hmr/patches.js')
|
|
157
|
-
|
|
158
|
-
return `__rolldown_runtime__.applyPatches(require('${patchesPath}'), ${JSON.stringify(route)});\n`
|
|
155
|
+
return `__rolldown_runtime__.applyPatches(require('${patchesPath}'));\n`
|
|
159
156
|
}
|
|
160
157
|
return ''
|
|
161
158
|
}
|
|
@@ -12,7 +12,7 @@ import { renderCapsule } from './render/capsule.ts'
|
|
|
12
12
|
import { renderNative } from './render/native.ts'
|
|
13
13
|
import { materializeTransport } from './render/transport.ts'
|
|
14
14
|
import { createResolver } from './resolve/resolver.ts'
|
|
15
|
-
import {
|
|
15
|
+
import { createWxStylePlugin } from './styles/plugins.ts'
|
|
16
16
|
|
|
17
17
|
type WxResolver = ReturnType<typeof createResolver>
|
|
18
18
|
|
|
@@ -23,13 +23,9 @@ export function createWxTargetPlugins(options: VptOptions): PluginOption[] {
|
|
|
23
23
|
// Reuse the resolver instance's ordered application subset. Rolldown's complete input also contains bootstrap, transport,
|
|
24
24
|
// shell, and component entries; entry membership alone cannot recover which roots define the App/Page CSS cascade.
|
|
25
25
|
const placement = createWxPlacementPlugin()
|
|
26
|
+
const styles = createWxStylePlugin(resolver.applicationEntryIds)
|
|
26
27
|
|
|
27
|
-
return [
|
|
28
|
-
placement,
|
|
29
|
-
createWxStylePlugins(),
|
|
30
|
-
createWxPlugin(options, resolver, placement),
|
|
31
|
-
createWxDevelopmentPlugin(options, resolver.applicationEntryIds)
|
|
32
|
-
]
|
|
28
|
+
return [placement, styles, createWxPlugin(options, resolver, placement), createWxDevelopmentPlugin(options, styles)]
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
/** Configures the complete wx target build pipeline. */
|
|
@@ -133,10 +129,8 @@ function createWxPlugin(options: VptOptions, resolver: WxResolver, placement: Wx
|
|
|
133
129
|
|
|
134
130
|
generateBundle: {
|
|
135
131
|
/*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* stylesheet is complete before native Page/component companions are emitted. Without this order, the finalizer
|
|
139
|
-
* could consume incomplete Tailwind output or mistake native WXSS companions for additional compiler styles.
|
|
132
|
+
* Registration after the style pipeline makes the compiler stylesheet final before native Page and component
|
|
133
|
+
* companions are emitted. The style finalizer therefore cannot mistake native WXSS for application CSS.
|
|
140
134
|
*/
|
|
141
135
|
order: 'post',
|
|
142
136
|
async handler(_, bundle) {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
transportPath,
|
|
19
19
|
vitePreloadId
|
|
20
20
|
} from '../module/module.ts'
|
|
21
|
-
import {
|
|
21
|
+
import { specializeAppCapsule } from './specialize-app-capsule.ts'
|
|
22
22
|
import { specializePageCapsule } from './specialize-page-capsule.ts'
|
|
23
23
|
|
|
24
24
|
/** Resolves one exact plugin-private ID using its importer and configured project root. */
|
|
@@ -26,7 +26,7 @@ type PrivateIdResolver = (importer: string | undefined, projectRoot: string) =>
|
|
|
26
26
|
|
|
27
27
|
/** Creates the resolver and source specializer for the wx module graph. */
|
|
28
28
|
export function createResolver(options: VptOptions) {
|
|
29
|
-
const
|
|
29
|
+
const normalizedAppCapsulePath = normalizePath(appCapsulePath)
|
|
30
30
|
const normalizedPageCapsulePath = normalizePath(pageCapsulePath)
|
|
31
31
|
|
|
32
32
|
// Construct output input and application traversal roots together once so style order cannot drift from route order.
|
|
@@ -70,8 +70,8 @@ export function createResolver(options: VptOptions) {
|
|
|
70
70
|
specialize(code: string, id: string, sourcemap = true) {
|
|
71
71
|
const normalizedId = normalizeModuleId(id)
|
|
72
72
|
|
|
73
|
-
if (normalizedId ===
|
|
74
|
-
return
|
|
73
|
+
if (normalizedId === normalizedAppCapsulePath) {
|
|
74
|
+
return specializeAppCapsule({ code, id, appConfig: createAppConfig(options), sourcemap })
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (normalizedId === normalizedPageCapsulePath) {
|
|
@@ -4,8 +4,8 @@ import { type AstTransformResult, replaceWithAst } from '../../../utils/transfor
|
|
|
4
4
|
|
|
5
5
|
const appConfigPlaceholder = '__VPT_APP_CONFIG__'
|
|
6
6
|
|
|
7
|
-
/** Specializes the
|
|
8
|
-
export function
|
|
7
|
+
/** Specializes the App capsule with its normalized native configuration. */
|
|
8
|
+
export function specializeAppCapsule({
|
|
9
9
|
code,
|
|
10
10
|
id,
|
|
11
11
|
appConfig,
|