@dcloudio/uni-cli-shared 3.0.0-alpha-3030520211229001 → 3.0.0-alpha-3030720220111001
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json/manifest.d.ts +1 -0
- package/dist/json/manifest.js +6 -1
- package/dist/logs/console.d.ts +4 -1
- package/dist/logs/console.js +5 -2
- package/dist/mp/template.d.ts +2 -1
- package/dist/mp/usingComponents.d.ts +8 -1
- package/dist/mp/usingComponents.js +9 -3
- package/dist/platform.d.ts +2 -0
- package/dist/platform.js +31 -0
- package/dist/scripts.js +18 -4
- package/dist/vite/plugins/console.js +6 -4
- package/dist/vite/plugins/copy.d.ts +4 -1
- package/dist/vite/plugins/copy.js +2 -1
- package/dist/vite/plugins/inject.js +3 -1
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/asset.js +3 -2
- package/dist/vite/plugins/vitejs/plugins/css.js +1 -0
- package/dist/vite/utils/index.d.ts +1 -0
- package/dist/vite/utils/index.js +1 -0
- package/dist/vite/utils/utils.d.ts +2 -0
- package/dist/vite/utils/utils.js +10 -0
- package/dist/watcher.js +3 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __exportStar(require("./filter"), exports);
|
|
|
32
32
|
__exportStar(require("./esbuild"), exports);
|
|
33
33
|
__exportStar(require("./resolve"), exports);
|
|
34
34
|
__exportStar(require("./scripts"), exports);
|
|
35
|
+
__exportStar(require("./platform"), exports);
|
|
35
36
|
var messages_1 = require("./messages");
|
|
36
37
|
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
|
37
38
|
__exportStar(require("./exports"), exports);
|
package/dist/json/manifest.d.ts
CHANGED
|
@@ -24,4 +24,5 @@ export declare function getRouterOptions(manifestJson: Record<string, any>): {
|
|
|
24
24
|
base?: string;
|
|
25
25
|
};
|
|
26
26
|
export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
|
|
27
|
+
export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
|
|
27
28
|
export {};
|
package/dist/json/manifest.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.isEnableTreeShaking = exports.getRouterOptions = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
6
|
+
exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -57,3 +57,8 @@ function isEnableTreeShaking(manifestJson) {
|
|
|
57
57
|
return ((_c = (_b = (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.treeShaking) === null || _c === void 0 ? void 0 : _c.enable) !== false;
|
|
58
58
|
}
|
|
59
59
|
exports.isEnableTreeShaking = isEnableTreeShaking;
|
|
60
|
+
function getDevServerOptions(manifestJson) {
|
|
61
|
+
var _a;
|
|
62
|
+
return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.devServer);
|
|
63
|
+
}
|
|
64
|
+
exports.getDevServerOptions = getDevServerOptions;
|
package/dist/logs/console.d.ts
CHANGED
package/dist/logs/console.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.rewriteConsoleExpr = void 0;
|
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const F = '__f__';
|
|
10
|
-
function rewriteConsoleExpr(filename, code) {
|
|
10
|
+
function rewriteConsoleExpr(id, filename, code, sourceMap = false) {
|
|
11
11
|
filename = (0, utils_1.normalizePath)(filename);
|
|
12
12
|
const re = /(console\.(log|info|debug|warn|error))\(([^)]+)\)/g;
|
|
13
13
|
const locate = getLocator(code);
|
|
@@ -17,7 +17,10 @@ function rewriteConsoleExpr(filename, code) {
|
|
|
17
17
|
const [, expr, type] = match;
|
|
18
18
|
s.overwrite(match.index, match.index + expr.length + 1, F + `('${type}','at ${filename}:${locate(match.index).line + 1}',`);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
code: s.toString(),
|
|
22
|
+
map: sourceMap ? s.generateMap({ source: id, hires: true }) : null,
|
|
23
|
+
};
|
|
21
24
|
}
|
|
22
25
|
exports.rewriteConsoleExpr = rewriteConsoleExpr;
|
|
23
26
|
function getLocator(source) {
|
package/dist/mp/template.d.ts
CHANGED
|
@@ -58,5 +58,12 @@ export declare function parseScriptDescriptor(filename: string, ast: Program, op
|
|
|
58
58
|
* @param dynamicImport
|
|
59
59
|
* @returns
|
|
60
60
|
*/
|
|
61
|
-
export declare function transformDynamicImports(code: string, imports: ImportDeclaration[],
|
|
61
|
+
export declare function transformDynamicImports(code: string, imports: ImportDeclaration[], { id, sourceMap, dynamicImport, }: {
|
|
62
|
+
id?: string;
|
|
63
|
+
sourceMap?: boolean;
|
|
64
|
+
dynamicImport: (name: string, source: string) => string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
code: string;
|
|
67
|
+
map: null;
|
|
68
|
+
}>;
|
|
62
69
|
export {};
|
|
@@ -376,15 +376,21 @@ async function parseVueComponentImports(importer, imports, resolve) {
|
|
|
376
376
|
* @param dynamicImport
|
|
377
377
|
* @returns
|
|
378
378
|
*/
|
|
379
|
-
async function transformDynamicImports(code, imports, dynamicImport) {
|
|
379
|
+
async function transformDynamicImports(code, imports, { id, sourceMap, dynamicImport, }) {
|
|
380
380
|
if (!imports.length) {
|
|
381
|
-
return
|
|
381
|
+
return {
|
|
382
|
+
code,
|
|
383
|
+
map: null,
|
|
384
|
+
};
|
|
382
385
|
}
|
|
383
386
|
const s = new magic_string_1.default(code);
|
|
384
387
|
for (let i = 0; i < imports.length; i++) {
|
|
385
388
|
const { start, end, specifiers: [specifier], source, } = imports[i];
|
|
386
389
|
s.overwrite(start, end, dynamicImport(specifier.local.name, source.value) + ';');
|
|
387
390
|
}
|
|
388
|
-
return
|
|
391
|
+
return {
|
|
392
|
+
code: s.toString(),
|
|
393
|
+
map: null,
|
|
394
|
+
};
|
|
389
395
|
}
|
|
390
396
|
exports.transformDynamicImports = transformDynamicImports;
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlatforms = exports.registerPlatform = void 0;
|
|
4
|
+
const BUILT_IN_PLATFORMS = [
|
|
5
|
+
'app',
|
|
6
|
+
'app-plus',
|
|
7
|
+
'h5',
|
|
8
|
+
'mp-360',
|
|
9
|
+
'mp-alipay',
|
|
10
|
+
'mp-baidu',
|
|
11
|
+
'mp-jd',
|
|
12
|
+
'mp-kuaishou',
|
|
13
|
+
'mp-lark',
|
|
14
|
+
'mp-qq',
|
|
15
|
+
'mp-toutiao',
|
|
16
|
+
'mp-weixin',
|
|
17
|
+
'quickapp-webview',
|
|
18
|
+
'quickapp-webview-huawei',
|
|
19
|
+
'quickapp-webview-union',
|
|
20
|
+
];
|
|
21
|
+
const platforms = [...BUILT_IN_PLATFORMS];
|
|
22
|
+
function registerPlatform(platform) {
|
|
23
|
+
if (!platforms.includes(platform)) {
|
|
24
|
+
platforms.push(platform);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.registerPlatform = registerPlatform;
|
|
28
|
+
function getPlatforms() {
|
|
29
|
+
return platforms;
|
|
30
|
+
}
|
|
31
|
+
exports.getPlatforms = getPlatforms;
|
package/dist/scripts.js
CHANGED
|
@@ -4,27 +4,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseScripts = void 0;
|
|
7
|
+
const shared_1 = require("@vue/shared");
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
function parseScripts(name, pkgPath) {
|
|
9
|
-
var _a, _b
|
|
10
|
+
var _a, _b;
|
|
10
11
|
if (!fs_1.default.existsSync(pkgPath)) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
14
|
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
|
|
14
|
-
const
|
|
15
|
+
const scripts = ((_a = pkg['uni-app']) === null || _a === void 0 ? void 0 : _a.scripts) || {};
|
|
16
|
+
const options = scripts[name];
|
|
15
17
|
if (!options) {
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
|
-
if (!((
|
|
20
|
+
if (!((_b = options.env) === null || _b === void 0 ? void 0 : _b.UNI_PLATFORM)) {
|
|
19
21
|
console.error(`package.json->uni-app->scripts->${name}->env->UNI_PLATFORM is required`);
|
|
20
22
|
process.exit(0);
|
|
21
23
|
}
|
|
22
24
|
const { UNI_PLATFORM, ...define } = options.env;
|
|
25
|
+
const context = options.define || {};
|
|
26
|
+
// 补充当前编译环境未定义的其他编译环境 define
|
|
27
|
+
Object.keys(scripts).forEach((scriptName) => {
|
|
28
|
+
if (scriptName !== name) {
|
|
29
|
+
const scriptDefine = scripts[scriptName].define || {};
|
|
30
|
+
Object.keys(scriptDefine).forEach((key) => {
|
|
31
|
+
if (!(0, shared_1.hasOwn)(context, key)) {
|
|
32
|
+
context[key] = false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
23
37
|
return {
|
|
24
38
|
name: name,
|
|
25
39
|
platform: UNI_PLATFORM,
|
|
26
40
|
define,
|
|
27
|
-
context
|
|
41
|
+
context,
|
|
28
42
|
};
|
|
29
43
|
}
|
|
30
44
|
exports.parseScripts = parseScripts;
|
|
@@ -8,12 +8,17 @@ const debug_1 = __importDefault(require("debug"));
|
|
|
8
8
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const console_1 = require("../../logs/console");
|
|
11
|
+
const utils_2 = require("../../vite/utils/utils");
|
|
11
12
|
const debugConsole = (0, debug_1.default)('vite:uni:console');
|
|
12
13
|
function uniConsolePlugin(options) {
|
|
13
14
|
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
15
|
+
let resolvedConfig;
|
|
14
16
|
return {
|
|
15
17
|
name: 'vite:uni-console',
|
|
16
18
|
enforce: 'pre',
|
|
19
|
+
configResolved(config) {
|
|
20
|
+
resolvedConfig = config;
|
|
21
|
+
},
|
|
17
22
|
transform(code, id) {
|
|
18
23
|
if (!filter(id))
|
|
19
24
|
return null;
|
|
@@ -30,10 +35,7 @@ function uniConsolePlugin(options) {
|
|
|
30
35
|
return null;
|
|
31
36
|
}
|
|
32
37
|
debugConsole(id);
|
|
33
|
-
return
|
|
34
|
-
code: (0, console_1.rewriteConsoleExpr)(filename, code),
|
|
35
|
-
map: null,
|
|
36
|
-
};
|
|
38
|
+
return (0, console_1.rewriteConsoleExpr)(id, filename, code, (0, utils_2.withSourcemap)(resolvedConfig));
|
|
37
39
|
},
|
|
38
40
|
};
|
|
39
41
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { WatchOptions } from 'chokidar';
|
|
1
2
|
import type { Plugin } from 'vite';
|
|
2
3
|
import { FileWatcherOptions } from '../../watcher';
|
|
3
|
-
export declare type UniViteCopyPluginTarget = Omit<FileWatcherOptions, 'verbose'
|
|
4
|
+
export declare type UniViteCopyPluginTarget = Omit<FileWatcherOptions, 'verbose'> & {
|
|
5
|
+
watchOptions?: WatchOptions;
|
|
6
|
+
};
|
|
4
7
|
export interface UniViteCopyPluginOptions {
|
|
5
8
|
targets: UniViteCopyPluginTarget[];
|
|
6
9
|
verbose: boolean;
|
|
@@ -21,13 +21,14 @@ function uniViteCopyPlugin({ targets, verbose, }) {
|
|
|
21
21
|
}
|
|
22
22
|
inited = true;
|
|
23
23
|
return new Promise((resolve) => {
|
|
24
|
-
Promise.all(targets.map((target) => {
|
|
24
|
+
Promise.all(targets.map(({ watchOptions, ...target }) => {
|
|
25
25
|
return new Promise((resolve) => {
|
|
26
26
|
new watcher_1.FileWatcher({
|
|
27
27
|
verbose,
|
|
28
28
|
...target,
|
|
29
29
|
}).watch({
|
|
30
30
|
cwd: process.env.UNI_INPUT_DIR,
|
|
31
|
+
...watchOptions,
|
|
31
32
|
}, (watcher) => {
|
|
32
33
|
if (process.env.NODE_ENV !== 'development') {
|
|
33
34
|
// 生产模式下,延迟 close,否则会影响 chokidar 初始化的 add 等事件
|
|
@@ -111,7 +111,9 @@ function uniViteInjectPlugin(options) {
|
|
|
111
111
|
if (reassignments.has(hash)) {
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
|
-
if (parent &&
|
|
114
|
+
if (parent &&
|
|
115
|
+
(0, utils_1.isAssignmentExpression)(parent) &&
|
|
116
|
+
parent.left === node) {
|
|
115
117
|
reassignments.add(hash);
|
|
116
118
|
return false;
|
|
117
119
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
|
|
2
3
|
import { Plugin } from '../plugin';
|
|
3
4
|
import { ResolvedConfig } from '../config';
|
|
4
|
-
import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
|
|
5
5
|
export declare const assetUrlRE: RegExp;
|
|
6
6
|
export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
|
|
7
7
|
/**
|
|
@@ -27,9 +27,10 @@ const path_1 = __importDefault(require("path"));
|
|
|
27
27
|
const url_1 = require("url");
|
|
28
28
|
const lite_1 = __importDefault(require("mime/lite"));
|
|
29
29
|
const fs_1 = __importStar(require("fs"));
|
|
30
|
-
const utils_1 = require("../utils");
|
|
31
30
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
32
31
|
const crypto_1 = require("crypto");
|
|
32
|
+
const utils_1 = require("../utils");
|
|
33
|
+
const utils_2 = require("../../../../vite/utils/utils");
|
|
33
34
|
exports.assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g;
|
|
34
35
|
// urls in JS must be quoted as strings, so when replacing them we need
|
|
35
36
|
// a different regex
|
|
@@ -99,7 +100,7 @@ function assetPlugin(config) {
|
|
|
99
100
|
if (s) {
|
|
100
101
|
return {
|
|
101
102
|
code: s.toString(),
|
|
102
|
-
map: config
|
|
103
|
+
map: (0, utils_2.withSourcemap)(config) ? s.generateMap({ hires: true }) : null,
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
else {
|
|
@@ -501,6 +501,7 @@ async function minifyCSS(css, config) {
|
|
|
501
501
|
const { code, warnings } = await (0, esbuild_1.transform)(css, {
|
|
502
502
|
loader: 'css',
|
|
503
503
|
minify: true,
|
|
504
|
+
target: config.build.cssTarget || undefined,
|
|
504
505
|
});
|
|
505
506
|
if (warnings.length) {
|
|
506
507
|
const msgs = await (0, esbuild_1.formatMessages)(warnings, { kind: 'warning' });
|
|
@@ -2,5 +2,6 @@ import type { ResolvedConfig } from 'vite';
|
|
|
2
2
|
export * from './ast';
|
|
3
3
|
export * from './url';
|
|
4
4
|
export * from './plugin';
|
|
5
|
+
export * from './utils';
|
|
5
6
|
export declare const buildInCssSet: Set<string>;
|
|
6
7
|
export declare function isCombineBuiltInCss(config: ResolvedConfig): boolean;
|
package/dist/vite/utils/index.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.isCombineBuiltInCss = exports.buildInCssSet = void 0;
|
|
|
14
14
|
__exportStar(require("./ast"), exports);
|
|
15
15
|
__exportStar(require("./url"), exports);
|
|
16
16
|
__exportStar(require("./plugin"), exports);
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
17
18
|
// 内置组件css列表,h5平台需要合并进去首页css中
|
|
18
19
|
exports.buildInCssSet = new Set();
|
|
19
20
|
function isCombineBuiltInCss(config) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withSourcemap = void 0;
|
|
4
|
+
function withSourcemap(config) {
|
|
5
|
+
if (config.command === 'serve') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return !!config.build.sourcemap;
|
|
9
|
+
}
|
|
10
|
+
exports.withSourcemap = withSourcemap;
|
package/dist/watcher.js
CHANGED
|
@@ -57,14 +57,14 @@ class FileWatcher {
|
|
|
57
57
|
if (content) {
|
|
58
58
|
return fs_extra_1.default
|
|
59
59
|
.outputFile(to, content)
|
|
60
|
-
.catch((
|
|
60
|
+
.catch(() => {
|
|
61
61
|
// this.info('copy', e)
|
|
62
62
|
})
|
|
63
63
|
.then(() => this.onChange && this.onChange());
|
|
64
64
|
}
|
|
65
65
|
return fs_extra_1.default
|
|
66
66
|
.copy(this.from(from), to, { overwrite: true })
|
|
67
|
-
.catch((
|
|
67
|
+
.catch(() => {
|
|
68
68
|
// this.info('copy', e)
|
|
69
69
|
})
|
|
70
70
|
.then(() => this.onChange && this.onChange());
|
|
@@ -74,7 +74,7 @@ class FileWatcher {
|
|
|
74
74
|
this.info('remove', from + '=>' + to);
|
|
75
75
|
return fs_extra_1.default
|
|
76
76
|
.remove(to)
|
|
77
|
-
.catch((
|
|
77
|
+
.catch(() => {
|
|
78
78
|
// this.info('remove', e)
|
|
79
79
|
})
|
|
80
80
|
.then(() => this.onChange && this.onChange());
|
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-3030720220111001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@babel/core": "^7.16.5",
|
|
22
22
|
"@babel/parser": "^7.16.4",
|
|
23
23
|
"@babel/types": "^7.16.0",
|
|
24
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
25
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
24
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3030720220111001",
|
|
25
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3030720220111001",
|
|
26
26
|
"@rollup/pluginutils": "^4.1.2",
|
|
27
27
|
"@vue/compiler-core": "3.2.26",
|
|
28
28
|
"@vue/compiler-dom": "3.2.26",
|