vite-plugin-taro 0.6.0 → 0.6.2

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.
Files changed (68) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/node/plugins/h5/transform-app.js +1 -1
  4. package/dist/node/plugins/wx/dev/plugins.js +1 -1
  5. package/dist/node/plugins/wx/dev/wx-dev-options.js +22 -1
  6. package/dist/node/plugins/wx/module/chunk-path.d.ts +8 -0
  7. package/dist/node/plugins/wx/module/chunk-path.js +18 -0
  8. package/dist/node/plugins/wx/{module.js → module/module.js} +2 -2
  9. package/dist/node/plugins/wx/native/create-native-component-output.d.ts +3 -1
  10. package/dist/node/plugins/wx/native/create-native-component-output.js +3 -5
  11. package/dist/node/plugins/wx/output/files.d.ts +3 -2
  12. package/dist/node/plugins/wx/output/files.js +2 -2
  13. package/dist/node/plugins/wx/output/json.d.ts +1 -1
  14. package/dist/node/plugins/wx/output/json.js +1 -1
  15. package/dist/node/plugins/wx/placer/placement.d.ts +51 -0
  16. package/dist/node/plugins/wx/placer/placement.js +245 -0
  17. package/dist/node/plugins/wx/placer/placer.d.ts +76 -0
  18. package/dist/node/plugins/wx/placer/placer.js +147 -0
  19. package/dist/node/plugins/wx/plugins.js +17 -17
  20. package/dist/node/plugins/wx/render/capsule.d.ts +35 -3
  21. package/dist/node/plugins/wx/render/capsule.js +53 -12
  22. package/dist/node/plugins/wx/render/native.d.ts +20 -2
  23. package/dist/node/plugins/wx/render/native.js +539 -35
  24. package/dist/node/plugins/wx/render/system-js/string-editor.d.ts +24 -0
  25. package/dist/node/plugins/wx/render/system-js/string-editor.js +93 -0
  26. package/dist/node/plugins/wx/render/system-js/system-js.d.ts +23 -0
  27. package/dist/node/plugins/wx/render/system-js/system-js.js +602 -0
  28. package/dist/node/plugins/wx/render/transport.d.ts +7 -3
  29. package/dist/node/plugins/wx/render/transport.js +19 -10
  30. package/dist/node/plugins/wx/resolve/resolver.js +1 -1
  31. package/dist/node/plugins/wx/resolve/specialize-bootstrap.js +1 -1
  32. package/dist/node/plugins/wx/resolve/specialize-page-capsule.js +1 -1
  33. package/dist/node/utils/modules.d.ts +0 -2
  34. package/dist/node/utils/modules.js +0 -7
  35. package/dist/node/utils/transform.d.ts +0 -3
  36. package/dist/node/utils/transform.js +0 -23
  37. package/package.json +8 -6
  38. package/src/node/plugins/h5/transform-app.ts +1 -1
  39. package/src/node/plugins/wx/dev/plugins.ts +1 -1
  40. package/src/node/plugins/wx/dev/wx-dev-options.ts +22 -1
  41. package/src/node/plugins/wx/module/chunk-path.ts +22 -0
  42. package/src/node/plugins/wx/{module.ts → module/module.ts} +2 -2
  43. package/src/node/plugins/wx/native/create-native-component-output.ts +6 -5
  44. package/src/node/plugins/wx/output/files.ts +5 -3
  45. package/src/node/plugins/wx/output/json.ts +1 -2
  46. package/src/node/plugins/wx/placer/placement.ts +364 -0
  47. package/src/node/plugins/wx/placer/placer.ts +179 -0
  48. package/src/node/plugins/wx/plugins.ts +19 -19
  49. package/src/node/plugins/wx/render/capsule.ts +53 -17
  50. package/src/node/plugins/wx/render/native.ts +670 -55
  51. package/src/node/plugins/wx/render/system-js/string-editor.ts +115 -0
  52. package/src/node/plugins/wx/render/system-js/system-js.ts +831 -0
  53. package/src/node/plugins/wx/render/transport.ts +25 -9
  54. package/src/node/plugins/wx/resolve/resolver.ts +1 -1
  55. package/src/node/plugins/wx/resolve/specialize-bootstrap.ts +1 -1
  56. package/src/node/plugins/wx/resolve/specialize-page-capsule.ts +1 -1
  57. package/src/node/utils/modules.ts +0 -8
  58. package/src/node/utils/transform.ts +0 -30
  59. package/dist/node/plugins/wx/placement/placer.d.ts +0 -78
  60. package/dist/node/plugins/wx/placement/placer.js +0 -158
  61. package/dist/node/plugins/wx/placement/plan.d.ts +0 -46
  62. package/dist/node/plugins/wx/placement/plan.js +0 -210
  63. package/dist/node/plugins/wx/render/capsule-wrapper.d.ts +0 -3
  64. package/dist/node/plugins/wx/render/capsule-wrapper.js +0 -64
  65. package/src/node/plugins/wx/placement/placer.ts +0 -187
  66. package/src/node/plugins/wx/placement/plan.ts +0 -306
  67. package/src/node/plugins/wx/render/capsule-wrapper.ts +0 -86
  68. /package/dist/node/plugins/wx/{module.d.ts → module/module.d.ts} +0 -0
