@dcloudio/uni-cli-shared 3.0.0-alpha-3021320211109002 → 3.0.0-alpha-3021220211105012
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/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/easycom.d.ts +7 -1
- package/dist/easycom.js +25 -6
- package/dist/env/define.d.ts +2 -0
- package/dist/env/define.js +5 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.js +8 -0
- package/dist/filter.d.ts +16 -0
- package/dist/filter.js +60 -0
- package/dist/hbx/index.js +0 -7
- package/dist/hbx/log.d.ts +2 -0
- package/dist/hbx/log.js +36 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/json/app/manifest/nvue.d.ts +3 -3
- package/dist/json/app/pages/index.d.ts +0 -1
- package/dist/json/app/pages/index.js +0 -11
- package/dist/json/manifest.d.ts +1 -1
- package/dist/json/manifest.js +9 -3
- package/dist/json/mp/index.d.ts +1 -0
- package/dist/json/mp/index.js +11 -0
- package/dist/json/mp/jsonFile.d.ts +7 -6
- package/dist/json/mp/jsonFile.js +56 -13
- package/dist/json/mp/pages.d.ts +1 -0
- package/dist/json/mp/pages.js +17 -3
- package/dist/json/mp/types.d.ts +1 -0
- package/dist/json/pages.js +0 -4
- package/dist/logs/console.js +5 -2
- package/dist/logs/format.js +6 -0
- package/dist/messages/index.d.ts +2 -0
- package/dist/messages/index.js +2 -0
- package/dist/mp/constants.d.ts +2 -0
- package/dist/mp/constants.js +5 -0
- package/dist/mp/event.d.ts +2 -1
- package/dist/mp/event.js +18 -3
- package/dist/mp/imports.d.ts +5 -0
- package/dist/mp/imports.js +63 -0
- package/dist/mp/index.d.ts +5 -0
- package/dist/mp/index.js +7 -0
- package/dist/mp/nvue.d.ts +1 -0
- package/dist/mp/nvue.js +18 -0
- package/dist/mp/style.d.ts +1 -0
- package/dist/mp/style.js +10 -0
- package/dist/mp/template.d.ts +55 -0
- package/dist/mp/template.js +73 -0
- package/dist/mp/transformImports.d.ts +14 -0
- package/dist/mp/transformImports.js +175 -0
- package/dist/postcss/plugins/stylePluginScoped.d.ts +1 -1
- package/dist/postcss/plugins/uniapp.d.ts +1 -1
- package/dist/postcss/plugins/uniapp.js +51 -21
- package/dist/preprocess/context.js +1 -0
- package/dist/utils.d.ts +8 -1
- package/dist/utils.js +71 -8
- package/dist/vite/features.d.ts +1 -1
- package/dist/vite/index.d.ts +2 -3
- package/dist/vite/plugins/copy.d.ts +1 -1
- package/dist/vite/plugins/cssScoped.d.ts +1 -1
- package/dist/vite/plugins/inject.d.ts +1 -1
- package/dist/vite/plugins/inject.js +2 -2
- package/dist/vite/plugins/vitejs/config.d.ts +1 -1
- package/dist/vite/plugins/vitejs/index.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugin.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/asset.js +28 -21
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -4
- package/dist/vite/plugins/vitejs/plugins/css.js +15 -24
- package/dist/vite/plugins/vitejs/server/moduleGraph.d.ts +1 -1
- package/dist/vite/plugins/vitejs/server/moduleGraph.js +0 -3
- package/dist/vite/utils/ast.d.ts +1 -1
- package/dist/vite/utils/index.d.ts +1 -1
- package/dist/vite/utils/plugin.d.ts +4 -4
- package/dist/vite/utils/plugin.js +2 -2
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +14 -0
- package/dist/vue/transforms/index.d.ts +10 -0
- package/dist/vue/transforms/index.js +36 -0
- package/dist/vue/transforms/transformComponent.d.ts +3 -0
- package/dist/vue/transforms/transformComponent.js +26 -0
- package/dist/vue/transforms/transformEvent.d.ts +2 -0
- package/dist/vue/transforms/transformEvent.js +22 -0
- package/dist/vue/transforms/transformPageHead.d.ts +2 -0
- package/dist/vue/transforms/transformPageHead.js +11 -0
- package/dist/vue/transforms/transformRef.d.ts +2 -0
- package/dist/vue/transforms/transformRef.js +32 -0
- package/dist/vue/transforms/transformTag.d.ts +3 -0
- package/dist/vue/transforms/transformTag.js +45 -0
- package/dist/vue/transforms/vModel.d.ts +12 -0
- package/dist/vue/transforms/vModel.js +33 -0
- package/dist/vue/transforms/vOn.d.ts +15 -0
- package/dist/vue/transforms/vOn.js +88 -0
- package/dist/vue/utils.d.ts +9 -0
- package/dist/vue/utils.js +66 -0
- package/lib/nvue.css +34 -0
- package/package.json +20 -6
- package/LICENSE +0 -202
- package/dist/json/app/pages/nvue.d.ts +0 -1
- package/dist/json/app/pages/nvue.js +0 -88
- package/dist/renderjs.d.ts +0 -16
- package/dist/renderjs.js +0 -44
|
@@ -4,12 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const shared_1 = require("@vue/shared");
|
|
7
|
-
const postcss_1 = require("postcss");
|
|
8
7
|
const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
|
|
9
8
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
}, uni_shared_1.defaultRpx2Unit);
|
|
9
|
+
const manifest_1 = require("../../json/manifest");
|
|
10
|
+
const defaultUniAppCssProcessorOptions = (0, shared_1.extend)({}, uni_shared_1.defaultRpx2Unit);
|
|
13
11
|
const BG_PROPS = [
|
|
14
12
|
'background',
|
|
15
13
|
'background-clip',
|
|
@@ -21,22 +19,14 @@ const BG_PROPS = [
|
|
|
21
19
|
'background-size',
|
|
22
20
|
'background-attachment',
|
|
23
21
|
];
|
|
24
|
-
function transform(selector,
|
|
22
|
+
function transform(selector, state, { rewriteTag }) {
|
|
25
23
|
if (selector.type !== 'tag') {
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
26
|
const { value } = selector;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else if (value === 'page') {
|
|
33
|
-
if (!page) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
selector.value = page;
|
|
37
|
-
if (page !== 'body') {
|
|
38
|
-
state.bg = true;
|
|
39
|
-
}
|
|
27
|
+
selector.value = rewriteTag(value);
|
|
28
|
+
if (value === 'page' && selector.value === 'uni-page-body') {
|
|
29
|
+
state.bg = true;
|
|
40
30
|
}
|
|
41
31
|
}
|
|
42
32
|
function createBodyBackgroundRule(origRule) {
|
|
@@ -47,13 +37,14 @@ function createBodyBackgroundRule(origRule) {
|
|
|
47
37
|
}
|
|
48
38
|
});
|
|
49
39
|
if (bgDecls.length) {
|
|
50
|
-
|
|
40
|
+
const { rule } = require('postcss');
|
|
41
|
+
origRule.after(rule({ selector: 'body' }).append(bgDecls));
|
|
51
42
|
}
|
|
52
43
|
}
|
|
53
|
-
function walkRules(
|
|
44
|
+
function walkRules(options) {
|
|
54
45
|
return (rule) => {
|
|
55
46
|
const state = { bg: false };
|
|
56
|
-
rule.selector = (0, postcss_selector_parser_1.default)((selectors) => selectors.walk((selector) => transform(selector,
|
|
47
|
+
rule.selector = (0, postcss_selector_parser_1.default)((selectors) => selectors.walk((selector) => transform(selector, state, options))).processSync(rule.selector);
|
|
57
48
|
state.bg && createBodyBackgroundRule(rule);
|
|
58
49
|
};
|
|
59
50
|
}
|
|
@@ -66,8 +57,42 @@ function walkDecls(rpx2unit) {
|
|
|
66
57
|
decl.value = rpx2unit(decl.value);
|
|
67
58
|
};
|
|
68
59
|
}
|
|
60
|
+
const baiduTags = {
|
|
61
|
+
navigator: 'nav',
|
|
62
|
+
};
|
|
63
|
+
function rewriteBaiduTags(tag) {
|
|
64
|
+
return baiduTags[tag] || tag;
|
|
65
|
+
}
|
|
66
|
+
function rewriteUniH5Tags(tag) {
|
|
67
|
+
if (tag === 'page') {
|
|
68
|
+
return 'uni-page-body';
|
|
69
|
+
}
|
|
70
|
+
if ((0, uni_shared_1.isBuiltInComponent)(tag)) {
|
|
71
|
+
return uni_shared_1.COMPONENT_SELECTOR_PREFIX + tag;
|
|
72
|
+
}
|
|
73
|
+
return tag;
|
|
74
|
+
}
|
|
75
|
+
function rewriteUniAppTags(tag) {
|
|
76
|
+
if (tag === 'page') {
|
|
77
|
+
return 'body';
|
|
78
|
+
}
|
|
79
|
+
if ((0, uni_shared_1.isBuiltInComponent)(tag)) {
|
|
80
|
+
return uni_shared_1.COMPONENT_SELECTOR_PREFIX + tag;
|
|
81
|
+
}
|
|
82
|
+
return tag;
|
|
83
|
+
}
|
|
84
|
+
const transforms = {
|
|
85
|
+
h5: rewriteUniH5Tags,
|
|
86
|
+
app: rewriteUniAppTags,
|
|
87
|
+
'mp-baidu': rewriteBaiduTags,
|
|
88
|
+
};
|
|
69
89
|
const uniapp = (opts) => {
|
|
70
|
-
const
|
|
90
|
+
const platform = process.env.UNI_PLATFORM;
|
|
91
|
+
if (!opts) {
|
|
92
|
+
const inputDir = process.env.UNI_INPUT_DIR;
|
|
93
|
+
opts = (0, shared_1.extend)((0, manifest_1.parseRpx2UnitOnce)(inputDir, platform));
|
|
94
|
+
}
|
|
95
|
+
const { unit, unitRatio, unitPrecision } = (0, shared_1.extend)({}, defaultUniAppCssProcessorOptions, opts || {});
|
|
71
96
|
const rpx2unit = (0, uni_shared_1.createRpx2Unit)(unit, unitRatio, unitPrecision);
|
|
72
97
|
return {
|
|
73
98
|
postcssPlugin: 'uni-app',
|
|
@@ -75,7 +100,12 @@ const uniapp = (opts) => {
|
|
|
75
100
|
return {
|
|
76
101
|
OnceExit(root) {
|
|
77
102
|
root.walkDecls(walkDecls(rpx2unit));
|
|
78
|
-
|
|
103
|
+
const rewriteTag = transforms[platform];
|
|
104
|
+
if (rewriteTag) {
|
|
105
|
+
root.walkRules(walkRules({
|
|
106
|
+
rewriteTag,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
79
109
|
},
|
|
80
110
|
};
|
|
81
111
|
},
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
export { default as hash } from 'hash-sum';
|
|
2
|
+
import type { SFCTemplateCompileOptions } from '@vue/compiler-sfc';
|
|
3
|
+
import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
|
|
2
4
|
export declare const isWindows: boolean;
|
|
3
5
|
export declare function normalizePath(id: string): string;
|
|
6
|
+
export declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode;
|
|
4
7
|
export declare const resolveMainPathOnce: (inputDir: string) => string;
|
|
8
|
+
export declare function resolveComponentsLibPath(): string;
|
|
9
|
+
export declare function getBuiltInPaths(): string[];
|
|
5
10
|
export declare function resolveBuiltIn(path: string): string;
|
|
6
11
|
export declare function normalizeIdentifier(str: string): string;
|
|
7
12
|
export declare function normalizePagePath(pagePath: string, platform: UniApp.PLATFORM): string | undefined;
|
|
8
|
-
export declare function removeExt(str: string
|
|
13
|
+
export declare function removeExt(str: string): string;
|
|
9
14
|
export declare function normalizeNodeModules(str: string): string;
|
|
15
|
+
export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
|
|
16
|
+
export declare function createUniVueTransformAssetUrls(base: string): SFCTemplateCompileOptions['transformAssetUrls'];
|
package/dist/utils.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.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.resolveBuiltIn = exports.resolveMainPathOnce = exports.normalizePath = exports.isWindows = exports.hash = void 0;
|
|
6
|
+
exports.createUniVueTransformAssetUrls = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveComponentsLibPath = exports.resolveMainPathOnce = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.hash = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -11,12 +11,17 @@ const shared_1 = require("@vue/shared");
|
|
|
11
11
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
12
12
|
var hash_sum_1 = require("hash-sum");
|
|
13
13
|
Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_sum_1).default; } });
|
|
14
|
+
const debug_1 = __importDefault(require("debug"));
|
|
14
15
|
const constants_1 = require("./constants");
|
|
15
16
|
exports.isWindows = os_1.default.platform() === 'win32';
|
|
16
17
|
function normalizePath(id) {
|
|
17
18
|
return exports.isWindows ? id.replace(/\\/g, '/') : id;
|
|
18
19
|
}
|
|
19
20
|
exports.normalizePath = normalizePath;
|
|
21
|
+
function checkElementNodeTag(node, tag) {
|
|
22
|
+
return !!node && node.type === 1 /* ELEMENT */ && node.tag === tag;
|
|
23
|
+
}
|
|
24
|
+
exports.checkElementNodeTag = checkElementNodeTag;
|
|
20
25
|
exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
|
|
21
26
|
const mainTsPath = path_1.default.resolve(inputDir, 'main.ts');
|
|
22
27
|
if (fs_1.default.existsSync(mainTsPath)) {
|
|
@@ -24,8 +29,42 @@ exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
|
|
|
24
29
|
}
|
|
25
30
|
return normalizePath(path_1.default.resolve(inputDir, 'main.js'));
|
|
26
31
|
});
|
|
32
|
+
let componentsLibPath = '';
|
|
33
|
+
function resolveComponentsLibPath() {
|
|
34
|
+
if (!componentsLibPath) {
|
|
35
|
+
componentsLibPath = path_1.default.resolve(resolveBuiltIn('@dcloudio/uni-components/package.json'), '../lib');
|
|
36
|
+
}
|
|
37
|
+
return componentsLibPath;
|
|
38
|
+
}
|
|
39
|
+
exports.resolveComponentsLibPath = resolveComponentsLibPath;
|
|
40
|
+
const ownerModules = ['@dcloudio/uni-app', '@dcloudio/vite-plugin-uni'];
|
|
41
|
+
const paths = [];
|
|
42
|
+
function initPaths() {
|
|
43
|
+
const cliContext = process.env.UNI_CLI_CONTEXT;
|
|
44
|
+
if (cliContext) {
|
|
45
|
+
const pathSet = new Set();
|
|
46
|
+
pathSet.add(path_1.default.join(cliContext, 'node_modules'));
|
|
47
|
+
[`@dcloudio/uni-` + process.env.UNI_PLATFORM, ...ownerModules].forEach((ownerModule) => {
|
|
48
|
+
try {
|
|
49
|
+
pathSet.add(path_1.default.resolve(require.resolve(ownerModule + '/package.json', {
|
|
50
|
+
paths: [cliContext],
|
|
51
|
+
}), '../node_modules'));
|
|
52
|
+
}
|
|
53
|
+
catch (e) { }
|
|
54
|
+
});
|
|
55
|
+
paths.push(...pathSet);
|
|
56
|
+
(0, debug_1.default)('uni-paths')(paths);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function getBuiltInPaths() {
|
|
60
|
+
if (!paths.length) {
|
|
61
|
+
initPaths();
|
|
62
|
+
}
|
|
63
|
+
return paths;
|
|
64
|
+
}
|
|
65
|
+
exports.getBuiltInPaths = getBuiltInPaths;
|
|
27
66
|
function resolveBuiltIn(path) {
|
|
28
|
-
return require.resolve(path, { paths:
|
|
67
|
+
return require.resolve(path, { paths: getBuiltInPaths() });
|
|
29
68
|
}
|
|
30
69
|
exports.resolveBuiltIn = resolveBuiltIn;
|
|
31
70
|
function normalizeIdentifier(str) {
|
|
@@ -47,12 +86,8 @@ function normalizePagePath(pagePath, platform) {
|
|
|
47
86
|
console.error(`${pagePath} not found`);
|
|
48
87
|
}
|
|
49
88
|
exports.normalizePagePath = normalizePagePath;
|
|
50
|
-
function removeExt(str
|
|
51
|
-
|
|
52
|
-
const reg = new RegExp(ext.replace(/\./, '\\.') + '$');
|
|
53
|
-
return normalizePath(str.replace(reg, ''));
|
|
54
|
-
}
|
|
55
|
-
return normalizePath(str.replace(/\.\w+$/g, ''));
|
|
89
|
+
function removeExt(str) {
|
|
90
|
+
return str.split('?')[0].replace(/\.\w+$/g, '');
|
|
56
91
|
}
|
|
57
92
|
exports.removeExt = removeExt;
|
|
58
93
|
const NODE_MODULES_REGEX = /(\.\.\/)?node_modules/g;
|
|
@@ -66,3 +101,31 @@ function normalizeNodeModules(str) {
|
|
|
66
101
|
return str;
|
|
67
102
|
}
|
|
68
103
|
exports.normalizeNodeModules = normalizeNodeModules;
|
|
104
|
+
function normalizeMiniProgramFilename(filename, inputDir) {
|
|
105
|
+
if (!inputDir || !path_1.default.isAbsolute(filename)) {
|
|
106
|
+
return normalizeNodeModules(filename);
|
|
107
|
+
}
|
|
108
|
+
return normalizeNodeModules(path_1.default.relative(inputDir, filename));
|
|
109
|
+
}
|
|
110
|
+
exports.normalizeMiniProgramFilename = normalizeMiniProgramFilename;
|
|
111
|
+
function createUniVueTransformAssetUrls(base) {
|
|
112
|
+
return {
|
|
113
|
+
base,
|
|
114
|
+
tags: {
|
|
115
|
+
audio: ['src'],
|
|
116
|
+
video: ['src', 'poster'],
|
|
117
|
+
img: ['src'],
|
|
118
|
+
image: ['src'],
|
|
119
|
+
'cover-image': ['src'],
|
|
120
|
+
// h5
|
|
121
|
+
'v-uni-audio': ['src'],
|
|
122
|
+
'v-uni-video': ['src', 'poster'],
|
|
123
|
+
'v-uni-image': ['src'],
|
|
124
|
+
'v-uni-cover-image': ['src'],
|
|
125
|
+
// nvue
|
|
126
|
+
'u-image': ['src'],
|
|
127
|
+
'u-video': ['src', 'poster'],
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
exports.createUniVueTransformAssetUrls = createUniVueTransformAssetUrls;
|
package/dist/vite/features.d.ts
CHANGED
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { EmittedAsset } from 'rollup';
|
|
3
3
|
import type { ParserOptions } from '@vue/compiler-core';
|
|
4
4
|
import type { CompilerOptions, TemplateCompiler } from '@vue/compiler-sfc';
|
|
5
5
|
import { UniViteCopyPluginOptions } from './plugins/copy';
|
|
@@ -14,14 +14,13 @@ interface UniVitePluginUniOptions {
|
|
|
14
14
|
compiler?: TemplateCompiler;
|
|
15
15
|
compilerOptions?: {
|
|
16
16
|
miniProgram?: {
|
|
17
|
-
emitFile?: (emittedFile:
|
|
17
|
+
emitFile?: (emittedFile: EmittedAsset) => string;
|
|
18
18
|
};
|
|
19
19
|
isNativeTag: ParserOptions['isNativeTag'];
|
|
20
20
|
isCustomElement: ParserOptions['isCustomElement'];
|
|
21
21
|
directiveTransforms?: CompilerOptions['directiveTransforms'];
|
|
22
22
|
nodeTransforms?: CompilerOptions['nodeTransforms'];
|
|
23
23
|
};
|
|
24
|
-
transformEvent?: Record<string, string>;
|
|
25
24
|
copyOptions?: CopyOptions | (() => CopyOptions);
|
|
26
25
|
}
|
|
27
26
|
export interface UniVitePlugin extends Plugin {
|
|
@@ -9,7 +9,7 @@ const debug_1 = __importDefault(require("debug"));
|
|
|
9
9
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
10
10
|
const estree_walker_1 = require("estree-walker");
|
|
11
11
|
const shared_1 = require("@vue/shared");
|
|
12
|
-
const
|
|
12
|
+
const magic_string_1 = __importDefault(require("magic-string"));
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
const debugInject = (0, debug_1.default)('vite:uni:inject');
|
|
15
15
|
const debugInjectTry = (0, debug_1.default)('vite:uni:inject-try');
|
|
@@ -74,7 +74,7 @@ function uniViteInjectPlugin(options) {
|
|
|
74
74
|
});
|
|
75
75
|
// analyse scopes
|
|
76
76
|
let scope = (0, pluginutils_1.attachScopes)(ast, 'scope');
|
|
77
|
-
const magicString = new
|
|
77
|
+
const magicString = new magic_string_1.default(code);
|
|
78
78
|
const newImports = new Map();
|
|
79
79
|
function handleReference(node, name, keypath) {
|
|
80
80
|
let mod = modulesMap.get(keypath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ResolvedConfig } from 'vite';
|
|
1
|
+
export type { ResolvedConfig } from 'vite';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ResolveFn, ViteDevServer } from 'vite';
|
|
1
|
+
export type { ResolveFn, ViteDevServer } from 'vite';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Plugin } from 'vite';
|
|
1
|
+
export type { Plugin } from 'vite';
|
|
@@ -10,7 +10,7 @@ export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>
|
|
|
10
10
|
export declare function assetPlugin(config: ResolvedConfig): Plugin;
|
|
11
11
|
export declare function registerAssetToChunk(chunk: RenderedChunk, file: string): void;
|
|
12
12
|
export declare function checkPublicFile(url: string, { publicDir }: ResolvedConfig): string | undefined;
|
|
13
|
-
export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext): string;
|
|
13
|
+
export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext, canInline?: boolean): string;
|
|
14
14
|
export declare function getAssetFilename(hash: string, config: ResolvedConfig): string | undefined;
|
|
15
15
|
export declare function getAssetHash(content: Buffer): string;
|
|
16
16
|
export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext): string;
|
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.urlToBuiltUrl = exports.getAssetHash = exports.getAssetFilename = exports.fileToUrl = exports.checkPublicFile = exports.registerAssetToChunk = exports.assetPlugin = exports.chunkToEmittedAssetsMap = exports.assetUrlRE = void 0;
|
|
26
26
|
const path_1 = __importDefault(require("path"));
|
|
27
27
|
const url_1 = require("url");
|
|
28
|
+
const lite_1 = __importDefault(require("mime/lite"));
|
|
28
29
|
const fs_1 = __importStar(require("fs"));
|
|
29
30
|
const utils_1 = require("../utils");
|
|
30
31
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
@@ -132,8 +133,8 @@ function checkPublicFile(url, { publicDir }) {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
exports.checkPublicFile = checkPublicFile;
|
|
135
|
-
function fileToUrl(id, config, ctx) {
|
|
136
|
-
return fileToBuiltUrl(id, config, ctx);
|
|
136
|
+
function fileToUrl(id, config, ctx, canInline = false) {
|
|
137
|
+
return fileToBuiltUrl(id, config, ctx, false, canInline);
|
|
137
138
|
}
|
|
138
139
|
exports.fileToUrl = fileToUrl;
|
|
139
140
|
function getAssetFilename(hash, config) {
|
|
@@ -145,7 +146,7 @@ exports.getAssetFilename = getAssetFilename;
|
|
|
145
146
|
* Register an asset to be emitted as part of the bundle (if necessary)
|
|
146
147
|
* and returns the resolved public URL
|
|
147
148
|
*/
|
|
148
|
-
function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false) {
|
|
149
|
+
function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canInline = false) {
|
|
149
150
|
if (!skipPublicCheck && checkPublicFile(id, config)) {
|
|
150
151
|
return config.base + id.slice(1);
|
|
151
152
|
}
|
|
@@ -157,27 +158,33 @@ function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false) {
|
|
|
157
158
|
const file = (0, utils_1.cleanUrl)(id);
|
|
158
159
|
const content = fs_1.default.readFileSync(file);
|
|
159
160
|
let url;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const postfix = (search || '') + (hash || '');
|
|
164
|
-
const fileName = (0, utils_1.normalizePath)(path_1.default.posix.relative(process.env.UNI_INPUT_DIR, file));
|
|
165
|
-
if (!map.has(contentHash)) {
|
|
166
|
-
map.set(contentHash, fileName);
|
|
161
|
+
if (canInline && content.length < Number(config.build.assetsInlineLimit)) {
|
|
162
|
+
// base64 inlined as a string
|
|
163
|
+
url = `data:${lite_1.default.getType(file)};base64,${content.toString('base64')}`;
|
|
167
164
|
}
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
165
|
+
else {
|
|
166
|
+
const map = assetHashToFilenameMap.get(config);
|
|
167
|
+
const contentHash = getAssetHash(content);
|
|
168
|
+
const { search, hash } = (0, url_1.parse)(id);
|
|
169
|
+
const postfix = (search || '') + (hash || '');
|
|
170
|
+
const fileName = (0, utils_1.normalizePath)(path_1.default.posix.relative(process.env.UNI_INPUT_DIR, file));
|
|
171
|
+
if (!map.has(contentHash)) {
|
|
172
|
+
map.set(contentHash, fileName);
|
|
173
|
+
}
|
|
174
|
+
if (!fileName.includes('/static/')) {
|
|
175
|
+
const emittedSet = emittedHashMap.get(config);
|
|
176
|
+
if (!emittedSet.has(contentHash)) {
|
|
177
|
+
pluginContext.emitFile({
|
|
178
|
+
name: fileName,
|
|
179
|
+
fileName,
|
|
180
|
+
type: 'asset',
|
|
181
|
+
source: content,
|
|
182
|
+
});
|
|
183
|
+
emittedSet.add(contentHash);
|
|
184
|
+
}
|
|
178
185
|
}
|
|
186
|
+
url = `__VITE_ASSET__${contentHash}__${postfix ? `$_${postfix}__` : ``}`;
|
|
179
187
|
}
|
|
180
|
-
url = `__VITE_ASSET__${contentHash}__${postfix ? `$_${postfix}__` : ``}`;
|
|
181
188
|
cache.set(id, url);
|
|
182
189
|
return url;
|
|
183
190
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { RollupError } from 'rollup';
|
|
1
2
|
import { Plugin } from '../plugin';
|
|
2
3
|
import { ResolvedConfig } from '../config';
|
|
3
|
-
import { RollupError } from 'rollup';
|
|
4
4
|
import * as Postcss from 'postcss';
|
|
5
5
|
export interface CSSOptions {
|
|
6
6
|
/**
|
|
@@ -33,9 +33,9 @@ export declare function cssPlugin(config: ResolvedConfig): Plugin;
|
|
|
33
33
|
/**
|
|
34
34
|
* Plugin applied after user plugins
|
|
35
35
|
*/
|
|
36
|
-
export declare function cssPostPlugin(config: ResolvedConfig, {
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
export declare function cssPostPlugin(config: ResolvedConfig, { chunkCssFilename, chunkCssCode, }: {
|
|
37
|
+
chunkCssFilename: (id: string) => string | void;
|
|
38
|
+
chunkCssCode: (filename: string, cssCode: string) => string;
|
|
39
39
|
}): Plugin;
|
|
40
40
|
export declare const cssUrlRE: RegExp;
|
|
41
41
|
export interface StylePreprocessorResults {
|
|
@@ -26,13 +26,11 @@ exports.cssUrlRE = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectC
|
|
|
26
26
|
const fs_1 = __importDefault(require("fs"));
|
|
27
27
|
const path_1 = __importDefault(require("path"));
|
|
28
28
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
29
|
-
const utils_1 = require("../utils");
|
|
30
|
-
const postcss_load_config_1 = __importDefault(require("postcss-load-config"));
|
|
31
29
|
const chalk_1 = __importDefault(require("chalk"));
|
|
30
|
+
const postcss_load_config_1 = __importDefault(require("postcss-load-config"));
|
|
31
|
+
const utils_1 = require("../utils");
|
|
32
32
|
const asset_1 = require("./asset");
|
|
33
33
|
const esbuild_1 = require("esbuild");
|
|
34
|
-
const utils_2 = require("../../../../utils");
|
|
35
|
-
const constants_1 = require("../../../../constants");
|
|
36
34
|
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
37
35
|
exports.cssLangRE = new RegExp(cssLangs);
|
|
38
36
|
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
@@ -77,7 +75,7 @@ function cssPlugin(config) {
|
|
|
77
75
|
}
|
|
78
76
|
const resolved = await resolveUrl(url, importer);
|
|
79
77
|
if (resolved) {
|
|
80
|
-
return (0, asset_1.fileToUrl)(resolved, config, this);
|
|
78
|
+
return (0, asset_1.fileToUrl)(resolved, config, this, true);
|
|
81
79
|
}
|
|
82
80
|
return url;
|
|
83
81
|
};
|
|
@@ -100,12 +98,6 @@ function cssPlugin(config) {
|
|
|
100
98
|
};
|
|
101
99
|
}
|
|
102
100
|
exports.cssPlugin = cssPlugin;
|
|
103
|
-
function normalizeCssChunkFilename(id, extname = '.css') {
|
|
104
|
-
return (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, id
|
|
105
|
-
.split('?')[0]
|
|
106
|
-
.replace(constants_1.EXTNAME_VUE_RE, extname)
|
|
107
|
-
.replace(constants_1.EXTNAME_JS_RE, extname)));
|
|
108
|
-
}
|
|
109
101
|
function findCssModuleIds(moduleId, cssModuleIds, seen) {
|
|
110
102
|
if (!cssModuleIds) {
|
|
111
103
|
cssModuleIds = new Set();
|
|
@@ -137,7 +129,7 @@ function findCssModuleIds(moduleId, cssModuleIds, seen) {
|
|
|
137
129
|
/**
|
|
138
130
|
* Plugin applied after user plugins
|
|
139
131
|
*/
|
|
140
|
-
function cssPostPlugin(config, {
|
|
132
|
+
function cssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
141
133
|
// styles initialization in buildStart causes a styling loss in watch
|
|
142
134
|
const styles = new Map();
|
|
143
135
|
let cssChunks;
|
|
@@ -146,7 +138,7 @@ function cssPostPlugin(config, { appCss, extname }) {
|
|
|
146
138
|
buildStart() {
|
|
147
139
|
cssChunks = new Map();
|
|
148
140
|
},
|
|
149
|
-
async transform(css, id
|
|
141
|
+
async transform(css, id) {
|
|
150
142
|
if (!exports.cssLangRE.test(id) || commonjsProxyRE.test(id)) {
|
|
151
143
|
return;
|
|
152
144
|
}
|
|
@@ -162,15 +154,10 @@ function cssPostPlugin(config, { appCss, extname }) {
|
|
|
162
154
|
},
|
|
163
155
|
async generateBundle() {
|
|
164
156
|
const moduleIds = Array.from(this.getModuleIds());
|
|
165
|
-
const mainPath = (0, utils_2.resolveMainPathOnce)(process.env.UNI_INPUT_DIR);
|
|
166
157
|
moduleIds.forEach((id) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
cssChunks.set(
|
|
170
|
-
}
|
|
171
|
-
else if (id.includes('mpType=page')) {
|
|
172
|
-
// 页面样式
|
|
173
|
-
cssChunks.set(normalizeCssChunkFilename(id, extname), findCssModuleIds.call(this, id));
|
|
158
|
+
const filename = chunkCssFilename(id);
|
|
159
|
+
if (filename) {
|
|
160
|
+
cssChunks.set(filename, findCssModuleIds.call(this, id));
|
|
174
161
|
}
|
|
175
162
|
});
|
|
176
163
|
if (!cssChunks.size) {
|
|
@@ -194,8 +181,12 @@ function cssPostPlugin(config, { appCss, extname }) {
|
|
|
194
181
|
.join('\n');
|
|
195
182
|
};
|
|
196
183
|
for (const filename of cssChunks.keys()) {
|
|
197
|
-
|
|
198
|
-
|
|
184
|
+
const cssCode = genCssCode(filename);
|
|
185
|
+
let source = await processChunkCSS(chunkCssCode(filename, cssCode), {
|
|
186
|
+
dirname: path_1.default.dirname(filename),
|
|
187
|
+
inlined: false,
|
|
188
|
+
minify: true,
|
|
189
|
+
});
|
|
199
190
|
this.emitFile({
|
|
200
191
|
fileName: filename,
|
|
201
192
|
type: 'asset',
|
|
@@ -554,7 +545,7 @@ const scss = async (source, root, options, resolvers) => {
|
|
|
554
545
|
rebaseUrls(resolved, options.filename, options.alias).then(done);
|
|
555
546
|
}
|
|
556
547
|
else {
|
|
557
|
-
done(null);
|
|
548
|
+
done && done(null);
|
|
558
549
|
}
|
|
559
550
|
});
|
|
560
551
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ModuleNode } from 'vite';
|
|
1
|
+
export type { ModuleNode } from 'vite';
|
package/dist/vite/utils/ast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Literal, BaseNode, Property, Identifier, CallExpression, MemberExpression, MethodDefinition, ExportSpecifier } from 'estree';
|
|
1
|
+
import type { Literal, BaseNode, Property, Identifier, CallExpression, MemberExpression, MethodDefinition, ExportSpecifier } from 'estree';
|
|
2
2
|
import { Node, ElementNode, DirectiveNode, SimpleExpressionNode } from '@vue/compiler-core';
|
|
3
3
|
export declare const isProperty: (node: BaseNode) => node is Property;
|
|
4
4
|
export declare const isIdentifier: (node: BaseNode) => node is Identifier;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, ResolvedConfig } from 'vite';
|
|
1
|
+
import type { Plugin, ResolvedConfig } from 'vite';
|
|
2
2
|
export declare type CreateUniViteFilterPlugin = (opts: UniViteFilterPluginOptions) => Plugin;
|
|
3
3
|
export interface UniViteFilterPluginOptions {
|
|
4
4
|
resolvedConfig: ResolvedConfig;
|
|
@@ -6,9 +6,9 @@ export interface UniViteFilterPluginOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function injectAssetPlugin(config: ResolvedConfig): void;
|
|
8
8
|
export declare function injectCssPlugin(config: ResolvedConfig): void;
|
|
9
|
-
export declare function injectCssPostPlugin(config: ResolvedConfig, {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export declare function injectCssPostPlugin(config: ResolvedConfig, { chunkCssFilename, chunkCssCode, }: {
|
|
10
|
+
chunkCssFilename: (id: string) => string | void;
|
|
11
|
+
chunkCssCode: (filename: string, cssCode: string) => string;
|
|
12
12
|
}): void;
|
|
13
13
|
export declare function replacePlugins(plugins: Plugin[], config: ResolvedConfig): void;
|
|
14
14
|
export declare function removePlugins(plugins: string | string[], config: ResolvedConfig): void;
|
|
@@ -11,8 +11,8 @@ function injectCssPlugin(config) {
|
|
|
11
11
|
replacePlugins([(0, css_1.cssPlugin)(config)], config);
|
|
12
12
|
}
|
|
13
13
|
exports.injectCssPlugin = injectCssPlugin;
|
|
14
|
-
function injectCssPostPlugin(config, {
|
|
15
|
-
replacePlugins([(0, css_1.cssPostPlugin)(config, {
|
|
14
|
+
function injectCssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
15
|
+
replacePlugins([(0, css_1.cssPostPlugin)(config, { chunkCssFilename, chunkCssCode })], config);
|
|
16
16
|
}
|
|
17
17
|
exports.injectCssPostPlugin = injectCssPostPlugin;
|
|
18
18
|
function replacePlugins(plugins, config) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./transforms"), exports);
|
|
14
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './transformRef';
|
|
2
|
+
export * from './transformPageHead';
|
|
3
|
+
export * from './transformComponent';
|
|
4
|
+
export * from './transformEvent';
|
|
5
|
+
export * from './transformTag';
|
|
6
|
+
export { ATTR_DATASET_EVENT_OPTS, createTransformOn, defaultMatch as matchTransformOn, } from './vOn';
|
|
7
|
+
export { createTransformModel, defaultMatch as matchTransformModel, } from './vModel';
|
|
8
|
+
export declare const transformMatchMedia: import("@vue/compiler-core").NodeTransform;
|
|
9
|
+
export declare const transformTapToClick: import("@vue/compiler-core").NodeTransform;
|
|
10
|
+
export declare const transformComponentLink: (node: import("@vue/compiler-core").RootNode | import("@vue/compiler-core").TemplateChildNode, context: import("@vue/compiler-core").TransformContext) => void;
|