@apployees-nx/webserver
Version:
A create-react-app inspired plugin for Nx, with SSR and PWA capabilities.
1,116 lines (997 loc) • 211 kB
JavaScript
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 108);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
module.exports = require("lodash");
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = require("path");
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = require("tslib");
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = require("typescript");
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = require("@nrwl/workspace");
/***/ }),
/* 5 */
/***/ (function(module, exports) {
module.exports = require("fs");
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = require("@angular-devkit/core");
/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return cssRegex; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cssModuleRegex; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return sassRegex; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return sassModuleRegex; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return lessRegex; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return lessModuleRegex; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getBaseLoaders; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getCSSModuleLocalIdent; });
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _import_transformer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74);
/*******************************************************************************
* © Apployees Inc., 2019
* All Rights Reserved.
******************************************************************************/
// style files regexes
var cssRegex = /\.css$/;
var cssModuleRegex = /\.module\.css$/;
var sassRegex = /\.(scss|sass)$/;
var sassModuleRegex = /\.module\.(scss|sass)$/;
var lessRegex = /\.less$/;
var lessModuleRegex = /\.module\.less$/;
function getBaseLoaders(options, context, esm, debug, // controls verbosity for babel
isEnvDevelopment, isEnvServer) {
var isEnvProduction = !isEnvDevelopment;
return [
// Disable require.ensure as it's not a standard language feature.
{ parser: { requireEnsure: false } },
{
test: /\.([jt])sx?$/,
loader: lodash__WEBPACK_IMPORTED_MODULE_0___default.a.isString(/*require.resolve*/(59)) ? /*require.resolve*/(59) : "ts-loader",
exclude: /node_modules/,
options: {
configFile: options.tsConfig,
silent: true,
transpileOnly: true,
// https://github.com/TypeStrong/ts-loader/pull/685
experimentalWatchApi: true,
compilerOptions: {
sourceMap: (isEnvServer && options.sourceMap) || isEnvDevelopment,
incremental: true,
tsBuildInfoFile: options.outputPath + (isEnvServer ? "server" : "client") + ".tsbuildinfo",
module: "esnext",
},
getCustomTransformers: function () { return ({
before: [Object(_import_transformer__WEBPACK_IMPORTED_MODULE_1__[/* importTransformer */ "a"])(options.importTransformers)],
}); },
},
},
];
}
function getCSSModuleLocalIdent(isEnvDevelopment) {
return isEnvDevelopment ? "[path][name]__[local]" : "[hash:base64]";
}
/***/ }),
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _lib_builder_sources__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "g", function() { return _lib_builder_sources__WEBPACK_IMPORTED_MODULE_0__["a"]; });
/* harmony import */ var _lib_builder_normalize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(50);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "i", function() { return _lib_builder_normalize__WEBPACK_IMPORTED_MODULE_1__["a"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "j", function() { return _lib_builder_normalize__WEBPACK_IMPORTED_MODULE_1__["b"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "k", function() { return _lib_builder_normalize__WEBPACK_IMPORTED_MODULE_1__["c"]; });
/* harmony import */ var _lib_builder_common_env_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(51);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _lib_builder_common_env_utils__WEBPACK_IMPORTED_MODULE_2__["a"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "f", function() { return _lib_builder_common_env_utils__WEBPACK_IMPORTED_MODULE_2__["b"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "h", function() { return _lib_builder_common_env_utils__WEBPACK_IMPORTED_MODULE_2__["c"]; });
/* harmony import */ var _lib_builder_common_plugins__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(53);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "e", function() { return _lib_builder_common_plugins__WEBPACK_IMPORTED_MODULE_3__["a"]; });
/* harmony import */ var _lib_generate_package_json_write_package_json__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(54);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "l", function() { return _lib_generate_package_json_write_package_json__WEBPACK_IMPORTED_MODULE_4__["a"]; });
/* harmony import */ var _lib_node_externals_externalized_imports__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(24);
/* harmony import */ var _lib_node_externals_node_externals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(55);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "d", function() { return _lib_node_externals_node_externals__WEBPACK_IMPORTED_MODULE_6__["a"]; });
/* harmony import */ var _lib_types_common_types__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(56);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _lib_types_common_types__WEBPACK_IMPORTED_MODULE_7__["a"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "b", function() { return _lib_types_common_types__WEBPACK_IMPORTED_MODULE_7__["b"]; });
/* harmony import */ var _lib_schematics_compatible_nx_version__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(57);
/*******************************************************************************
* © Apployees Inc., 2019
* All Rights Reserved.
******************************************************************************/
/***/ }),
/* 9 */,
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return extensions; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getAliases; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getStatsConfig; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return FILENAMES; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tslib__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
var extensions = [
".web.mjs",
".mjs",
".web.js",
".js",
".web.ts",
".ts",
".web.tsx",
".tsx",
".json",
".web.jsx",
".jsx",
];
function getAliases(replacements) {
return lodash__WEBPACK_IMPORTED_MODULE_1___default.a.extend({}, {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
"react-native": "react-native-web",
}, (replacements || []).reduce(function (aliases, replacement) {
var _a;
return (Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, aliases), (_a = {}, _a[replacement.replace] = replacement.with, _a)));
}, {}));
}
function getStatsConfig(options) {
return {
hash: true,
timings: false,
cached: false,
cachedAssets: false,
modules: false,
warnings: true,
errors: true,
colors: !options.verbose && !options.statsJson,
chunks: !options.verbose && !options.dev,
assets: !!options.verbose,
chunkOrigins: !!options.verbose,
chunkModules: !!options.verbose,
children: !!options.verbose,
reasons: !!options.verbose,
version: !!options.verbose,
errorDetails: !!options.verbose,
moduleTrace: !!options.verbose,
usedExports: !!options.verbose,
};
}
var FILENAMES = {
thirdPartyLicenses: "3rdpartylicenses.txt",
appHtml: "app.html",
manifestJson: "asset-manifest.json",
publicFolder: "public",
};
/***/ }),
/* 11 */
/***/ (function(module, exports) {
module.exports = require("findup-sync");
/***/ }),
/* 12 */
/***/ (function(module, exports) {
module.exports = require("@nrwl/workspace/src/utils/app-root");
/***/ }),
/* 13 */
/***/ (function(module, exports) {
module.exports = require("webpack");
/***/ }),
/* 14 */
/***/ (function(module, exports) {
module.exports = require("rxjs/operators");
/***/ }),
/* 15 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export ensureSlash */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getAssetsUrl; });
/* unused harmony export getPublicUrl */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getWebserverEnvironmentVariables; });
/* harmony import */ var _apployees_nx_common_build_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
// Grab NODE_ENV and CLIENT_ONLY_* environment variables and prepare them to be
// injected into the application via DefinePlugin in Webpack configuration.
var IN_CLIENT_PREFIX = /^IN_CLIENT_/i;
function ensureSlash(inputPath, needsSlash) {
var _inputPath = inputPath || "";
var hasSlash = _inputPath.endsWith("/");
if (hasSlash && !needsSlash) {
return _inputPath.substr(0, _inputPath.length - 1);
}
else if (!hasSlash && needsSlash) {
return _inputPath + "/";
}
else {
return _inputPath;
}
}
function getAssetsUrl(options, withSlash) {
if (withSlash === void 0) { withSlash = true; }
return ensureSlash(process.env.ASSETS_URL || options.assetsUrl, withSlash);
}
function getPublicUrl(options, withSlash) {
if (withSlash === void 0) { withSlash = true; }
return ensureSlash(process.env.PUBLIC_URL || options.publicUrl || process.env.ASSETS_URL || options.assetsUrl, withSlash);
}
function getWebserverEnvironmentVariables(options, context, isEnvClient) {
var envVars = Object(_apployees_nx_common_build_utils__WEBPACK_IMPORTED_MODULE_0__[/* loadEnvironmentVariables */ "h"])(options, context);
if (options.dev) {
envVars.HTTPS = options.devHttps;
envVars.PORT = options.devAppPort ? options.devAppPort.toString() : "";
envVars.HOST = options.devHost ? options.devHost : "localhost";
if (options.devHttpsSslKey) {
if (Object(fs__WEBPACK_IMPORTED_MODULE_1__["existsSync"])(options.devHttpsSslKey)) {
envVars.HTTPS_KEY = Object(fs__WEBPACK_IMPORTED_MODULE_1__["readFileSync"])(options.devHttpsSslKey, "utf-8");
}
else {
envVars.HTTPS_KEY = options.devHttpsSslKey;
}
}
if (options.devHttpsSslCert) {
if (Object(fs__WEBPACK_IMPORTED_MODULE_1__["existsSync"])(options.devHttpsSslCert)) {
envVars.HTTPS_CERT = Object(fs__WEBPACK_IMPORTED_MODULE_1__["readFileSync"])(options.devHttpsSslCert, "utf-8");
}
else {
envVars.HTTPS_CERT = options.devHttpsSslCert;
}
}
}
var keys = Object.keys(envVars);
if (isEnvClient) {
keys = keys.filter(function (key) { return IN_CLIENT_PREFIX.test(key); });
}
var raw = keys.reduce(function (env, key) {
env[key] = envVars[key];
return env;
}, {
// Useful for determining whether we’re running in production mode.
// Most importantly, it switches React into the correct mode.
NODE_ENV: options.dev ? "development" : "production",
// whether we are running on client or server
RENDER_ENV: isEnvClient ? "client" : "server",
// For example, <img src={env.ASSETS_URL + 'img/logo.png'} />.
// This should only be used as an escape hatch. Normally you would put
// images into the `src` and `import` them in code to get their paths.
ASSETS_URL: getAssetsUrl(options, true),
// The URL at which the server can be reached.
// Also used to set the start_url in the manifest.json. Clients can also use this
// to make API calls on the server.
PUBLIC_URL: getPublicUrl(options, true),
});
return Object(_apployees_nx_common_build_utils__WEBPACK_IMPORTED_MODULE_0__[/* getProcessedEnvironmentVariables */ "f"])(raw, isEnvClient ? "process.env" : "env");
}
/***/ }),
/* 16 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return prepareUrls; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return printInstructions; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return createCompiler; });
/* unused harmony export prepareProxy */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return choosePort; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tslib__WEBPACK_IMPORTED_MODULE_0__);
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var address = __webpack_require__(113);
var fs = __webpack_require__(5);
var path = __webpack_require__(1);
var url = __webpack_require__(114);
var chalk = __webpack_require__(22);
var detect = __webpack_require__(115);
var isRoot = __webpack_require__(116);
var inquirer = __webpack_require__(117);
var clearConsole = __webpack_require__(118);
var formatWebpackMessages = __webpack_require__(119);
var getProcessForPort = __webpack_require__(120);
var typescriptFormatter = __webpack_require__(47);
var forkTsCheckerWebpackPlugin = __webpack_require__(121);
var isInteractive = process.stdout.isTTY;
function prepareUrls(protocol, host, port) {
var formatUrl = function (hostname) {
return url.format({
protocol: protocol,
hostname: hostname,
port: port,
pathname: "/",
});
};
var prettyPrintUrl = function (hostname) {
return url.format({
protocol: protocol,
hostname: hostname,
port: chalk.bold(port),
pathname: "/",
});
};
var isUnspecifiedHost = host === "0.0.0.0" || host === "::";
var prettyHost, lanUrlForConfig, lanUrlForTerminal;
if (isUnspecifiedHost) {
prettyHost = "localhost";
try {
// This can only return an IPv4 address
lanUrlForConfig = address.ip();
if (lanUrlForConfig) {
// Check if the address is a private ip
// https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces
if (/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(lanUrlForConfig)) {
// Address is private, format it for later use
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig);
}
else {
// Address is not private, so we will discard it
lanUrlForConfig = undefined;
}
}
}
catch (_e) {
// ignored
}
}
else {
prettyHost = host;
}
var localUrlForTerminal = prettyPrintUrl(prettyHost);
var localUrlForBrowser = formatUrl(prettyHost);
return {
lanUrlForConfig: lanUrlForConfig,
lanUrlForTerminal: lanUrlForTerminal,
localUrlForTerminal: localUrlForTerminal,
localUrlForBrowser: localUrlForBrowser,
};
}
function printInstructions(appName, urls, useYarn) {
console.log();
console.log("You can now view " + chalk.bold(appName) + " in the browser.");
console.log();
if (urls.lanUrlForTerminal) {
console.log(" " + chalk.bold("Local:") + " " + urls.localUrlForTerminal);
console.log(" " + chalk.bold("On Your Network:") + " " + urls.lanUrlForTerminal);
}
else {
console.log(" " + urls.localUrlForTerminal);
}
console.log();
console.log("Note that the development build is not optimized.");
console.log("To create a production build, use " + (chalk.cyan((useYarn ? "yarn" : "npm run") + " build") + "."));
console.log();
}
function createCompiler(_a) {
var _this = this;
var appName = _a.appName, config = _a.config, devSocket = _a.devSocket, urls = _a.urls, useYarn = _a.useYarn, useTypeScript = _a.useTypeScript, tscCompileOnError = _a.tscCompileOnError, webpack = _a.webpack;
// "Compiler" is a low-level interface to Webpack.
// It lets us listen to some events and provide our own custom messages.
var compiler;
try {
compiler = webpack(config);
}
catch (err) {
console.log(chalk.red("(" + appName + ") Failed to compile."));
console.log();
console.log(err.message || err);
console.log();
process.exit(1);
}
// "invalid" event fires when you have changed a file, and Webpack is
// recompiling a bundle. WebpackDevServer takes care to pause serving the
// bundle, so if you refresh, it'll wait instead of serving the old one.
// "invalid" is short for "bundle invalidated", it doesn't imply any errors.
compiler.hooks.invalid.tap(appName + "-invalid", function () {
if (isInteractive) {
clearConsole();
}
console.log("(" + appName + ") Compiling...");
});
var isFirstCompile = true;
var tsMessagesPromise;
var tsMessagesResolver;
if (useTypeScript) {
compiler.hooks.beforeCompile.tap(appName + "-beforeCompile", function () {
tsMessagesPromise = new Promise(function (resolve) {
tsMessagesResolver = function (msgs) { return resolve(msgs); };
});
});
forkTsCheckerWebpackPlugin
.getCompilerHooks(compiler)
.receive.tap(appName + "-afterTypeScriptCheck", function (diagnostics, lints) {
var allMsgs = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spreadArrays"])(diagnostics, lints);
var format = function (message) { return message.file + "\n" + typescriptFormatter(message, true); };
tsMessagesResolver({
errors: allMsgs.filter(function (msg) { return msg.severity === "error"; }).map(format),
warnings: allMsgs.filter(function (msg) { return msg.severity === "warning"; }).map(format),
});
});
}
// "done" event fires when Webpack has finished recompiling the bundle.
// Whether or not you have warnings or errors, you will get this event.
compiler.hooks.done.tap(appName + "-done", function (stats) { return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(_this, void 0, void 0, function () {
var statsData, messages_1, messages, isSuccessful;
var _a, _b, _c, _d, _f, _g;
return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"])(this, function (_h) {
switch (_h.label) {
case 0:
statsData = stats.toJson({
all: false,
warnings: true,
errors: true,
});
if (!(useTypeScript && statsData.errors.length === 0)) return [3 /*break*/, 2];
console.log(chalk.yellow("(" + appName + ") Files successfully emitted, waiting for typecheck results..."));
return [4 /*yield*/, tsMessagesPromise];
case 1:
messages_1 = _h.sent();
console.log(chalk.yellow("(" + appName + ") typecheck results completed."));
if (tscCompileOnError) {
(_a = statsData.warnings).push.apply(_a, messages_1.errors);
}
else {
(_b = statsData.errors).push.apply(_b, messages_1.errors);
}
(_c = statsData.warnings).push.apply(_c, messages_1.warnings);
// Push errors and warnings into compilation result
// to show them after page refresh triggered by user.
if (tscCompileOnError) {
(_d = stats.compilation.warnings).push.apply(_d, messages_1.errors);
}
else {
(_f = stats.compilation.errors).push.apply(_f, messages_1.errors);
}
(_g = stats.compilation.warnings).push.apply(_g, messages_1.warnings);
if (messages_1.errors.length > 0) {
if (tscCompileOnError) {
devSocket.warnings(messages_1.errors);
}
else {
devSocket.errors(messages_1.errors);
}
}
else if (messages_1.warnings.length > 0) {
devSocket.warnings(messages_1.warnings);
}
_h.label = 2;
case 2:
messages = formatWebpackMessages(statsData);
isSuccessful = !messages.errors.length && !messages.warnings.length;
if (isSuccessful) {
console.log(chalk.green("(" + appName + ") Compiled successfully!"));
}
isFirstCompile = false;
// If errors exist, only show errors.
if (messages.errors.length) {
// Only keep the first error. Others are often indicative
// of the same problem, but confuse the reader with noise.
if (messages.errors.length > 1) {
messages.errors.length = 1;
}
console.log(chalk.red("(" + appName + ") Failed to compile.\n"));
console.log(messages.errors.join("\n\n"));
return [2 /*return*/];
}
// Show warnings if no errors were found.
if (messages.warnings.length) {
console.log(chalk.yellow("(" + appName + ") Compiled with warnings.\n"));
console.log(messages.warnings.join("\n\n"));
// Teach some ESLint tricks.
console.log("\nSearch for the " + chalk.underline(chalk.yellow("keywords")) + " to learn more about each warning.");
console.log("To ignore, add " + chalk.cyan("// eslint-disable-next-line") + " to the line before.\n");
}
return [2 /*return*/];
}
});
}); });
// You can safely remove this after ejecting.
// We only use this block for testing of Create React App itself:
var isSmokeTest = process.argv.some(function (arg) { return arg.indexOf("--smoke-test") > -1; });
if (isSmokeTest) {
compiler.hooks.failed.tap(appName + "-smokeTest", function () { return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(_this, void 0, void 0, function () {
return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"])(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, tsMessagesPromise];
case 1:
_a.sent();
process.exit(1);
return [2 /*return*/];
}
});
}); });
compiler.hooks.done.tap(appName + "-smokeTest", function (stats) { return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(_this, void 0, void 0, function () {
return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"])(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, tsMessagesPromise];
case 1:
_a.sent();
if (stats.hasErrors() || stats.hasWarnings()) {
process.exit(1);
}
else {
process.exit(0);
}
return [2 /*return*/];
}
});
}); });
}
return compiler;
}
function resolveLoopback(proxy) {
var o = url.parse(proxy);
o.host = undefined;
if (o.hostname !== "localhost") {
return proxy;
}
// Unfortunately, many languages (unlike node) do not yet support IPv6.
// This means even though localhost resolves to ::1, the application
// must fall back to IPv4 (on 127.0.0.1).
// We can re-enable this in a few years.
/*try {
o.hostname = address.ipv6() ? '::1' : '127.0.0.1';
} catch (_ignored) {
o.hostname = '127.0.0.1';
}*/
try {
// Check if we're on a network; if we are, chances are we can resolve
// localhost. Otherwise, we can just be safe and assume localhost is
// IPv4 for maximum compatibility.
if (!address.ip()) {
o.hostname = "127.0.0.1";
}
}
catch (_ignored) {
o.hostname = "127.0.0.1";
}
return url.format(o);
}
// We need to provide a custom onError function for httpProxyMiddleware.
// It allows us to log custom error messages on the console.
function onProxyError(proxy) {
return function (err, req, res) {
var host = req.headers && req.headers.host;
console.log(chalk.red("Proxy error:") +
" Could not proxy request " +
chalk.cyan(req.url) +
" from " +
chalk.cyan(host) +
" to " +
chalk.cyan(proxy) +
".");
console.log("See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (" +
chalk.cyan(err.code) +
").");
console.log();
// And immediately send the proper error response to the client.
// Otherwise, the request will eventually timeout with ERR_EMPTY_RESPONSE on the client side.
if (res.writeHead && !res.headersSent) {
res.writeHead(500);
}
res.end("Proxy error: Could not proxy request " + req.url + " from " + host + " to " + proxy + " (" + err.code + ").");
};
}
function prepareProxy(proxy, appPublicFolder) {
// `proxy` lets you specify alternate servers for specific requests.
if (!proxy) {
return undefined;
}
if (typeof proxy !== "string") {
console.log(chalk.red('When specified, "proxy" in package.json must be a string.'));
console.log(chalk.red('Instead, the type of "proxy" was "' + typeof proxy + '".'));
console.log(chalk.red('Either remove "proxy" from package.json, or make it a string.'));
process.exit(1);
}
// If proxy is specified, let it handle any request except for
// files in the public folder and requests to the WebpackDevServer socket endpoint.
// https://github.com/facebook/create-react-app/issues/6720
function mayProxy(pathname) {
var maybePublicPath = path.resolve(appPublicFolder, pathname.slice(1));
var isPublicFileRequest = fs.existsSync(maybePublicPath);
var isWdsEndpointRequest = pathname.startsWith("/sockjs-node"); // used by webpackHotDevClient
return !(isPublicFileRequest || isWdsEndpointRequest);
}
if (!/^http(s)?:\/\//.test(proxy)) {
console.log(chalk.red('When "proxy" is specified in package.json it must start with either http:// or https://'));
process.exit(1);
}
var target;
if (process.platform === "win32") {
target = resolveLoopback(proxy);
}
else {
target = proxy;
}
return [
{
target: target,
logLevel: "silent",
// For single page apps, we generally want to fallback to /index.html.
// However we also want to respect `proxy` for API calls.
// So if `proxy` is specified as a string, we need to decide which fallback to use.
// We use a heuristic: We want to proxy all the requests that are not meant
// for static assets and as all the requests for static assets will be using
// `GET` method, we can proxy all non-`GET` requests.
// For `GET` requests, if request `accept`s text/html, we pick /index.html.
// Modern browsers include text/html into `accept` header when navigating.
// However API calls like `fetch()` won’t generally accept text/html.
// If this heuristic doesn’t work well for you, use `src/setupProxy.js`.
context: function (pathname, req) {
return (req.method !== "GET" ||
(mayProxy(pathname) && req.headers.accept && req.headers.accept.indexOf("text/html") === -1));
},
onProxyReq: function (proxyReq) {
// Browsers may send Origin headers even with same-origin
// requests. To prevent CORS issues, we have to change
// the Origin to match the target URL.
if (proxyReq.getHeader("origin")) {
proxyReq.setHeader("origin", target);
}
},
onError: onProxyError(target),
secure: false,
changeOrigin: true,
ws: true,
xfwd: true,
},
];
}
function choosePort(host, defaultPort) {
return detect(defaultPort, host).then(function (port) {
return new Promise(function (resolve) {
if (port === defaultPort) {
return resolve(port);
}
var message = process.platform !== "win32" && defaultPort < 1024 && !isRoot()
? "Admin permissions are required to run a server on a port below 1024."
: "Something is already running on port " + defaultPort + ".";
if (isInteractive) {
clearConsole();
var existingProcess = getProcessForPort(defaultPort);
var question = {
type: "confirm",
name: "shouldChangePort",
message: chalk.yellow(message + ("" + (existingProcess ? " Probably:\n " + existingProcess : ""))) +
"\n\nWould you like to run the app on another port instead?",
default: true,
};
inquirer.prompt(question).then(function (answer) {
if (answer.shouldChangePort) {
resolve(port);
}
else {
resolve(null);
}
});
}
else {
console.log(chalk.red(message));
resolve(null);
}
});
}, function (err) {
throw new Error(chalk.red("Could not find an open port at " + chalk.bold(host) + ".") +
"\n" +
("Network error message: " + err.message || false) +
"\n");
});
}
/***/ }),
/* 17 */
/***/ (function(module, exports) {
module.exports = require("resolve-url-loader");
/***/ }),
/* 18 */
/***/ (function(module, exports) {
module.exports = require("sass-loader");
/***/ }),
/* 19 */
/***/ (function(module, exports) {
module.exports = require("less-loader");
/***/ }),
/* 20 */
/***/ (function(module, exports) {
module.exports = require("@nrwl/workspace/src/utils/fileutils");
/***/ }),
/* 21 */
/***/ (function(module, exports) {
module.exports = require("rxjs");
/***/ }),
/* 22 */
/***/ (function(module, exports) {
module.exports = require("chalk");
/***/ }),
/* 23 */
/***/ (function(module, exports) {
module.exports = require("css-loader");
/***/ }),
/* 24 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getExternalizedLibraryImports; });
/* harmony import */ var _nrwl_workspace__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
/* harmony import */ var _nrwl_workspace__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_nrwl_workspace__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
/*******************************************************************************
* © Apployees Inc., 2019
* All Rights Reserved.
******************************************************************************/
/**
* the name of the import as it appears in code
* such as: @apployees-nx/examples/library1 to true if the library should
* be externalized.
*/
function getExternalizedLibraryImports(externalLibraries, npmScope) {
var isLibraryExternalized = {};
if (externalLibraries === "all" || lodash__WEBPACK_IMPORTED_MODULE_1__["isArray"](externalLibraries)) {
var workspaceJson = Object(_nrwl_workspace__WEBPACK_IMPORTED_MODULE_0__["readWorkspaceJson"])();
var possibleProjectIds_1 = {};
/*
first, we generate the permutations of all the types of IDs we may encounter
in the externalLibraries array
E.g.
"externalLibraries": [
"examples-library1",
"examples/library1",
"@apployees-nx/examples/library1"
]
*/
lodash__WEBPACK_IMPORTED_MODULE_1__["forEach"](workspaceJson.projects, function (project, projectName) {
if (project.projectType === "library") {
var projectRootWithoutAppsOrLibs = project.root.split("/").slice(1).join("/");
var importName = "@" + npmScope + "/" + projectRootWithoutAppsOrLibs;
if (externalLibraries === "all") {
isLibraryExternalized[importName] = true;
}
else {
// let's just save them here for now, we will come back to them and
// use them to look up externalLibraries
possibleProjectIds_1[importName] = importName;
possibleProjectIds_1[projectName] = importName;
possibleProjectIds_1[projectRootWithoutAppsOrLibs] = importName;
possibleProjectIds_1[project.root] = importName;
possibleProjectIds_1[project.sourceRoot] = importName;
}
}
});
/*
Now that we have a list of all possible project ID mappings, we can look up
them up using externalLibraries array to figure out which libraries need to be
externalized...
*/
if (lodash__WEBPACK_IMPORTED_MODULE_1__["isArray"](externalLibraries)) {
lodash__WEBPACK_IMPORTED_MODULE_1__["forEach"](externalLibraries, function (externalLibrary) {
var importName = possibleProjectIds_1[externalLibrary];
if (importName) {
isLibraryExternalized[importName] = true;
}
else {
// we weren't able to find it, but add this as-is anyway. Perhaps the
// project has been deleted now and the import still exists, or that
// it is being run as part of some tests.
isLibraryExternalized[externalLibrary] = true;
}
});
}
}
return isLibraryExternalized;
}
/***/ }),
/* 25 */
/***/ (function(module, exports) {
module.exports = require("@angular-devkit/schematics/tools/file-system-utility");
/***/ }),
/* 26 */
/***/ (function(module, exports) {
module.exports = require("node-sass");
/***/ }),
/* 27 */
/***/ (function(module, exports) {
module.exports = require("pnp-webpack-plugin");
/***/ }),
/* 28 */
/***/ (function(module, exports) {
module.exports = require("fs-extra");
/***/ }),
/* 29 */
/***/ (function(module, exports) {
module.exports = require("@angular-devkit/build-webpack");
/***/ }),
/* 30 */
/***/ (function(module, exports) {
module.exports = require("postcss-loader");
/***/ }),
/* 31 */
/***/ (function(module, exports) {
module.exports = require("url-loader");
/***/ }),
/* 32 */
/***/ (function(module, exports) {
module.exports = require("file-loader");
/***/ }),
/* 33 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getSourceRoot; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return readRootPackageJson; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tslib__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _angular_devkit_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
/* harmony import */ var _angular_devkit_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_angular_devkit_core__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _angular_devkit_core_node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(66);
/* harmony import */ var _angular_devkit_core_node__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_angular_devkit_core_node__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _nrwl_workspace_src_utils_app_root__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
/* harmony import */ var _nrwl_workspace_src_utils_app_root__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_nrwl_workspace_src_utils_app_root__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _nrwl_workspace_src_utils_fileutils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20);
/* harmony import */ var _nrwl_workspace_src_utils_fileutils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_nrwl_workspace_src_utils_fileutils__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _angular_devkit_schematics_tools_file_system_utility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(25);
/* harmony import */ var _angular_devkit_schematics_tools_file_system_utility__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_angular_devkit_schematics_tools_file_system_utility__WEBPACK_IMPORTED_MODULE_5__);
function getSourceRoot(context) {
return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, function () {
var workspaceHost, workspace, message;
return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"])(this, function (_a) {
switch (_a.label) {
case 0:
workspaceHost = _angular_devkit_core__WEBPACK_IMPORTED_MODULE_1__["workspaces"].createWorkspaceHost(new _angular_devkit_core_node__WEBPACK_IMPORTED_MODULE_2__["NodeJsSyncHost"]());
return [4 /*yield*/, _angular_devkit_core__WEBPACK_IMPORTED_MODULE_1__["workspaces"].readWorkspace(context.workspaceRoot, workspaceHost)];
case 1:
workspace = (_a.sent()).workspace;
if (workspace.projects.get(context.target.project).sourceRoot) {
return [2 /*return*/, workspace.projects.get(context.target.project).sourceRoot];
}
else {
context.reportStatus("Error");
message = context.target.project + " does not have a sourceRoot. Please define one.";
context.logger.error(message);
throw new Error(message);
}
return [2 /*return*/];
}
});
});
}
function readRootPackageJson() {
var rootPackageJsonPath = _nrwl_workspace_src_utils_app_root__WEBPACK_IMPORTED_MODULE_3__["appRootPath"] + "/package.json";
var rootPackageJson = Object(_nrwl_workspace_src_utils_fileutils__WEBPACK_IMPORTED_MODULE_4__["fileExists"])(rootPackageJsonPath)
? Object(_angular_devkit_schematics_tools_file_system_utility__WEBPACK_IMPORTED_MODULE_5__["readJsonFile"])(rootPackageJsonPath)
: {};
return rootPackageJson;
}
/***/ }),
/* 34 */,
/* 35 */
/***/ (function(module, exports) {
module.exports = require("@nrwl/workspace/src/command-line/shared");
/***/ }),
/* 36 */
/***/ (function(module, exports) {
module.exports = require("license-webpack-plugin");
/***/ }),
/* 37 */
/***/ (function(module, exports) {
module.exports = require("tsconfig-paths-webpack-plugin");
/***/ }),
/* 38 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getPlugins; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tslib__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _env__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
/* harmony import */ var webpack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
/* harmony import */ var webpack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(webpack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var mini_css_extract_plugin__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(39);
/* harmony import */ var mini_css_extract_plugin__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(mini_css_extract_plugin__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var write_file_webpack_plugin__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(75);
/* harmony import */ var write_file_webpack_plugin__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(write_file_webpack_plugin__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var case_sensitive_paths_webpack_plugin__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(76);
/* harmony import */ var case_sensitive_paths_webpack_plugin__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(case_sensitive_paths_webpack_plugin__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var react_dev_utils_ModuleNotFoundPlugin__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(77);
/* harmony import */ var react_dev_utils_ModuleNotFoundPlugin__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_dev_utils_ModuleNotFoundPlugin__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var fork_ts_checker_webpack_plugin__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(78);
/* harmony import */ var fork_ts_checker_webpack_plugin__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(fork_ts_checker_webpack_plugin__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var react_dev_utils_typescriptFormatter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(47);
/* harmony import */ var react_dev_utils_typescriptFormatter__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(react_dev_utils_typescriptFormatter__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var react_dev_utils_WatchMissingNodeModulesPlugin__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(79);
/* harmony import */ var react_dev_utils_WatchMissingNodeModulesPlugin__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(react_dev_utils_WatchMiss