Skip to content

Commit 1960a67

Browse files
committedFeb 8, 2024
Add webpack-cli to webpack plugin enablers (resolves #492)
1 parent 91bef85 commit 1960a67

File tree

7 files changed

+45
-1
lines changed

7 files changed

+45
-1
lines changed
 

‎packages/knip/fixtures/plugins/webpack-cli/node_modules/copy-webpack-plugin/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/knip/fixtures/plugins/webpack-cli/node_modules/copy-webpack-plugin/package.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/knip/fixtures/plugins/webpack-cli/node_modules/webpack-cli/package.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@fixtures/webpack-cli",
3+
"scripts": {
4+
"build": "webpack"
5+
},
6+
"dependencies": {},
7+
"devDependencies": {
8+
"webpack-cli": "*",
9+
"copy-webpack-plugin": "*"
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const CopyWebpackPlugin = require('copy-webpack-plugin');

‎packages/knip/src/plugins/webpack/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { RuleSetRule, RuleSetUseItem } from 'webpack';
1313

1414
const NAME = 'Webpack';
1515

16-
const ENABLERS = ['webpack'];
16+
const ENABLERS = ['webpack', 'webpack-cli'];
1717

1818
const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
1919

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import assert from 'node:assert/strict';
2+
// eslint-disable-next-line n/no-restricted-import
3+
import test from 'node:test';
4+
import { main } from '../../src/index.js';
5+
import { resolve } from '../../src/util/path.js';
6+
import baseArguments from '../helpers/baseArguments.js';
7+
import baseCounters from '../helpers/baseCounters.js';
8+
9+
const cwd = resolve('fixtures/plugins/webpack-cli');
10+
11+
test('Find dependencies in Webpack CLI-only configuration', async () => {
12+
const { counters } = await main({
13+
...baseArguments,
14+
cwd,
15+
});
16+
17+
assert.deepEqual(counters, {
18+
...baseCounters,
19+
processed: 1,
20+
total: 1,
21+
});
22+
});

0 commit comments

Comments
 (0)
Please sign in to comment.