Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate names in entry-files.json causes one to not be built #442

Closed
JorgenStenshaugen opened this issue Mar 9, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@JorgenStenshaugen
Copy link
Contributor

If a entry point with the names "editor.js" and "editor.css" exists, only one of them will be built. To solve this we would need to call one of them something else, and this is not a big deal, the only issue is that it's confusing and hard to debug if you're not familiar with the issue.

Possible solutions:
Add a suffix to the duplicate entry if it's a style or script.

const prepareConfig = (dir, files) => {
	const entries = {};

	files.forEach((file) => {
		const filePath = path.resolve(__dirname, dir, file);
		const fileExt = path.parse(file).ext;
		let fileName = path.parse(file).name;

		// If a duplicate entry is found, add a suffix to the entry name.
		if (Array.isArray(entries[fileName])) {
			if (fileExt === '.js') {
				fileName = fileName + '-scripts';
			}

			if (fileExt === '.css' || fileExt === '.scss') {
				fileName = fileName + '-styles';
			}

			entries[fileName] = [];
		}

		if (typeof entries[fileName] === 'undefined') {
			entries[fileName] = [];
		}

		entries[fileName].push(filePath);
	});

or throw an error so that atleast we get some feedback to why it's not building the other file

const prepareConfig = (dir, files) => {
	const entries = {};

	files.forEach((file) => {
		const filePath = path.resolve(__dirname, dir, file);
		const fileName = path.parse(file).name;

		if (Array.isArray(entries[fileName])) {
			throw new Error(
				`Duplicate entry found: ${fileName} in ${dir}. Please rename the entry files.`,
			);
		}

		if (typeof entries[fileName] === 'undefined') {
			entries[fileName] = [];
		}

		entries[fileName].push(filePath);
	});
@JorgenStenshaugen JorgenStenshaugen added the bug Something isn't working label Mar 9, 2023
@stian-overasen
Copy link
Member

Entry files are no more. Can we close this issue @JorgenStenshaugen ?

@JorgenStenshaugen
Copy link
Contributor Author

Entry files are no more. Can we close this issue @JorgenStenshaugen ?

Yep, not relevant anymore 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants