UNPKG

liferay-npm-bundler-preset-reactjs

Version:

liferay npm bundler preset react

87 lines (86 loc) 3.31 kB
"use strict"; /** * SPDX-FileCopyrightText: © 2020 Liferay, Inc. <https://liferay.com> * SPDX-License-Identifier: LGPL-3.0-or-later */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const dot_prop_1 = __importDefault(require("dot-prop")); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); /** * Reflects miscellaneous project configuration values. */ class Misc { /** * * @param {Project} project */ constructor(project) { this._project = project; } /** * Get maximum number of files to process in parallel in any parallelizable * operation. */ get maxParallelFiles() { const { npmbundlerrc } = this._project; // Default values for "ulimit -n" vary across different OSes. Some // // values I have found are: // - Apparently Mac OS X limit is 256 but usually people increase it // - Fedora: 1024 // - Windows: there's no ulimit, but MSVCRT.DLL has a 2048 limit // // Given this mess and the impossibility of retrieving the limit from // Node, I'm giving this a default value of 128 because it looks like it // doesn't impact performance and should be low enough to make it work // in all OSes. return dot_prop_1.default.get(npmbundlerrc, 'max-parallel-files', 128); } /** * Whether or not to track usage */ get noTracking() { const { _project } = this; const { npmbundlerrc } = _project; if (!dot_prop_1.default.has(npmbundlerrc, 'no-tracking')) { if (dot_prop_1.default.has(process, 'env.LIFERAY_NPM_BUNDLER_NO_TRACKING')) { dot_prop_1.default.set(npmbundlerrc, 'no-tracking', true); } } if (!dot_prop_1.default.has(npmbundlerrc, 'no-tracking')) { let dir = _project.dir.asNative; while (!fs_1.default.existsSync(path_1.default.join(dir, '.liferay-npm-bundler-no-tracking')) && path_1.default.resolve(dir, '..') !== dir) { dir = path_1.default.resolve(dir, '..'); } if (fs_1.default.existsSync(path_1.default.join(dir, '.liferay-npm-bundler-no-tracking'))) { dot_prop_1.default.set(npmbundlerrc, 'no-tracking', true); } } // Disable tracking by default return dot_prop_1.default.get(npmbundlerrc, 'no-tracking', true); } /** * Get the path to the report file or undefined if no report is configured. */ get reportFile() { const { _project } = this; const { npmbundlerrc } = _project; const dumpReport = dot_prop_1.default.get(npmbundlerrc, 'dump-report', false); return dumpReport ? _project.dir.join('liferay-npm-bundler-report.html') : undefined; } /** * Whether or not to dump detailed information about what the tool is doing */ get verbose() { const { npmbundlerrc } = this._project; return dot_prop_1.default.get(npmbundlerrc, 'verbose', false); } } exports.default = Misc;