async function entryReducer(entry, list, name) {
		// JS / TS

		const
			componentsToIgnore = /^[iv]-/,
			cursor = isStandalone(name) ? STANDALONE : RUNTIME;

		const
			webpackRuntime = "require('core/prelude/webpack');";

		let
			taskProcess = processes[cursor];

		{
			const
				entrySrc = path.join(tmpEntries, `${name}.js`);

			const content = await $C(list).async.to('').reduce(async (str, {name}) => {
				const
					component = components.get(name),
					logic = await component?.logic;

				if (component) {
					$C(component.libs).forEach((el) => str += `require('${el}');\n`);
				}

				const needRequireAsLogic = component ?
					logic :
					/^$|^\.(?:js|ts)(?:\?|$)/.test(path.extname(name));

				if (needRequireAsLogic) {
					let
						entry;

					if (logic) {
						entry = logic;

					} else if (resolve.isNodeModule(name)) {
						entry = name;

					} else {
						entry = path.resolve(tmpEntries, '../', name);
					}

					str += `require('${getEntryPath(entry)}');\n`;
				}

				return str;
			});

			fs.writeFileSync(entrySrc, content);
			entry[name] = entrySrc;
			taskProcess[name] = entrySrc;
		}

		// TEMPLATES

		{
			const
				entryName = `${name}_tpl`,
				entrySrc = path.join(tmpEntries, `${name}.ss.js`);

			const content = await $C(list).async.to('').reduce(async (str, {name, isParent}) => {
				const
					component = components.get(name),
					tpl = await component?.tpl;

				if (!isParent && tpl && !componentsToIgnore.test(name)) {
					const entry = getEntryPath(tpl);
					str += `Object.assign(TPLS, require('./${entry}'));\n`;
				}

				return str;
			});

			fs.writeFileSync(
				entrySrc,

				[
					webpackRuntime,
					'window.TPLS = window.TPLS || Object.create(null);',
					content
				].join('\n')
			);

			entry[entryName] = entrySrc;
			taskProcess[entryName] = entrySrc;
		}

		taskProcess = processes[buildIterator];

		const canAddMoreProcess =
			cursor !== STANDALONE &&
			MAX_PROCESS > buildIterator &&
			$C(taskProcess).length() >= MAX_TASKS_PER_ONE_PROCESS;

		if (canAddMoreProcess) {
			taskProcess = {};
			processes.push(taskProcess);
			buildIterator++;
		}

		// CSS

		{
			const
				entryName = `${name}_style`,
				stylSrc = path.join(tmpEntries, `${name}.styl`);

			const content = await $C(list).async.to('').reduce(async (str, {name, isParent}) => {
				const
					component = components.get(name),
					styles = await component?.styles;

				const needRequireAsStyles = component ?
					!isParent && styles && styles.length && !componentsToIgnore.test(name) :
					/^\.(?:styl|css)(?:\?|$)/.test(path.extname(name));

				if (needRequireAsStyles) {
					const
						getImport = (filePath) => `@import "${getEntryPath(filePath)}"\n`;

					if (component) {
						$C(styles).forEach((filePath) => {
							str += getImport(filePath);
						});

					} else {
						str += getImport(name);
					}

					if (!needLoadStylesAsJS) {
						const
							normalizedName = path.basename(name, path.extname(name));

						if (/^[bp]-/.test(normalizedName)) {
							str +=
								`
.${normalizedName}
	extends($${normalizedName.camelize(false)})

`;
						}
					}
				}

				return str;
			});

			let
				entrySrc;

			if (needLoadStylesAsJS) {
				entrySrc = path.join(tmpEntries, `${name}.styl.js`);
				fs.writeFileSync(stylSrc, content);
				fs.writeFileSync(entrySrc, [webpackRuntime, `require('${stylSrc}');`].join('\n'));

			} else {
				entrySrc = stylSrc;
				fs.writeFileSync(entrySrc, [content, 'generateImgClasses()'].join('\n'));
			}

			entry[entryName] = entrySrc;
			taskProcess[entryName] = entrySrc;
		}

		// HTML

		{
			const
				entryName = `${name}_view`,
				entrySrc = path.join(tmpEntries, `${entryName}.html.js`);

			const content = await $C(list).async.to('').reduce(async (str, {name}) => {
				const
					component = components.get(name),
					html = await component?.etpl;

				if (html && !componentsToIgnore.test(name)) {
					str += [webpackRuntime, `require('./${getEntryPath(html)}');\n`].join('\n');
				}

				return str;
			});

			fs.writeFileSync(entrySrc, content);

			entry[entryName] = entrySrc;

			// eslint-disable-next-line require-atomic-updates
			processes[HTML][entryName] = entrySrc;
		}

		return entry;
	}
/**
	 * Reducer to create an entry point object
	 */
