How to use liferay-npm-build-tools-common - 10 common examples

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-namespace-amd-define / src / index.js View on Github external
exit(path, state) {
					// We must traverse the AST again because the third party
					// transform-es2015-modules-amd emits its define() call after
					// Program exit :-(
					firstDefineNamespaced = false;
					extraNamespaceCount = 0;

					path.traverse(namespaceVisitor, {opts: state.opts});

					if (extraNamespaceCount > 0) {
						const {log} = babelIpc.get(state, () => ({
							log: new PluginLogger(),
						}));

						if (firstDefineNamespaced) {
							log.info(
								'namespace-amd-define',
								'Namespaced first AMD define in file'
							);
						}

						if (extraNamespaceCount) {
							log.warn(
								'namespace-amd-define',
								'Found',
								extraNamespaceCount,
								'define() calls inside the module definition',
github liferay / liferay-js-toolkit / packages / babel-plugin-namespace-modules / src / index.js View on Github external
exit(path, state) {
					// We must traverse the AST again because the
					// transform-es2015-modules-amd plugin emits its define()
					// call after exiting Program node :-(
					path.traverse(amdDefineVisitor, state);

					// Dump final report statistics
					if (
						state.namesCount > 0 ||
						state.depsCount > 0 ||
						state.requiresCount > 0
					) {
						const {log} = babelIpc.get(state, () => ({
							log: new PluginLogger(),
						}));

						log.info(
							'namespace-modules',
							'Namespaced',
							state.namesCount,
							'define() names,',
							state.depsCount,
							'define() dependencies,',
							'and',
							state.requiresCount,
							'require() names'
						);
					}
				},
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 / babel-plugin-alias-modules / src / index.ts View on Github external
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-imports-checker / src / liferay-npm-imports-checker.js View on Github external
return;
				}

				const {npmbundlerrc} = new Project(pkgJsonDir);

				if (npmbundlerrc.config && npmbundlerrc.config.imports) {
					npmbundlerrc.config.imports = normalizeImportsConfig(
						npmbundlerrc.config.imports,
						true
					);
				}

				projects[pkgJson.name] = {
					name: pkgJson.name,
					dir: new FilePath(pkgJsonDir),
					pkgJson,
					npmbundlerrc,
				};

				_msg(1, pkgJsonDir);
			} catch (err) {
				// Swallow.
			}
		});
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler-plugin-replace-browser-modules / src / index.ts View on Github external
`/* redirected by alias field(s) in ${rootRelAbsDirPosixPath} */`,
						`module.exports = require('${alias.to}');`
					);

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

				case AliasToType.LOCAL: {
					const absToFile = alias.absDir.join(
						new FilePath(alias.to as string, {posix: true})
					);
					const fromRelToFile = absFromFile
						.dirname()
						.relative(absToFile);

					rewriteFile(
						absFromFile,
						`/* redirected by alias field(s) in ${rootRelAbsDirPosixPath} */`,
						`module.exports = require('./${fromRelToFile.asPosix}');`
					);

					log.info(
						'replace-browser-modules',
						`Redirected file '${rootRelFilePosixPath}' to ` +
							`'./${fromRelToFile.asPosix}' as configured in ` +
							`'${rootRelAbsDirPosixPath}'`
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / config / index.js View on Github external
presetFile = require.resolve('liferay-npm-bundler-preset-standard');
	} else if (config.preset === '' || config.preset === false) {
		// don't load preset
	} else {
		presetFile = resolveModule.sync(config.preset, {
			basedir: '.',
		});
	}

	if (presetFile) {
		const originalConfig = Object.assign({}, config);
		Object.assign(
			config,
			merge.recursive(readJsonSync(presetFile), originalConfig)
		);
		config.pluginsBaseDir = getPackageDir(presetFile);
	}

	// Normalize
	config['/'] = config['/'] || {};
	config['config'] = config['config'] || {};
	config.packages = config.packages || {};
}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / config.js View on Github external
config = readJsonSync('.npmbundlerrc');
	} catch (err) {
		if (err.code !== 'ENOENT') {
			throw err;
		}
	}

	// Apply preset if necessary
	if (config.preset) {
		const presetFile = resolveModule.sync(config.preset, {
			basedir: '.',
		});

		// Merge preset with base configuration
		config = Object.assign(readJsonSync(presetFile), config);
		pluginsBaseDir = getPackageDir(presetFile);
	}

	// Normalize
	config.packages = config.packages || {};

	return config;
}