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

Add Eleventy data directory as entry pattern #454

Merged
merged 20 commits into from
Jan 18, 2024
Merged

Add Eleventy data directory as entry pattern #454

merged 20 commits into from
Jan 18, 2024

Conversation

uncenter
Copy link
Contributor

Closes #453.

Copy link

vercel bot commented Jan 17, 2024

Someone is attempting to deploy a commit to a Personal Account owned by @webpro on Vercel.

@webpro first needs to authorize it.

@uncenter uncenter changed the title Add dummy userConfig class, load config, add default config Add Eleventy data directory as entry pattern Jan 17, 2024
@uncenter uncenter requested a review from webpro January 17, 2024 12:35
@uncenter uncenter marked this pull request as ready for review January 17, 2024 12:54
Copy link
Collaborator

@webpro webpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, looks good so far but I do have a few comments.

packages/knip/src/plugins/eleventy/helpers.ts Outdated Show resolved Hide resolved
packages/knip/src/plugins/eleventy/index.ts Outdated Show resolved Hide resolved
packages/knip/src/plugins/eleventy/index.ts Outdated Show resolved Hide resolved
packages/knip/test/plugins/eleventy.test.ts Show resolved Hide resolved
@uncenter uncenter requested a review from webpro January 17, 2024 15:02
@uncenter
Copy link
Contributor Author

Will PRODUCTION_ENTRY_FILE_PATTERNS merge with the results of findDependencies?

@webpro
Copy link
Collaborator

webpro commented Jan 17, 2024

Will PRODUCTION_ENTRY_FILE_PATTERNS merge with the results of findDependencies?

Not automatically, we'll have to do that inside findDependencies

@uncenter
Copy link
Contributor Author

uncenter commented Jan 17, 2024

I actually think we don't want to that, since it might accidentally count some files as entry files when they really aren't. More "correct" versions of all of the PRODUCTION_ENTRY_FILE_PATTERNS are detectable by findDependencies.

@webpro
Copy link
Collaborator

webpro commented Jan 17, 2024

I actually think we don't want to that, since it might accidentally count some files as entry files when they really aren't. More "correct" versions of all of the PRODUCTION_ENTRY_FILE_PATTERNS are detectable by findDependencies.

What about the workspaces that don't have that .eleventy.js file? We'll need fallback values when there's no localConfig to parse, right?

@uncenter
Copy link
Contributor Author

uncenter commented Jan 17, 2024

Ah right, sorry. So maybe if (!localConfig) return PRODUCTION_ENTRY_FILE_PATTERNS instead of if (!localConfig) return []?

@webpro
Copy link
Collaborator

webpro commented Jan 17, 2024

Ah right. So maybe if (!localConfig) return PRODUCTION_ENTRY_FILE_PATTERNS instead of if (!localConfig) return []?

Exactly, in that case it should do something like it did without your PR :)

@uncenter
Copy link
Contributor Author

Done. Anything else?

Copy link
Collaborator

@webpro webpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great, almost there :)

packages/knip/src/plugins/eleventy/index.ts Outdated Show resolved Hide resolved
packages/knip/src/plugins/eleventy/index.ts Outdated Show resolved Hide resolved
packages/knip/src/plugins/eleventy/index.ts Outdated Show resolved Hide resolved
packages/knip/src/plugins/eleventy/index.ts Outdated Show resolved Hide resolved
@uncenter uncenter requested a review from webpro January 17, 2024 22:26
@uncenter
Copy link
Contributor Author

uncenter commented Jan 18, 2024

Wow that npm run watch tip was very helpful, I tested and verified it works on my website repository as well as the official Eleventy website repository. I've also reverted the change to PRODUCTION_ENTRY_FILE_PATTERNS.

@webpro
Copy link
Collaborator

webpro commented Jan 18, 2024

Thanks @uncenter!

By the way, I'm introducing Knip in the ESLint repo (eslint/eslint#18005) and they're using Eleventy for their docs (in the /docs folder). I think it might be interesting for users of Knip + 11ty to look if it's possible to extract out that dependency:

./node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js

Knip has function(s) to extract the algoliasearch from this so it does not need to be in ignoreDependencies.

My question is, do you think even trying this could be interesting for more Eleventy users? We don't need to solve it for a single case of course, but if there's more interest we might be able to give it a shot.

But I guess that should not be part of this PR. This PR is ready, right? Happy to merge it :)

@uncenter
Copy link
Contributor Author

Yep, good to merge!

@uncenter
Copy link
Contributor Author

And yep, I've actually been working on that! That kind of pattern of passthrough copying files from node_modules is also in the 11ty-website repo. I'll have a go at it in another PR later today.

@webpro webpro merged commit 85e7fe2 into webpro-nl:main Jan 18, 2024
8 of 11 checks passed
@uncenter uncenter deleted the impr/eleventy branch January 18, 2024 15:41
@webpro
Copy link
Collaborator

webpro commented Jan 18, 2024

And yep, I've actually been working on that! That kind of pattern of passthrough copying files from node_modules is also in the 11ty-website repo. I'll have a go at it in another PR later today.

Please don't feel pushed or anything, only if you like to :)

@uncenter
Copy link
Contributor Author

Entry files are prefixed withentry: and are dependencies just the name of the package with no prefix? Is that right?

@webpro
Copy link
Collaborator

webpro commented Jan 18, 2024

Entry files are prefixed withentry: and are dependencies just the name of the package with no prefix? Is that right?

Yes, exactly. When we know for sure in the plugin we're dealing with entry files we can mark them as such. When we don't do that, Knip might still figure it out, but that's more error-prone and slower.

@webpro
Copy link
Collaborator

webpro commented Jan 19, 2024

🚀 This pull request is included in v4.0.4. See Release 4.0.4 for release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eleventy plugin: ignore JavaScript "data" files
2 participants