Reducer to create an entry point object
Reducer to create an entry point object
async function entryReducer(entry, list, name) {
		const
			componentsToIgnore = /^[iv]-/,
			cursor = isStandalone(name) ? STANDALONE : RUNTIME;
		const
			webpackRuntime = "require('core/prelude/webpack');";
		let
			taskProcess = processes[cursor];
		{
			const
				entrySrc = path.join(tmpEntries, `${name}.js`);
			const content = await $C(list).async.to('').reduce(async (str, {name}) => {
				const
					component = components.get(name),
					logic = await component?.logic;
				if (component) {
					$C(component.libs).forEach((el) => str += `require('${el}');\n`);
				}
				const needRequireAsLogic = component ?
					logic :
					/^$|^\.(?:js|ts)(?:\?|$)/.test(path.extname(name));
				if (needRequireAsLogic) {
					let
						entry;
					if (logic) {
						entry = logic;
					} else if (resolve.isNodeModule(name)) {
						entry = name;
					} else {
						entry = path.resolve(tmpEntries, '../', name);
					}
					str += `require('${getEntryPath(entry)}');\n`;
				}
				return str;
			});
			fs.writeFileSync(entrySrc, content);
			entry[name] = entrySrc;
			taskProcess[name] = entrySrc;
		}
		{
			const
				entryName = `${name}_tpl`,
				entrySrc = path.join(tmpEntries, `${name}.ss.js`);
			const content = await $C(list).async.to('').reduce(async (str, {name, isParent}) => {
				const
					component = components.get(name),
					tpl = await component?.tpl;
				if (!isParent && tpl && !componentsToIgnore.test(name)) {
					const entry = getEntryPath(tpl);
					str += `Object.assign(TPLS, require('./${entry}'));\n`;
				}
				return str;
			});
			fs.writeFileSync(
				entrySrc,
				[
					webpackRuntime,
					'window.TPLS = window.TPLS || Object.create(null);',
					content
				].join('\n')
			);
			entry[entryName] = entrySrc;
			taskProcess[entryName] = entrySrc;
		}
		taskProcess = processes[buildIterator];
		const canAddMoreProcess =
			cursor !== STANDALONE &&
			MAX_PROCESS > buildIterator &&
			$C(taskProcess).length() >= MAX_TASKS_PER_ONE_PROCESS;
		if (canAddMoreProcess) {
			taskProcess = {};
			processes.push(taskProcess);
			buildIterator++;
		}
		{
			const
				entryName = `${name}_style`,
				stylSrc = path.join(tmpEntries, `${name}.styl`);
			const content = await $C(list).async.to('').reduce(async (str, {name, isParent}) => {
				const
					component = components.get(name),
					styles = await component?.styles;
				const needRequireAsStyles = component ?
					!isParent && styles && styles.length && !componentsToIgnore.test(name) :
					/^\.(?:styl|css)(?:\?|$)/.test(path.extname(name));
				if (needRequireAsStyles) {
					const
						getImport = (filePath) => `@import "${getEntryPath(filePath)}"\n`;
					if (component) {
						$C(styles).forEach((filePath) => {
							str += getImport(filePath);
						});
					} else {
						str += getImport(name);
					}
					if (!needLoadStylesAsJS) {
						const
							normalizedName = path.basename(name, path.extname(name));
						if (/^[bp]-/.test(normalizedName)) {
							str +=
								`
.${normalizedName}
	extends($${normalizedName.camelize(false)})
`;
						}
					}
				}
				return str;
			});
			let
				entrySrc;
			if (needLoadStylesAsJS) {
				entrySrc = path.join(tmpEntries, `${name}.styl.js`);
				fs.writeFileSync(stylSrc, content);
				fs.writeFileSync(entrySrc, [webpackRuntime, `require('${stylSrc}');`].join('\n'));
			} else {
				entrySrc = stylSrc;
				fs.writeFileSync(entrySrc, [content, 'generateImgClasses()'].join('\n'));
			}
			entry[entryName] = entrySrc;
			taskProcess[entryName] = entrySrc;
		}
		{
			const
				entryName = `${name}_view`,
				entrySrc = path.join(tmpEntries, `${entryName}.html.js`);
			const content = await $C(list).async.to('').reduce(async (str, {name}) => {
				const
					component = components.get(name),
					html = await component?.etpl;
				if (html && !componentsToIgnore.test(name)) {
					str += [webpackRuntime, `require('./${getEntryPath(html)}');\n`].join('\n');
				}
				return str;
			});
			fs.writeFileSync(entrySrc, content);
			entry[entryName] = entrySrc;
			processes[HTML][entryName] = entrySrc;
		}
		return entry;
	}
