@dcloudio/uni-cli-shared 3.0.0-alpha-3030020211124001 → 3.0.0-alpha-3030020211130002
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/env/index.d.ts +1 -1
- package/dist/env/index.js +2 -2
- package/dist/env/provide.d.ts +1 -1
- package/dist/env/provide.js +3 -3
- package/dist/json/app/pages/definePage.js +2 -2
- package/dist/json/app/pages/index.js +1 -1
- package/dist/json/mp/jsonFile.d.ts +2 -1
- package/dist/json/mp/jsonFile.js +15 -3
- package/dist/json/pages.d.ts +9 -0
- package/dist/json/pages.js +24 -1
- package/dist/mp/imports.d.ts +7 -0
- package/dist/mp/imports.js +9 -0
- package/dist/mp/transformImports.js +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +14 -1
- package/dist/vite/plugins/cssScoped.d.ts +2 -4
- package/dist/vite/plugins/cssScoped.js +6 -18
- package/dist/vite/plugins/index.d.ts +2 -2
- package/dist/vite/plugins/index.js +3 -1
- package/dist/vite/plugins/inject.js +6 -1
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +2 -2
- package/dist/vite/utils/plugin.d.ts +0 -3
- package/dist/vite/utils/plugin.js +1 -15
- package/dist/vite/utils/url.d.ts +0 -1
- package/dist/vue/utils.d.ts +1 -0
- package/dist/vue/utils.js +8 -1
- package/package.json +7 -7
- package/dist/vite/plugins/vitejs/plugins/h5Asset.d.ts +0 -40
- package/dist/vite/plugins/vitejs/plugins/h5Asset.js +0 -319
- package/dist/vite/plugins/vitejs/plugins/h5Css.d.ts +0 -67
- package/dist/vite/plugins/vitejs/plugins/h5Css.js +0 -922
package/dist/constants.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export declare const PUBLIC_DIR = "static";
|
|
2
2
|
export declare const EXTNAME_JS: string[];
|
|
3
|
+
export declare const EXTNAME_TS: string[];
|
|
3
4
|
export declare const EXTNAME_VUE: string[];
|
|
4
5
|
export declare const EXTNAME_VUE_RE: RegExp;
|
|
5
6
|
export declare const EXTNAME_JS_RE: RegExp;
|
|
7
|
+
export declare const EXTNAME_TS_RE: RegExp;
|
|
6
8
|
export declare const ASSETS_INLINE_LIMIT: number;
|
|
7
9
|
export declare const APP_SERVICE_FILENAME = "app-service.js";
|
|
8
10
|
export declare const BINDING_COMPONENTS = "__BINDING_COMPONENTS__";
|
package/dist/constants.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
3
|
+
exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
4
4
|
exports.PUBLIC_DIR = 'static';
|
|
5
5
|
exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
|
|
6
|
+
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
|
6
7
|
exports.EXTNAME_VUE = ['.vue', '.nvue'];
|
|
7
8
|
exports.EXTNAME_VUE_RE = /\.(vue|nvue)$/;
|
|
8
9
|
exports.EXTNAME_JS_RE = /\.[jt]sx?$/;
|
|
10
|
+
exports.EXTNAME_TS_RE = /\.tsx?$/;
|
|
9
11
|
exports.ASSETS_INLINE_LIMIT = 40 * 1024;
|
|
10
12
|
exports.APP_SERVICE_FILENAME = 'app-service.js';
|
|
11
13
|
exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
|
package/dist/env/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initDefine } from './define';
|
|
2
|
-
export {
|
|
2
|
+
export { initAppProvide } from './provide';
|
package/dist/env/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.initAppProvide = exports.initDefine = void 0;
|
|
4
4
|
var define_1 = require("./define");
|
|
5
5
|
Object.defineProperty(exports, "initDefine", { enumerable: true, get: function () { return define_1.initDefine; } });
|
|
6
6
|
var provide_1 = require("./provide");
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "initAppProvide", { enumerable: true, get: function () { return provide_1.initAppProvide; } });
|
package/dist/env/provide.d.ts
CHANGED
package/dist/env/provide.js
CHANGED
|
@@ -3,10 +3,10 @@ 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.
|
|
6
|
+
exports.initAppProvide = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
|
9
|
-
function
|
|
9
|
+
function initAppProvide() {
|
|
10
10
|
const cryptoDefine = [path_1.default.join(libDir, 'crypto.js'), 'default'];
|
|
11
11
|
return {
|
|
12
12
|
__f__: ['@dcloudio/uni-shared', 'formatAppLog'],
|
|
@@ -15,4 +15,4 @@ function initProvide() {
|
|
|
15
15
|
'global.crypto': cryptoDefine,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
18
|
+
exports.initAppProvide = initAppProvide;
|
|
@@ -15,10 +15,10 @@ function definePageCode(pagesJson) {
|
|
|
15
15
|
if (pagePathWithExtname) {
|
|
16
16
|
if (process.env.UNI_APP_CODE_SPLITING) {
|
|
17
17
|
// 拆分页面
|
|
18
|
-
importPagesCode.push(`const ${pageIdentifier} = ()=>import('./${pagePathWithExtname}
|
|
18
|
+
importPagesCode.push(`const ${pageIdentifier} = ()=>import('./${pagePathWithExtname}')`);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
importPagesCode.push(`import ${pageIdentifier} from './${pagePathWithExtname}
|
|
21
|
+
importPagesCode.push(`import ${pageIdentifier} from './${pagePathWithExtname}'`);
|
|
22
22
|
}
|
|
23
23
|
definePagesCode.push(`__definePage('${pagePath}',${pageIdentifier})`);
|
|
24
24
|
}
|
|
@@ -17,7 +17,7 @@ function normalizeAppConfigService(pagesJson, manifestJson) {
|
|
|
17
17
|
const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
|
|
18
18
|
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
|
19
19
|
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
|
20
|
-
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:
|
|
20
|
+
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:16})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,${code_1.globalCode}}}}});
|
|
21
21
|
})();
|
|
22
22
|
`;
|
|
23
23
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentJson, PageWindowOptions, UsingComponents } from './types';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean;
|
|
3
|
+
export declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean;
|
|
3
4
|
export declare function hasJsonFile(filename: string): boolean;
|
|
4
5
|
export declare function normalizeJsonFilename(filename: string): string;
|
|
5
6
|
export declare function findChangedJsonFiles(): Map<string, string>;
|
package/dist/json/mp/jsonFile.js
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.hasJsonFile = exports.
|
|
6
|
+
exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const shared_1 = require("@vue/shared");
|
|
5
9
|
const utils_1 = require("../../utils");
|
|
6
10
|
const resolve_1 = require("../../resolve");
|
|
11
|
+
const utils_2 = require("../../vue/utils");
|
|
7
12
|
let appJsonCache = {};
|
|
8
13
|
const jsonFilesCache = new Map();
|
|
9
14
|
const jsonPagesCache = new Map();
|
|
10
15
|
const jsonComponentsCache = new Map();
|
|
11
16
|
const jsonUsingComponentsCache = new Map();
|
|
12
|
-
function
|
|
17
|
+
function isMiniProgramPageFile(file, inputDir) {
|
|
18
|
+
if (inputDir && path_1.default.isAbsolute(file)) {
|
|
19
|
+
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
|
|
20
|
+
}
|
|
13
21
|
return jsonPagesCache.has((0, utils_1.removeExt)(file));
|
|
14
22
|
}
|
|
15
|
-
exports.
|
|
23
|
+
exports.isMiniProgramPageFile = isMiniProgramPageFile;
|
|
24
|
+
function isMiniProgramPageSfcFile(file, inputDir) {
|
|
25
|
+
return (0, utils_2.isVueSfcFile)(file) && isMiniProgramPageFile(file, inputDir);
|
|
26
|
+
}
|
|
27
|
+
exports.isMiniProgramPageSfcFile = isMiniProgramPageSfcFile;
|
|
16
28
|
function hasJsonFile(filename) {
|
|
17
29
|
return (filename === 'app' ||
|
|
18
30
|
jsonPagesCache.has(filename) ||
|
package/dist/json/pages.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
export declare function isUniPageFile(file: string, inputDir?: string): boolean;
|
|
2
|
+
export declare function isUniPageSfcFile(file: string, inputDir?: string): boolean;
|
|
1
3
|
export declare const parsePagesJson: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
|
2
4
|
export declare const parsePagesJsonOnce: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
|
5
|
+
/**
|
|
6
|
+
* 目前 App 和 H5 使用了该方法
|
|
7
|
+
* @param jsonStr
|
|
8
|
+
* @param platform
|
|
9
|
+
* @param param2
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
3
12
|
export declare function normalizePagesJson(jsonStr: string, platform: UniApp.PLATFORM, { subpackages, }?: {
|
|
4
13
|
subpackages: boolean;
|
|
5
14
|
}): UniApp.PagesJson;
|
package/dist/json/pages.js
CHANGED
|
@@ -3,13 +3,26 @@ 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.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = void 0;
|
|
6
|
+
exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageFile = 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");
|
|
10
10
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
const json_1 = require("./json");
|
|
13
|
+
const utils_2 = require("../vue/utils");
|
|
14
|
+
const pagesCacheSet = new Set();
|
|
15
|
+
function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
16
|
+
if (inputDir && path_1.default.isAbsolute(file)) {
|
|
17
|
+
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
|
|
18
|
+
}
|
|
19
|
+
return pagesCacheSet.has((0, utils_1.removeExt)(file));
|
|
20
|
+
}
|
|
21
|
+
exports.isUniPageFile = isUniPageFile;
|
|
22
|
+
function isUniPageSfcFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
23
|
+
return (0, utils_2.isVueSfcFile)(file) && isUniPageFile(file, inputDir);
|
|
24
|
+
}
|
|
25
|
+
exports.isUniPageSfcFile = isUniPageSfcFile;
|
|
13
26
|
const parsePagesJson = (inputDir, platform, normalize = true) => {
|
|
14
27
|
const jsonStr = fs_1.default.readFileSync(path_1.default.join(inputDir, 'pages.json'), 'utf8');
|
|
15
28
|
if (normalize) {
|
|
@@ -19,6 +32,13 @@ const parsePagesJson = (inputDir, platform, normalize = true) => {
|
|
|
19
32
|
};
|
|
20
33
|
exports.parsePagesJson = parsePagesJson;
|
|
21
34
|
exports.parsePagesJsonOnce = (0, uni_shared_1.once)(exports.parsePagesJson);
|
|
35
|
+
/**
|
|
36
|
+
* 目前 App 和 H5 使用了该方法
|
|
37
|
+
* @param jsonStr
|
|
38
|
+
* @param platform
|
|
39
|
+
* @param param2
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
22
42
|
function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages: false }) {
|
|
23
43
|
let pagesJson = {
|
|
24
44
|
pages: [],
|
|
@@ -66,6 +86,9 @@ function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages:
|
|
|
66
86
|
delete pagesJson.tabBar;
|
|
67
87
|
}
|
|
68
88
|
}
|
|
89
|
+
// 缓存页面列表
|
|
90
|
+
pagesCacheSet.clear();
|
|
91
|
+
pagesJson.pages.forEach((page) => pagesCacheSet.add(page.path));
|
|
69
92
|
return pagesJson;
|
|
70
93
|
}
|
|
71
94
|
exports.normalizePagesJson = normalizePagesJson;
|
package/dist/mp/imports.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { PluginContext } from 'rollup';
|
|
2
2
|
import { ImportSpecifier } from 'es-module-lexer';
|
|
3
|
+
/**
|
|
4
|
+
* 暂时没用
|
|
5
|
+
* @param source
|
|
6
|
+
* @param importer
|
|
7
|
+
* @param resolve
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
3
10
|
export declare function findVueComponentImports(source: string, importer: string, resolve: PluginContext['resolve']): Promise<(ImportSpecifier & {
|
|
4
11
|
i: string;
|
|
5
12
|
})[]>;
|
package/dist/mp/imports.js
CHANGED
|
@@ -10,6 +10,14 @@ const shared_1 = require("@vue/shared");
|
|
|
10
10
|
const types_1 = require("@babel/types");
|
|
11
11
|
const parser_1 = require("@babel/parser");
|
|
12
12
|
const constants_1 = require("../constants");
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
/**
|
|
15
|
+
* 暂时没用
|
|
16
|
+
* @param source
|
|
17
|
+
* @param importer
|
|
18
|
+
* @param resolve
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
13
21
|
async function findVueComponentImports(source, importer, resolve) {
|
|
14
22
|
await es_module_lexer_1.init;
|
|
15
23
|
let imports = [];
|
|
@@ -44,6 +52,7 @@ async function findVueComponentImports(source, importer, resolve) {
|
|
|
44
52
|
}
|
|
45
53
|
if (constants_1.EXTNAME_VUE_RE.test(res.id)) {
|
|
46
54
|
const expr = (0, parser_1.parse)(source.slice(importSpecifier.ss, importSpecifier.se), {
|
|
55
|
+
plugins: (0, utils_1.normalizeParsePlugins)(res.id),
|
|
47
56
|
sourceType: 'module',
|
|
48
57
|
}).program.body[0];
|
|
49
58
|
if ((0, types_1.isImportDeclaration)(expr) && expr.specifiers.length === 1) {
|
|
@@ -19,7 +19,7 @@ async function transformVueComponentImports(code, importer, { root, resolve, glo
|
|
|
19
19
|
}
|
|
20
20
|
const s = new magic_string_1.default(code);
|
|
21
21
|
const scriptAst = (0, parser_1.parse)(code, {
|
|
22
|
-
plugins:
|
|
22
|
+
plugins: (0, utils_1.normalizeParsePlugins)(importer, babelParserPlugins),
|
|
23
23
|
sourceType: 'module',
|
|
24
24
|
}).program;
|
|
25
25
|
const imports = findVueComponentImports(scriptAst.body, global
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as hash } from 'hash-sum';
|
|
2
2
|
import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
|
|
3
|
+
import { ParserPlugin } from '@babel/parser';
|
|
3
4
|
export declare let isRunningWithYarnPnp: boolean;
|
|
4
5
|
export declare const isWindows: boolean;
|
|
5
6
|
export declare function normalizePath(id: string): string;
|
|
@@ -9,3 +10,4 @@ export declare function normalizePagePath(pagePath: string, platform: UniApp.PLA
|
|
|
9
10
|
export declare function removeExt(str: string): string;
|
|
10
11
|
export declare function normalizeNodeModules(str: string): string;
|
|
11
12
|
export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
|
|
13
|
+
export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): ParserPlugin[];
|
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.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.hash = void 0;
|
|
6
|
+
exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = 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"));
|
|
@@ -65,3 +65,16 @@ function normalizeMiniProgramFilename(filename, inputDir) {
|
|
|
65
65
|
return normalizeNodeModules(path_1.default.relative(inputDir, filename));
|
|
66
66
|
}
|
|
67
67
|
exports.normalizeMiniProgramFilename = normalizeMiniProgramFilename;
|
|
68
|
+
function normalizeParsePlugins(importer, babelParserPlugins) {
|
|
69
|
+
const isTS = constants_1.EXTNAME_TS_RE.test(importer.split('?')[0]);
|
|
70
|
+
const plugins = [];
|
|
71
|
+
if (isTS) {
|
|
72
|
+
plugins.push('jsx');
|
|
73
|
+
}
|
|
74
|
+
if (babelParserPlugins)
|
|
75
|
+
plugins.push(...babelParserPlugins);
|
|
76
|
+
if (isTS)
|
|
77
|
+
plugins.push('typescript', 'decorators-legacy');
|
|
78
|
+
return plugins;
|
|
79
|
+
}
|
|
80
|
+
exports.normalizeParsePlugins = normalizeParsePlugins;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
import { FilterPattern } from '@rollup/pluginutils';
|
|
3
2
|
interface UniCssScopedPluginOptions {
|
|
4
|
-
|
|
5
|
-
exclude?: FilterPattern;
|
|
3
|
+
filter: (id: string) => boolean;
|
|
6
4
|
}
|
|
7
|
-
export declare function uniCssScopedPlugin(
|
|
5
|
+
export declare function uniCssScopedPlugin({ filter }?: UniCssScopedPluginOptions): Plugin;
|
|
8
6
|
export {};
|
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.uniCssScopedPlugin = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
|
9
|
-
const utils_1 = require("../utils");
|
|
10
9
|
const constants_1 = require("../../constants");
|
|
11
|
-
const pluginutils_1 = require("@rollup/pluginutils");
|
|
12
10
|
const preprocess_1 = require("../../preprocess");
|
|
13
11
|
const debugScoped = (0, debug_1.default)('vite:uni:scoped');
|
|
14
12
|
const SCOPED_RE = /<style\s[^>]*scoped[^>]*>/i;
|
|
@@ -18,28 +16,18 @@ function addScoped(code) {
|
|
|
18
16
|
}
|
|
19
17
|
return code.replace(/(<style\b[^><]*)>/gi, '$1 scoped>');
|
|
20
18
|
}
|
|
21
|
-
function uniCssScopedPlugin(
|
|
22
|
-
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
19
|
+
function uniCssScopedPlugin({ filter } = { filter: () => false }) {
|
|
23
20
|
return {
|
|
24
21
|
name: 'vite:uni-css-scoped',
|
|
25
22
|
enforce: 'pre',
|
|
26
23
|
transform(code, id) {
|
|
27
|
-
if (id.endsWith('App.vue')) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
24
|
if (!filter(id))
|
|
31
25
|
return null;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
debugScoped(id);
|
|
38
|
-
return {
|
|
39
|
-
code: addScoped(code),
|
|
40
|
-
map: null,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
26
|
+
debugScoped(id);
|
|
27
|
+
return {
|
|
28
|
+
code: addScoped(code),
|
|
29
|
+
map: null,
|
|
30
|
+
};
|
|
43
31
|
},
|
|
44
32
|
// 仅 h5
|
|
45
33
|
handleHotUpdate(ctx) {
|
|
@@ -4,5 +4,5 @@ export * from './inject';
|
|
|
4
4
|
export * from './mainJs';
|
|
5
5
|
export * from './jsonJs';
|
|
6
6
|
export * from './console';
|
|
7
|
-
export { assetPlugin } from './vitejs/plugins/asset';
|
|
8
|
-
export { isCSSRequest, cssPlugin, cssPostPlugin } from './vitejs/plugins/css';
|
|
7
|
+
export { assetPlugin, getAssetHash } from './vitejs/plugins/asset';
|
|
8
|
+
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, } from './vitejs/plugins/css';
|
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.assetPlugin = void 0;
|
|
13
|
+
exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.assetPlugin = void 0;
|
|
14
14
|
__exportStar(require("./cssScoped"), exports);
|
|
15
15
|
__exportStar(require("./copy"), exports);
|
|
16
16
|
__exportStar(require("./inject"), exports);
|
|
@@ -19,7 +19,9 @@ __exportStar(require("./jsonJs"), exports);
|
|
|
19
19
|
__exportStar(require("./console"), exports);
|
|
20
20
|
var asset_1 = require("./vitejs/plugins/asset");
|
|
21
21
|
Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
|
|
22
|
+
Object.defineProperty(exports, "getAssetHash", { enumerable: true, get: function () { return asset_1.getAssetHash; } });
|
|
22
23
|
var css_1 = require("./vitejs/plugins/css");
|
|
23
24
|
Object.defineProperty(exports, "isCSSRequest", { enumerable: true, get: function () { return css_1.isCSSRequest; } });
|
|
24
25
|
Object.defineProperty(exports, "cssPlugin", { enumerable: true, get: function () { return css_1.cssPlugin; } });
|
|
25
26
|
Object.defineProperty(exports, "cssPostPlugin", { enumerable: true, get: function () { return css_1.cssPostPlugin; } });
|
|
27
|
+
Object.defineProperty(exports, "minifyCSS", { enumerable: true, get: function () { return css_1.minifyCSS; } });
|
|
@@ -42,6 +42,8 @@ function uniViteInjectPlugin(options) {
|
|
|
42
42
|
const callback = options.callback;
|
|
43
43
|
return {
|
|
44
44
|
name: 'vite:uni-inject',
|
|
45
|
+
// 确保在 commonjs 之后,否则会混合 es6 module 与 cjs 的代码,导致 commonjs 失效
|
|
46
|
+
enforce: 'post',
|
|
45
47
|
transform(code, id) {
|
|
46
48
|
if (!filter(id))
|
|
47
49
|
return null;
|
|
@@ -165,7 +167,10 @@ function uniViteInjectPlugin(options) {
|
|
|
165
167
|
if (newImports.size === 0) {
|
|
166
168
|
return {
|
|
167
169
|
code,
|
|
168
|
-
ast
|
|
170
|
+
// 不能返回 ast ,否则会导致代码不能被再次修改
|
|
171
|
+
// 比如 App.vue 中,console.log('uniCloud') 触发了 inject 检测,检测完,发现不需要
|
|
172
|
+
// 此时返回 ast,会导致 import { setupApp } from '@dcloudio/uni-h5' 不会被编译
|
|
173
|
+
// ast
|
|
169
174
|
map: sourceMap ? magicString.generateMap({ hires: true }) : null,
|
|
170
175
|
};
|
|
171
176
|
}
|
|
@@ -38,10 +38,10 @@ export declare function cssPostPlugin(config: ResolvedConfig, { chunkCssFilename
|
|
|
38
38
|
chunkCssCode: (filename: string, cssCode: string) => string;
|
|
39
39
|
}): Plugin;
|
|
40
40
|
export declare const cssUrlRE: RegExp;
|
|
41
|
+
export declare function minifyCSS(css: string, config: ResolvedConfig): Promise<string>;
|
|
41
42
|
export interface StylePreprocessorResults {
|
|
42
43
|
code: string;
|
|
43
44
|
map?: object;
|
|
44
45
|
errors: RollupError[];
|
|
45
46
|
deps: string[];
|
|
46
47
|
}
|
|
47
|
-
export declare function preprocessCss(content: string): any;
|
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.minifyCSS = exports.cssUrlRE = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectCSSRequest = exports.isCSSRequest = exports.cssLangRE = void 0;
|
|
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"));
|
|
@@ -508,6 +508,7 @@ async function minifyCSS(css, config) {
|
|
|
508
508
|
}
|
|
509
509
|
return code;
|
|
510
510
|
}
|
|
511
|
+
exports.minifyCSS = minifyCSS;
|
|
511
512
|
const AtImportHoistPlugin = () => {
|
|
512
513
|
return {
|
|
513
514
|
postcssPlugin: 'vite-hoist-at-imports',
|
|
@@ -602,7 +603,6 @@ function preprocessCss(content) {
|
|
|
602
603
|
}
|
|
603
604
|
return content;
|
|
604
605
|
}
|
|
605
|
-
exports.preprocessCss = preprocessCss;
|
|
606
606
|
/**
|
|
607
607
|
* relative url() inside \@imported sass and less files must be rebased to use
|
|
608
608
|
* root file as base.
|
|
@@ -4,9 +4,6 @@ export interface UniViteFilterPluginOptions {
|
|
|
4
4
|
resolvedConfig: ResolvedConfig;
|
|
5
5
|
filter: (id: string) => boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function injectH5AssetPlugin(config: ResolvedConfig): void;
|
|
8
|
-
export declare function injectH5CssPlugin(config: ResolvedConfig): void;
|
|
9
|
-
export declare function injectH5CssPostPlugin(config: ResolvedConfig): void;
|
|
10
7
|
export declare function injectAssetPlugin(config: ResolvedConfig): void;
|
|
11
8
|
export declare function injectCssPlugin(config: ResolvedConfig): void;
|
|
12
9
|
export declare function injectCssPostPlugin(config: ResolvedConfig, { chunkCssFilename, chunkCssCode, }: {
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removePlugins = exports.replacePlugins = exports.injectCssPostPlugin = exports.injectCssPlugin = exports.injectAssetPlugin =
|
|
3
|
+
exports.removePlugins = exports.replacePlugins = exports.injectCssPostPlugin = exports.injectCssPlugin = exports.injectAssetPlugin = void 0;
|
|
4
4
|
const asset_1 = require("../plugins/vitejs/plugins/asset");
|
|
5
5
|
const css_1 = require("../plugins/vitejs/plugins/css");
|
|
6
|
-
const h5Asset_1 = require("../plugins/vitejs/plugins/h5Asset");
|
|
7
|
-
const h5Css_1 = require("../plugins/vitejs/plugins/h5Css");
|
|
8
|
-
function injectH5AssetPlugin(config) {
|
|
9
|
-
replacePlugins([(0, h5Asset_1.assetPlugin)(config)], config);
|
|
10
|
-
}
|
|
11
|
-
exports.injectH5AssetPlugin = injectH5AssetPlugin;
|
|
12
|
-
function injectH5CssPlugin(config) {
|
|
13
|
-
replacePlugins([(0, h5Css_1.cssPlugin)(config)], config);
|
|
14
|
-
}
|
|
15
|
-
exports.injectH5CssPlugin = injectH5CssPlugin;
|
|
16
|
-
function injectH5CssPostPlugin(config) {
|
|
17
|
-
replacePlugins([(0, h5Css_1.cssPostPlugin)(config)], config);
|
|
18
|
-
}
|
|
19
|
-
exports.injectH5CssPostPlugin = injectH5CssPostPlugin;
|
|
20
6
|
function injectAssetPlugin(config) {
|
|
21
7
|
replacePlugins([(0, asset_1.assetPlugin)(config)], config);
|
|
22
8
|
}
|
package/dist/vite/utils/url.d.ts
CHANGED
package/dist/vue/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AttributeNode, ComponentNode, DirectiveNode, ElementNode, RootNode, ExpressionNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
|
|
2
2
|
export declare const VUE_REF = "r";
|
|
3
3
|
export declare const VUE_REF_IN_FOR = "r-i-f";
|
|
4
|
+
export declare function isVueSfcFile(id: string): boolean;
|
|
4
5
|
export declare function isUserComponent(node: RootNode | TemplateChildNode, context: {
|
|
5
6
|
isBuiltInComponent: TransformContext['isBuiltInComponent'];
|
|
6
7
|
}): node is ComponentNode;
|
package/dist/vue/utils.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
3
|
+
exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
5
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
6
6
|
const compiler_core_1 = require("@vue/compiler-core");
|
|
7
7
|
const templateTransformAssetUrl_1 = require("./transforms/templateTransformAssetUrl");
|
|
8
8
|
const templateTransformSrcset_1 = require("./transforms/templateTransformSrcset");
|
|
9
|
+
const url_1 = require("../vite/utils/url");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
9
11
|
exports.VUE_REF = 'r';
|
|
10
12
|
exports.VUE_REF_IN_FOR = 'r-i-f';
|
|
13
|
+
function isVueSfcFile(id) {
|
|
14
|
+
const { filename, query } = (0, url_1.parseVueRequest)(id);
|
|
15
|
+
return constants_1.EXTNAME_VUE_RE.test(filename) && !query.vue;
|
|
16
|
+
}
|
|
17
|
+
exports.isVueSfcFile = isVueSfcFile;
|
|
11
18
|
function isUserComponent(node, context) {
|
|
12
19
|
return (node.type === 1 /* ELEMENT */ &&
|
|
13
20
|
node.tagType === 1 /* COMPONENT */ &&
|
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-3030020211130002",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/parser": "^7.15.0",
|
|
22
22
|
"@babel/types": "^7.15.0",
|
|
23
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
24
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
23
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3030020211130002",
|
|
24
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3030020211130002",
|
|
25
25
|
"@rollup/pluginutils": "^4.1.1",
|
|
26
|
-
"@vue/compiler-core": "3.2.
|
|
27
|
-
"@vue/compiler-dom": "3.2.
|
|
28
|
-
"@vue/compiler-sfc": "3.2.
|
|
29
|
-
"@vue/shared": "3.2.
|
|
26
|
+
"@vue/compiler-core": "3.2.23",
|
|
27
|
+
"@vue/compiler-dom": "3.2.23",
|
|
28
|
+
"@vue/compiler-sfc": "3.2.23",
|
|
29
|
+
"@vue/shared": "3.2.23",
|
|
30
30
|
"chalk": "^4.1.1",
|
|
31
31
|
"chokidar": "^3.5.2",
|
|
32
32
|
"compare-versions": "^3.6.0",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Plugin } from '../plugin';
|
|
3
|
-
import { ResolvedConfig } from '../config';
|
|
4
|
-
import { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
|
|
5
|
-
export declare const assetUrlRE: RegExp;
|
|
6
|
-
export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
|
|
7
|
-
/**
|
|
8
|
-
* Also supports loading plain strings with import text from './foo.txt?raw'
|
|
9
|
-
*/
|
|
10
|
-
export declare function assetPlugin(config: ResolvedConfig): Plugin;
|
|
11
|
-
export declare function registerAssetToChunk(chunk: RenderedChunk, file: string): void;
|
|
12
|
-
export declare function checkPublicFile(url: string, { publicDir }: ResolvedConfig): string | undefined;
|
|
13
|
-
export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext): string | Promise<string>;
|
|
14
|
-
export declare function getAssetFilename(hash: string, config: ResolvedConfig): string | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* converts the source filepath of the asset to the output filename based on the assetFileNames option. \
|
|
17
|
-
* this function imitates the behavior of rollup.js. \
|
|
18
|
-
* https://rollupjs.org/guide/en/#outputassetfilenames
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* const content = Buffer.from('text');
|
|
23
|
-
* const fileName = assetFileNamesToFileName(
|
|
24
|
-
* 'assets/[name].[hash][extname]',
|
|
25
|
-
* '/path/to/file.txt',
|
|
26
|
-
* getAssetHash(content),
|
|
27
|
-
* content
|
|
28
|
-
* )
|
|
29
|
-
* // fileName: 'assets/file.982d9e3e.txt'
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @param assetFileNames filename pattern. e.g. `'assets/[name].[hash][extname]'`
|
|
33
|
-
* @param file filepath of the asset
|
|
34
|
-
* @param contentHash hash of the asset. used for `'[hash]'` placeholder
|
|
35
|
-
* @param content content of the asset. passed to `assetFileNames` if `assetFileNames` is a function
|
|
36
|
-
* @returns output filename
|
|
37
|
-
*/
|
|
38
|
-
export declare function assetFileNamesToFileName(assetFileNames: Exclude<OutputOptions['assetFileNames'], undefined>, file: string, contentHash: string, content: string | Buffer): string;
|
|
39
|
-
export declare function getAssetHash(content: Buffer): string;
|
|
40
|
-
export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext): Promise<string>;
|