@twilio/flex-plugin-webpack5 0.0.1 → 7.1.4-alpha.202610140448
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/LICENSE +21 -0
- package/README.md +39 -3
- package/dist/compiler.d.ts +38 -0
- package/dist/compiler.js +252 -0
- package/dist/compiler.js.map +1 -0
- package/dist/devServer/ipcServer.d.ts +73 -0
- package/dist/devServer/ipcServer.js +253 -0
- package/dist/devServer/ipcServer.js.map +1 -0
- package/dist/devServer/pluginServer.d.ts +79 -0
- package/dist/devServer/pluginServer.js +313 -0
- package/dist/devServer/pluginServer.js.map +1 -0
- package/dist/devServer/webpackDevServer.d.ts +11 -0
- package/dist/devServer/webpackDevServer.js +110 -0
- package/dist/devServer/webpackDevServer.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/DelayRenderStaticPlugin.d.ts +4 -0
- package/dist/plugins/DelayRenderStaticPlugin.js +64 -0
- package/dist/plugins/DelayRenderStaticPlugin.js.map +1 -0
- package/dist/prints/devServerSuccessful.d.ts +12 -0
- package/dist/prints/devServerSuccessful.js +48 -0
- package/dist/prints/devServerSuccessful.js.map +1 -0
- package/dist/prints/dotEnvIncorrectVariable.d.ts +2 -0
- package/dist/prints/dotEnvIncorrectVariable.js +11 -0
- package/dist/prints/dotEnvIncorrectVariable.js.map +1 -0
- package/dist/prints/index.d.ts +3 -0
- package/dist/prints/index.js +13 -0
- package/dist/prints/index.js.map +1 -0
- package/dist/prints/remotePluginNotFound.d.ts +9 -0
- package/dist/prints/remotePluginNotFound.js +57 -0
- package/dist/prints/remotePluginNotFound.js.map +1 -0
- package/dist/webpack/clientVariables.d.ts +25 -0
- package/dist/webpack/clientVariables.js +107 -0
- package/dist/webpack/clientVariables.js.map +1 -0
- package/dist/webpack/pnpTs.d.ts +10 -0
- package/dist/webpack/pnpTs.js +14 -0
- package/dist/webpack/pnpTs.js.map +1 -0
- package/dist/webpack/webpack.config.d.ts +74 -0
- package/dist/webpack/webpack.config.js +569 -0
- package/dist/webpack/webpack.config.js.map +1 -0
- package/dist/webpack/webpack.dev.d.ts +22 -0
- package/dist/webpack/webpack.dev.js +80 -0
- package/dist/webpack/webpack.dev.js.map +1 -0
- package/package.json +78 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2018, Twilio, Inc. <help@twilio.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+
[](../../LICENSE)
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
# Flex Plugin Webpack 5
|
|
6
|
+
|
|
7
|
+
Webpack 5 configurations for building and running Flex plugins - the Webpack 5 counterpart to
|
|
8
|
+
[`@twilio/flex-plugin-webpack`](../flex-plugin-webpack), which remains on Webpack 4 and is still the default.
|
|
9
|
+
|
|
10
|
+
This package is not used directly; it is consumed by
|
|
11
|
+
[`@twilio/flex-plugin-scripts`](../flex-plugin-scripts), which selects between the two webpack
|
|
12
|
+
major versions based on the `--wp5` flag passed to the `flex-plugin build`/`flex-plugin start`
|
|
13
|
+
scripts (surfaced through the `twilio flex:plugins:build`/`twilio flex:plugins:start` CLI commands
|
|
14
|
+
as `--wp5`).
|
|
15
|
+
|
|
16
|
+
Because a project can only ever depend on one version of a given npm package at a time, every
|
|
17
|
+
export from this package is named with a `Wp5` suffix (`webpackFactoryWp5`, `compilerWp5`,
|
|
18
|
+
`WebpackTypeWp5`, and so on) so it can be imported side by side with `@twilio/flex-plugin-webpack`'s
|
|
19
|
+
un-suffixed equivalents without collisions. Its Webpack-version-specific dependencies (`webpack`,
|
|
20
|
+
`webpack-dev-server`, `html-webpack-plugin`, `terser-webpack-plugin`, etc.) are similarly installed
|
|
21
|
+
under aliased package names (e.g. `webpack5`, `html-webpack-plugin-wp5`) so both webpack majors can
|
|
22
|
+
coexist in the same `node_modules` tree without version conflicts.
|
|
23
|
+
|
|
24
|
+
## Notable differences from `@twilio/flex-plugin-webpack`
|
|
25
|
+
|
|
26
|
+
- Uses `fork-ts-checker-webpack-plugin@^9`, a modern, actively maintained major version compatible
|
|
27
|
+
with current TypeScript syntax - unlike webpack 4's still-pinned `^4.1.6`. TypeScript type-checking
|
|
28
|
+
prefers the **plugin project's own installed TypeScript** version over this package's own, so a
|
|
29
|
+
plugin's dependencies (e.g. newer `@twilio/flex-ui`/`@apollo/client` releases using modern
|
|
30
|
+
`.d.ts` syntax) are checked with a compatible compiler rather than failing against a stale one.
|
|
31
|
+
- Targets Webpack 5's APIs directly (asset modules, the new `Stats` schema, `processAssets` hooks)
|
|
32
|
+
rather than Webpack 4's.
|
|
33
|
+
|
|
34
|
+
## Contributors
|
|
35
|
+
|
|
36
|
+
Thank you to all the lovely contributors to this project. Please check the main repository to see [all contributors](https://github.com/twilio/flex-plugin-builder#contributors).
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
[MIT](../../LICENSE)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AsyncSeriesHook, SyncHook } from 'tapable';
|
|
2
|
+
import { Compiler as WebpackCompiler, Configuration, Stats } from 'webpack5';
|
|
3
|
+
import { OnCompileCompletePayload } from './devServer/ipcServer';
|
|
4
|
+
import { OnRemotePlugins } from './devServer/pluginServer';
|
|
5
|
+
type OnCompile = (payload: OnCompileCompletePayload) => void;
|
|
6
|
+
interface CompilerHooks {
|
|
7
|
+
beforeCompile: AsyncSeriesHook<[any]>;
|
|
8
|
+
done: AsyncSeriesHook<Stats>;
|
|
9
|
+
invalid: SyncHook<[null | string, number]>;
|
|
10
|
+
}
|
|
11
|
+
interface Hook extends CompilerHooks {
|
|
12
|
+
tsCompiled: SyncHook<string[], string[]>;
|
|
13
|
+
}
|
|
14
|
+
export interface Compiler extends WebpackCompiler {
|
|
15
|
+
hooks: Hook;
|
|
16
|
+
}
|
|
17
|
+
interface CompilerRenderer {
|
|
18
|
+
onCompile: OnCompile;
|
|
19
|
+
onRemotePlugins: OnRemotePlugins;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a webpack compiler
|
|
23
|
+
*
|
|
24
|
+
* @param config the Webpack configuration
|
|
25
|
+
* @param devServer whether to run the devserver or not
|
|
26
|
+
* @param type the webpack compile type
|
|
27
|
+
* @param localPlugins the names of plugins to run locally
|
|
28
|
+
*/
|
|
29
|
+
declare const _default: (config: Configuration, devServer: boolean, isJavaScriptServer: boolean, onCompile: OnCompile) => Compiler;
|
|
30
|
+
export default _default;
|
|
31
|
+
/**
|
|
32
|
+
* Prints the errors and warnings or a successful message when compilation finishes
|
|
33
|
+
* @param port the port the server is running on
|
|
34
|
+
* @param localPlugins the local plugins running
|
|
35
|
+
* @param showSuccessMsg whether to show succecss message or not
|
|
36
|
+
* @param hasRemote whether there are any remote plugins
|
|
37
|
+
*/
|
|
38
|
+
export declare const compilerRenderer: (port: number, localPlugins: string[], showSuccessMsg: boolean, hasRemote: boolean) => CompilerRenderer;
|
package/dist/compiler.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* c8 ignore start */
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
30
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
51
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
52
|
+
if (!m) return o;
|
|
53
|
+
var i = m.call(o), r, ar = [], e;
|
|
54
|
+
try {
|
|
55
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
56
|
+
}
|
|
57
|
+
catch (error) { e = { error: error }; }
|
|
58
|
+
finally {
|
|
59
|
+
try {
|
|
60
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
61
|
+
}
|
|
62
|
+
finally { if (e) throw e.error; }
|
|
63
|
+
}
|
|
64
|
+
return ar;
|
|
65
|
+
};
|
|
66
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
67
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
68
|
+
if (ar || !(i in from)) {
|
|
69
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
70
|
+
ar[i] = from[i];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
74
|
+
};
|
|
75
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
76
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
77
|
+
};
|
|
78
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
79
|
+
exports.compilerRenderer = void 0;
|
|
80
|
+
var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
|
|
81
|
+
var errors_1 = require("@twilio/flex-dev-utils/dist/errors");
|
|
82
|
+
var tapable_1 = require("tapable");
|
|
83
|
+
var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
84
|
+
var webpack5_1 = __importDefault(require("webpack5"));
|
|
85
|
+
var fs_1 = require("@twilio/flex-dev-utils/dist/fs");
|
|
86
|
+
var format_webpack_messages_1 = __importDefault(require("@k88/format-webpack-messages"));
|
|
87
|
+
var urls_1 = require("@twilio/flex-dev-utils/dist/urls");
|
|
88
|
+
var prints_1 = require("./prints");
|
|
89
|
+
// Holds all compilation errors
|
|
90
|
+
var results = {};
|
|
91
|
+
/**
|
|
92
|
+
* Creates a webpack compiler
|
|
93
|
+
*
|
|
94
|
+
* @param config the Webpack configuration
|
|
95
|
+
* @param devServer whether to run the devserver or not
|
|
96
|
+
* @param type the webpack compile type
|
|
97
|
+
* @param localPlugins the names of plugins to run locally
|
|
98
|
+
*/
|
|
99
|
+
/* c8 ignore next */
|
|
100
|
+
exports.default = (function (config, devServer, isJavaScriptServer, onCompile) {
|
|
101
|
+
flex_dev_utils_1.logger.debug('Creating webpack compiler');
|
|
102
|
+
try {
|
|
103
|
+
var compiler_1 = (0, webpack5_1.default)(config);
|
|
104
|
+
if (!Object.isExtensible(compiler_1.hooks)) {
|
|
105
|
+
compiler_1.hooks = __assign({}, compiler_1.hooks);
|
|
106
|
+
}
|
|
107
|
+
compiler_1.hooks.tsCompiled = new tapable_1.SyncHook(['warnings', 'errors']);
|
|
108
|
+
// For build, we don't need to tap into any hooks
|
|
109
|
+
if (!devServer) {
|
|
110
|
+
return compiler_1;
|
|
111
|
+
}
|
|
112
|
+
var tsMessagesPromise_1;
|
|
113
|
+
var tsMessagesResolver_1;
|
|
114
|
+
if ((0, fs_1.getPaths)().app.isTSProject()) {
|
|
115
|
+
compiler_1.hooks.beforeCompile.tap('beforeCompile', function () {
|
|
116
|
+
tsMessagesPromise_1 = new Promise(function (resolve) {
|
|
117
|
+
tsMessagesResolver_1 = function (msgs) { return resolve(msgs); };
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
/*
|
|
121
|
+
* fork-ts-checker-webpack-plugin resolves its own nested copy of the `webpack` peer dependency,
|
|
122
|
+
* which TypeScript sees as a distinct (though compatible) Compiler type from our own webpack5 import.
|
|
123
|
+
*/
|
|
124
|
+
fork_ts_checker_webpack_plugin_1.default.getCompilerHooks(compiler_1).issues.tap('afterTSCheck', function (issues) {
|
|
125
|
+
var format = function (issue) {
|
|
126
|
+
var _a;
|
|
127
|
+
var location = issue.location ? ":".concat(issue.location.start.line, ":").concat(issue.location.start.column) : '';
|
|
128
|
+
return "".concat((_a = issue.file) !== null && _a !== void 0 ? _a : '').concat(location, "\n").concat(issue.code, ": ").concat(issue.message);
|
|
129
|
+
};
|
|
130
|
+
if (tsMessagesResolver_1) {
|
|
131
|
+
tsMessagesResolver_1({
|
|
132
|
+
errors: issues.filter(function (issue) { return issue.severity === 'error'; }).map(format),
|
|
133
|
+
warnings: issues.filter(function (issue) { return issue.severity === 'warning'; }).map(format),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// issues is a SyncWaterfallHook - must return the (possibly filtered) issues to pass along
|
|
137
|
+
return issues;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// invalid is `bundle invalidated` and is invoked when files are modified in dev-server.
|
|
141
|
+
compiler_1.hooks.invalid.tap('invalid', function () {
|
|
142
|
+
flex_dev_utils_1.logger.clearTerminal();
|
|
143
|
+
flex_dev_utils_1.logger.info("Re-compiling **".concat((0, fs_1.getPaths)().app.name, "**"));
|
|
144
|
+
});
|
|
145
|
+
compiler_1.hooks.done.tap('done', function (stats) { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var result, delayedMsg, messages, config;
|
|
147
|
+
var _a, _b;
|
|
148
|
+
var _c, _d;
|
|
149
|
+
return __generator(this, function (_e) {
|
|
150
|
+
switch (_e.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
result = stats === null || stats === void 0 ? void 0 : stats.toJson({ all: false, errors: true, warnings: true });
|
|
153
|
+
if (!((0, fs_1.getPaths)().app.isTSProject() && !stats.hasErrors())) return [3 /*break*/, 2];
|
|
154
|
+
delayedMsg = setTimeout(function () {
|
|
155
|
+
flex_dev_utils_1.logger.notice('Waiting for Typescript check results...');
|
|
156
|
+
}, 100);
|
|
157
|
+
return [4 /*yield*/, tsMessagesPromise_1];
|
|
158
|
+
case 1:
|
|
159
|
+
messages = _e.sent();
|
|
160
|
+
clearTimeout(delayedMsg);
|
|
161
|
+
// Push ts-compile errors into compiler
|
|
162
|
+
(_c = result === null || result === void 0 ? void 0 : result.errors) === null || _c === void 0 ? void 0 : _c.push.apply(_c, __spreadArray([], __read(messages.errors), false));
|
|
163
|
+
(_a = stats.compilation.errors).push.apply(_a, __spreadArray([], __read(messages.errors), false));
|
|
164
|
+
(_d = result === null || result === void 0 ? void 0 : result.warnings) === null || _d === void 0 ? void 0 : _d.push.apply(_d, __spreadArray([], __read(messages.warnings), false));
|
|
165
|
+
(_b = stats.compilation.warnings).push.apply(_b, __spreadArray([], __read(messages.warnings), false));
|
|
166
|
+
compiler_1.hooks.tsCompiled.call(messages.warnings, messages.errors);
|
|
167
|
+
_e.label = 2;
|
|
168
|
+
case 2:
|
|
169
|
+
config = (0, fs_1.readRunPluginsJson)();
|
|
170
|
+
// Add the plugin to the loaded plugins configuration file
|
|
171
|
+
if (isJavaScriptServer) {
|
|
172
|
+
config.loadedPlugins.push((0, fs_1.getPaths)().app.name);
|
|
173
|
+
(0, fs_1.writeJSONFile)(config, (0, fs_1.getCliPaths)().localPluginsJsonPath);
|
|
174
|
+
}
|
|
175
|
+
// Check to see if the plugin is the last bundle to be loaded
|
|
176
|
+
onCompile({
|
|
177
|
+
result: result,
|
|
178
|
+
appName: (0, fs_1.getPaths)().app.name,
|
|
179
|
+
lastPluginBundle: config.plugins.length === config.loadedPlugins.length,
|
|
180
|
+
});
|
|
181
|
+
return [2 /*return*/];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}); });
|
|
185
|
+
return compiler_1;
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
// @ts-ignore
|
|
189
|
+
throw new errors_1.FlexPluginError("Failed to create a webpack compiler: ".concat(err.message));
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
/**
|
|
193
|
+
* Prints the errors and warnings or a successful message when compilation finishes
|
|
194
|
+
* @param port the port the server is running on
|
|
195
|
+
* @param localPlugins the local plugins running
|
|
196
|
+
* @param showSuccessMsg whether to show succecss message or not
|
|
197
|
+
* @param hasRemote whether there are any remote plugins
|
|
198
|
+
*/
|
|
199
|
+
var compilerRenderer = function (port, localPlugins, showSuccessMsg, hasRemote) {
|
|
200
|
+
var _a = (0, urls_1.getLocalAndNetworkUrls)(port), local = _a.local, network = _a.network;
|
|
201
|
+
var remotePlugins = [];
|
|
202
|
+
var serverSuccessful = function (list) {
|
|
203
|
+
list.forEach(function (l) {
|
|
204
|
+
if (!remotePlugins.some(function (r) { return r.name === l.name; })) {
|
|
205
|
+
remotePlugins.push(l);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
flex_dev_utils_1.logger.clearTerminal();
|
|
209
|
+
(0, prints_1.devServerSuccessful)(local, network, localPlugins, remotePlugins, hasRemote);
|
|
210
|
+
};
|
|
211
|
+
return {
|
|
212
|
+
onRemotePlugins: serverSuccessful,
|
|
213
|
+
onCompile: function (_a) {
|
|
214
|
+
var result = _a.result, appName = _a.appName;
|
|
215
|
+
flex_dev_utils_1.logger.clearTerminal();
|
|
216
|
+
results[appName] = result;
|
|
217
|
+
var isSuccessful = Object.values(results).every(function (r) { return r.errors && r.errors.length === 0 && r.warnings && r.warnings.length === 0; });
|
|
218
|
+
if (isSuccessful) {
|
|
219
|
+
if (showSuccessMsg) {
|
|
220
|
+
serverSuccessful([]);
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
Object.keys(results).forEach(function (name) {
|
|
225
|
+
var formatted = (0, format_webpack_messages_1.default)({
|
|
226
|
+
errors: results[name].errors,
|
|
227
|
+
warnings: results[name].warnings,
|
|
228
|
+
});
|
|
229
|
+
// Only show errors if both exist
|
|
230
|
+
if (results[name].errors.length) {
|
|
231
|
+
/*
|
|
232
|
+
* Most errors are duplicate of the same error
|
|
233
|
+
* So only show the first error
|
|
234
|
+
*/
|
|
235
|
+
formatted.errors.length = 1;
|
|
236
|
+
flex_dev_utils_1.logger.error("Failed to compile plugin ".concat(flex_dev_utils_1.logger.colors.red.bold(name), "."));
|
|
237
|
+
flex_dev_utils_1.logger.info(formatted.errors.join('\n'));
|
|
238
|
+
flex_dev_utils_1.logger.newline();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (results[name].warnings.length) {
|
|
242
|
+
flex_dev_utils_1.logger.warning("Compiled plugin ".concat(flex_dev_utils_1.logger.colors.yellow.bold(name), " with warning(s)."));
|
|
243
|
+
flex_dev_utils_1.logger.info(formatted.warnings.join('\n'));
|
|
244
|
+
flex_dev_utils_1.logger.newline();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
exports.compilerRenderer = compilerRenderer;
|
|
251
|
+
/* c8 ignore stop */
|
|
252
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":";AAAA,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErB,yDAAoE;AACpE,6DAAqE;AACrE,mCAAoD;AACpD,kGAAwE;AAExE,sDAAgH;AAChH,qDAA0G;AAC1G,yFAAiE;AACjE,yDAA0E;AAI1E,mCAA+C;AA6B/C,+BAA+B;AAC/B,IAAM,OAAO,GAAoB,EAAE,CAAC;AAEpC;;;;;;;GAOG;AACH,oBAAoB;AACpB,mBAAe,UACb,MAAqB,EACrB,SAAkB,EAClB,kBAA2B,EAC3B,SAAoB;IAEpB,uBAAM,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAE1C,IAAI;QACF,IAAM,UAAQ,GAAa,IAAA,kBAAO,EAAC,MAAM,CAAwB,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAQ,CAAC,KAAK,CAAC,EAAE;YACxC,UAAQ,CAAC,KAAK,gBAAQ,UAAQ,CAAC,KAAK,CAAE,CAAC;SACxC;QACD,UAAQ,CAAC,KAAK,CAAC,UAAU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;oBACtC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,MAA6B;oBACnD,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,QAA+B;iBACxD,CAAC,CAAC;gBAEH,iCAAiC;gBACjC,IAAK,OAAO,CAAC,IAAI,CAAC,CAAC,MAA8B,CAAC,MAAM,EAAE;oBACxD;;;uBAGG;oBACH,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;oBAE5B,uBAAM,CAAC,KAAK,CAAC,mCAA4B,uBAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAG,CAAC,CAAC;oBAC1E,uBAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;oBACzC,uBAAM,CAAC,OAAO,EAAE,CAAC;oBACjB,OAAO;iBACR;gBAED,IAAK,OAAO,CAAC,IAAI,CAAC,CAAC,QAAgC,CAAC,MAAM,EAAE;oBAC1D,uBAAM,CAAC,OAAO,CAAC,0BAAmB,uBAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAmB,CAAC,CAAC;oBACtF,uBAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC3C,uBAAM,CAAC,OAAO,EAAE,CAAC;iBAClB;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,gBAAgB,oBA+D3B;AACF,oBAAoB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import webpack from 'webpack5';
|
|
2
|
+
import * as self from './ipcServer';
|
|
3
|
+
import ToJsonOutput = webpack.StatsCompilation;
|
|
4
|
+
export declare enum IPCType {
|
|
5
|
+
onCompileComplete = "onCompileComplete",
|
|
6
|
+
onDevServerCrashed = "onDevServerCrashed",
|
|
7
|
+
onEmitAllCompilesComplete = "onEmitAllCompilesComplete"
|
|
8
|
+
}
|
|
9
|
+
export interface OnCompileCompletePayload {
|
|
10
|
+
result: ToJsonOutput;
|
|
11
|
+
appName: string;
|
|
12
|
+
lastPluginBundle: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface OnDevServerCrashedPayload {
|
|
15
|
+
exception: {
|
|
16
|
+
message: string;
|
|
17
|
+
stack?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface IPCPayload {
|
|
21
|
+
onCompileComplete: OnCompileCompletePayload;
|
|
22
|
+
onDevServerCrashed: OnDevServerCrashedPayload;
|
|
23
|
+
onEmitAllCompilesComplete: unknown;
|
|
24
|
+
}
|
|
25
|
+
type MessageCallback<T extends IPCType> = (payload: IPCPayload[T]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Processes the emit queue
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
export declare const _processEmitQueue: () => Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Processes on client connected
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
export declare const _onClientConnected: () => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Emits to the server
|
|
38
|
+
* @param type the event type
|
|
39
|
+
* @param payload the event payload
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
export declare const _emitToServer: <T extends self.IPCType>(type: T, payload: IPCPayload[T]) => Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Starts an IPC server
|
|
45
|
+
*/
|
|
46
|
+
export declare const startIPCServer: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Starts an IPC Client
|
|
49
|
+
*/
|
|
50
|
+
export declare const startIPCClient: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* onMessage event for the IPC server
|
|
53
|
+
* @param type
|
|
54
|
+
* @param callback
|
|
55
|
+
*/
|
|
56
|
+
export declare const onIPCServerMessage: <T extends self.IPCType>(type: T, callback: MessageCallback<T>) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Emits to the server that all of the JS Bundles have completed compiling
|
|
59
|
+
* @param payload
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
export declare const emitAllCompilesComplete: () => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Emits a compilation complete event
|
|
65
|
+
* @param payload
|
|
66
|
+
*/
|
|
67
|
+
export declare const emitCompileComplete: (payload: OnCompileCompletePayload) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Emits a dev-server failed event
|
|
70
|
+
* @param error
|
|
71
|
+
*/
|
|
72
|
+
export declare const emitDevServerCrashed: (error: Error) => Promise<void>;
|
|
73
|
+
export {};
|