vite-plugin-taro 0.5.16 → 0.6.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 +1 -1
- package/README.md +1 -1
- 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/chunk-path.d.ts +8 -0
- package/dist/node/plugins/wx/chunk-path.js +18 -0
- package/dist/node/plugins/wx/dev/dev-host.d.ts +2 -2
- 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/dev/wx-dev-options.js +21 -0
- package/dist/node/plugins/wx/native/create-native-component-output.d.ts +3 -1
- package/dist/node/plugins/wx/native/create-native-component-output.js +3 -5
- package/dist/node/plugins/wx/output/files.d.ts +5 -4
- package/dist/node/plugins/wx/output/files.js +2 -2
- package/dist/node/plugins/wx/output/json.d.ts +4 -4
- package/dist/node/plugins/wx/output/json.js +2 -2
- package/dist/node/plugins/wx/output/templates.d.ts +2 -2
- package/dist/node/plugins/wx/placer/placement.d.ts +50 -0
- package/dist/node/plugins/wx/placer/placement.js +245 -0
- package/dist/node/plugins/wx/placer/placer.d.ts +60 -0
- package/dist/node/plugins/wx/placer/placer.js +123 -0
- package/dist/node/plugins/wx/plugins.d.ts +2 -2
- package/dist/node/plugins/wx/plugins.js +16 -16
- package/dist/node/plugins/wx/render/capsule-wrapper.js +3 -3
- package/dist/node/plugins/wx/render/native.js +5 -5
- package/dist/node/plugins/wx/render/transport.d.ts +7 -3
- package/dist/node/plugins/wx/render/transport.js +18 -9
- 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/modules.d.ts +0 -2
- package/dist/node/utils/modules.js +0 -7
- 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/chunk-path.ts +22 -0
- package/src/node/plugins/wx/dev/dev-host.ts +2 -2
- package/src/node/plugins/wx/dev/plugins.ts +2 -5
- package/src/node/plugins/wx/dev/wx-dev-options.ts +23 -2
- package/src/node/plugins/wx/native/create-native-component-output.ts +6 -5
- package/src/node/plugins/wx/output/files.ts +7 -5
- package/src/node/plugins/wx/output/json.ts +9 -10
- package/src/node/plugins/wx/output/templates.ts +3 -3
- package/src/node/plugins/wx/placer/placement.ts +364 -0
- package/src/node/plugins/wx/placer/placer.ts +154 -0
- package/src/node/plugins/wx/plugins.ts +20 -20
- package/src/node/plugins/wx/render/capsule-wrapper.ts +3 -3
- package/src/node/plugins/wx/render/native.ts +5 -5
- package/src/node/plugins/wx/render/transport.ts +24 -8
- 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/modules.ts +0 -8
- 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/plugins/wx/placement/placer.d.ts +0 -78
- package/dist/node/plugins/wx/placement/placer.js +0 -158
- package/dist/node/plugins/wx/placement/plan.d.ts +0 -46
- package/dist/node/plugins/wx/placement/plan.js +0 -210
- package/dist/node/vite-plugin.d.ts +0 -4
- package/src/node/plugins/wx/placement/placer.ts +0 -187
- package/src/node/plugins/wx/placement/plan.ts +0 -306
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Transport itself executes only as native CommonJS. It lives beside bootstrap because together they implement the
|
|
2
2
|
// amphibious boundary that publishes native namespaces to SystemJS without re-evaluating their module bodies.
|
|
3
3
|
/** Dispatches to one generated literal require and bridges amphibious CommonJS namespaces inline. */
|
|
4
|
-
export const transport =
|
|
4
|
+
export const transport = __VPT_TRANSPORT__;
|
|
@@ -3,5 +3,5 @@ import './app.js';
|
|
|
3
3
|
// @ts-expect-error: The wx build replaces this private import with the configured Page component.
|
|
4
4
|
import PageComponent from '\0vpt:page-component';
|
|
5
5
|
import { createPageConfig } from './taro-runtime.js';
|
|
6
|
-
const config = createPageConfig(PageComponent,
|
|
6
|
+
const config = createPageConfig(PageComponent, __VPT_PAGE_PATH__, { root: { cn: [] } }, __VPT_PAGE_CONFIG__);
|
|
7
7
|
export default config;
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from './node/
|
|
2
|
-
export type {
|
|
1
|
+
export { default } from './node/vpt.ts';
|
|
2
|
+
export type { VptJsonObject, VptOptions, VptPageOption, VptTarget } from './options.ts';
|
package/dist/vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './node/
|
|
1
|
+
export { default } from './node/vpt.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
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",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"rxjs": "^7.8.2",
|
|
77
77
|
"tailwindcss": "^4.3.3",
|
|
78
78
|
"weapp-tailwindcss": "^5.2.11",
|
|
79
|
-
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.
|
|
80
|
-
"@tarojs/react": "npm:vite-plugin-taro-react@0.
|
|
79
|
+
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.6.1",
|
|
80
|
+
"@tarojs/react": "npm:vite-plugin-taro-react@0.6.1"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"react": "^19.0.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizePath, type Plugin } from 'vite'
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptTarget } from '../../../options.ts'
|
|
3
3
|
import { normalizeModuleId } from '../../utils/modules.ts'
|
|
4
4
|
import { resolvePackageFile } from '../../utils/packages.ts'
|
|
5
5
|
import { clientTaroNativeId } from './constant.ts'
|
|
@@ -32,7 +32,7 @@ const clientTaroModules = new Map([
|
|
|
32
32
|
])
|
|
33
33
|
|
|
34
34
|
/** Creates the shared Taro facade backed by the selected target's API implementation. */
|
|
35
|
-
export function createClientTaroPlugin(target:
|
|
35
|
+
export function createClientTaroPlugin(target: VptTarget): Plugin {
|
|
36
36
|
const platformTaroId = resolvePlatformTaroId(target)
|
|
37
37
|
|
|
38
38
|
return {
|
|
@@ -62,7 +62,7 @@ export function createClientTaroPlugin(target: VitePluginTaroTarget): Plugin {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
function resolvePlatformTaroId(target:
|
|
65
|
+
function resolvePlatformTaroId(target: VptTarget): string {
|
|
66
66
|
return target === 'h5' ? '@tarojs/plugin-platform-h5/dist/runtime/apis' : '@tarojs/taro'
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Plugin } from 'vite'
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptTarget } from '../../../options.ts'
|
|
3
3
|
import { normalizeModuleId } from '../../utils/modules.ts'
|
|
4
4
|
|
|
5
5
|
/** Creates source-level target conditional handling shared by H5 and WX. */
|
|
6
|
-
export function createConditionalDirectivePlugin(target:
|
|
6
|
+
export function createConditionalDirectivePlugin(target: VptTarget): Plugin {
|
|
7
7
|
return {
|
|
8
8
|
name: 'vpt:conditional-directives',
|
|
9
9
|
enforce: 'pre',
|
|
@@ -37,7 +37,7 @@ type DirectiveFrame = {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Keeps only the source branches active for one build target. */
|
|
40
|
-
function transformConditionalDirectives(code: string, target:
|
|
40
|
+
function transformConditionalDirectives(code: string, target: VptTarget): string {
|
|
41
41
|
const lines = code.match(/[^\n]*(?:\n|$)/g) ?? []
|
|
42
42
|
const frames: DirectiveFrame[] = []
|
|
43
43
|
let transformed = ''
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import babel, { defineRolldownBabelPreset } from '@rolldown/plugin-babel'
|
|
2
2
|
import type { HtmlTagDescriptor, Plugin, PluginOption } from 'vite'
|
|
3
3
|
import { WeappTailwindcss } from 'weapp-tailwindcss/vite'
|
|
4
|
-
import type {
|
|
4
|
+
import type { VptOptions } from '../../../options.ts'
|
|
5
5
|
import { esTarget } from '../../utils/constant.ts'
|
|
6
6
|
import { toViteFileImportPath } from '../../utils/modules.ts'
|
|
7
7
|
import { packageRequire } from '../../utils/packages.ts'
|
|
@@ -12,7 +12,7 @@ import { createStencilClientAdapter } from './create-stencil-client-adapter.ts'
|
|
|
12
12
|
import { createModuleResolver } from './resolver/module-resolver.ts'
|
|
13
13
|
|
|
14
14
|
/** Creates the plugins that own the H5 target. */
|
|
15
|
-
export function createH5TargetPlugins(options:
|
|
15
|
+
export function createH5TargetPlugins(options: VptOptions): PluginOption[] {
|
|
16
16
|
return [
|
|
17
17
|
WeappTailwindcss({
|
|
18
18
|
appType: 'weapp-vite',
|
|
@@ -36,7 +36,7 @@ export function createH5TargetPlugins(options: VitePluginTaroOptions): PluginOpt
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** Configures H5 resolution and supplies the specialized physical application entry. */
|
|
39
|
-
function createH5TargetPlugin(options:
|
|
39
|
+
function createH5TargetPlugin(options: VptOptions): Plugin {
|
|
40
40
|
const moduleResolver = createModuleResolver(options)
|
|
41
41
|
|
|
42
42
|
return {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { normalizePath } from 'vite'
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../../options.ts'
|
|
3
3
|
import { normalizeModuleId, resolveAppComponentPath } from '../../../utils/modules.ts'
|
|
4
4
|
import { appComponentId } from '../../client/constant.ts'
|
|
5
5
|
import { h5AppPath } from '../constant.ts'
|
|
6
6
|
import { transformH5App } from '../transform-app.ts'
|
|
7
7
|
|
|
8
8
|
/** Creates H5 application module resolution and specialization. */
|
|
9
|
-
export function createModuleResolver(options:
|
|
9
|
+
export function createModuleResolver(options: VptOptions) {
|
|
10
10
|
return {
|
|
11
11
|
resolveId({ id, projectRoot }: { id: string; projectRoot: string }): string | undefined {
|
|
12
12
|
if (id === appComponentId) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { types } from '@babel/core'
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions, VptPageOption } from '../../../options.ts'
|
|
3
3
|
import { createPageComponentImportPath } from '../../utils/modules.ts'
|
|
4
4
|
import { createAppConfig } from '../../utils/project-config.ts'
|
|
5
5
|
import { type AstTransformResult, replaceWithAst } from '../../utils/transform.ts'
|
|
6
6
|
|
|
7
|
-
const appConfigPlaceholder = '
|
|
8
|
-
const routesPlaceholder = '
|
|
7
|
+
const appConfigPlaceholder = '__VPT_H5_APP_CONFIG__'
|
|
8
|
+
const routesPlaceholder = '__VPT_H5_ROUTES__'
|
|
9
9
|
|
|
10
10
|
/** Specializes the physical H5 App for one configured project. */
|
|
11
11
|
export async function transformH5App({
|
|
@@ -17,7 +17,7 @@ export async function transformH5App({
|
|
|
17
17
|
}: {
|
|
18
18
|
code: string
|
|
19
19
|
id: string
|
|
20
|
-
options:
|
|
20
|
+
options: VptOptions
|
|
21
21
|
projectRoot: string
|
|
22
22
|
sourcemap?: boolean
|
|
23
23
|
}): Promise<AstTransformResult> {
|
|
@@ -56,7 +56,7 @@ function createRoute({
|
|
|
56
56
|
page,
|
|
57
57
|
projectRoot
|
|
58
58
|
}: {
|
|
59
|
-
page:
|
|
59
|
+
page: VptPageOption
|
|
60
60
|
projectRoot: string
|
|
61
61
|
}): ReturnType<typeof types.objectExpression> {
|
|
62
62
|
const pageComponentPath = createPageComponentImportPath({ pagePath: page.path, projectRoot })
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
/** Physical directory in which Rolldown writes generated JavaScript chunks inside each native package. */
|
|
4
|
+
export const generatedChunkDirectory = 'assets'
|
|
5
|
+
|
|
6
|
+
/** Projects one Rolldown-owned physical candidate path into the package-neutral SystemJS identity. */
|
|
7
|
+
export function toLogicalChunkId(physicalChunkId: string): string {
|
|
8
|
+
return path.posix.relative(generatedChunkDirectory, physicalChunkId)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Resolves one relative Rolldown-generated import to its preliminary physical chunk path. */
|
|
12
|
+
export function resolvePhysicalChunkReference(importerChunkId: string, reference: string): string {
|
|
13
|
+
if (!reference.startsWith('./') && !reference.startsWith('../')) {
|
|
14
|
+
throw new Error(`Expected a relative chunk reference in ${importerChunkId}: ${reference}`)
|
|
15
|
+
}
|
|
16
|
+
return path.posix.join(path.posix.dirname(importerChunkId), reference)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Projects one relative Rolldown-generated import into its package-neutral SystemJS identity. */
|
|
20
|
+
export function resolveLogicalChunkReference(importerChunkId: string, reference: string): string {
|
|
21
|
+
return toLogicalChunkId(resolvePhysicalChunkReference(importerChunkId, reference))
|
|
22
|
+
}
|
|
@@ -5,7 +5,7 @@ import colors from 'picocolors'
|
|
|
5
5
|
import { type DevEngine, type DevOptions, dev } from 'rolldown/experimental'
|
|
6
6
|
import { asyncScheduler } from 'rxjs'
|
|
7
7
|
import type { Connect, ViteDevServer } from 'vite'
|
|
8
|
-
import type {
|
|
8
|
+
import type { VptOptions } from '../../../../options.ts'
|
|
9
9
|
import { createHmrResultsStream } from './create-hmr-results-stream.ts'
|
|
10
10
|
import { createStyleCapture, type StyleCaptureAction } from './create-style-capture.ts'
|
|
11
11
|
import {
|
|
@@ -61,7 +61,7 @@ export async function createWxDevHost({
|
|
|
61
61
|
applicationEntryIds
|
|
62
62
|
}: {
|
|
63
63
|
server: ViteDevServer
|
|
64
|
-
options:
|
|
64
|
+
options: VptOptions
|
|
65
65
|
applicationEntryIds: readonly string[]
|
|
66
66
|
}): Promise<WxDevHost> {
|
|
67
67
|
const bundledDev = getBundledDev(server)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizePath, type PluginOption, transformWithOxc } from 'vite'
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../../options.ts'
|
|
3
3
|
import { esTarget } from '../../../utils/constant.ts'
|
|
4
4
|
import { memoize } from '../../../utils/memoize.ts'
|
|
5
5
|
import { normalizeModuleId } from '../../../utils/modules.ts'
|
|
@@ -22,10 +22,7 @@ export function isWxClientEnvironment(environment: Readonly<{ name: string }>):
|
|
|
22
22
|
* The ordered application entries cross this configuration boundary unchanged so the host can compose global CSS without
|
|
23
23
|
* reconstructing the resolver's App/Page ownership policy from unrelated Rolldown shell and transport entries.
|
|
24
24
|
*/
|
|
25
|
-
export function createWxDevelopmentPlugin(
|
|
26
|
-
options: VitePluginTaroOptions,
|
|
27
|
-
applicationEntryIds: readonly string[]
|
|
28
|
-
): PluginOption[] {
|
|
25
|
+
export function createWxDevelopmentPlugin(options: VptOptions, applicationEntryIds: readonly string[]): PluginOption[] {
|
|
29
26
|
/*
|
|
30
27
|
* Vite creates this plugin descriptor before a server or DevEngine exists, then invokes configureServer and closeBundle on
|
|
31
28
|
* different lifecycle stacks. This mutable handle transfers the one client-owned host between those hooks: configureServer
|
|
@@ -3,7 +3,7 @@ import type { InputOptions, OutputOptions, Plugin } from 'rolldown'
|
|
|
3
3
|
import { build } from 'rolldown'
|
|
4
4
|
import { type DevEngine, viteReporterPlugin } from 'rolldown/experimental'
|
|
5
5
|
import type { ViteDevServer } from 'vite'
|
|
6
|
-
import type {
|
|
6
|
+
import type { VptOptions } from '../../../../options.ts'
|
|
7
7
|
import { once } from '../../../utils/once.ts'
|
|
8
8
|
import { resolvePackageFile } from '../../../utils/packages.ts'
|
|
9
9
|
import { appShellFileName } from '../module.ts'
|
|
@@ -35,7 +35,7 @@ export function installWxDevOptions({
|
|
|
35
35
|
}: {
|
|
36
36
|
bundledDev: BundledDev
|
|
37
37
|
server: ViteDevServer
|
|
38
|
-
options:
|
|
38
|
+
options: VptOptions
|
|
39
39
|
hostPlugins: Plugin[]
|
|
40
40
|
}): void {
|
|
41
41
|
/*
|
|
@@ -68,12 +68,26 @@ export function installWxDevOptions({
|
|
|
68
68
|
* mutating configuredOutput itself would leak development normalization back into the user's resolved Vite config.
|
|
69
69
|
*/
|
|
70
70
|
Object.assign(output, configured, {
|
|
71
|
+
// Development output is overwritten in place after every complete build. Strip hash placeholders from the
|
|
72
|
+
// configured asset pattern so old files cannot accumulate and native JSON/WXML references remain stable.
|
|
71
73
|
assetFileNames: createStableFileNames(configured.assetFileNames, 'assets/[name][extname]'),
|
|
74
|
+
// Banners create physical CommonJS edges after graph analysis: App initializes the dev runtime and each Page
|
|
75
|
+
// consumes the stable patch journal without allowing those host-only files into the application chunk graph.
|
|
72
76
|
banner: createEntryBanner(pageFiles),
|
|
77
|
+
// Preserve the configured directory/name shape while removing content hashes. Stable chunk paths let DevTools
|
|
78
|
+
// overwrite executable files and let cumulative HMR patches address one persistent physical module identity.
|
|
73
79
|
chunkFileNames: createStableFileNames(configured.chunkFileNames, 'assets/[name].js'),
|
|
80
|
+
// Native entry paths are public Mini Program routes (`app.js`, `pages/.../index.js`); development must never hash
|
|
81
|
+
// or relocate them because DevTools determines App/Page reload behavior from those exact filenames.
|
|
74
82
|
entryFileNames: createStableFileNames(configured.entryFileNames, '[name]'),
|
|
83
|
+
// Keep ESM until the existing WX renderChunk pipeline classifies each final chunk and converts capsules to
|
|
84
|
+
// System.register data or native/amphibious entries to CommonJS. Choosing CommonJS here would erase that boundary.
|
|
75
85
|
format: 'es',
|
|
86
|
+
// Bundled development emits complete physical output repeatedly. Minifying bounds disk transfer and DevTools
|
|
87
|
+
// compile work; source-level HMR diagnostics still come from Vite/Rolldown before this final output pass.
|
|
76
88
|
minify: true,
|
|
89
|
+
// DevTools executes physical WX files and HMR applies module factories rather than browser source maps. Disabling
|
|
90
|
+
// maps avoids extra output files and prevents Vite's Oxc sourcemap transform from touching generated host code.
|
|
77
91
|
sourcemap: false
|
|
78
92
|
})
|
|
79
93
|
|
|
@@ -84,9 +98,16 @@ export function installWxDevOptions({
|
|
|
84
98
|
rolldownOptions.experimental ??= {}
|
|
85
99
|
const existingDevMode = rolldownOptions.experimental.devMode
|
|
86
100
|
rolldownOptions.experimental.devMode = {
|
|
101
|
+
// Retain unknown user/forward-compatible devMode fields while the three explicit WX invariants below win.
|
|
87
102
|
...(typeof existingDevMode === 'object' ? existingDevMode : {}),
|
|
103
|
+
// Install the WX-adapted self-contained Rolldown runtime. It consumes physical patch journals and reports
|
|
104
|
+
// acknowledgements/rebuild requests through the host bridge instead of relying on browser globals or sockets.
|
|
88
105
|
implement: await bundleRuntimeSource(),
|
|
106
|
+
// Produce a complete output graph on the initial build. Lazy per-request compilation cannot establish the closed
|
|
107
|
+
// App/Page graph, native companions, style sidecars, and build identity required before any patch is admitted.
|
|
89
108
|
lazy: false,
|
|
109
|
+
// Keep Rolldown's common runtime injection because generated application factories call its module registry and
|
|
110
|
+
// HMR primitives. Skipping it would leave the custom implementation without the runtime surface it extends.
|
|
90
111
|
skipCommonRuntimeInjection: false
|
|
91
112
|
}
|
|
92
113
|
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import type { Rolldown } from 'vite'
|
|
4
|
-
import {
|
|
4
|
+
import type { PackageLocation } from '../placer/placement.ts'
|
|
5
5
|
import { getNativeComponentSources } from './native-component-assets.ts'
|
|
6
6
|
|
|
7
7
|
/** Creates opaque native files and their registrations from each surviving JSX interface module. */
|
|
8
8
|
export async function createNativeComponentOutput({
|
|
9
9
|
bundle,
|
|
10
|
-
getModuleInfo
|
|
10
|
+
getModuleInfo,
|
|
11
|
+
getPackageLocation
|
|
11
12
|
}: {
|
|
12
13
|
bundle: Rolldown.OutputBundle
|
|
13
14
|
getModuleInfo: (moduleId: string) => { meta: Rolldown.CustomPluginOptions } | null
|
|
15
|
+
getPackageLocation(chunk: Rolldown.OutputChunk): PackageLocation
|
|
14
16
|
}) {
|
|
15
17
|
// Files and registrations accumulate in final chunk order for deterministic output.
|
|
16
18
|
const files: Rolldown.EmittedAsset[] = []
|
|
@@ -25,9 +27,8 @@ export async function createNativeComponentOutput({
|
|
|
25
27
|
if (output.type !== 'chunk') {
|
|
26
28
|
continue
|
|
27
29
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
: undefined
|
|
30
|
+
const location = getPackageLocation(output)
|
|
31
|
+
const packageRoot = location.kind === 'subpackage' ? location.root : undefined
|
|
31
32
|
|
|
32
33
|
for (const moduleId of output.moduleIds) {
|
|
33
34
|
const sources = getNativeComponentSources(getModuleInfo(moduleId)?.meta)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Rolldown } from 'vite'
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptOptions } from '../../../../options.ts'
|
|
3
3
|
import { createNativeComponentOutput } from '../native/create-native-component-output.ts'
|
|
4
|
-
import type { GeneratedSubpackage } from '../placement
|
|
4
|
+
import type { GeneratedSubpackage, PackageLocation } from '../placer/placement.ts'
|
|
5
5
|
import { createJsonAssets } from './json.ts'
|
|
6
6
|
import { createTemplateAssets } from './templates.ts'
|
|
7
7
|
|
|
@@ -10,14 +10,16 @@ export async function createOutputFiles({
|
|
|
10
10
|
bundle,
|
|
11
11
|
options,
|
|
12
12
|
subpackages,
|
|
13
|
-
getModuleInfo
|
|
13
|
+
getModuleInfo,
|
|
14
|
+
getPackageLocation
|
|
14
15
|
}: {
|
|
15
16
|
bundle: Rolldown.OutputBundle
|
|
16
|
-
options:
|
|
17
|
+
options: VptOptions
|
|
17
18
|
subpackages: readonly GeneratedSubpackage[]
|
|
18
19
|
getModuleInfo: (moduleId: string) => { meta: Rolldown.CustomPluginOptions } | null
|
|
20
|
+
getPackageLocation(chunk: Rolldown.OutputChunk): PackageLocation
|
|
19
21
|
}): Promise<Rolldown.EmittedFile[]> {
|
|
20
|
-
const nativeOutput = await createNativeComponentOutput({ bundle, getModuleInfo })
|
|
22
|
+
const nativeOutput = await createNativeComponentOutput({ bundle, getModuleInfo, getPackageLocation })
|
|
21
23
|
|
|
22
24
|
return [
|
|
23
25
|
{
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Rolldown } from 'vite'
|
|
2
|
-
import type {
|
|
2
|
+
import type { VptJsonObject, VptOptions, VptPageOption } from '../../../../options.ts'
|
|
3
3
|
import { createAppConfig } from '../../../utils/project-config.ts'
|
|
4
|
-
import type
|
|
5
|
-
import { isGeneratedSubpackageFile } from '../placement/plan.ts'
|
|
4
|
+
import { type GeneratedSubpackage, isGeneratedSubpackageFile } from '../placer/placement.ts'
|
|
6
5
|
import { toRootRelativePath } from './relative-root.ts'
|
|
7
6
|
|
|
8
7
|
/** Creates every configured native JSON asset. */
|
|
@@ -11,7 +10,7 @@ export function createJsonAssets({
|
|
|
11
10
|
subpackages,
|
|
12
11
|
nativeComponents
|
|
13
12
|
}: {
|
|
14
|
-
options:
|
|
13
|
+
options: VptOptions
|
|
15
14
|
subpackages: readonly GeneratedSubpackage[]
|
|
16
15
|
nativeComponents: readonly { name: string; componentPath: string }[]
|
|
17
16
|
}): Rolldown.EmittedAsset[] {
|
|
@@ -29,15 +28,15 @@ export function createJsonAssets({
|
|
|
29
28
|
? [createJsonAsset('project.private.config.json', options.projectPrivateConfigJson)]
|
|
30
29
|
: []),
|
|
31
30
|
|
|
32
|
-
createJsonAsset('sitemap.json', options.sitemapJson)
|
|
31
|
+
...(options.sitemapJson ? [createJsonAsset('sitemap.json', options.sitemapJson)] : [])
|
|
33
32
|
]
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/** Creates Page JSON with generated Taro and native component registrations. */
|
|
37
36
|
function createPageJson(
|
|
38
|
-
page:
|
|
37
|
+
page: VptPageOption,
|
|
39
38
|
nativeComponents: readonly { name: string; componentPath: string }[]
|
|
40
|
-
):
|
|
39
|
+
): VptJsonObject {
|
|
41
40
|
const usingComponents = isJsonObject(page.config.usingComponents) ? page.config.usingComponents : {}
|
|
42
41
|
|
|
43
42
|
// Cross-package components require a placeholder while WeChat downloads their generated subpackage. Paths are
|
|
@@ -60,17 +59,17 @@ function createPageJson(
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
/** Tests whether a configured JSON value can be merged as an object. */
|
|
63
|
-
function isJsonObject(value: unknown): value is
|
|
62
|
+
function isJsonObject(value: unknown): value is VptJsonObject {
|
|
64
63
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
/** Serializes one native JSON object with stable formatting. */
|
|
68
|
-
export function renderJson(value:
|
|
67
|
+
export function renderJson(value: VptJsonObject): string {
|
|
69
68
|
return `${JSON.stringify(value, null, 4)}\n`
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
/** Creates one native JSON asset. */
|
|
73
|
-
function createJsonAsset(fileName: string, value:
|
|
72
|
+
function createJsonAsset(fileName: string, value: VptJsonObject): Rolldown.EmittedAsset {
|
|
74
73
|
return {
|
|
75
74
|
type: 'asset',
|
|
76
75
|
fileName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { recursiveMerge } from '@tarojs/helper'
|
|
2
2
|
import { Weapp as WxPlatform } from '@tarojs/plugin-platform-weapp'
|
|
3
3
|
import type { Rolldown } from 'vite'
|
|
4
|
-
import type {
|
|
4
|
+
import type { VptJsonObject, VptOptions } from '../../../../options.ts'
|
|
5
5
|
import { normalizeModuleId } from '../../../utils/modules.ts'
|
|
6
6
|
import { packageRequire } from '../../../utils/packages.ts'
|
|
7
7
|
import { renderJson } from './json.ts'
|
|
@@ -19,7 +19,7 @@ const taroComponentsModulePath = packageRequire.resolve('@tarojs/plugin-platform
|
|
|
19
19
|
/** Creates Taro's shared WeChat templates and native WXML/WXSS companions for every Page. */
|
|
20
20
|
export function createTemplateAssets(
|
|
21
21
|
bundle: Rolldown.OutputBundle,
|
|
22
|
-
options:
|
|
22
|
+
options: VptOptions,
|
|
23
23
|
nativeComponents: readonly {
|
|
24
24
|
name: string
|
|
25
25
|
fields: readonly string[]
|
|
@@ -121,7 +121,7 @@ function toDashed(value: string): string {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** Creates the recursive component configuration expected by Taro's templates. */
|
|
124
|
-
function createComponentJson():
|
|
124
|
+
function createComponentJson(): VptJsonObject {
|
|
125
125
|
return {
|
|
126
126
|
component: true,
|
|
127
127
|
styleIsolation: 'apply-shared',
|