-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize --include-entry-exports, include scripts (closes #142)
- Loading branch information
Showing
16 changed files
with
96 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = () => {}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/fixtures/include-entry-exports-scripts/src/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Head from 'next/head'; | ||
|
||
function IndexPage() { | ||
return ( | ||
<div> | ||
<Head> | ||
<title>My page title</title> | ||
</Head> | ||
</div> | ||
); | ||
} | ||
|
||
export default IndexPage; |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...plugin-entry-exports/src/module3/index.ts → ...lude-entry-exports-scripts/src/script3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import assert from 'node:assert/strict'; | ||
import test from 'node:test'; | ||
import { main } from '../src/index.js'; | ||
import { resolve } from '../src/util/path.js'; | ||
import baseArguments from './helpers/baseArguments.js'; | ||
import baseCounters from './helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('tests/fixtures/include-entry-exports-scripts'); | ||
|
||
test('Skip unused exports in entry source files and scripts', async () => { | ||
const { counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
isIncludeEntryExports: false, | ||
}); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
processed: 5, | ||
total: 5, | ||
}); | ||
}); | ||
|
||
test('Report unused exports in source files and scripts (skip for plugin entry files)', async () => { | ||
const { counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
isIncludeEntryExports: true, | ||
}); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
exports: 5, | ||
processed: 5, | ||
total: 5, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,42 @@ | ||
import assert from 'node:assert/strict'; | ||
import test from 'node:test'; | ||
import { main } from '../src/index.js'; | ||
import { resolve, join } from '../src/util/path.js'; | ||
import { resolve } from '../src/util/path.js'; | ||
import baseArguments from './helpers/baseArguments.js'; | ||
import baseCounters from './helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('tests/fixtures/include-entry-exports'); | ||
|
||
test('Report unused files and exports in entry files', async () => { | ||
const { issues, counters } = await main({ | ||
test('Skip unused exports in entry source files', async () => { | ||
const { counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
isIncludeEntryExports: true, | ||
isIncludeEntryExports: false, | ||
}); | ||
|
||
assert(issues.files.has(join(cwd, 'unused.ts'))); | ||
|
||
assert(issues.exports['cli.js']['a']); | ||
assert(issues.exports['index.ts']['default']); | ||
assert(issues.exports['main.ts']['x']); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
files: 1, | ||
exports: 3, | ||
types: 3, | ||
processed: 5, | ||
total: 5, | ||
processed: 4, | ||
total: 4, | ||
}); | ||
}); | ||
|
||
test('Skip unused files and exports in entry files', async () => { | ||
test('Report unused exports in entry source files', async () => { | ||
const { issues, counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
isIncludeEntryExports: false, | ||
isIncludeEntryExports: true, | ||
}); | ||
|
||
assert(issues.files.has(join(cwd, 'unused.ts'))); | ||
assert(issues.exports['cli.js']['a']); | ||
assert(issues.exports['index.ts']['default']); | ||
assert(issues.exports['main.ts']['x']); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
files: 1, | ||
processed: 5, | ||
total: 5, | ||
exports: 3, | ||
types: 3, | ||
processed: 4, | ||
total: 4, | ||
}); | ||
}); |