How to use the liferay-npm-build-tools-common/lib/alias.loadAliases 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 / babel-plugin-alias-modules / src / index.ts View on Github external
private _getAliasForExternal(
		absSearchDir: FilePath,
		requiredModule: FilePath
	): AliasToValue | undefined {
		const {_absRootDir, _aliasFields} = this;

		const aliases = loadAliases(
			absSearchDir.join('package.json'),
			_aliasFields
		);

		let alias = aliases[requiredModule.asPosix];

		// Found: return it
		if (alias !== undefined) {
			return alias;
		}

		// Search finished
		if (absSearchDir.is(_absRootDir)) {
			return undefined;
		}
github liferay / liferay-js-toolkit / packages / babel-plugin-alias-modules / src / index.ts View on Github external
private _getAliasForLocal(
		absSearchTopDir: FilePath,
		absSearchDir: FilePath,
		searchRelModuleName: FilePath
	): AliasToValue | undefined {
		const {_aliasFields} = this;

		const aliases = loadAliases(
			absSearchDir.join('package.json'),
			_aliasFields
		);
		const normalizedSearchRelModuleName = `./${searchRelModuleName.asPosix}`;

		let alias = aliases[normalizedSearchRelModuleName];

		// Try with file alias
		if (
			alias === undefined &&
			!normalizedSearchRelModuleName.toLowerCase().endsWith('.js')
		) {
			alias = aliases[`${normalizedSearchRelModuleName}.js`];
		}

		// Try with external module aliases