@module-federation/nextjs-mf 5.4.0 → 5.4.1
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/ModuleFederationPlugin.js +3 -1
- package/lib/NextFederationPlugin.js +29 -43
- package/lib/_virtual/Template.js +7 -0
- package/lib/_virtual/UrlNode.js +9 -0
- package/lib/_virtual/_fast-glob.js +16 -0
- package/lib/_virtual/_fs.js +16 -0
- package/lib/_virtual/_path.js +6 -1
- package/lib/_virtual/_webpack-sources.js +16 -0
- package/lib/_virtual/fs.js +0 -3
- package/lib/_virtual/helpers.js +7 -0
- package/lib/_virtual/nextPageMapLoader.js +7 -0
- package/lib/build-utils.js +176 -0
- package/lib/dependencies/webpack/lib/Template.js +437 -0
- package/lib/index.js +1 -1
- package/lib/internal.js +25 -12
- package/lib/loaders/UrlNode.js +9 -1
- package/lib/loaders/fixImageLoader.js +14 -8
- package/lib/loaders/helpers.js +16 -3
- package/lib/loaders/nextPageMapLoader.js +26 -5
- package/lib/plugins/DevHmrFixInvalidPongPlugin.js +9 -1
- package/lib/utils.js +12 -2
- package/package.json +4 -2
- package/lib/node-plugin/streaming/CommonJsChunkLoadingPlugin.js +0 -92
- package/lib/node-plugin/streaming/LoadFileChunkLoadingRuntimeModule.js +0 -412
- package/lib/node-plugin/streaming/NodeRuntime.js +0 -247
- package/lib/node-plugin/streaming/index.js +0 -44
- package/lib/node-plugin/streaming/loadScript.js +0 -57
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
/*
|
|
4
6
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
5
7
|
Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy
|
|
@@ -79,4 +81,4 @@ class ModuleFederationPlugin {
|
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
exports["default"] = ModuleFederationPlugin;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var require$$1 = require('fs');
|
|
4
6
|
var path = require('path');
|
|
7
|
+
var helpers = require('./loaders/helpers.js');
|
|
8
|
+
var nextPageMapLoader = require('./loaders/nextPageMapLoader.js');
|
|
9
|
+
var DevHmrFixInvalidPongPlugin = require('./plugins/DevHmrFixInvalidPongPlugin.js');
|
|
5
10
|
var internal = require('./internal.js');
|
|
6
|
-
var index = require('./node-plugin/streaming/index.js');
|
|
7
|
-
var NodeRuntime = require('./node-plugin/streaming/NodeRuntime.js');
|
|
8
11
|
var ModuleFederationPlugin = require('./ModuleFederationPlugin.js');
|
|
9
12
|
|
|
10
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
14
|
|
|
12
|
-
var
|
|
15
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
13
16
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
14
17
|
|
|
15
18
|
/*
|
|
@@ -17,13 +20,6 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
|
17
20
|
Author Zackary Jackson @ScriptedAlchemy
|
|
18
21
|
*/
|
|
19
22
|
'use strict';
|
|
20
|
-
const {
|
|
21
|
-
injectRuleLoader,
|
|
22
|
-
hasLoader,
|
|
23
|
-
toDisplayErrors,
|
|
24
|
-
} = require('./loaders/helpers');
|
|
25
|
-
const { exposeNextjsPages } = require('./loaders/nextPageMapLoader');
|
|
26
|
-
const DevHmrFixInvalidPongPlugin = require('./plugins/DevHmrFixInvalidPongPlugin');
|
|
27
23
|
|
|
28
24
|
const CHILD_PLUGIN_NAME = 'ChildFederationPlugin';
|
|
29
25
|
|
|
@@ -128,7 +124,7 @@ class ChildFederationPlugin {
|
|
|
128
124
|
};
|
|
129
125
|
|
|
130
126
|
// using ModuleFederationPlugin does not work, i had to fork because of afterPlugins hook on containerPlugin.
|
|
131
|
-
const FederationPlugin = ModuleFederationPlugin;
|
|
127
|
+
const FederationPlugin = ModuleFederationPlugin["default"];
|
|
132
128
|
|
|
133
129
|
const federationPluginOptions = {
|
|
134
130
|
// library: {type: 'var', name: buildName},
|
|
@@ -137,7 +133,7 @@ class ChildFederationPlugin {
|
|
|
137
133
|
exposes: {
|
|
138
134
|
...this._options.exposes,
|
|
139
135
|
...(this._extraOptions.exposePages
|
|
140
|
-
? exposeNextjsPages(compiler.options.context)
|
|
136
|
+
? nextPageMapLoader.exposeNextjsPages(compiler.options.context)
|
|
141
137
|
: {}),
|
|
142
138
|
},
|
|
143
139
|
runtime: false,
|
|
@@ -165,8 +161,11 @@ class ChildFederationPlugin {
|
|
|
165
161
|
new AddRuntimeRequirementToPromiseExternal(),
|
|
166
162
|
];
|
|
167
163
|
} else if (compiler.options.name === 'server') {
|
|
164
|
+
const StreamingTargetPlugin = require('../node-plugin/streaming').default;
|
|
165
|
+
const NodeFederationPlugin = require('../node-plugin/streaming/NodeRuntime').default;
|
|
166
|
+
|
|
168
167
|
plugins = [
|
|
169
|
-
new
|
|
168
|
+
new NodeFederationPlugin(federationPluginOptions, {ModuleFederationPlugin: FederationPlugin}),
|
|
170
169
|
new webpack.node.NodeTemplatePlugin(childOutput),
|
|
171
170
|
//TODO: Externals function needs to internalize any shared module for host and remote build
|
|
172
171
|
new webpack.ExternalsPlugin(compiler.options.externalsType, [
|
|
@@ -178,7 +177,7 @@ class ChildFederationPlugin {
|
|
|
178
177
|
'react/jsx-dev-runtime',
|
|
179
178
|
]),
|
|
180
179
|
// new LoaderTargetPlugin('async-node'),
|
|
181
|
-
new
|
|
180
|
+
new StreamingTargetPlugin(federationPluginOptions, webpack),
|
|
182
181
|
new LibraryPlugin(federationPluginOptions.library.type),
|
|
183
182
|
// new webpack.DefinePlugin({
|
|
184
183
|
// 'process.env.REMOTES': JSON.stringify(this._options.remotes),
|
|
@@ -198,9 +197,9 @@ class ChildFederationPlugin {
|
|
|
198
197
|
// next-image-loader fix which adds remote's hostname to the assets url
|
|
199
198
|
if (
|
|
200
199
|
this._extraOptions.enableImageLoaderFix &&
|
|
201
|
-
hasLoader(rule, 'next-image-loader')
|
|
200
|
+
helpers.hasLoader(rule, 'next-image-loader')
|
|
202
201
|
) {
|
|
203
|
-
injectRuleLoader(rule, {
|
|
202
|
+
helpers.injectRuleLoader(rule, {
|
|
204
203
|
loader: path__default["default"].resolve(__dirname, './loaders/fixImageLoader.js'),
|
|
205
204
|
});
|
|
206
205
|
}
|
|
@@ -208,9 +207,9 @@ class ChildFederationPlugin {
|
|
|
208
207
|
// url-loader fix for which adds remote's hostname to the assets url
|
|
209
208
|
if (
|
|
210
209
|
this._extraOptions.enableUrlLoaderFix &&
|
|
211
|
-
hasLoader(rule, 'url-loader')
|
|
210
|
+
helpers.hasLoader(rule, 'url-loader')
|
|
212
211
|
) {
|
|
213
|
-
injectRuleLoader({
|
|
212
|
+
helpers.injectRuleLoader({
|
|
214
213
|
loader: path__default["default"].resolve(__dirname, './loaders/fixUrlLoader.js'),
|
|
215
214
|
});
|
|
216
215
|
}
|
|
@@ -219,7 +218,7 @@ class ChildFederationPlugin {
|
|
|
219
218
|
childCompiler.options.optimization.runtimeChunk = false;
|
|
220
219
|
// no custom chunk splitting should be derived from host (next)
|
|
221
220
|
delete childCompiler.options.optimization.splitChunks;
|
|
222
|
-
childCompiler.outputFileSystem =
|
|
221
|
+
childCompiler.outputFileSystem = require$$1__default["default"];
|
|
223
222
|
|
|
224
223
|
if (compiler.options.optimization.minimize) {
|
|
225
224
|
for (const minimizer of compiler.options.optimization.minimizer) {
|
|
@@ -329,7 +328,7 @@ class ChildFederationPlugin {
|
|
|
329
328
|
}
|
|
330
329
|
if (stats && stats.hasErrors()) {
|
|
331
330
|
compilation.errors.push(
|
|
332
|
-
new Error(toDisplayErrors(stats.compilation.errors))
|
|
331
|
+
new Error(helpers.toDisplayErrors(stats.compilation.errors))
|
|
333
332
|
);
|
|
334
333
|
}
|
|
335
334
|
});
|
|
@@ -349,7 +348,7 @@ class ChildFederationPlugin {
|
|
|
349
348
|
}
|
|
350
349
|
if (stats && stats.hasErrors()) {
|
|
351
350
|
compilation.errors.push(
|
|
352
|
-
new Error(toDisplayErrors(stats.compilation.errors))
|
|
351
|
+
new Error(helpers.toDisplayErrors(stats.compilation.errors))
|
|
353
352
|
);
|
|
354
353
|
rej();
|
|
355
354
|
}
|
|
@@ -365,7 +364,7 @@ class ChildFederationPlugin {
|
|
|
365
364
|
}
|
|
366
365
|
if (stats && stats.hasErrors()) {
|
|
367
366
|
compilation.errors.push(
|
|
368
|
-
new Error(toDisplayErrors(stats.compilation.errors))
|
|
367
|
+
new Error(helpers.toDisplayErrors(stats.compilation.errors))
|
|
369
368
|
);
|
|
370
369
|
}
|
|
371
370
|
});
|
|
@@ -438,7 +437,8 @@ class NextFederationPlugin {
|
|
|
438
437
|
console.error('[nextjs-mf] WARNING: SSR IS NOT FULLY SUPPORTED YET, Only use pluign on client builds');
|
|
439
438
|
// target false because we use our own target for node env
|
|
440
439
|
compiler.options.target = false;
|
|
441
|
-
|
|
440
|
+
const StreamingTargetPlugin = require('../node-plugin/streaming').default;
|
|
441
|
+
new StreamingTargetPlugin(this._options, webpack).apply(compiler);
|
|
442
442
|
this._options.library = {};
|
|
443
443
|
this._options.library.type = 'commonjs-module';
|
|
444
444
|
this._options.library.name = this._options.name;
|
|
@@ -457,20 +457,9 @@ class NextFederationPlugin {
|
|
|
457
457
|
loader: path__default["default"].resolve(__dirname, './loaders/patchNextClientPageLoader'),
|
|
458
458
|
});
|
|
459
459
|
}
|
|
460
|
+
|
|
460
461
|
if (this._options.remotes) {
|
|
461
|
-
|
|
462
|
-
(acc, remote) => {
|
|
463
|
-
if (remote[1].includes('@')) {
|
|
464
|
-
const [url, global] = internal.extractUrlAndGlobal(remote[1]);
|
|
465
|
-
acc[remote[0]] = internal.generateRemoteTemplate(url, global);
|
|
466
|
-
return acc;
|
|
467
|
-
}
|
|
468
|
-
acc[remote[0]] = remote[1];
|
|
469
|
-
return acc;
|
|
470
|
-
},
|
|
471
|
-
{}
|
|
472
|
-
);
|
|
473
|
-
this._options.remotes = parsedRemotes;
|
|
462
|
+
this._options.remotes = internal.parseRemotes(this._options.remotes);
|
|
474
463
|
}
|
|
475
464
|
if (this._options.library) {
|
|
476
465
|
console.error('[mf] you cannot set custom library');
|
|
@@ -488,11 +477,8 @@ class NextFederationPlugin {
|
|
|
488
477
|
'process.env.CURRENT_HOST': JSON.stringify(this._options.name),
|
|
489
478
|
}).apply(compiler);
|
|
490
479
|
|
|
480
|
+
const ModuleFederationPlugin = isServer ? require('../node-plugin/streaming/NodeRuntime').default : webpack.container.ModuleFederationPlugin;
|
|
491
481
|
|
|
492
|
-
const ModuleFederationPlugin = {
|
|
493
|
-
client: webpack.container.ModuleFederationPlugin,
|
|
494
|
-
server: NodeRuntime,
|
|
495
|
-
}[compiler.options.name];
|
|
496
482
|
// ignore edge runtime and middleware builds
|
|
497
483
|
if (ModuleFederationPlugin) {
|
|
498
484
|
const internalShare = internal.reKeyHostShared(this._options.shared);
|
|
@@ -518,10 +504,10 @@ class NextFederationPlugin {
|
|
|
518
504
|
new ChildFederationPlugin(this._options, this._extraOptions).apply(compiler);
|
|
519
505
|
new AddRuntimeRequirementToPromiseExternal().apply(compiler);
|
|
520
506
|
if (compiler.options.mode === 'development') {
|
|
521
|
-
new DevHmrFixInvalidPongPlugin().apply(compiler);
|
|
507
|
+
new DevHmrFixInvalidPongPlugin["default"]().apply(compiler);
|
|
522
508
|
}
|
|
523
509
|
}
|
|
524
510
|
}
|
|
525
511
|
}
|
|
526
512
|
|
|
527
|
-
|
|
513
|
+
exports["default"] = NextFederationPlugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var require$$0 = require('fast-glob');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, 'default', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return require$$0__default["default"]; }
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var require$$1 = require('fs');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, 'default', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return require$$1__default["default"]; }
|
|
16
|
+
});
|
package/lib/_virtual/_path.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var path = require('path');
|
|
4
6
|
|
|
5
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -8,4 +10,7 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Object.defineProperty(exports, 'default', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return path__default["default"]; }
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var require$$0 = require('webpack-sources');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, 'default', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return require$$0__default["default"]; }
|
|
16
|
+
});
|
package/lib/_virtual/fs.js
CHANGED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var internal = require('./internal.js');
|
|
6
|
+
require('./utils.js');
|
|
7
|
+
var Template = require('./dependencies/webpack/lib/Template.js');
|
|
8
|
+
|
|
9
|
+
const swc = require("@swc/core");
|
|
10
|
+
|
|
11
|
+
const transformInput = (code) => {
|
|
12
|
+
return swc.transformSync(code, {
|
|
13
|
+
// Some options cannot be specified in .swcrc
|
|
14
|
+
sourceMaps: false,
|
|
15
|
+
// Input files are treated as module by default.
|
|
16
|
+
isModule: false,
|
|
17
|
+
// All options below can be configured via .swcrc
|
|
18
|
+
jsc: {
|
|
19
|
+
"loose": false,
|
|
20
|
+
target: "es5",
|
|
21
|
+
"externalHelpers": false,
|
|
22
|
+
parser: {
|
|
23
|
+
syntax: "ecmascript",
|
|
24
|
+
},
|
|
25
|
+
transform: {},
|
|
26
|
+
},
|
|
27
|
+
}).code
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//urlAndGlobal is defined in the template wrapper
|
|
31
|
+
const remoteTemplate = function() {
|
|
32
|
+
const index = urlAndGlobal.indexOf('@');
|
|
33
|
+
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
34
|
+
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
|
35
|
+
}
|
|
36
|
+
var remote = {url: urlAndGlobal.substring(index + 1), global: urlAndGlobal.substring(0, index)};
|
|
37
|
+
return new Promise(function (resolve, reject) {
|
|
38
|
+
var __webpack_error__ = new Error();
|
|
39
|
+
if (typeof window[remote.global] !== 'undefined') {
|
|
40
|
+
return resolve();
|
|
41
|
+
}
|
|
42
|
+
__webpack_require__.l(remote.url, function (event) {
|
|
43
|
+
if (typeof window[remote.global] !== 'undefined') {
|
|
44
|
+
return resolve();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
48
|
+
var realSrc = event && event.target && event.target.src;
|
|
49
|
+
__webpack_error__.message = 'Loading script failed.(' + errorType + ': ' + realSrc + ' or global var ' + remote.global + ')';
|
|
50
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
51
|
+
__webpack_error__.type = errorType;
|
|
52
|
+
__webpack_error__.request = realSrc;
|
|
53
|
+
reject(__webpack_error__);
|
|
54
|
+
}, remote.global);
|
|
55
|
+
}).then(function () {
|
|
56
|
+
const proxy = {
|
|
57
|
+
get: window[remote.global].get,
|
|
58
|
+
init: function (shareScope) {
|
|
59
|
+
const handler = {
|
|
60
|
+
get(target, prop) {
|
|
61
|
+
if (target[prop]) {
|
|
62
|
+
Object.values(target[prop]).forEach(function (o) {
|
|
63
|
+
if (o.from === '_N_E') {
|
|
64
|
+
o.loaded = 1;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return target[prop]
|
|
69
|
+
},
|
|
70
|
+
set(target, property, value, receiver) {
|
|
71
|
+
if (target[property]) {
|
|
72
|
+
return target[property]
|
|
73
|
+
}
|
|
74
|
+
target[property] = value;
|
|
75
|
+
return true
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
window[remote.global].init(new Proxy(shareScope, handler));
|
|
80
|
+
} catch (e) {
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
window[remote.global].__initialized = true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
if (!window[remote.global].__initialized) {
|
|
87
|
+
proxy.init();
|
|
88
|
+
}
|
|
89
|
+
return proxy
|
|
90
|
+
})
|
|
91
|
+
};
|
|
92
|
+
const promiseFactory = (factory) => {
|
|
93
|
+
|
|
94
|
+
const wrapper = `new Promise(${factory.toString()})`;
|
|
95
|
+
if (wrapper.includes('require(', 'import(', 'import ')) {
|
|
96
|
+
throw new Error('promiseFactory does not support require, import, or import statements');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const template = Template["default"].asString([
|
|
100
|
+
'function() {',
|
|
101
|
+
Template["default"].indent([
|
|
102
|
+
wrapper
|
|
103
|
+
]),
|
|
104
|
+
'}',
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
return template
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const promiseTemplate = (remote, ...otherPromises) => {
|
|
111
|
+
let promises = '';
|
|
112
|
+
if (otherPromises) {
|
|
113
|
+
promises = otherPromises.map((p) => {
|
|
114
|
+
return Template["default"].getFunctionContent(promiseFactory(p))
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
let remoteSyntax = remote;
|
|
121
|
+
let remoteFactory = internal.parseRemoteSyntax;
|
|
122
|
+
|
|
123
|
+
if(typeof remote === 'function' || remote.startsWith('function') || remote.startsWith('(')) {
|
|
124
|
+
remoteSyntax = Template["default"].getFunctionContent(promiseFactory(remote));
|
|
125
|
+
remoteFactory = (remoteSyntax) => {
|
|
126
|
+
return Template["default"].asString([
|
|
127
|
+
`${remoteSyntax}.then(function(urlAndGlobal) {`,
|
|
128
|
+
Template["default"].indent([
|
|
129
|
+
Template["default"].getFunctionContent(remoteTemplate)
|
|
130
|
+
]),
|
|
131
|
+
'})'
|
|
132
|
+
])
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
const allPromises = [
|
|
138
|
+
remoteFactory(remoteSyntax),
|
|
139
|
+
...promises
|
|
140
|
+
].join(',\n');
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
return Template["default"].asString([
|
|
144
|
+
'promise new Promise(function(resolve, reject) {',
|
|
145
|
+
transformInput(Template["default"].indent([
|
|
146
|
+
'Promise.all([',
|
|
147
|
+
Template["default"].indent(allPromises),
|
|
148
|
+
']).then(function(promises) {',
|
|
149
|
+
Template["default"].indent([
|
|
150
|
+
'resolve(promises[0]);',
|
|
151
|
+
]),
|
|
152
|
+
'})',
|
|
153
|
+
])),
|
|
154
|
+
'})',
|
|
155
|
+
])
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// remotes: {
|
|
159
|
+
// shop: promiseTemplate('global@url', (resolve,reject) => {}),
|
|
160
|
+
// shop: promiseTemplate(
|
|
161
|
+
// // can also be a string if it needs to be computed in scope
|
|
162
|
+
// `(resolve, reject) => {
|
|
163
|
+
// resolve("${remotes.shop}");
|
|
164
|
+
// }`,
|
|
165
|
+
// (resolve,reject)=>{
|
|
166
|
+
// console.log('runing other promise');
|
|
167
|
+
// setTimeout(() => {
|
|
168
|
+
// console.log('resolving promise');
|
|
169
|
+
// resolve();
|
|
170
|
+
// } , 1000);
|
|
171
|
+
// }),
|
|
172
|
+
// checkout: remotes.checkout,
|
|
173
|
+
// },
|
|
174
|
+
|
|
175
|
+
exports.promiseFactory = promiseFactory;
|
|
176
|
+
exports.promiseTemplate = promiseTemplate;
|