@arkxio/ark-dev-utils 0.1.6 → 0.1.9

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.
@@ -1,72 +1,72 @@
1
- /** @typedef {import('../../typings').IInnerSubAppOptions} IInnerSubAppOptions */
2
- /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
3
- import * as base from '../base-utils/index';
4
- import cst from '../configs/consts';
5
- import presetExternals from '../configs/presetExternals';
6
-
7
- /**
8
- *
9
- * @param {Record<string, any>} pkg
10
- * @param {IInnerSubAppOptions} innerOptions
11
- * @param {ICreateSubAppOptions} [userOptions]
12
- * @returns
13
- */
14
- export default function createSubApp(pkg, innerOptions, userOptions) {
15
- const { frameworkType } = innerOptions;
16
- const optionsVar = Object.assign(
17
- {
18
- platform: cst.DEFAULT_PLAT,
19
- npmCdnType: cst.DEFAULT_NPM_CDN_TYPE,
20
- handleHomePage: true,
21
- semverApi: cst.DEFAULT_SEMVER_API,
22
- distDir: cst.ARK_DIST_DIR,
23
- },
24
- userOptions || {},
25
- );
26
- const envParams = base.getHelEnvParams(pkg, optionsVar);
27
- const externals = Object.assign({}, optionsVar.externals || {}, presetExternals[frameworkType] || {});
28
- const jsonpFnName = base.getJsonpFnName(envParams.appName || pkg.name);
29
-
30
- return {
31
- platform: optionsVar.platform,
32
- /**
33
- * 资源的网络根目录
34
- * 形如:
35
- * 1 /web-app/sub-apps/ticket
36
- * 2 http://www.cdn.com/xxx/yyy
37
- */
38
- homePage: envParams.appHomePage,
39
- npmCdnType: optionsVar.npmCdnType,
40
- groupName: envParams.appGroupName,
41
- /** 构建时可注入到应用的APP_NAME下 */
42
- name: envParams.appName,
43
- externals,
44
- /**
45
- * @param {Record<string, any>} userExternals
46
- * @returns
47
- */
48
- getExternals: (userExternals) => {
49
- if (userExternals && !Array.isArray(userExternals)) {
50
- return { ...userExternals, externals };
51
- }
52
- return externals;
53
- },
54
- jsonpFnName,
55
- /**
56
- * @param {string} [fallbackPathOrUrl] 兜底用的 publicPathOrUrl
57
- * @param {boolean} [needEndSlash]
58
- * @returns
59
- */
60
- getPublicPathOrUrl: (fallbackPathOrUrl = '/', needEndSlash = true) => {
61
- let pathOrUrl = envParams.appHomePage;
62
- // 用户传递了非 / 的值时,优先采用用户传递的值
63
- if (pathOrUrl === '/' && fallbackPathOrUrl !== '/') {
64
- pathOrUrl = fallbackPathOrUrl;
65
- }
66
-
67
- const finalPathOrUrl = base.getPublicPathOrUrl(pathOrUrl, needEndSlash);
68
- return finalPathOrUrl;
69
- },
70
- distDir: optionsVar.distDir,
71
- };
72
- }
1
+ /** @typedef {import('../../typings').IInnerSubAppOptions} IInnerSubAppOptions */
2
+ /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
3
+ import * as base from '../base-utils/index';
4
+ import cst from '../configs/consts';
5
+ import presetExternals from '../configs/presetExternals';
6
+
7
+ /**
8
+ *
9
+ * @param {Record<string, any>} pkg
10
+ * @param {IInnerSubAppOptions} innerOptions
11
+ * @param {ICreateSubAppOptions} [userOptions]
12
+ * @returns
13
+ */
14
+ export default function createSubApp(pkg, innerOptions, userOptions) {
15
+ const { frameworkType } = innerOptions;
16
+ const optionsVar = Object.assign(
17
+ {
18
+ platform: cst.DEFAULT_PLAT,
19
+ npmCdnType: cst.DEFAULT_NPM_CDN_TYPE,
20
+ handleHomePage: true,
21
+ semverApi: cst.DEFAULT_SEMVER_API,
22
+ distDir: cst.ARK_DIST_DIR,
23
+ },
24
+ userOptions || {},
25
+ );
26
+ const envParams = base.getHelEnvParams(pkg, optionsVar);
27
+ const externals = Object.assign({}, optionsVar.externals || {}, presetExternals[frameworkType] || {});
28
+ const jsonpFnName = base.getJsonpFnName(envParams.appName || pkg.name);
29
+
30
+ return {
31
+ platform: optionsVar.platform,
32
+ /**
33
+ * 资源的网络根目录
34
+ * 形如:
35
+ * 1 /web-app/sub-apps/ticket
36
+ * 2 http://www.cdn.com/xxx/yyy
37
+ */
38
+ homePage: envParams.appHomePage,
39
+ npmCdnType: optionsVar.npmCdnType,
40
+ groupName: envParams.appGroupName,
41
+ /** 构建时可注入到应用的APP_NAME下 */
42
+ name: envParams.appName,
43
+ externals,
44
+ /**
45
+ * @param {Record<string, any>} userExternals
46
+ * @returns
47
+ */
48
+ getExternals: (userExternals) => {
49
+ if (userExternals && !Array.isArray(userExternals)) {
50
+ return { ...userExternals, externals };
51
+ }
52
+ return externals;
53
+ },
54
+ jsonpFnName,
55
+ /**
56
+ * @param {string} [fallbackPathOrUrl] 兜底用的 publicPathOrUrl
57
+ * @param {boolean} [needEndSlash]
58
+ * @returns
59
+ */
60
+ getPublicPathOrUrl: (fallbackPathOrUrl = '/', needEndSlash = true) => {
61
+ let pathOrUrl = envParams.appHomePage;
62
+ // 用户传递了非 / 的值时,优先采用用户传递的值
63
+ if (pathOrUrl === '/' && fallbackPathOrUrl !== '/') {
64
+ pathOrUrl = fallbackPathOrUrl;
65
+ }
66
+
67
+ const finalPathOrUrl = base.getPublicPathOrUrl(pathOrUrl, needEndSlash);
68
+ return finalPathOrUrl;
69
+ },
70
+ distDir: optionsVar.distDir,
71
+ };
72
+ }
@@ -1,12 +1,12 @@
1
- /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
2
- import createSubApp from '../share/createSubApp';
3
-
4
- /**
5
- *
6
- * @param {Record<string, any>} pkg
7
- * @param {ICreateSubAppOptions} [options]
8
- * @returns
9
- */
10
- export default function createLibSubApp(pkg, options) {
11
- return createSubApp(pkg, { frameworkType: 'lib' }, options);
12
- }
1
+ /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
2
+ import createSubApp from '../share/createSubApp';
3
+
4
+ /**
5
+ *
6
+ * @param {Record<string, any>} pkg
7
+ * @param {ICreateSubAppOptions} [options]
8
+ * @returns
9
+ */
10
+ export default function createLibSubApp(pkg, options) {
11
+ return createSubApp(pkg, { frameworkType: 'lib' }, options);
12
+ }
@@ -1,12 +1,12 @@
1
- /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
2
- import createSubApp from '../share/createSubApp';
3
-
4
- /**
5
- *
6
- * @param {Record<string, any>} pkg
7
- * @param {ICreateSubAppOptions} [options]
8
- * @returns
9
- */
10
- export default function createReactSubApp(pkg, options) {
11
- return createSubApp(pkg, { frameworkType: 'react' }, options);
12
- }
1
+ /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
2
+ import createSubApp from '../share/createSubApp';
3
+
4
+ /**
5
+ *
6
+ * @param {Record<string, any>} pkg
7
+ * @param {ICreateSubAppOptions} [options]
8
+ * @returns
9
+ */
10
+ export default function createReactSubApp(pkg, options) {
11
+ return createSubApp(pkg, { frameworkType: 'react' }, options);
12
+ }
@@ -1,12 +1,12 @@
1
- /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
2
- import createSubApp from '../share/createSubApp';
3
-
4
- /**
5
- * 创建 vue 应用的描述对象
6
- * @param {Record<string, any>} pkg
7
- * @param {ICreateSubAppOptions} [options]
8
- * @returns
9
- */
10
- export function createVueSubApp(pkg, options) {
11
- return createSubApp(pkg, { frameworkType: 'vue' }, options);
12
- }
1
+ /** @typedef {import('../../typings').ICreateSubAppOptions} ICreateSubAppOptions */
2
+ import createSubApp from '../share/createSubApp';
3
+
4
+ /**
5
+ * 创建 vue 应用的描述对象
6
+ * @param {Record<string, any>} pkg
7
+ * @param {ICreateSubAppOptions} [options]
8
+ * @returns
9
+ */
10
+ export function createVueSubApp(pkg, options) {
11
+ return createSubApp(pkg, { frameworkType: 'vue' }, options);
12
+ }