@@ -1,19 +1,24 @@
1
1
  import path from 'node:path';
2
- import { types } from '@babel/core';
2
+ import * as types from '@babel/types';
3
3
  import { replaceWithAst } from '../../../utils/transform.js';
4
- import { getWxExecutionKind } from '../module.js';
4
+ import { toLogicalChunkId } from '../module/chunk-path.js';
5
+ import { getWxExecutionKind } from '../module/module.js';
5
6
  const transportPlaceholder = '__VPT_TRANSPORT__';
6
7
  const moduleIdParameter = 'moduleId';
7
8
  const exportBindingParameter = 'exportBinding';
8
9
  /**
9
- * Materializes transport while Rolldown's preliminary hash placeholders are still active, so every injected physical
10
- * reference participates in final hash calculation instead of changing code after its filename has been fixed.
10
+ * Materializes transport while Rolldown's preliminary hash placeholders are still active. Each switch case deliberately has
11
+ * two IDs: the package-neutral preliminary filename without its `assets/` directory becomes the SystemJS registration
12
+ * identity, while the LTHP-selected assets/package-qualified filename becomes the literal native require path. Rolldown
13
+ * substitutes both hashes after this transform, so the
14
+ * generated transport code and its own content hash describe the exact files that `generateBundle` later materializes.
11
15
  *
12
16
  * This intentionally creates broad hash invalidation: changing one capsule can rename transport, then bootstrap, then
13
17
  * chunks that import bootstrap. A Mini Program ships one application package rather than independently cached HTTP
14
18
  * chunks, so honest content hashes and automatic graph linking are more valuable than minimizing that hash fan-out.
15
19
  */