async function entryReducer ( entry , list , name ) { const componentsToIgnore = / ^[iv]- / , cursor = isStandalone ( name ) ? STANDALONE : RUNTIME ; const webpackRuntime = "require('core/prelude/webpack');" ; let taskProcess = processes [ cursor ] ; { const entrySrc = path . join ( tmpEntries , ` ${ name } ` ) ; const content = await $C ( list ) . async . to ( '' ) . reduce ( async ( str , { name } ) => { const component = components . get ( name ) , logic = await component ?. logic ; if ( component ) { $C ( component . libs ) . forEach ( ( el ) => str += ` ${ el } \n ` ) ; } const needRequireAsLogic = component ? logic : / ^$|^\.(?:js|ts)(?:\?|$) / . test ( path . extname ( name ) ) ; if ( needRequireAsLogic ) { let entry ; if ( logic ) { entry = logic ; } else if ( resolve . isNodeModule ( name ) ) { entry = name ; } else { entry = path . resolve ( tmpEntries , '../' , name ) ; } str += ` ${ getEntryPath ( entry ) } \n ` ; } return str ; } ) ; fs . writeFileSync ( entrySrc , content ) ; entry [ name ] = entrySrc ; taskProcess [ name ] = entrySrc ; } { const entryName = ` ${ name } ` , entrySrc = path . join ( tmpEntries , ` ${ name } ` ) ; const content = await $C ( list ) . async . to ( '' ) . reduce ( async ( str , { name , isParent } ) => { const component = components . get ( name ) , tpl = await component ?. tpl ; if ( ! isParent && tpl && ! componentsToIgnore . test ( name ) ) { const entry = getEntryPath ( tpl ) ; str += ` ${ entry } \n ` ; } return str ; } ) ; fs . writeFileSync ( entrySrc , [ webpackRuntime , 'window.TPLS = window.TPLS || Object.create(null);' , content ] . join ( '\n' ) ) ; entry [ entryName ] = entrySrc ; taskProcess [ entryName ] = entrySrc ; } taskProcess = processes [ buildIterator ] ; const canAddMoreProcess = cursor !== STANDALONE && MAX_PROCESS > buildIterator && $C ( taskProcess ) . length ( ) >= MAX_TASKS_PER_ONE_PROCESS ; if ( canAddMoreProcess ) { taskProcess = { } ; processes . push ( taskProcess ) ; buildIterator ++ ; } { const entryName = ` ${ name } ` , stylSrc = path . join ( tmpEntries , ` ${ name } ` ) ; const content = await $C ( list ) . async . to ( '' ) . reduce ( async ( str , { name , isParent } ) => { const component = components . get ( name ) , styles = await component ?. styles ; const needRequireAsStyles = component ? ! isParent && styles && styles . length && ! componentsToIgnore . test ( name ) : / ^\.(?:styl|css)(?:\?|$) / . test ( path . extname ( name ) ) ; if ( needRequireAsStyles ) { const getImport = ( filePath ) => ` ${ getEntryPath ( filePath ) } \n ` ; if ( component ) { $C ( styles ) . forEach ( ( filePath ) => { str += getImport ( filePath ) ; } ) ; } else { str += getImport ( name ) ; } if ( ! needLoadStylesAsJS ) { const normalizedName = path . basename ( name , path . extname ( name ) ) ; if ( / ^[bp]- / . test ( normalizedName ) ) { str += ` ${ normalizedName } ${ normalizedName . camelize ( false ) } ` ; } } } return str ; } ) ; let entrySrc ; if ( needLoadStylesAsJS ) { entrySrc = path . join ( tmpEntries , ` ${ name } ` ) ; fs . writeFileSync ( stylSrc , content ) ; fs . writeFileSync ( entrySrc , [ webpackRuntime , ` ${ stylSrc } ` ] . join ( '\n' ) ) ; } else { entrySrc = stylSrc ; fs . writeFileSync ( entrySrc , [ content , 'generateImgClasses()' ] . join ( '\n' ) ) ; } entry [ entryName ] = entrySrc ; taskProcess [ entryName ] = entrySrc ; } { const entryName = ` ${ name } ` , entrySrc = path . join ( tmpEntries , ` ${ entryName } ` ) ; const content = await $C ( list ) . async . to ( '' ) . reduce ( async ( str , { name } ) => { const component = components . get ( name ) , html = await component ?. etpl ; if ( html && ! componentsToIgnore . test ( name ) ) { str += [ webpackRuntime , ` ${ getEntryPath ( html ) } \n ` ] . join ( '\n' ) ; } return str ; } ) ; fs . writeFileSync ( entrySrc , content ) ; entry [ entryName ] = entrySrc ; processes [ HTML ] [ entryName ] = entrySrc ; } return entry ; }
Reducer to create an entry point object
Reducer to create an entry point object
// JS / TS // TEMPLATES // CSS // HTML // eslint-disable-next-line require-atomic-updates