How to use the liferay-npm-build-tools-common/lib/project.dir function in liferay-npm-build-tools-common

To help you get started, we’ve selected a few liferay-npm-build-tools-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liferay / liferay-js-toolkit / packages / liferay-npm-build-support / src / config.js View on Github external
function loadConfig() {
	npmbuildrc = safeReadJsonSync(project.dir.join('.npmbuildrc').asNative);
	npmbundlerrc = project._npmbundlerrc;

	// Normalize configurations
	normalize(npmbuildrc, 'supportedLocales', []);
	normalize(npmbuildrc, 'webpack.mainModule', 'index.js');
	normalize(npmbuildrc, 'webpack.rules', []);
	normalize(npmbuildrc, 'webpack.extensions', ['.js']);
	normalize(npmbuildrc, 'webpack.port', null);

	normalize(
		npmbundlerrc,
		'create-jar.features.localization',
		'features/localization/Language'
	);
}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler-loader-babel-loader / src / index.js View on Github external
export default function(context, config) {
	const {content, filePath, log, sourceMap} = context;

	const babelConfig = {
		filename: project.dir.join(filePath).asNative,
		filenameRelative: filePath,
		inputSourceMap: sourceMap,
		...config,
	};

	// Tune babel config
	babelConfig.babelrc = false;
	babelConfig.only = '**/*';
	if (babelConfig.sourceMaps === undefined) {
		babelConfig.sourceMaps = true;
	}

	// Intercept presets and plugins to load them from project
	babelConfig.plugins = loadBabelPlugins(
		babelConfig.presets || [],
		babelConfig.plugins || []
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / steps / transform.js View on Github external
return new Promise(resolve => {
		const logger = new PluginLogger();

		babelIpc.set(project.dir.join(prjRelPath).asNative, {
			log: logger,
			manifest,
			rootPkgJson: clone(project.pkgJson),
			globalConfig: clone(project.globalConfig),
		});

		const fileAbsPath = project.dir.join(prjRelPath).asNative;
		const filePkgRelPath = project.dir
			.join(destPkg.dir)
			.relative(fileAbsPath).asNative;

		babel.transformFile(
			fileAbsPath,
			{
				filename: fileAbsPath,
				filenameRelative: prjRelPath,
				inputSourceMap: loadSourceMap(fileAbsPath),
				...babelConfig,
			},
			(err, result) => {
				// Generate and/or log results
				if (err) {
					logger.error('babel', err);
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler-plugin-replace-browser-modules / src / index.ts View on Github external
export default function(
	params: BundlerPluginParams,
	{}: BundlerTransformPluginState
): void {
	const {log, pkg} = params;

	const absRootDir = project.dir.join(pkg.dir);

	const aliasesMap = readAliases(params, absRootDir);

	const unrolledAliasesMap = unrollAliasesMap(aliasesMap);

	reportAndResolveCollisions(log, absRootDir, unrolledAliasesMap);

	processAliases(log, absRootDir, unrolledAliasesMap);
}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / steps / transform.js View on Github external
return new Promise(resolve => {
		const logger = new PluginLogger();

		babelIpc.set(project.dir.join(prjRelPath).asNative, {
			log: logger,
			manifest,
			rootPkgJson: clone(project.pkgJson),
			globalConfig: clone(project.globalConfig),
		});

		const fileAbsPath = project.dir.join(prjRelPath).asNative;
		const filePkgRelPath = project.dir
			.join(destPkg.dir)
			.relative(fileAbsPath).asNative;

		babel.transformFile(
			fileAbsPath,
			{
				filename: fileAbsPath,
				filenameRelative: prjRelPath,
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / steps / copy.js View on Github external
function copyFile(srcPkg, destPkg, srcPkgRelPath) {
	const absSrcFilePath = project.dir.join(srcPkg.dir, srcPkgRelPath).asNative;
	const absDestFilePath = project.dir.join(destPkg.dir, srcPkgRelPath)
		.asNative;

	return fs
		.mkdirp(path.dirname(absDestFilePath))
		.then(() => fs.copyFile(absSrcFilePath, absDestFilePath));
}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / steps / rules.js View on Github external
([extraPrjRelPath, content]) => {
			if (content == undefined) {
				return;
			}

			writeRuleFile(
				destPkg,
				srcPkg.dir.relative(project.dir.join(extraPrjRelPath)).asNative,
				content
			);

			context.log.info(
				'liferay-npm-bundler',
				`Rules generated extra artifact: ${extraPrjRelPath}`
			);
		}
	);
github liferay / liferay-js-toolkit / packages / babel-plugin-alias-modules / src / index.ts View on Github external
import {
	AliasToValue,
	getAliasFields,
	getAliasToType,
	loadAliases,
	AliasToType,
} from 'liferay-npm-build-tools-common/lib/alias';
import {BabelIpcObject} from 'liferay-npm-build-tools-common/lib/api/plugins';
import * as babelIpc from 'liferay-npm-build-tools-common/lib/babel-ipc';
import FilePath from 'liferay-npm-build-tools-common/lib/file-path';
import * as mod from 'liferay-npm-build-tools-common/lib/modules';
import PluginLogger from 'liferay-npm-build-tools-common/lib/plugin-logger';
import project from 'liferay-npm-build-tools-common/lib/project';

const absPrjDirPath = project.dir.asNative;
const absBuildDirPath = project.dir.join(project.buildDir).asNative;
let t;

/**
 * @return {object} a babel visitor
 */
export default function({types}) {
	t = types;

	return {
		visitor: {
			CallExpression(bpath, state) {
				state.visitor.CallExpression(bpath);
			},
			Program(bpath, state) {
				new Visitor(state);
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / dependencies.js View on Github external
export function addPackageDependencies(
	collectedDependencies,
	basedirPath,
	extraDependencies = []
) {
	const packageJson = readJsonSync(path.join(basedirPath, '/package.json'));
	const pkg = new PkgDesc(
		packageJson.name,
		packageJson.version,
		path.resolve(basedirPath) == path.resolve(project.dir.asNative)
			? null
			: basedirPath
	);

	if (collectedDependencies[pkg.id]) {
		return;
	}

	collectedDependencies[pkg.id] = pkg;

	let dependencies = packageJson.dependencies || {};
	dependencies = Object.keys(dependencies);
	dependencies = dependencies.concat(extraDependencies);

	const dependencyDirs = dependencies
		.map(dependency => {