@dcloudio/uni-cli-shared 3.0.0-alpha-3090820231120001 → 3.0.0-alpha-3090920231203001
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/hbx/log.js +2 -1
- package/dist/json/app/pages/uniConfig.d.ts +5 -0
- package/dist/json/app/pages/uniConfig.js +2 -1
- package/dist/json/index.d.ts +1 -1
- package/dist/json/index.js +5 -3
- package/dist/json/mp/pages.js +1 -1
- package/dist/json/uni-x/index.d.ts +9 -0
- package/dist/json/uni-x/index.js +206 -0
- package/dist/json/uni-x/uniConfig.d.ts +1 -0
- package/dist/json/uni-x/uniConfig.js +18 -0
- package/dist/vite/plugins/vitejs/utils.d.ts +5 -1
- package/dist/vite/plugins/vitejs/utils.js +22 -2
- package/dist/vite/utils/utils.d.ts +3 -0
- package/dist/vite/utils/utils.js +30 -1
- package/package.json +4 -4
- package/dist/json/uniAppX.d.ts +0 -1
- package/dist/json/uniAppX.js +0 -79
package/dist/hbx/log.js
CHANGED
|
@@ -43,7 +43,8 @@ if (typeof console !== 'undefined') {
|
|
|
43
43
|
// overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
|
|
44
44
|
}
|
|
45
45
|
function formatAtFilename(filename, line, column) {
|
|
46
|
-
|
|
46
|
+
const file = path_1.default.relative(process.env.UNI_INPUT_DIR, filename.replace('\x00', '').split('?')[0]);
|
|
47
|
+
return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(file === 'pages-json-uts' ? 'pages.json' : file) +
|
|
47
48
|
':' +
|
|
48
49
|
(line || 1) +
|
|
49
50
|
':' +
|
|
@@ -1 +1,6 @@
|
|
|
1
1
|
export declare function normalizeAppUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
2
|
+
export declare function parseEntryPagePath(pagesJson: UniApp.PagesJson): {
|
|
3
|
+
entryPagePath: string;
|
|
4
|
+
entryPageQuery: string;
|
|
5
|
+
realEntryPagePath: string;
|
|
6
|
+
};
|
|
@@ -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.normalizeAppUniConfig = void 0;
|
|
6
|
+
exports.parseEntryPagePath = exports.normalizeAppUniConfig = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const i18n_1 = require("../../../i18n");
|
|
9
9
|
const manifest_1 = require("../../manifest");
|
|
@@ -70,3 +70,4 @@ function parseEntryPagePath(pagesJson) {
|
|
|
70
70
|
}
|
|
71
71
|
return res;
|
|
72
72
|
}
|
|
73
|
+
exports.parseEntryPagePath = parseEntryPagePath;
|
package/dist/json/index.d.ts
CHANGED
package/dist/json/index.js
CHANGED
|
@@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.normalizeUniAppXAppPagesJson = void 0;
|
|
17
|
+
exports.checkPagesJson = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
18
18
|
__exportStar(require("./mp"), exports);
|
|
19
19
|
__exportStar(require("./app"), exports);
|
|
20
20
|
__exportStar(require("./json"), exports);
|
|
21
21
|
__exportStar(require("./pages"), exports);
|
|
22
22
|
__exportStar(require("./manifest"), exports);
|
|
23
23
|
__exportStar(require("./theme"), exports);
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return
|
|
24
|
+
var uni_x_1 = require("./uni-x");
|
|
25
|
+
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppPagesJson; } });
|
|
26
|
+
Object.defineProperty(exports, "normalizeUniAppXAppConfig", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppConfig; } });
|
|
27
|
+
Object.defineProperty(exports, "checkPagesJson", { enumerable: true, get: function () { return uni_x_1.checkPagesJson; } });
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -24,9 +24,9 @@ const NON_APP_JSON_KEYS = [
|
|
|
24
24
|
'usingComponents',
|
|
25
25
|
'optimization',
|
|
26
26
|
'scopedSlotsCompiler',
|
|
27
|
-
'usingComponents',
|
|
28
27
|
'uniStatistics',
|
|
29
28
|
'mergeVirtualHostAttributes',
|
|
29
|
+
'styleIsolation',
|
|
30
30
|
];
|
|
31
31
|
function mergeMiniProgramAppJson(appJson, platformJson = {}) {
|
|
32
32
|
Object.keys(platformJson).forEach((name) => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function checkPagesJson(jsonStr: string, inputDir: string): boolean;
|
|
2
|
+
export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
|
|
3
|
+
/**
|
|
4
|
+
* TODO 应该闭包,通过globalThis赋值?
|
|
5
|
+
* @param pagesJson
|
|
6
|
+
* @param manifestJson
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeUniAppXAppConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = exports.checkPagesJson = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const shared_1 = require("@vue/shared");
|
|
10
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
11
|
+
const json_1 = require("../json");
|
|
12
|
+
const pages_1 = require("../pages");
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
const uniRoutes_1 = require("../app/pages/uniRoutes");
|
|
15
|
+
const uniConfig_1 = require("./uniConfig");
|
|
16
|
+
const utils_2 = require("../../vite/plugins/vitejs/utils");
|
|
17
|
+
function checkPagesJson(jsonStr, inputDir) {
|
|
18
|
+
if (!inputDir) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const errors = [];
|
|
22
|
+
const root = (0, jsonc_parser_1.parseTree)(jsonStr, errors);
|
|
23
|
+
if (!root) {
|
|
24
|
+
if (errors.length) {
|
|
25
|
+
for (const error of errors) {
|
|
26
|
+
const { line, column } = (0, utils_2.offsetToLineColumn)(jsonStr, error.offset);
|
|
27
|
+
throw {
|
|
28
|
+
name: 'SyntaxError',
|
|
29
|
+
code: error.error,
|
|
30
|
+
message: (0, jsonc_parser_1.printParseErrorCode)(error.error),
|
|
31
|
+
loc: {
|
|
32
|
+
start: { line, column },
|
|
33
|
+
},
|
|
34
|
+
offsetStart: error.offset,
|
|
35
|
+
offsetEnd: error.offset + error.length,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const pagePathNodes = walkNodes(findRootNode(root, ['pages']));
|
|
42
|
+
findRootNode(root, ['subPackages', 'subpackages']).forEach((node) => {
|
|
43
|
+
const subPackageRoot = findSubPackageRoot(node);
|
|
44
|
+
if (subPackageRoot) {
|
|
45
|
+
findRootNode(node, ['pages']).forEach((subNode) => {
|
|
46
|
+
walkNodes(subNode.children ?? []).forEach((node) => {
|
|
47
|
+
pagePathNodes.push({
|
|
48
|
+
...node,
|
|
49
|
+
value: (0, utils_1.normalizePath)(path_1.default.join(subPackageRoot, node.value)),
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
if (pagePathNodes.length) {
|
|
56
|
+
for (const node of pagePathNodes) {
|
|
57
|
+
const pagePath = node.value ?? '';
|
|
58
|
+
if (fs_1.default.existsSync(path_1.default.join(inputDir, pagePath + '.uvue')) ||
|
|
59
|
+
fs_1.default.existsSync(path_1.default.join(inputDir, pagePath + '.vue'))) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const { line, column } = (0, utils_2.offsetToLineColumn)(jsonStr, node.offset);
|
|
63
|
+
throw {
|
|
64
|
+
name: 'CompilerError',
|
|
65
|
+
code: 'CompilerError',
|
|
66
|
+
message: `The page path "${pagePath}" does not exist`,
|
|
67
|
+
loc: {
|
|
68
|
+
start: { line, column },
|
|
69
|
+
},
|
|
70
|
+
offsetStart: node.offset,
|
|
71
|
+
offsetEnd: node.offset + node.length,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
exports.checkPagesJson = checkPagesJson;
|
|
78
|
+
function findSubPackageRoot(node) {
|
|
79
|
+
const child = node.children?.find((child) => child.type === 'property' &&
|
|
80
|
+
child.children &&
|
|
81
|
+
child.children.find((child) => child.type === 'string' && child.value === 'root'));
|
|
82
|
+
if (child && child.children?.length === 2) {
|
|
83
|
+
return child.children[1].value;
|
|
84
|
+
}
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
function findRootNode(node, property) {
|
|
88
|
+
const { type, children } = node;
|
|
89
|
+
if (type === 'object' && children) {
|
|
90
|
+
const child = children.find((child) => child.type === 'property' &&
|
|
91
|
+
child.children &&
|
|
92
|
+
child.children.find((child) => child.type === 'string' && property.includes(child.value)));
|
|
93
|
+
if (child) {
|
|
94
|
+
const node = child.children.find((child) => child.type === 'array');
|
|
95
|
+
return node?.children ?? [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
function walkNodes(node) {
|
|
101
|
+
const pagePathNodes = [];
|
|
102
|
+
node.forEach((node) => walkNode(node, pagePathNodes));
|
|
103
|
+
return pagePathNodes;
|
|
104
|
+
}
|
|
105
|
+
function walkNode(node, pagePathNodes) {
|
|
106
|
+
const { type, children } = node;
|
|
107
|
+
if (type === 'property' && children && children.length === 2) {
|
|
108
|
+
const maybePagePathNode = children[0];
|
|
109
|
+
const maybePagePathValueNode = children[1];
|
|
110
|
+
if (maybePagePathNode.type === 'string' &&
|
|
111
|
+
maybePagePathNode.value === 'path' &&
|
|
112
|
+
maybePagePathValueNode.type === 'string' &&
|
|
113
|
+
(0, shared_1.isString)(maybePagePathValueNode.value)) {
|
|
114
|
+
pagePathNodes.push(maybePagePathValueNode);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (children) {
|
|
118
|
+
children.forEach((node) => walkNode(node, pagePathNodes));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function normalizeUniAppXAppPagesJson(jsonStr) {
|
|
122
|
+
checkPagesJson(jsonStr, process.env.UNI_INPUT_DIR);
|
|
123
|
+
const pagesJson = {
|
|
124
|
+
pages: [],
|
|
125
|
+
globalStyle: {},
|
|
126
|
+
};
|
|
127
|
+
let userPagesJson = {
|
|
128
|
+
pages: [],
|
|
129
|
+
globalStyle: {},
|
|
130
|
+
};
|
|
131
|
+
// preprocess
|
|
132
|
+
try {
|
|
133
|
+
userPagesJson = (0, json_1.parseJson)(jsonStr, true);
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
console.error(`[vite] Error: pages.json parse failed.\n`, jsonStr, e);
|
|
137
|
+
}
|
|
138
|
+
// pages
|
|
139
|
+
(0, pages_1.validatePages)(userPagesJson, jsonStr);
|
|
140
|
+
userPagesJson.subPackages =
|
|
141
|
+
userPagesJson.subPackages || userPagesJson.subpackages;
|
|
142
|
+
// subPackages
|
|
143
|
+
if (userPagesJson.subPackages) {
|
|
144
|
+
userPagesJson.pages.push(...normalizeSubPackages(userPagesJson.subPackages));
|
|
145
|
+
}
|
|
146
|
+
pagesJson.pages = userPagesJson.pages;
|
|
147
|
+
// pageStyle
|
|
148
|
+
normalizePages(pagesJson.pages);
|
|
149
|
+
// globalStyle
|
|
150
|
+
pagesJson.globalStyle = normalizePageStyle(userPagesJson.globalStyle);
|
|
151
|
+
// tabBar
|
|
152
|
+
if (userPagesJson.tabBar) {
|
|
153
|
+
pagesJson.tabBar = userPagesJson.tabBar;
|
|
154
|
+
}
|
|
155
|
+
// condition
|
|
156
|
+
if (userPagesJson.condition) {
|
|
157
|
+
pagesJson.condition = userPagesJson.condition;
|
|
158
|
+
}
|
|
159
|
+
// uniIdRouter
|
|
160
|
+
if (userPagesJson.uniIdRouter) {
|
|
161
|
+
pagesJson.uniIdRouter = userPagesJson.uniIdRouter;
|
|
162
|
+
}
|
|
163
|
+
return pagesJson;
|
|
164
|
+
}
|
|
165
|
+
exports.normalizeUniAppXAppPagesJson = normalizeUniAppXAppPagesJson;
|
|
166
|
+
function normalizeSubPackages(subPackages) {
|
|
167
|
+
const pages = [];
|
|
168
|
+
if ((0, shared_1.isArray)(subPackages)) {
|
|
169
|
+
subPackages.forEach(({ root, pages: subPages }) => {
|
|
170
|
+
if (root && subPages.length) {
|
|
171
|
+
subPages.forEach((subPage) => {
|
|
172
|
+
subPage.path = (0, utils_1.normalizePath)(path_1.default.join(root, subPage.path));
|
|
173
|
+
subPage.style = subPage.style;
|
|
174
|
+
pages.push(subPage);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return pages;
|
|
180
|
+
}
|
|
181
|
+
function normalizePages(pages) {
|
|
182
|
+
pages.forEach((page) => {
|
|
183
|
+
page.style = normalizePageStyle(page.style);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function normalizePageStyle(pageStyle) {
|
|
187
|
+
if (pageStyle) {
|
|
188
|
+
(0, shared_1.extend)(pageStyle, pageStyle['app']);
|
|
189
|
+
(0, pages_1.removePlatformStyle)(pageStyle);
|
|
190
|
+
return pageStyle;
|
|
191
|
+
}
|
|
192
|
+
return {};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* TODO 应该闭包,通过globalThis赋值?
|
|
196
|
+
* @param pagesJson
|
|
197
|
+
* @param manifestJson
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
200
|
+
function normalizeUniAppXAppConfig(pagesJson, manifestJson) {
|
|
201
|
+
return `const __uniConfig = ${(0, uniConfig_1.normalizeAppXUniConfig)(pagesJson, manifestJson)};
|
|
202
|
+
const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
|
|
203
|
+
|
|
204
|
+
`;
|
|
205
|
+
}
|
|
206
|
+
exports.normalizeUniAppXAppConfig = normalizeUniAppXAppConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeAppXUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeAppXUniConfig = void 0;
|
|
4
|
+
const uniConfig_1 = require("../app/pages/uniConfig");
|
|
5
|
+
function normalizeAppXUniConfig(pagesJson, manifestJson) {
|
|
6
|
+
const config = {
|
|
7
|
+
pages: [],
|
|
8
|
+
globalStyle: pagesJson.globalStyle,
|
|
9
|
+
appname: manifestJson.name || '',
|
|
10
|
+
compilerVersion: process.env.UNI_COMPILER_VERSION,
|
|
11
|
+
...(0, uniConfig_1.parseEntryPagePath)(pagesJson),
|
|
12
|
+
tabBar: pagesJson.tabBar,
|
|
13
|
+
fallbackLocale: manifestJson.fallbackLocale,
|
|
14
|
+
};
|
|
15
|
+
// TODO 待支持分包
|
|
16
|
+
return JSON.stringify(config);
|
|
17
|
+
}
|
|
18
|
+
exports.normalizeAppXUniConfig = normalizeAppXUniConfig;
|
|
@@ -15,6 +15,10 @@ export declare const multilineCommentsRE: RegExp;
|
|
|
15
15
|
export declare function asyncReplace(input: string, re: RegExp, replacer: (match: RegExpExecArray) => string | Promise<string>): Promise<string>;
|
|
16
16
|
export declare function isObject(value: unknown): value is Record<string, any>;
|
|
17
17
|
export declare function pad(source: string, n?: number): string;
|
|
18
|
+
export declare function offsetToLineColumn(source: string, offset: number): {
|
|
19
|
+
line: number;
|
|
20
|
+
column: number;
|
|
21
|
+
};
|
|
18
22
|
export declare function posToNumber(source: string, pos: number | {
|
|
19
23
|
line: number;
|
|
20
24
|
column: number;
|
|
@@ -30,7 +34,7 @@ export declare function locToStartAndEnd(source: string, loc: {
|
|
|
30
34
|
};
|
|
31
35
|
}): {
|
|
32
36
|
start: number;
|
|
33
|
-
end: number;
|
|
37
|
+
end: number | undefined;
|
|
34
38
|
};
|
|
35
39
|
export declare function generateCodeFrame(source: string, start?: number | {
|
|
36
40
|
line: number;
|
|
@@ -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.combineSourcemaps = exports.processSrcSet = exports.generateCodeFrame = exports.locToStartAndEnd = exports.posToNumber = exports.pad = exports.isObject = exports.asyncReplace = exports.multilineCommentsRE = exports.isDataUrl = exports.dataUrlRE = exports.isExternalUrl = exports.externalRE = exports.cleanUrl = exports.hashRE = exports.queryRE = exports.normalizePath = exports.isWindows = exports.deepImportRE = exports.bareImportRE = exports.slash = void 0;
|
|
6
|
+
exports.combineSourcemaps = exports.processSrcSet = exports.generateCodeFrame = exports.locToStartAndEnd = exports.posToNumber = exports.offsetToLineColumn = exports.pad = exports.isObject = exports.asyncReplace = exports.multilineCommentsRE = exports.isDataUrl = exports.dataUrlRE = exports.isExternalUrl = exports.externalRE = exports.cleanUrl = exports.hashRE = exports.queryRE = exports.normalizePath = exports.isWindows = exports.deepImportRE = exports.bareImportRE = exports.slash = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts
|
|
9
9
|
*/
|
|
@@ -56,6 +56,24 @@ function pad(source, n = 2) {
|
|
|
56
56
|
return lines.map((l) => ` `.repeat(n) + l).join(`\n`);
|
|
57
57
|
}
|
|
58
58
|
exports.pad = pad;
|
|
59
|
+
function offsetToLineColumn(source, offset) {
|
|
60
|
+
const lines = source.split(splitRE);
|
|
61
|
+
let line = 1;
|
|
62
|
+
let column = 0;
|
|
63
|
+
for (let i = 0; i < lines.length; i++) {
|
|
64
|
+
const lineLength = lines[i].length + 1;
|
|
65
|
+
if (offset <= lineLength) {
|
|
66
|
+
column = offset;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
offset -= lineLength;
|
|
71
|
+
line++;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { line, column };
|
|
75
|
+
}
|
|
76
|
+
exports.offsetToLineColumn = offsetToLineColumn;
|
|
59
77
|
function posToNumber(source, pos) {
|
|
60
78
|
if (typeof pos === 'number')
|
|
61
79
|
return pos;
|
|
@@ -73,7 +91,9 @@ function posToNumberByLines(lines, line, column) {
|
|
|
73
91
|
function locToStartAndEnd(source, loc) {
|
|
74
92
|
const lines = source.split(splitRE);
|
|
75
93
|
const start = posToNumberByLines(lines, loc.start.line, loc.start.column);
|
|
76
|
-
const end =
|
|
94
|
+
const end = loc.end
|
|
95
|
+
? posToNumberByLines(lines, loc.end.line, loc.end.column)
|
|
96
|
+
: undefined;
|
|
77
97
|
return { start, end };
|
|
78
98
|
}
|
|
79
99
|
exports.locToStartAndEnd = locToStartAndEnd;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ConfigEnv, ResolvedConfig, UserConfig } from 'vite';
|
|
2
|
+
import { RollupError } from 'rollup';
|
|
3
|
+
import { CompilerError } from '@vue/compiler-sfc';
|
|
2
4
|
export declare function withSourcemap(config: ResolvedConfig): boolean;
|
|
3
5
|
export declare function isInHybridNVue(config: UserConfig | ResolvedConfig): boolean;
|
|
4
6
|
export declare function isSsr(command: ConfigEnv['command'], config: UserConfig | ResolvedConfig): boolean;
|
|
7
|
+
export declare function createRollupError(plugin: string, id: string, error: CompilerError | SyntaxError, source?: string): RollupError;
|
package/dist/vite/utils/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSsr = exports.isInHybridNVue = exports.withSourcemap = void 0;
|
|
3
|
+
exports.createRollupError = exports.isSsr = exports.isInHybridNVue = exports.withSourcemap = void 0;
|
|
4
|
+
const utils_1 = require("../plugins/vitejs/utils");
|
|
4
5
|
function withSourcemap(config) {
|
|
5
6
|
if (config.command === 'serve') {
|
|
6
7
|
return true;
|
|
@@ -22,3 +23,31 @@ function isSsr(command, config) {
|
|
|
22
23
|
return false;
|
|
23
24
|
}
|
|
24
25
|
exports.isSsr = isSsr;
|
|
26
|
+
function createRollupError(plugin, id, error, source) {
|
|
27
|
+
const { message, name, stack } = error;
|
|
28
|
+
const rollupError = {
|
|
29
|
+
id,
|
|
30
|
+
plugin,
|
|
31
|
+
message,
|
|
32
|
+
name,
|
|
33
|
+
stack,
|
|
34
|
+
};
|
|
35
|
+
if ('code' in error && error.loc) {
|
|
36
|
+
rollupError.loc = {
|
|
37
|
+
file: id,
|
|
38
|
+
line: error.loc.start.line,
|
|
39
|
+
column: error.loc.start.column,
|
|
40
|
+
};
|
|
41
|
+
if (source && source.length > 0) {
|
|
42
|
+
if ('offsetStart' in error && 'offsetEnd' in error) {
|
|
43
|
+
rollupError.frame = (0, utils_1.generateCodeFrame)(source, error.offsetStart, error.offsetEnd).replace(/\t/g, ' ');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const { start, end } = (0, utils_1.locToStartAndEnd)(source, error.loc);
|
|
47
|
+
rollupError.frame = (0, utils_1.generateCodeFrame)(source, start, end).replace(/\t/g, ' ');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return rollupError;
|
|
52
|
+
}
|
|
53
|
+
exports.createRollupError = createRollupError;
|
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-3090920231203001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@babel/core": "^7.21.3",
|
|
26
26
|
"@babel/parser": "^7.16.4",
|
|
27
27
|
"@babel/types": "^7.20.7",
|
|
28
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
29
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
28
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3090920231203001",
|
|
29
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3090920231203001",
|
|
30
30
|
"@intlify/core-base": "9.1.9",
|
|
31
31
|
"@intlify/shared": "9.1.9",
|
|
32
32
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
67
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-3090920231203001",
|
|
68
68
|
"@types/babel__core": "^7.1.19",
|
|
69
69
|
"@types/debug": "^4.1.7",
|
|
70
70
|
"@types/estree": "^0.0.51",
|
package/dist/json/uniAppX.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
|
package/dist/json/uniAppX.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeUniAppXAppPagesJson = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const shared_1 = require("@vue/shared");
|
|
9
|
-
const json_1 = require("./json");
|
|
10
|
-
const pages_1 = require("./pages");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
function normalizeUniAppXAppPagesJson(jsonStr) {
|
|
13
|
-
const pagesJson = {
|
|
14
|
-
pages: [],
|
|
15
|
-
globalStyle: {},
|
|
16
|
-
};
|
|
17
|
-
let userPagesJson = {
|
|
18
|
-
pages: [],
|
|
19
|
-
globalStyle: {},
|
|
20
|
-
};
|
|
21
|
-
// preprocess
|
|
22
|
-
try {
|
|
23
|
-
userPagesJson = (0, json_1.parseJson)(jsonStr, true);
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
console.error(`[vite] Error: pages.json parse failed.\n`, jsonStr, e);
|
|
27
|
-
}
|
|
28
|
-
// pages
|
|
29
|
-
(0, pages_1.validatePages)(userPagesJson, jsonStr);
|
|
30
|
-
userPagesJson.subPackages =
|
|
31
|
-
userPagesJson.subPackages || userPagesJson.subpackages;
|
|
32
|
-
// subPackages
|
|
33
|
-
if (userPagesJson.subPackages) {
|
|
34
|
-
userPagesJson.pages.push(...normalizeSubPackages(userPagesJson.subPackages));
|
|
35
|
-
}
|
|
36
|
-
pagesJson.pages = userPagesJson.pages;
|
|
37
|
-
// pageStyle
|
|
38
|
-
normalizePages(pagesJson.pages);
|
|
39
|
-
// globalStyle
|
|
40
|
-
pagesJson.globalStyle = normalizePageStyle(userPagesJson.globalStyle);
|
|
41
|
-
// tabBar
|
|
42
|
-
if (userPagesJson.tabBar) {
|
|
43
|
-
pagesJson.tabBar = userPagesJson.tabBar;
|
|
44
|
-
}
|
|
45
|
-
// condition
|
|
46
|
-
if (userPagesJson.condition) {
|
|
47
|
-
pagesJson.condition = userPagesJson.condition;
|
|
48
|
-
}
|
|
49
|
-
return pagesJson;
|
|
50
|
-
}
|
|
51
|
-
exports.normalizeUniAppXAppPagesJson = normalizeUniAppXAppPagesJson;
|
|
52
|
-
function normalizeSubPackages(subPackages) {
|
|
53
|
-
const pages = [];
|
|
54
|
-
if ((0, shared_1.isArray)(subPackages)) {
|
|
55
|
-
subPackages.forEach(({ root, pages: subPages }) => {
|
|
56
|
-
if (root && subPages.length) {
|
|
57
|
-
subPages.forEach((subPage) => {
|
|
58
|
-
subPage.path = (0, utils_1.normalizePath)(path_1.default.join(root, subPage.path));
|
|
59
|
-
subPage.style = subPage.style;
|
|
60
|
-
pages.push(subPage);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return pages;
|
|
66
|
-
}
|
|
67
|
-
function normalizePages(pages) {
|
|
68
|
-
pages.forEach((page) => {
|
|
69
|
-
page.style = normalizePageStyle(page.style);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function normalizePageStyle(pageStyle) {
|
|
73
|
-
if (pageStyle) {
|
|
74
|
-
(0, shared_1.extend)(pageStyle, pageStyle['app']);
|
|
75
|
-
(0, pages_1.removePlatformStyle)(pageStyle);
|
|
76
|
-
return pageStyle;
|
|
77
|
-
}
|
|
78
|
-
return {};
|
|
79
|
-
}
|