@dcloudio/uni-cli-shared 3.0.0-alpha-5020620260914001 → 3.0.0-alpha-5020720260921001
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.
|
@@ -5,9 +5,16 @@ export declare function hasJsonFile(filename: string): boolean;
|
|
|
5
5
|
export declare function getComponentJsonFilenames(): string[];
|
|
6
6
|
export declare function findJsonFile(filename: string): Record<string, any> | ComponentJson | PageWindowOptions | undefined;
|
|
7
7
|
export declare function findUsingComponents(filename: string): UsingComponents | undefined;
|
|
8
|
+
export declare function findMiniProgramSubPackageRoot(filename: string): string | undefined;
|
|
9
|
+
export declare function addMiniProgramComponentPackageRoot(filename: string, packageRoot?: string): void;
|
|
10
|
+
export declare function findMiniProgramComponentPackageRoot(filename: string): string | undefined;
|
|
11
|
+
export declare function findMiniProgramComponentPackageRoots(filename: string): (string | undefined)[] | undefined;
|
|
12
|
+
export declare function resolveMiniProgramComponentPackageRoot(filename: string, packageRoot?: string): string | undefined;
|
|
8
13
|
export declare function normalizeJsonFilename(filename: string): string;
|
|
9
14
|
export declare function findChangedJsonFiles(supportGlobalUsingComponents?: boolean | ((filename: string) => boolean)): Map<string, string>;
|
|
10
|
-
export declare function addMiniProgramAppJson(appJson: Record<string, any
|
|
15
|
+
export declare function addMiniProgramAppJson(appJson: Record<string, any>, options?: {
|
|
16
|
+
subPackages?: boolean;
|
|
17
|
+
}): void;
|
|
11
18
|
export declare function addMiniProgramPageJson(filename: string, json: PageWindowOptions): void;
|
|
12
19
|
export declare function addMiniProgramComponentJson(filename: string, json: ComponentJson): void;
|
|
13
20
|
export declare function addMiniProgramUsingComponents(filename: string, json: UsingComponents): void;
|
package/dist/json/mp/jsonFile.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.resetMiniProgramJsonFiles = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
|
|
6
|
+
exports.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.resetMiniProgramJsonFiles = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.resolveMiniProgramComponentPackageRoot = exports.findMiniProgramComponentPackageRoots = exports.findMiniProgramComponentPackageRoot = exports.addMiniProgramComponentPackageRoot = exports.findMiniProgramSubPackageRoot = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -12,12 +12,16 @@ const resolve_1 = require("../../resolve");
|
|
|
12
12
|
const utils_2 = require("../../vue/utils");
|
|
13
13
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
14
14
|
const subpackage_1 = require("./subpackage");
|
|
15
|
+
const x_1 = require("../../x");
|
|
15
16
|
let appJsonCache = {};
|
|
17
|
+
let subPackageRootsCache = [];
|
|
16
18
|
let independentRootsCache = [];
|
|
17
19
|
const jsonFilesCache = new Map();
|
|
18
20
|
const jsonPagesCache = new Map();
|
|
19
21
|
const jsonComponentsCache = new Map();
|
|
20
22
|
const jsonUsingComponentsCache = new Map();
|
|
23
|
+
const componentPackageRootsCache = new Map();
|
|
24
|
+
const mainPackageRoot = '';
|
|
21
25
|
function isMiniProgramPageFile(file, inputDir) {
|
|
22
26
|
if (inputDir && path_1.default.isAbsolute(file)) {
|
|
23
27
|
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
|
|
@@ -50,6 +54,74 @@ function findUsingComponents(filename) {
|
|
|
50
54
|
return jsonUsingComponentsCache.get(filename);
|
|
51
55
|
}
|
|
52
56
|
exports.findUsingComponents = findUsingComponents;
|
|
57
|
+
function findMiniProgramSubPackageRoot(filename) {
|
|
58
|
+
if (!(0, x_1.isUniAppX)()) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
return findSubPackageRoot(filename, subPackageRootsCache);
|
|
62
|
+
}
|
|
63
|
+
exports.findMiniProgramSubPackageRoot = findMiniProgramSubPackageRoot;
|
|
64
|
+
function addMiniProgramComponentPackageRoot(filename, packageRoot) {
|
|
65
|
+
if (!(0, x_1.isUniAppX)()) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const normalizedFilename = normalizeComponentPackageFilename(filename);
|
|
69
|
+
if (!normalizedFilename.startsWith('uni_modules/')) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const roots = componentPackageRootsCache.get(normalizedFilename) || new Set();
|
|
73
|
+
roots.add(packageRoot || mainPackageRoot);
|
|
74
|
+
componentPackageRootsCache.set(normalizedFilename, roots);
|
|
75
|
+
}
|
|
76
|
+
exports.addMiniProgramComponentPackageRoot = addMiniProgramComponentPackageRoot;
|
|
77
|
+
function findMiniProgramComponentPackageRoot(filename) {
|
|
78
|
+
if (!(0, x_1.isUniAppX)()) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const roots = getMiniProgramComponentPackageRoots(filename);
|
|
82
|
+
if (roots?.size === 1) {
|
|
83
|
+
const [root] = [...roots];
|
|
84
|
+
return root || undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.findMiniProgramComponentPackageRoot = findMiniProgramComponentPackageRoot;
|
|
88
|
+
function findMiniProgramComponentPackageRoots(filename) {
|
|
89
|
+
if (!(0, x_1.isUniAppX)()) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const roots = getMiniProgramComponentPackageRoots(filename);
|
|
93
|
+
if (roots) {
|
|
94
|
+
if (roots.has(mainPackageRoot) || roots.size > 1) {
|
|
95
|
+
return [undefined];
|
|
96
|
+
}
|
|
97
|
+
return [...roots].map((root) => root || undefined);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.findMiniProgramComponentPackageRoots = findMiniProgramComponentPackageRoots;
|
|
101
|
+
function resolveMiniProgramComponentPackageRoot(filename, packageRoot) {
|
|
102
|
+
if (!(0, x_1.isUniAppX)()) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const roots = getMiniProgramComponentPackageRoots(filename);
|
|
106
|
+
if (!roots) {
|
|
107
|
+
return packageRoot;
|
|
108
|
+
}
|
|
109
|
+
if (roots.has(mainPackageRoot)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (roots.size > 1) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const normalizedPackageRoot = packageRoot || mainPackageRoot;
|
|
116
|
+
if (roots.has(normalizedPackageRoot)) {
|
|
117
|
+
return packageRoot;
|
|
118
|
+
}
|
|
119
|
+
if (roots.size === 1) {
|
|
120
|
+
const [root] = [...roots];
|
|
121
|
+
return root || undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.resolveMiniProgramComponentPackageRoot = resolveMiniProgramComponentPackageRoot;
|
|
53
125
|
function normalizeJsonFilename(filename) {
|
|
54
126
|
return (0, utils_1.normalizeNodeModules)(filename);
|
|
55
127
|
}
|
|
@@ -57,16 +129,20 @@ exports.normalizeJsonFilename = normalizeJsonFilename;
|
|
|
57
129
|
function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
58
130
|
const changedJsonFiles = new Map();
|
|
59
131
|
function findChangedFile(filename, json) {
|
|
132
|
+
const cacheFilename = filename;
|
|
133
|
+
const outputFilename = (0, x_1.isUniAppX)()
|
|
134
|
+
? normalizeJsonPackageFilename(filename)
|
|
135
|
+
: filename;
|
|
60
136
|
const newJson = JSON.parse(JSON.stringify(json));
|
|
61
137
|
if (!newJson.usingComponents) {
|
|
62
138
|
newJson.usingComponents = {};
|
|
63
139
|
}
|
|
64
|
-
(0, shared_1.extend)(newJson.usingComponents, jsonUsingComponentsCache.get(
|
|
140
|
+
(0, shared_1.extend)(newJson.usingComponents, jsonUsingComponentsCache.get(cacheFilename));
|
|
65
141
|
// 格式化为相对路径,这样作为分包也可以直接运行
|
|
66
142
|
// app.json mp-baidu 在 win 不支持相对路径。所有平台改用绝对路径
|
|
67
|
-
if (
|
|
143
|
+
if (outputFilename !== 'app') {
|
|
68
144
|
let usingComponents = newJson.usingComponents;
|
|
69
|
-
const independentRoot =
|
|
145
|
+
const independentRoot = findSubPackageRoot(outputFilename, independentRootsCache);
|
|
70
146
|
const supportGlobalUsingComponentsForFile = typeof supportGlobalUsingComponents === 'function'
|
|
71
147
|
? supportGlobalUsingComponents(filename)
|
|
72
148
|
: supportGlobalUsingComponents;
|
|
@@ -82,20 +158,22 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
82
158
|
};
|
|
83
159
|
}
|
|
84
160
|
if (independentRoot) {
|
|
85
|
-
validateIndependentUsingComponents(
|
|
161
|
+
validateIndependentUsingComponents(outputFilename, independentRoot, usingComponents);
|
|
86
162
|
}
|
|
87
163
|
Object.keys(usingComponents).forEach((name) => {
|
|
88
|
-
const componentFilename =
|
|
164
|
+
const componentFilename = (0, x_1.isUniAppX)()
|
|
165
|
+
? normalizeUsingComponentPackageFilename(usingComponents[name], outputFilename)
|
|
166
|
+
: usingComponents[name];
|
|
89
167
|
if (componentFilename.startsWith('/')) {
|
|
90
|
-
usingComponents[name] = (0, resolve_1.relativeFile)(
|
|
168
|
+
usingComponents[name] = (0, resolve_1.relativeFile)(outputFilename, componentFilename.slice(1));
|
|
91
169
|
}
|
|
92
170
|
});
|
|
93
171
|
newJson.usingComponents = usingComponents;
|
|
94
172
|
}
|
|
95
173
|
const jsonStr = JSON.stringify(newJson, null, 2);
|
|
96
|
-
if (jsonFilesCache.get(
|
|
97
|
-
changedJsonFiles.set(
|
|
98
|
-
jsonFilesCache.set(
|
|
174
|
+
if (jsonFilesCache.get(outputFilename) !== jsonStr) {
|
|
175
|
+
changedJsonFiles.set(outputFilename, jsonStr);
|
|
176
|
+
jsonFilesCache.set(outputFilename, jsonStr);
|
|
99
177
|
}
|
|
100
178
|
}
|
|
101
179
|
function findChangedFiles(jsonsCache) {
|
|
@@ -111,8 +189,8 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
111
189
|
return changedJsonFiles;
|
|
112
190
|
}
|
|
113
191
|
exports.findChangedJsonFiles = findChangedJsonFiles;
|
|
114
|
-
function
|
|
115
|
-
return
|
|
192
|
+
function findSubPackageRoot(filename, roots) {
|
|
193
|
+
return roots.find((root) => {
|
|
116
194
|
return filename === root || filename.startsWith(root + '/');
|
|
117
195
|
});
|
|
118
196
|
}
|
|
@@ -142,8 +220,13 @@ function isLocalUsingComponent(componentFilename) {
|
|
|
142
220
|
return (!/^(?:plugin|dynamicLib|ext):\/\//.test(componentFilename) &&
|
|
143
221
|
!componentFilename.startsWith('weui-miniprogram'));
|
|
144
222
|
}
|
|
145
|
-
function addMiniProgramAppJson(appJson) {
|
|
223
|
+
function addMiniProgramAppJson(appJson, options = {}) {
|
|
146
224
|
appJsonCache = appJson;
|
|
225
|
+
componentPackageRootsCache.clear();
|
|
226
|
+
subPackageRootsCache =
|
|
227
|
+
!(0, x_1.isUniAppX)() || options.subPackages === false
|
|
228
|
+
? []
|
|
229
|
+
: parseSubPackageRoots(appJson);
|
|
147
230
|
independentRootsCache = (0, subpackage_1.parseIndependentSubPackages)(appJson).map(({ root }) => root);
|
|
148
231
|
}
|
|
149
232
|
exports.addMiniProgramAppJson = addMiniProgramAppJson;
|
|
@@ -161,14 +244,89 @@ function addMiniProgramUsingComponents(filename, json) {
|
|
|
161
244
|
exports.addMiniProgramUsingComponents = addMiniProgramUsingComponents;
|
|
162
245
|
function resetMiniProgramJsonFiles() {
|
|
163
246
|
appJsonCache = {};
|
|
247
|
+
subPackageRootsCache = [];
|
|
164
248
|
independentRootsCache = [];
|
|
165
249
|
(0, subpackage_1.setIndependentSubPackages)([]);
|
|
250
|
+
componentPackageRootsCache.clear();
|
|
166
251
|
jsonFilesCache.clear();
|
|
167
252
|
jsonPagesCache.clear();
|
|
168
253
|
jsonComponentsCache.clear();
|
|
169
254
|
jsonUsingComponentsCache.clear();
|
|
170
255
|
}
|
|
171
256
|
exports.resetMiniProgramJsonFiles = resetMiniProgramJsonFiles;
|
|
257
|
+
function parseSubPackageRoots(pagesJson) {
|
|
258
|
+
const subPackages = pagesJson?.subPackages || pagesJson?.subpackages || [];
|
|
259
|
+
if (!Array.isArray(subPackages)) {
|
|
260
|
+
return [];
|
|
261
|
+
}
|
|
262
|
+
return subPackages
|
|
263
|
+
.map((subPackage) => {
|
|
264
|
+
if (!subPackage ||
|
|
265
|
+
subPackage.independent === true ||
|
|
266
|
+
typeof subPackage.root !== 'string') {
|
|
267
|
+
return '';
|
|
268
|
+
}
|
|
269
|
+
return (0, utils_1.normalizePath)(subPackage.root).replace(/^\/+|\/+$/g, '');
|
|
270
|
+
})
|
|
271
|
+
.filter(Boolean)
|
|
272
|
+
.sort((a, b) => b.length - a.length);
|
|
273
|
+
}
|
|
274
|
+
function normalizeJsonPackageFilename(filename) {
|
|
275
|
+
const unrootedFilename = withoutSubPackageRootForUniModules(filename);
|
|
276
|
+
const ownerRoot = findMiniProgramSubPackageRoot(filename);
|
|
277
|
+
const roots = getMiniProgramComponentPackageRoots(unrootedFilename);
|
|
278
|
+
if (unrootedFilename !== filename &&
|
|
279
|
+
roots &&
|
|
280
|
+
(roots.has(mainPackageRoot) ||
|
|
281
|
+
roots.size > 1 ||
|
|
282
|
+
!ownerRoot ||
|
|
283
|
+
!roots.has(ownerRoot))) {
|
|
284
|
+
return unrootedFilename;
|
|
285
|
+
}
|
|
286
|
+
return filename;
|
|
287
|
+
}
|
|
288
|
+
function normalizeUsingComponentPackageFilename(componentFilename, ownerFilename) {
|
|
289
|
+
if (!componentFilename.startsWith('/')) {
|
|
290
|
+
return componentFilename;
|
|
291
|
+
}
|
|
292
|
+
const normalizedFilename = (0, utils_1.normalizePath)(componentFilename).replace(/^\/+/, '');
|
|
293
|
+
const unrootedFilename = withoutSubPackageRootForUniModules(normalizedFilename);
|
|
294
|
+
if (!unrootedFilename.startsWith('uni_modules/')) {
|
|
295
|
+
return componentFilename;
|
|
296
|
+
}
|
|
297
|
+
const roots = getMiniProgramComponentPackageRoots(unrootedFilename);
|
|
298
|
+
if (!roots) {
|
|
299
|
+
return componentFilename;
|
|
300
|
+
}
|
|
301
|
+
if (roots.has(mainPackageRoot) || roots.size > 1) {
|
|
302
|
+
return '/' + unrootedFilename;
|
|
303
|
+
}
|
|
304
|
+
const ownerRoot = findMiniProgramSubPackageRoot(ownerFilename);
|
|
305
|
+
if (ownerRoot && roots.has(ownerRoot)) {
|
|
306
|
+
return '/' + `${ownerRoot}/${unrootedFilename}`;
|
|
307
|
+
}
|
|
308
|
+
const packageRoot = findMiniProgramComponentPackageRoot(unrootedFilename);
|
|
309
|
+
return '/' + (packageRoot ? `${packageRoot}/` : '') + unrootedFilename;
|
|
310
|
+
}
|
|
311
|
+
function withoutSubPackageRootForUniModules(filename) {
|
|
312
|
+
for (const root of subPackageRootsCache) {
|
|
313
|
+
if (filename.startsWith(`${root}/uni_modules/`)) {
|
|
314
|
+
return filename.slice(root.length + 1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return filename;
|
|
318
|
+
}
|
|
319
|
+
function normalizeComponentPackageFilename(filename) {
|
|
320
|
+
let normalizedFilename = withoutSubPackageRootForUniModules((0, utils_1.normalizePath)(filename).split('?')[0].replace(/^\/+/, ''));
|
|
321
|
+
const uniModulesIndex = normalizedFilename.indexOf('uni_modules/');
|
|
322
|
+
if (uniModulesIndex > -1) {
|
|
323
|
+
normalizedFilename = normalizedFilename.slice(uniModulesIndex);
|
|
324
|
+
}
|
|
325
|
+
return (0, utils_1.removeExt)(normalizedFilename);
|
|
326
|
+
}
|
|
327
|
+
function getMiniProgramComponentPackageRoots(filename) {
|
|
328
|
+
return componentPackageRootsCache.get(normalizeComponentPackageFilename(filename));
|
|
329
|
+
}
|
|
172
330
|
function isMiniProgramUsingComponent(name, options) {
|
|
173
331
|
return !!findMiniProgramUsingComponents(options)[name];
|
|
174
332
|
}
|
|
@@ -11,8 +11,8 @@ interface MainDescriptor {
|
|
|
11
11
|
template: string;
|
|
12
12
|
}
|
|
13
13
|
export declare function parseMainDescriptor(filename: string, ast: Program, resolve: ParseDescriptor['resolve'], root?: string): Promise<MainDescriptor>;
|
|
14
|
-
export declare function updateMiniProgramComponentsByScriptFilename(scriptFilename: string, inputDir: string, normalizeComponentName: (name: string) => string, root?: string): void;
|
|
15
|
-
export declare function updateMiniProgramComponentsByTemplateFilename(templateFilename: string, inputDir: string, normalizeComponentName: (name: string) => string, root?: string): void;
|
|
14
|
+
export declare function updateMiniProgramComponentsByScriptFilename(scriptFilename: string, inputDir: string, normalizeComponentName: (name: string) => string, root?: string, packageRoot?: string): void;
|
|
15
|
+
export declare function updateMiniProgramComponentsByTemplateFilename(templateFilename: string, inputDir: string, normalizeComponentName: (name: string) => string, root?: string, packageRoot?: string): void;
|
|
16
16
|
export declare function updateMiniProgramGlobalComponents(filename: string, ast: Program, { inputDir, resolve, normalizeComponentName, root, }: {
|
|
17
17
|
inputDir: string;
|
|
18
18
|
resolve: ParseDescriptor['resolve'];
|
|
@@ -21,7 +21,7 @@ export declare function updateMiniProgramGlobalComponents(filename: string, ast:
|
|
|
21
21
|
}): Promise<{
|
|
22
22
|
imports: ImportDeclaration[];
|
|
23
23
|
}>;
|
|
24
|
-
export declare function updateMiniProgramComponentsByMainFilename(mainFilename: string, inputDir: string, normalizeComponentName: (name: string) => string, root?: string): void;
|
|
24
|
+
export declare function updateMiniProgramComponentsByMainFilename(mainFilename: string, inputDir: string, normalizeComponentName: (name: string) => string, root?: string, packageRoot?: string): void;
|
|
25
25
|
export interface TemplateDescriptor {
|
|
26
26
|
bindingComponents: BindingComponents;
|
|
27
27
|
imports: ImportDeclaration[];
|
|
@@ -13,6 +13,7 @@ const messages_1 = require("../messages");
|
|
|
13
13
|
const constants_1 = require("../constants");
|
|
14
14
|
const utils_1 = require("../utils");
|
|
15
15
|
const utils_2 = require("../vite/utils");
|
|
16
|
+
const x_1 = require("../x");
|
|
16
17
|
const jsonFile_1 = require("../json/mp/jsonFile");
|
|
17
18
|
const subpackage_1 = require("../json/mp/subpackage");
|
|
18
19
|
const mainDescriptors = new Map();
|
|
@@ -94,17 +95,17 @@ function updateMainDescriptorIndex(mainDescriptorKey, descriptor) {
|
|
|
94
95
|
scriptDescriptorMainMap.set(descriptor.script, mainDescriptorKey);
|
|
95
96
|
templateDescriptorMainMap.set(descriptor.template, mainDescriptorKey);
|
|
96
97
|
}
|
|
97
|
-
function updateMiniProgramComponentsByScriptFilename(scriptFilename, inputDir, normalizeComponentName, root) {
|
|
98
|
+
function updateMiniProgramComponentsByScriptFilename(scriptFilename, inputDir, normalizeComponentName, root, packageRoot) {
|
|
98
99
|
const mainFilename = findMainFilenameByScriptFilename(createDescriptorKey(scriptFilename, root));
|
|
99
100
|
if (mainFilename) {
|
|
100
|
-
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName, root);
|
|
101
|
+
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName, root, packageRoot);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
exports.updateMiniProgramComponentsByScriptFilename = updateMiniProgramComponentsByScriptFilename;
|
|
104
|
-
function updateMiniProgramComponentsByTemplateFilename(templateFilename, inputDir, normalizeComponentName, root) {
|
|
105
|
+
function updateMiniProgramComponentsByTemplateFilename(templateFilename, inputDir, normalizeComponentName, root, packageRoot) {
|
|
105
106
|
const mainFilename = findMainFilenameByTemplateFilename(createDescriptorKey(templateFilename, root));
|
|
106
107
|
if (mainFilename) {
|
|
107
|
-
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName, root);
|
|
108
|
+
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName, root, packageRoot);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
exports.updateMiniProgramComponentsByTemplateFilename = updateMiniProgramComponentsByTemplateFilename;
|
|
@@ -126,14 +127,18 @@ async function updateMiniProgramGlobalComponents(filename, ast, { inputDir, reso
|
|
|
126
127
|
globalComponentSourceMap.set(bindingComponents[name].tag, (0, subpackage_1.withoutIndependentRoot)(value));
|
|
127
128
|
}
|
|
128
129
|
});
|
|
129
|
-
(0, jsonFile_1.addMiniProgramUsingComponents)('app', createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName));
|
|
130
|
+
(0, jsonFile_1.addMiniProgramUsingComponents)('app', createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName, undefined, undefined, !!root));
|
|
130
131
|
return {
|
|
131
132
|
imports,
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
135
|
exports.updateMiniProgramGlobalComponents = updateMiniProgramGlobalComponents;
|
|
135
|
-
function createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName) {
|
|
136
|
+
function createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName, ownerFilename, ownerPackageRoot, ownerIsIndependent) {
|
|
136
137
|
const usingComponents = {};
|
|
138
|
+
const ownerSubPackageRoot = (0, x_1.isUniAppX)() && !ownerIsIndependent
|
|
139
|
+
? ownerPackageRoot ||
|
|
140
|
+
(ownerFilename && (0, jsonFile_1.findMiniProgramSubPackageRoot)(ownerFilename))
|
|
141
|
+
: undefined;
|
|
137
142
|
imports.forEach(({ source: { value }, specifiers: [specifier] }) => {
|
|
138
143
|
const { name } = specifier.local;
|
|
139
144
|
if (!bindingComponents[name]) {
|
|
@@ -141,12 +146,23 @@ function createUsingComponents(bindingComponents, imports, inputDir, normalizeCo
|
|
|
141
146
|
}
|
|
142
147
|
const componentName = normalizeComponentName((0, shared_1.hyphenate)(bindingComponents[name].tag));
|
|
143
148
|
if (!usingComponents[componentName]) {
|
|
144
|
-
|
|
149
|
+
let componentFilename = (0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)((0, subpackage_1.withoutIndependentRoot)(value), inputDir));
|
|
150
|
+
if ((0, x_1.isUniAppX)() &&
|
|
151
|
+
!ownerIsIndependent &&
|
|
152
|
+
componentFilename.startsWith('uni_modules/')) {
|
|
153
|
+
(0, jsonFile_1.addMiniProgramComponentPackageRoot)(componentFilename, ownerSubPackageRoot);
|
|
154
|
+
const componentPackageRoot = (0, jsonFile_1.resolveMiniProgramComponentPackageRoot)(componentFilename, ownerSubPackageRoot);
|
|
155
|
+
if (ownerSubPackageRoot &&
|
|
156
|
+
componentPackageRoot === ownerSubPackageRoot) {
|
|
157
|
+
componentFilename = `${ownerSubPackageRoot}/${componentFilename}`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
usingComponents[componentName] = (0, uni_shared_1.addLeadingSlash)(componentFilename);
|
|
145
161
|
}
|
|
146
162
|
});
|
|
147
163
|
return usingComponents;
|
|
148
164
|
}
|
|
149
|
-
function updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName, root) {
|
|
165
|
+
function updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName, root, packageRoot) {
|
|
150
166
|
const mainDescriptor = mainDescriptors.get(createDescriptorKey(mainFilename, root));
|
|
151
167
|
if (!mainDescriptor) {
|
|
152
168
|
return;
|
|
@@ -164,7 +180,11 @@ function updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, norma
|
|
|
164
180
|
...scriptDescriptor.setupBindingComponents,
|
|
165
181
|
}, scriptDescriptor.bindingComponents);
|
|
166
182
|
const imports = parseImports(mainDescriptor.imports, scriptDescriptor.imports, templateDescriptor.imports);
|
|
167
|
-
|
|
183
|
+
const normalizedOwnerFilename = (0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)((0, subpackage_1.withoutIndependentRoot)(mainFilename), inputDir));
|
|
184
|
+
const ownerFilename = packageRoot && normalizedOwnerFilename.startsWith('uni_modules/')
|
|
185
|
+
? `${packageRoot}/${normalizedOwnerFilename}`
|
|
186
|
+
: normalizedOwnerFilename;
|
|
187
|
+
(0, jsonFile_1.addMiniProgramUsingComponents)(ownerFilename, createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName, ownerFilename, root ? undefined : packageRoot, !!root));
|
|
168
188
|
}
|
|
169
189
|
exports.updateMiniProgramComponentsByMainFilename = updateMiniProgramComponentsByMainFilename;
|
|
170
190
|
function findBindingComponent(tag, bindingComponents) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-5020720260921001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"unimport": "4.1.1",
|
|
70
70
|
"unplugin-auto-import": "19.1.0",
|
|
71
71
|
"xregexp": "5.1.2",
|
|
72
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
73
|
-
"@dcloudio/uni-
|
|
74
|
-
"@dcloudio/uni-
|
|
72
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-5020720260921001",
|
|
73
|
+
"@dcloudio/uni-nvue-styler": "3.0.0-alpha-5020720260921001",
|
|
74
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-5020720260921001"
|
|
75
75
|
},
|
|
76
76
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
77
77
|
"devDependencies": {
|
|
@@ -91,6 +91,6 @@
|
|
|
91
91
|
"code-frame": "link:@types/@babel/code-frame",
|
|
92
92
|
"postcss": "8.5.6",
|
|
93
93
|
"vue": "3.4.21",
|
|
94
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
94
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-5020720260921001"
|
|
95
95
|
}
|
|
96
96
|
}
|