@cloudbase/framework-plugin-low-code 0.6.22 → 0.6.25
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/lib/builder/service/builder/generate.js +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -21
- package/package.json +1 -1
- package/template/mp/common/util.js +2 -2
- package/template/mp/common/weapp-component.js +1 -1
- package/template/mp/common/weapp-page.js +1 -1
- package/template/mp/common/widget.js +3 -3
- package/template/src/app/global-api.js +1 -1
- package/template/src/handlers/FieldMiddleware/renderer.jsx +19 -6
- package/template/src/handlers/actionHandler/utils.js +10 -6
- package/template/src/handlers/utils/common.js +3 -2
- package/template/src/handlers/utils/widgets.js +6 -5
- package/template/webpack/web.prod.js +41 -11
|
@@ -608,7 +608,7 @@ function generateRouterFile(allAppDataList, appBuildDir, basename = '', buildTyp
|
|
|
608
608
|
weapps_core_1.loopDealWithFn(pageInstanceList, (pageInstance) => {
|
|
609
609
|
const pageId = [rootPath, pageInstance.id].filter((i) => i).join('_');
|
|
610
610
|
if (pageInstance.isHome && !rootPath) {
|
|
611
|
-
routerRenders.push(`<
|
|
611
|
+
routerRenders.push(`<Route from="/" exact children={() => <Redirect to="/${pageId}" />} />`);
|
|
612
612
|
}
|
|
613
613
|
routerImports.push(`import Page${pageId} from '${pageFilePath}pages/${pageInstance.id}/index';`);
|
|
614
614
|
routerRenders.push(`<Route path="/${pageId}" component={Page${pageId}}/>`);
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUrE,OAAO,EACL,SAAS,EAET,cAAc,EAG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,QAAQ,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAM;IAC9B,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;IACxB,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;IACtB,SAAS,CAAC,eAAe,EAAE,GAAG,CAAC;IAC/B,SAAS,CAAC,cAAc,CAAC,EAAE;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;gBAEO,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,6BAA6B;IA8I9C,QAAQ;IAMR,qBAAqB,CAAC,aAAa,EAAE,cAAc;IAmGnD,eAAe;IAUf,KAAK,CAAC,KAAK,KAAA;IASX,QAAQ,CAAC,KAAK,KAAA;IAWR,IAAI;IAKJ,GAAG;IAKH,MAAM;IAKN,OAAO;IAKP,KAAK;IA0RL,OAAO;IA6FP,MAAM;IAwGN,mBAAmB,CAAC,KAAK,KAAA,EAAE,KAAK,GAAE,OAAe;IAgBjD,eAAe,CAAC,KAAK,KAAA,EAAE,KAAK,GAAE,OAAe;IAqBnD,eAAe,CAAC,OAAO,KAAA;IAIjB,gBAAgB;IA4HhB,2BAA2B;IA6E3B,UAAU;IAwBV,OAAO,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA;IAejB,uBAAuB;IAuCvB,yBAAyB;CA2FhC;AAgCD,eAAO,MAAM,MAAM,sBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -292,7 +292,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
292
292
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
293
293
|
}
|
|
294
294
|
build() {
|
|
295
|
-
var _a, _b, _c, _d;
|
|
295
|
+
var _a, _b, _c, _d, _e;
|
|
296
296
|
return __awaiter(this, void 0, void 0, function* () {
|
|
297
297
|
let { logger } = this.api;
|
|
298
298
|
const staticDir = path_1.default.resolve(__dirname, '../../../static');
|
|
@@ -342,12 +342,8 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
342
342
|
WeAppId: appId,
|
|
343
343
|
},
|
|
344
344
|
});
|
|
345
|
-
this.api.logger.debug('DescribeAppCustomUrls', Data
|
|
346
|
-
|
|
347
|
-
IgnorePublished: true,
|
|
348
|
-
WeAppId: appId,
|
|
349
|
-
});
|
|
350
|
-
this._gatewayConfig = (_d = Data === null || Data === void 0 ? void 0 : Data.Items) === null || _d === void 0 ? void 0 : _d[0];
|
|
345
|
+
this.api.logger.debug('DescribeAppCustomUrls:', (_d = Data === null || Data === void 0 ? void 0 : Data.Items) === null || _d === void 0 ? void 0 : _d[0]);
|
|
346
|
+
this._gatewayConfig = (_e = Data === null || Data === void 0 ? void 0 : Data.Items) === null || _e === void 0 ? void 0 : _e[0];
|
|
351
347
|
if (this._gatewayConfig) {
|
|
352
348
|
const path = this._gatewayConfig.Path;
|
|
353
349
|
window.publicPath = `https://${domain}${this._getWebRootPath()}`;
|
|
@@ -372,7 +368,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
372
368
|
}
|
|
373
369
|
this._time("build process");
|
|
374
370
|
this._appPath = yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
375
|
-
var
|
|
371
|
+
var _f, _g;
|
|
376
372
|
try {
|
|
377
373
|
yield core_1.default({
|
|
378
374
|
mainAppSerializeData,
|
|
@@ -385,14 +381,14 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
385
381
|
runtime: this._resolvedInputs.runtime,
|
|
386
382
|
ignoreInstall: this._resolvedInputs.ignoreInstall,
|
|
387
383
|
mode: webpackMode,
|
|
388
|
-
deployMode: (
|
|
384
|
+
deployMode: (_f = this._resolvedInputs.deployOptions) === null || _f === void 0 ? void 0 : _f.mode,
|
|
389
385
|
watch: false,
|
|
390
386
|
generateMpType,
|
|
391
387
|
generateMpPath,
|
|
392
388
|
isCleanDistDir: false,
|
|
393
389
|
plugins,
|
|
394
390
|
extraData,
|
|
395
|
-
isCrossAccount: this._resolvedInputs.mpAppId !== ((
|
|
391
|
+
isCrossAccount: this._resolvedInputs.mpAppId !== ((_g = this._resolvedInputs.deployOptions) === null || _g === void 0 ? void 0 : _g.targetMpAppId),
|
|
396
392
|
resourceAppid: this._resolvedInputs.mpAppId,
|
|
397
393
|
domain,
|
|
398
394
|
}, (err, result) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -595,7 +591,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
595
591
|
const { deployOptions, appId } = this._resolvedInputs;
|
|
596
592
|
const isPreview = (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.PREVIEW;
|
|
597
593
|
const link = common_2.buildAsAdminPortalByBuildType(this._resolvedInputs.buildTypeList)
|
|
598
|
-
? `https://${this._website.cdnDomain}/adminportal/#/app/${isPreview ? `${appId}-preview` : appId}?envType=${isPreview ? '
|
|
594
|
+
? `https://${this._website.cdnDomain}/adminportal/#/app/${isPreview ? `${appId}-preview` : appId}?envType=${isPreview ? 'preview' : 'prod'}`
|
|
599
595
|
: this._gatewayConfig
|
|
600
596
|
? `https://${this._gatewayConfig.Domain + this._gatewayConfig.Path}`
|
|
601
597
|
: `https://${this._website.cdnDomain +
|
|
@@ -980,22 +976,20 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
980
976
|
domainConfig: { FollowRedirect: 'on' },
|
|
981
977
|
}));
|
|
982
978
|
yield Promise.all(modifyDomainConfigPromises);
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
.commonService('lowcode', '2021-01-08')
|
|
986
|
-
.call({
|
|
979
|
+
yield Promise.all([
|
|
980
|
+
this.api.cloudbaseManager.commonService('lowcode', '2021-01-08').call({
|
|
987
981
|
Action: 'PublishAppCustomUrl',
|
|
988
982
|
Param: {
|
|
989
983
|
EnvId: this.api.envId,
|
|
990
984
|
WeAppId: this._resolvedInputs.appId,
|
|
991
985
|
IndexPath: this._getWebRootPath(),
|
|
992
986
|
},
|
|
993
|
-
})
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
987
|
+
}),
|
|
988
|
+
hostingService.setWebsiteDocument({
|
|
989
|
+
indexDocument: 'index.html',
|
|
990
|
+
routingRules: this._rules,
|
|
991
|
+
}),
|
|
992
|
+
]);
|
|
999
993
|
}
|
|
1000
994
|
catch (e) {
|
|
1001
995
|
this.api.logger.error('网站路由注册失败: ', e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.25",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -28,7 +28,7 @@ export function createComputed(funcs, bindContext = null) {
|
|
|
28
28
|
return computed
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export function createEventHandlers(evtListeners) {
|
|
31
|
+
export function createEventHandlers(evtListeners, context) {
|
|
32
32
|
const evtHandlers = {}
|
|
33
33
|
for (const name in evtListeners) {
|
|
34
34
|
const listeners = evtListeners[name]
|
|
@@ -41,7 +41,7 @@ export function createEventHandlers(evtListeners) {
|
|
|
41
41
|
let { data = {}, boundData = {} } = l
|
|
42
42
|
data = { ...data }
|
|
43
43
|
for (const k in boundData) {
|
|
44
|
-
set(data, k, boundData[k](lists, itemsById, event))
|
|
44
|
+
set(data, k, boundData[k](lists, itemsById, event, context))
|
|
45
45
|
}
|
|
46
46
|
try {
|
|
47
47
|
let res = await l.handler.call(self, { event, lists, forItems: itemsById, data })
|
|
@@ -97,7 +97,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
97
97
|
},
|
|
98
98
|
|
|
99
99
|
methods: {
|
|
100
|
-
...createEventHandlers(evtListeners),
|
|
100
|
+
...createEventHandlers(evtListeners, context),
|
|
101
101
|
...mergeRenderer,
|
|
102
102
|
getWeAppInst() {
|
|
103
103
|
const $comp = this.$WEAPPS_COMP
|
|
@@ -25,7 +25,7 @@ export function createPage(
|
|
|
25
25
|
app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
-
const evtHandlers = createEventHandlers(evtListeners);
|
|
28
|
+
const evtHandlers = createEventHandlers(evtListeners, context);
|
|
29
29
|
|
|
30
30
|
function extractLifecyles() {
|
|
31
31
|
const result = { ...lifecycle };
|
|
@@ -71,7 +71,7 @@ function createSubWidgetTree(curForNode, widgetProps, dataBinds, ownerMpInst, wi
|
|
|
71
71
|
} else {
|
|
72
72
|
disposeWidget(existedWidget, true)
|
|
73
73
|
}
|
|
74
|
-
setUpWidateDataBinds(w, dataBinds[node.id], forItems, failedBinds)
|
|
74
|
+
setUpWidateDataBinds(w, dataBinds[node.id], forItems, failedBinds, context)
|
|
75
75
|
widgetHolder[node.id] = w
|
|
76
76
|
} else if (!existedWidget) {
|
|
77
77
|
const len = parentForWidgetArr.push(observable([]))
|
|
@@ -188,7 +188,7 @@ function createAWidget(props, id, parent, ownerMpInst) {
|
|
|
188
188
|
return w
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
function setUpWidateDataBinds(w, dataBinds, forItems, failedBinds) {
|
|
191
|
+
function setUpWidateDataBinds(w, dataBinds, forItems, failedBinds, context) {
|
|
192
192
|
Object.keys(dataBinds || {}).map(prop => {
|
|
193
193
|
if (prop === '_waFor') { return }
|
|
194
194
|
const setUpDataBind = () => {
|
|
@@ -196,7 +196,7 @@ function setUpWidateDataBinds(w, dataBinds, forItems, failedBinds) {
|
|
|
196
196
|
const dispose = autorun(() => {
|
|
197
197
|
try {
|
|
198
198
|
// Computed data bind in the next tick since data bind may read widgets data
|
|
199
|
-
w[prop] = dataBinds[prop](forItems.lists, forItems.itemsById)
|
|
199
|
+
w[prop] = dataBinds[prop](forItems.lists, forItems.itemsById, undefined, context)
|
|
200
200
|
} catch (e) {
|
|
201
201
|
if(prop === '_waIf'){
|
|
202
202
|
w[prop] = false
|
|
@@ -64,14 +64,25 @@ export const CompRenderer = observer(function (props) {
|
|
|
64
64
|
// 组件最终用于执行的事件函数
|
|
65
65
|
const emit = useCallback(
|
|
66
66
|
(trigger, event, forItems, scopeContext) => {
|
|
67
|
+
const listeners = listenerInstances || [];
|
|
68
|
+
|
|
67
69
|
// 如果是数据容器,则将传过来的data,赋值给容器上下文context
|
|
68
70
|
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
componentSchema?.compConfig?.isDataContainer &&
|
|
72
|
+
!listeners?.some((listener) => listener.trigger === 'onDataChange')
|
|
71
73
|
) {
|
|
72
|
-
|
|
74
|
+
listeners?.push({
|
|
75
|
+
key: `wa${Date.now().toString().slice(-8)}`,
|
|
76
|
+
trigger: 'onDataChange',
|
|
77
|
+
isCapturePhase: false,
|
|
78
|
+
data: {},
|
|
79
|
+
dataBinds: {},
|
|
80
|
+
instanceFunction: ({ event }) => {
|
|
81
|
+
return updateContext(compId, event?.detail?.data);
|
|
82
|
+
},
|
|
83
|
+
});
|
|
73
84
|
}
|
|
74
|
-
|
|
85
|
+
|
|
75
86
|
event = { detail: event, name: trigger };
|
|
76
87
|
forItems = {
|
|
77
88
|
...forItems,
|
|
@@ -85,7 +96,8 @@ export const CompRenderer = observer(function (props) {
|
|
|
85
96
|
customEventData: event,
|
|
86
97
|
forItems,
|
|
87
98
|
},
|
|
88
|
-
scopeContext
|
|
99
|
+
scopeContext,
|
|
100
|
+
context
|
|
89
101
|
);
|
|
90
102
|
},
|
|
91
103
|
[props]
|
|
@@ -113,7 +125,8 @@ export const CompRenderer = observer(function (props) {
|
|
|
113
125
|
customEventData: event,
|
|
114
126
|
forItems,
|
|
115
127
|
},
|
|
116
|
-
scopeContext
|
|
128
|
+
scopeContext,
|
|
129
|
+
context
|
|
117
130
|
);
|
|
118
131
|
},
|
|
119
132
|
[props]
|
|
@@ -11,7 +11,7 @@ export function getMetaInfoBySourceKey(sourceKey) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function emitEvent(trigger, listeners = [], args, scopeContext = {}) {
|
|
14
|
+
export function emitEvent(trigger, listeners = [], args, scopeContext = {}, context) {
|
|
15
15
|
const targetListeners = listeners.filter((l) => l.trigger === trigger);
|
|
16
16
|
targetListeners.forEach(async (listener) => {
|
|
17
17
|
// 当前非捕获Event,再判断冒泡行为
|
|
@@ -28,7 +28,7 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}) {
|
|
|
28
28
|
(args?.customEventData?.detail?.isCapturePhase || false)
|
|
29
29
|
) {
|
|
30
30
|
try {
|
|
31
|
-
const res = await invokeListener(listener, args, scopeContext);
|
|
31
|
+
const res = await invokeListener(listener, args, scopeContext, context);
|
|
32
32
|
const eventName = `${listener.key}.success`;
|
|
33
33
|
const event = {
|
|
34
34
|
detail: {
|
|
@@ -46,7 +46,8 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}) {
|
|
|
46
46
|
event,
|
|
47
47
|
customEventData: event,
|
|
48
48
|
},
|
|
49
|
-
scopeContext
|
|
49
|
+
scopeContext,
|
|
50
|
+
context
|
|
50
51
|
);
|
|
51
52
|
} catch (e) {
|
|
52
53
|
const eventName = `${listener.key}.fail`;
|
|
@@ -66,7 +67,8 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}) {
|
|
|
66
67
|
event,
|
|
67
68
|
customEventData: event,
|
|
68
69
|
},
|
|
69
|
-
scopeContext
|
|
70
|
+
scopeContext,
|
|
71
|
+
context
|
|
70
72
|
);
|
|
71
73
|
// 之前 invoke 内部catch 了错误,不会抛错
|
|
72
74
|
// throw e
|
|
@@ -78,7 +80,8 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}) {
|
|
|
78
80
|
async function invokeListener(
|
|
79
81
|
{ instanceFunction, data = {}, dataBinds = {} },
|
|
80
82
|
args,
|
|
81
|
-
scopeContext
|
|
83
|
+
scopeContext,
|
|
84
|
+
context
|
|
82
85
|
) {
|
|
83
86
|
// ToDo resolve databinds
|
|
84
87
|
const action = instanceFunction;
|
|
@@ -93,7 +96,8 @@ async function invokeListener(
|
|
|
93
96
|
args.forItems,
|
|
94
97
|
{ event: args.event },
|
|
95
98
|
scopeContext,
|
|
96
|
-
true
|
|
99
|
+
true,
|
|
100
|
+
context
|
|
97
101
|
);
|
|
98
102
|
|
|
99
103
|
// eslint-disable-next-line no-restricted-syntax
|
|
@@ -23,7 +23,8 @@ export function resolveDataBinds(
|
|
|
23
23
|
forItems,
|
|
24
24
|
codeContext,
|
|
25
25
|
scopeContext,
|
|
26
|
-
throwError
|
|
26
|
+
throwError,
|
|
27
|
+
context
|
|
27
28
|
) {
|
|
28
29
|
const resolvedProps = {};
|
|
29
30
|
for (const prop in dataBinds) {
|
|
@@ -35,7 +36,7 @@ export function resolveDataBinds(
|
|
|
35
36
|
resolvedProps[prop] = fn(
|
|
36
37
|
forItems,
|
|
37
38
|
codeContext && codeContext.event,
|
|
38
|
-
|
|
39
|
+
context
|
|
39
40
|
);
|
|
40
41
|
} catch (e) {
|
|
41
42
|
console.error('Error resolving data binding', prop, dataBinds[prop], e);
|
|
@@ -119,7 +119,7 @@ export function createWidgets(widgetProps, dataBinds, scopeContext = {}, context
|
|
|
119
119
|
) {
|
|
120
120
|
const nodeId = curForNode.id;
|
|
121
121
|
if (!curForNode.value) {
|
|
122
|
-
return createSubTree(curForNode, {}, scopeContext);
|
|
122
|
+
return createSubTree(curForNode, {}, scopeContext, context);
|
|
123
123
|
}
|
|
124
124
|
const dispose = autorun(() => {
|
|
125
125
|
let forList = [];
|
|
@@ -149,7 +149,7 @@ export function createWidgets(widgetProps, dataBinds, scopeContext = {}, context
|
|
|
149
149
|
|
|
150
150
|
forList.forEach((item, index) => {
|
|
151
151
|
const subForItems = { ...forItems, [nodeId]: item };
|
|
152
|
-
createSubTree(curForNode, subForItems, scopeContext);
|
|
152
|
+
createSubTree(curForNode, subForItems, scopeContext, context);
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
// 非初始化时遇到需要重新构建 dataBinds
|
|
@@ -159,7 +159,7 @@ export function createWidgets(widgetProps, dataBinds, scopeContext = {}, context
|
|
|
159
159
|
|
|
160
160
|
return dispose;
|
|
161
161
|
|
|
162
|
-
function createSubTree(curForNode, subForItems, scopeContext) {
|
|
162
|
+
function createSubTree(curForNode, subForItems, scopeContext, context) {
|
|
163
163
|
const widgets = {};
|
|
164
164
|
|
|
165
165
|
// traverse down the tree to set all widgets
|
|
@@ -212,7 +212,8 @@ export function createWidgets(widgetProps, dataBinds, scopeContext = {}, context
|
|
|
212
212
|
w[prop] = dataBinds[node.id][prop](
|
|
213
213
|
subForItems,
|
|
214
214
|
undefined,
|
|
215
|
-
|
|
215
|
+
context,
|
|
216
|
+
scopeContext,
|
|
216
217
|
);
|
|
217
218
|
disposeError = false;
|
|
218
219
|
} catch (e) {
|
|
@@ -250,7 +251,7 @@ export function createWidgets(widgetProps, dataBinds, scopeContext = {}, context
|
|
|
250
251
|
widgets,
|
|
251
252
|
node.parent && widgets[node.parent.id],
|
|
252
253
|
scopeContext,
|
|
253
|
-
context
|
|
254
|
+
context,
|
|
254
255
|
);
|
|
255
256
|
curForNode.id && widgets[curForNode.id]._disposers.push(dispose);
|
|
256
257
|
}
|
|
@@ -27,6 +27,7 @@ module.exports = function (options) {
|
|
|
27
27
|
definePlugin = {},
|
|
28
28
|
} = options;
|
|
29
29
|
const isDevelopment = mode !== 'production';
|
|
30
|
+
|
|
30
31
|
const babelLoader = {
|
|
31
32
|
loader: 'babel-loader',
|
|
32
33
|
options: {
|
|
@@ -64,24 +65,49 @@ module.exports = function (options) {
|
|
|
64
65
|
].filter(Boolean),
|
|
65
66
|
},
|
|
66
67
|
};
|
|
68
|
+
const typescriptLoader = {
|
|
69
|
+
loader: 'ts-loader',
|
|
70
|
+
options: {
|
|
71
|
+
compilerOptions: {
|
|
72
|
+
target: 'ESNext',
|
|
73
|
+
module: 'ESNext',
|
|
74
|
+
esModuleInterop: true,
|
|
75
|
+
},
|
|
76
|
+
happyPackMode: true,
|
|
77
|
+
transpileOnly: true,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
67
81
|
let plugins = [
|
|
68
82
|
new HappyPack({
|
|
69
|
-
id:
|
|
83
|
+
id: 'vue',
|
|
84
|
+
cache: true,
|
|
85
|
+
verbose: true,
|
|
70
86
|
loaders: [
|
|
71
87
|
babelLoader,
|
|
88
|
+
typescriptLoader,
|
|
72
89
|
{
|
|
73
|
-
loader: '
|
|
90
|
+
loader: 'vue-loader',
|
|
74
91
|
options: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
threadMode: true,
|
|
93
|
+
loaders: {
|
|
94
|
+
js: [babelLoader],
|
|
95
|
+
ts: [
|
|
96
|
+
babelLoader,
|
|
97
|
+
typescriptLoader,
|
|
98
|
+
],
|
|
99
|
+
}
|
|
100
|
+
}
|
|
83
101
|
},
|
|
84
102
|
],
|
|
103
|
+
threadPool: happyThreadPool
|
|
104
|
+
}),
|
|
105
|
+
new HappyPack({
|
|
106
|
+
id: TS_LOADER_ID,
|
|
107
|
+
loaders: [
|
|
108
|
+
babelLoader,
|
|
109
|
+
typescriptLoader,
|
|
110
|
+
],
|
|
85
111
|
threadPool: happyThreadPool,
|
|
86
112
|
}),
|
|
87
113
|
new HappyPack({
|
|
@@ -156,6 +182,10 @@ module.exports = function (options) {
|
|
|
156
182
|
},
|
|
157
183
|
module: {
|
|
158
184
|
rules: [
|
|
185
|
+
{
|
|
186
|
+
test: /\.vue$/,
|
|
187
|
+
loader: 'happypack/loader?id=vue'
|
|
188
|
+
},
|
|
159
189
|
{
|
|
160
190
|
test: /\.tsx?$/,
|
|
161
191
|
exclude: /node_modules\/(?!@cloudbase\/weda-ui)|gsd-kbone-react/,
|
|
@@ -163,7 +193,7 @@ module.exports = function (options) {
|
|
|
163
193
|
},
|
|
164
194
|
{
|
|
165
195
|
test: /\.(js|jsx)$/,
|
|
166
|
-
exclude: /node_modules\/(
|
|
196
|
+
exclude: /node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera))|gsd-kbone-react/,
|
|
167
197
|
use: ['happypack/loader?id=babel'],
|
|
168
198
|
},
|
|
169
199
|
{
|