Skip to content

Commit

Permalink
Check for node_modules presence instead of isInternal for Eleventy pl…
Browse files Browse the repository at this point in the history
…ugin (#462)

* Check for node_modules presence instead of isInternal

* Remove unused import

* Update fixtures to catch regression
  • Loading branch information
uncenter authored Jan 21, 2024
1 parent 59e341f commit c0b23b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/knip/fixtures/plugins/eleventy2/.eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addNunjucksShortcode('link', () => {});
eleventyConfig.addShortcode('related_rules', () => {});
eleventyConfig.addWatchTarget('./src/assets/');
eleventyConfig.addPassthroughCopy({
'src/_includes/abc.js': '/assets/abc.js',
});
eleventyConfig.addPassthroughCopy({
'./src/static': '/',
});
Expand Down
8 changes: 4 additions & 4 deletions packages/knip/src/plugins/eleventy/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DEFAULT_EXTENSIONS } from '../../constants.js';
import { isDirectory } from '../../util/fs.js';
import { dirname, isInternal, join } from '../../util/path.js';
import { dirname, isInNodeModules, join } from '../../util/path.js';
import { timerify } from '../../util/Performance.js';
import { hasDependency, load } from '../../util/plugin.js';
import { toProductionEntryPattern } from '../../util/protocols.js';
Expand Down Expand Up @@ -50,10 +50,10 @@ const findEleventyDependencies: GenericPluginCallback = async (configFilePath, o
const isDir = !path.includes('*') && isDirectory(join(dirname(configFilePath), path));
if (isDir) {
copiedEntries.add(join(path, `**/*.{${exts}}`));
} else if (isInternal(path)) {
copiedEntries.add(path);
} else {
} else if (isInNodeModules(path)) {
copiedPackages.add(path);
} else {
copiedEntries.add(path);
}
}

Expand Down

0 comments on commit c0b23b5

Please sign in to comment.