How to use the liferay-npm-build-tools-common/lib/alias.getAliasToType 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
// Search finished
		if (absSearchDir.is(absSearchTopDir)) {
			return undefined;
		}

		// Look up in hierachy
		alias = this._getAliasForLocal(
			absSearchTopDir,
			absSearchDir.dirname(),
			absSearchDir.basename().join(searchRelModuleName)
		);

		// Rebase to current folder
		if (
			alias !== undefined &&
			getAliasToType(alias) === AliasToType.LOCAL
		) {
			alias = new FilePath(`../${alias}`, {posix: true}).normalize()
				.asPosix;
		}

		return alias;
	}
github liferay / liferay-js-toolkit / packages / babel-plugin-alias-modules / src / index.ts View on Github external
);

			// Then, if not found, recursively from target module up
			if (alias === undefined) {
				const moduleDir = absFileDir.join(requiredModule.dirname());
				const moduleBasename = requiredModule.basename();

				alias = this._getAliasForLocal(
					_absRootDir,
					moduleDir,
					moduleBasename
				);

				if (
					alias !== undefined &&
					getAliasToType(alias) === AliasToType.LOCAL
				) {
					alias = absFileDir
						.relative(moduleDir)
						.join(new FilePath(alias, {posix: true})).asPosix;

					if (!alias.startsWith('.')) {
						alias = `./${alias}`;
					}
				}
			}
		} else {
			alias = this._getAliasForExternal(absFileDir, requiredModule);
		}

		return alias === undefined ? requiredModuleName : alias;
	}
github liferay / liferay-js-toolkit / packages / babel-plugin-alias-modules / src / index.ts View on Github external
// Search finished
		if (absSearchDir.is(_absRootDir)) {
			return undefined;
		}

		// Look up in hierachy
		alias = this._getAliasForExternal(
			absSearchDir.dirname(),
			requiredModule
		);

		// Rebase to current folder
		if (
			alias !== undefined &&
			getAliasToType(alias) === AliasToType.LOCAL
		) {
			alias = new FilePath(`../${alias}`, {posix: true}).normalize()
				.asPosix;
		}

		return alias;
	}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler-plugin-replace-browser-modules / src / index.ts View on Github external
if (unrolledAliases.length > 1) {
				throw new Error(
					'Unrolled aliases map has unresolved collisions'
				);
			}

			const alias = unrolledAliases[0];

			const absFromFile = new FilePath(absFromPath);
			const rootRelAbsDirPosixPath = absRootDir.relative(alias.absDir)
				.asPosix;

			const rootRelFilePosixPath = absRootDir.relative(absFromFile)
				.asPosix;

			switch (getAliasToType(alias.to)) {
				case AliasToType.IGNORE: {
					rewriteFile(
						absFromFile,
						`/* ignored by alias field(s) configured in ${rootRelAbsDirPosixPath} */`
					);

					log.info(
						'replace-browser-modules',
						`Emptied file '${rootRelFilePosixPath}' as ` +
							`configured in '${rootRelAbsDirPosixPath}'`
					).linkToCode(1);
					break;
				}

				case AliasToType.EXTERNAL: {
					rewriteFile(