16
- export async function materializeTransport({ code, transportChunk, chunks, getLoadMode, sourcemap = true }) {
20
+ export async function materializeTransport({ code, transportChunk, chunks, getLoadMode, getPhysicalChunkId = (chunk) => chunk.fileName, sourcemap = true }) {
21
+ const physicalTransportId = getPhysicalChunkId(transportChunk);
17
22
  // Babel constructs and safely serializes an expression shaped like:
18
23
  // (moduleId) => {
19
24
  // switch (moduleId) {
@@ -28,12 +33,16 @@ export async function materializeTransport({ code, transportChunk, chunks, getLo
28
33
  .sort((left, right) => left.chunk.fileName.localeCompare(right.chunk.fileName))
29
34
  .map(({ chunk, kind }) => {
30
35
  const loadMode = getLoadMode(chunk);
36
+ const logicalChunkId = toLogicalChunkId(chunk.fileName);
37
+ // Only native loading crosses the logical/physical boundary and receives the assets/package-qualified path.
38
+ const physicalChunkId = getPhysicalChunkId(chunk);
31
39
  if (kind === 'amphibious' && loadMode !== 'sync') {
32
40
  throw new Error(`Amphibious wx module must be in the main package: ${chunk.fileName}`);
33
41
  }
34
42
  return createTransportCase({
35
- chunkId: chunk.fileName,
36
- transportFileName: transportChunk.fileName,
43
+ chunkId: logicalChunkId,
44
+ transportFileName: physicalTransportId,
45
+ physicalChunkId: physicalChunkId,
37
46
  loadMode,
38
47
  kind
39
48
  });
@@ -58,9 +67,9 @@ function getTransportedChunks(chunks) {
58
67
  }
59
68
  return transportedChunks;
60
69
  }
61
- /** Creates one canonical-ID switch case while keeping its native require argument literal. */
62
- function createTransportCase({ chunkId, transportFileName, loadMode, kind }) {
63
- const requirePath = toNativeRequirePath(transportFileName, chunkId);
70
+ /** Creates one logical-ID switch case while keeping its physical native require argument literal. */
71
+ function createTransportCase({ chunkId, transportFileName, loadMode, kind, physicalChunkId }) {
72
+ const requirePath = toNativeRequirePath(transportFileName, physicalChunkId);
64
73
  const requireCallee = loadMode === 'sync'
65
74
  ? types.identifier('require')
66
75
  : types.memberExpression(types.identifier('require'), types.identifier('async'));
@@ -2,7 +2,7 @@ import { normalizePath } from 'vite';
2
2
  import { normalizeModuleId, resolveAppComponentPath, resolvePageComponentPath } from '../../../utils/modules.js';
3
3
  import { createAppConfig } from '../../../utils/project-config.js';
4
4
  import { appComponentId } from '../../client/constant.js';
5
- import { appCapsulePath, appShellFileName, appShellPath, bootstrapPath, componentCapsulePath, componentShellFileName, componentShellPath, pageCapsuleId, pageCapsulePath, pageComponentId, pageShellPath, transportPath, vitePreloadId } from '../module.js';
5
+ import { appCapsulePath, appShellFileName, appShellPath, bootstrapPath, componentCapsulePath, componentShellFileName, componentShellPath, pageCapsuleId, pageCapsulePath, pageComponentId, pageShellPath, transportPath, vitePreloadId } from '../module/module.js';
6
6
  import { specializeBootstrap } from './specialize-bootstrap.js';
7
7
  import { specializePageCapsule } from './specialize-page-capsule.js';
8
8
  /** Creates the resolver and source specializer for the wx module graph. */
@@ -1,4 +1,4 @@
1
- import { types } from '@babel/core';
1
+ import * as types from '@babel/types';
2
2
  import { replaceWithAst } from '../../../utils/transform.js';
3
3
  const appConfigPlaceholder = '__VPT_APP_CONFIG__';
4
4
  /** Specializes the amphibious bootstrap with the shared App configuration. */
@@ -1,4 +1,4 @@
1
- import { types } from '@babel/core';
1
+ import * as types from '@babel/types';
2
2
  import { replaceWithAst } from '../../../utils/transform.js';
3
3
  const pagePathPlaceholder = '__VPT_PAGE_PATH__';
4
4
  const pageConfigPlaceholder = '__VPT_PAGE_CONFIG__';
@@ -6,8 +6,6 @@ type PageComponentPathOptions = {
6
6
  pagePath: string;
7
7
  projectRoot: string;
8
8
  };
9
- /** Resolves a final relative reference to the canonical output chunk ID used by the WX module registry. */
10
- export declare function resolveChunkReference(importerChunkId: string, reference: string): string;
11
9
  /** Resolves the source file for the configured App component. */
12
10
  export declare function resolveAppComponentPath({ appPath, projectRoot }: AppComponentPathOptions): string;
13
11
  /** Resolves the source file for one configured Page component. */
@@ -1,12 +1,5 @@
1
1
  import path from 'node:path';
2
2
  import { normalizePath } from 'vite';
3
- /** Resolves a final relative reference to the canonical output chunk ID used by the WX module registry. */
4
- export function resolveChunkReference(importerChunkId, reference) {
5
- if (!reference.startsWith('./') && !reference.startsWith('../')) {
6
- throw new Error(`Expected a relative chunk reference in ${importerChunkId}: ${reference}`);
7
- }
8
- return path.posix.join(path.posix.dirname(importerChunkId), reference);
9
- }
10
3
  /** Resolves the source file for the configured App component. */
11
4
  export function resolveAppComponentPath({ appPath, projectRoot }) {
12
5
  return path.resolve(projectRoot, appPath);
@@ -1,4 +1,3 @@
1
- import { type PluginItem } from '@babel/core';
2
1
  import { generate } from '@babel/generator';
3
2
  import { type Rolldown } from 'vite';
4
3
  export type AstTransformResult = {
@@ -7,5 +6,3 @@ export type AstTransformResult = {
7
6
  };
8
7
  /** Replaces each placeholder with a Babel AST expression while transforming the module through Oxc. */
9
8
  export declare function replaceWithAst(code: string, filename: string, replacement: Readonly<Record<string, Parameters<typeof generate>[0]>>, sourcemap?: boolean): Promise<AstTransformResult>;
10
- /** Transforms one module with Babel's shared parser and source-map configuration. */
11
- export declare function transformWithBabel(code: string, filename: string, plugins: PluginItem[], sourcemap?: boolean): AstTransformResult;
@@ -1,4 +1,3 @@
1
- import { transformSync } from '@babel/core';
2
1
  import { generate } from '@babel/generator';
3
2
  import { transformWithOxc } from 'vite';
4
3
  import { esTarget } from './constant.js';
@@ -34,25 +33,3 @@ function requireOnePlaceholder(code, placeholder) {
34
33
  throw new Error(`Expected one placeholder ${placeholder}, found ${replacementCount}`);
35
34
  }
36
35
  }
37
- /** Transforms one module with Babel's shared parser and source-map configuration. */
38
- export function transformWithBabel(code, filename, plugins, sourcemap = true) {
39
- const transformed = transformSync(code, {
40
- babelrc: false,
41
- compact: true,
42
- minified: true,
43
- comments: false,
44
- configFile: false,
45
- filename,
46
- plugins,
47
- sourceFileName: filename,
48
- sourceMaps: sourcemap,
49
- sourceType: 'module'
50
- });
51
- if (!transformed?.code || (sourcemap && !transformed.map)) {
52
- throw new Error(`Failed to transform ${filename} with Babel`);
53
- }
54
- return {
55
- code: transformed.code,
56
- map: sourcemap ? transformed.map : null
57
- };
58
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-taro",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
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",
@@ -53,9 +53,8 @@
53
53
  "dependencies": {
54
54
  "@babel/core": "^7.29.7",
55
55
  "@babel/generator": "^7.29.8",
56
- "@babel/plugin-transform-dynamic-import": "^7.29.7",
57
- "@babel/plugin-transform-modules-commonjs": "^7.29.7",
58
- "@babel/plugin-transform-modules-systemjs": "^7.29.8",
56
+ "@babel/types": "^7.29.8",
57
+ "@oxc-project/types": "0.143.0",
59
58
  "@rolldown/plugin-babel": "^0.2.3",
60
59
  "@tailwindcss-mangle/engine": "0.2.0",
61
60
  "@tarojs/components": "4.2.0",
@@ -76,8 +75,8 @@
76
75
  "rxjs": "^7.8.2",
77
76
  "tailwindcss": "^4.3.3",
78
77
  "weapp-tailwindcss": "^5.2.11",
79
- "@tarojs/react": "npm:vite-plugin-taro-react@0.6.0",
80
- "@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.6.0"
78
+ "@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.6.2",
79
+ "@tarojs/react": "npm:vite-plugin-taro-react@0.6.2"
81
80
  },
82
81
  "peerDependencies": {
83
82
  "react": "^19.0.0",
@@ -85,6 +84,9 @@
85
84
  "vite": "8.2.1"
86
85
  },
87
86
  "devDependencies": {
87
+ "@babel/plugin-transform-dynamic-import": "^7.29.7",
88
+ "@babel/plugin-transform-modules-commonjs": "^7.29.7",
89
+ "@babel/plugin-transform-modules-systemjs": "^7.29.8",
88
90
  "@types/babel__core": "^7.20.5",
89
91
  "@types/babel__generator": "^7.27.0",
90
92
  "@types/node": "^26.1.1",
@@ -1,4 +1,4 @@
1
- import { types } from '@babel/core'
1
+ import * as types from '@babel/types'
2
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'
@@ -3,7 +3,7 @@ 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'
6
- import { appCapsulePath, pageCapsulePath, rolldownRuntimeId, taroRuntimePath } from '../module.ts'
6
+ import { appCapsulePath, pageCapsulePath, rolldownRuntimeId, taroRuntimePath } from '../module/module.ts'
7
7
  import { createWxDevHost, type WxDevHost } from './dev-host.ts'
8
8
  import { developmentAppWxssFileName } from './hmr-files.ts'
9
9
  import { createWxReactRefreshTransforms } from './react-refresh.ts'
@@ -6,7 +6,7 @@ import type { ViteDevServer } from 'vite'
6
6
  import type { VptOptions } from '../../../../options.ts'
7
7
  import { once } from '../../../utils/once.ts'
8
8
  import { resolvePackageFile } from '../../../utils/packages.ts'
9
- import { appShellFileName } from '../module.ts'
9
+ import { appShellFileName } from '../module/module.ts'
10
10
 
11
11
  type BundledDevRolldownOptions = InputOptions & {
12
12
  experimental?: {
@@ -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
 
@@ -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
+ }
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path'
2
2
  import { normalizePath, type Rolldown } from 'vite'
3
- import { normalizeModuleId } from '../../utils/modules.ts'
4
- import { packageRequire, resolvePackageFile } from '../../utils/packages.ts'
3
+ import { normalizeModuleId } from '../../../utils/modules.ts'
4
+ import { packageRequire, resolvePackageFile } from '../../../utils/packages.ts'
5
5
 
6
6
  /** Identifies Rolldown's generated helper module independently of its unstable output filename. */
7
7
  export const rolldownRuntimeId = '\0rolldown/runtime.js'
@@ -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 { isGeneratedSubpackageFile } from '../placement/plan.ts'
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 packageRoot = isGeneratedSubpackageFile(output.fileName)
29
- ? path.posix.dirname(path.posix.dirname(output.fileName))
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
2
  import type { VptOptions } from '../../../../options.ts'
3
3
  import { createNativeComponentOutput } from '../native/create-native-component-output.ts'
4
- import type { GeneratedSubpackage } from '../placement/placer.ts'
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
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
2
  import type { VptJsonObject, VptOptions, VptPageOption } from '../../../../options.ts'
3
3
  import { createAppConfig } from '../../../utils/project-config.ts'
4
- import type { GeneratedSubpackage } from '../placement/placer.ts'
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. */