Skip to content

Commit c7fae50

Browse files
committed
feat(module-loader): add "sync" param in options
affects: @vue-async/module-loader exec scripts synchronously
1 parent b8b6384 commit c7fae50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+74
-10857
lines changed

packages/module-loader/dev/main.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,59 @@ addRoutes([
2121
{
2222
path: 'remote-component-a',
2323
name: 'remote-component-a',
24-
component: () => lazyLoadView(app.$componentLoader('componentA', '/static/componentA/componentA.umd.min.js')),
24+
component: () =>
25+
lazyLoadView(app.$componentLoader('componentA', 'http://localhost:7001/componentA/componentA.umd.min.js')),
2526
},
2627
{
2728
path: 'remote-component-b',
2829
name: 'remote-component-b',
29-
component: () => lazyLoadView(app.$componentLoader('componentB', '/static/componentB/componentB.umd.min.js')),
30+
component: () =>
31+
lazyLoadView(app.$componentLoader('componentB', 'http://localhost:7001/componentB/componentB.umd.min.js')),
3032
},
3133
{
3234
path: 'wrong-component-name',
3335
name: 'wrong-component-name',
3436
component: () =>
35-
lazyLoadView(app.$componentLoader('wrongComponentName', '/static/componentB/componentB.umd.min.js')),
37+
lazyLoadView(
38+
app.$componentLoader('wrongComponentName', 'http://localhost:7001/componentB/componentB.umd.min.js'),
39+
),
3640
},
3741
{
3842
path: 'wrong-component-entry',
3943
name: 'wrong-component-entry',
4044
component: () =>
41-
lazyLoadView(app.$componentLoader('entry', 'http://www.xx.com/static/componentB/errorComponent.umd.min.js')),
45+
lazyLoadView(
46+
app.$componentLoader('entry', 'http://www.xx.comhttp://localhost:7001/componentB/errorComponent.umd.min.js'),
47+
),
4248
},
4349
]);
4450

4551
app
4652
.$moduleLoader(
4753
[
4854
{
49-
dymanicRouter: '/static/dymanicRouter/dymanicRouter.umd.js',
55+
dymanicRouter: 'http://localhost:7001/dymanicRouter/dymanicRouter.umd.js',
5056
// page 异步加载,样式限 page load 加载出来
5157
// dymanicRouter: {
52-
// entry: '/static/dymanicRouter/dymanicRouter.umd.min.js',
53-
// css: ['/static/dymanicRouter/css/1.281753bd.css', '/static/dymanicRouter/css/2.2b65cb29.css'],
58+
// entry: 'http://localhost:7001/dymanicRouter/dymanicRouter.umd.min.js',
59+
// css: ['http://localhost:7001/dymanicRouter/css/1.281753bd.css', 'http://localhost:7001/dymanicRouter/css/2.2b65cb29.css'],
5460
// },
61+
sortTest: 'http://localhost:7001/sortTest/sortTest.umd.js',
5562
dymanicComponent: {
56-
entry: '/static/dymanicComponent/dymanicComponent.umd.min.js',
57-
styles: '/static/dymanicComponent/dymanicComponent.css',
63+
entry: 'http://localhost:7001/dymanicComponent/dymanicComponent.umd.js',
64+
styles: 'http://localhost:7001/dymanicComponent/dymanicComponent.css',
5865
},
5966
},
6067
{
6168
// 同名
6269
moduleName: 'dymanicComponent',
63-
entry: '/static/dymanicComponentCopy/dymanicComponent.umd.min.js',
64-
styles: '/static/dymanicComponentCopy/dymanicComponent.css',
70+
entry: 'http://localhost:7001/dymanicComponentCopy/dymanicComponent.umd.min.js',
71+
styles: 'http://localhost:7001/dymanicComponentCopy/dymanicComponent.css',
6572
},
6673
{
6774
// 错误 module name (执行正常)
6875
moduleName: 'wrongName',
69-
entry: '/static/dymanicComponentCopy/dymanicComponent.umd.min.js',
76+
entry: 'http://localhost:7001/dymanicComponentCopy/dymanicComponent.umd.min.js',
7077
},
7178
{
7279
// 错误 entry (执行 error)
@@ -79,14 +86,16 @@ app
7986
// },
8087
],
8188
{
89+
// sync: true,
8290
success: () => {
8391
app.$mount('#app');
8492
},
8593
error(msg, module) {
94+
// eslint-disable-next-line no-console
8695
console.warn(msg, module);
8796
},
8897
},
8998
)
9099
.then(() => {
91-
// then won't exec when success is set in options
100+
// then won't exec when success set up
92101
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const path = require('path');
2+
const express = require('express');
3+
const app = express();
4+
5+
const ipAddress = process.env.MODULE_IP_ADDRESS || '127.0.0.1';
6+
const port = process.env.MODULE_PORT || 7001;
7+
8+
app.use('/', express.static(path.join(__dirname, './dist')));
9+
10+
// eslint-disable-next-line no-console
11+
app.listen(port, ipAddress, () => console.log(`Module server is listening on: ${ipAddress}:${port}`));

0 commit comments

Comments
 (0)