Skip to content

Commit

Permalink
Improve support for importing from index file, with or without custom…
Browse files Browse the repository at this point in the history
… paths or /index.x - #266 (#267)

Improve support for importing from index file, with or without custom paths or /index.x

* Add example to reproduce with import @x
* Working example - issue is the imported file is index.ts
* Improve support for importing from index file, with or without custom paths or /index.x
* Run itests using npm ci to preserve package lock versions
* Add more index itest cases
* Bump version
* Up CHANGELOG
  • Loading branch information
mrseanryan authored Feb 5, 2023
1 parent c496f7f commit a14db2d
Show file tree
Hide file tree
Showing 47 changed files with 864 additions and 33 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [9.0.3] - 5 Feb 2023

### Changed

- Fix for import from index file via a custom path - avoids false positives on index files - #266. Now tested with more cases such as import from "foo" OR import from "foo/index" with various file extensions supported.
- ts-unused-exports npm package: Updated the version in package-lock.json

## [9.0.2] - 15 Jan 2023

### Added
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Fork, then clone the repo:

Install dependencies:

npm i
npm ci

Make sure the tests pass:

Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.DS_Store
38 changes: 30 additions & 8 deletions example/absolute-paths-2-tsconfigs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/absolute-paths-2-tsconfigs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"scripts": {
"build": "tsc -p ./tsconfig.json",
"test": "npm i && npm run build && npm run test:test",
"test": "npm ci && npm run build && npm run test:test",
"test:test": "../../bin/ts-unused-exports ./tsconfig.json"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { MyComponent1 } from 'components/MyComponent';
import { fromIndex } from 'components/index';

const comp1: MyComponent1 = new MyComponent1();

export class UnusedComponent {}

console.log(fromIndex);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const fromIndex = "foo2";
24 changes: 23 additions & 1 deletion example/absolute-paths-simple/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/absolute-paths-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "main.js",
"scripts": {
"build": "tsc",
"test": "npm i && npm run build && ../../bin/ts-unused-exports ./tsconfig.json --ignorePaths=to-ignore"
"test": "npm ci && npm run build && ../../bin/ts-unused-exports ./tsconfig.json --ignorePaths=to-ignore"
},
"dependencies": {
"typescript": "^3.7.4"
Expand Down
1 change: 1 addition & 0 deletions example/absolute-paths-simple/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const fromIndex = "foo2";
1 change: 1 addition & 0 deletions example/absolute-paths-simple/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MyComponent1 } from 'components/MyComponent';
import { fromIndex } from 'components';

export class UnusedClassFromMain {}
2 changes: 1 addition & 1 deletion example/library-usage-via-JavaScript/execute.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm i && npm start
npm ci && npm start
2 changes: 1 addition & 1 deletion example/library-usage-via-TypeScript/execute.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm i && npm build && npm start
npm ci && npm build && npm start
2 changes: 1 addition & 1 deletion example/library-usage-via-TypeScript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"build": "tsc",
"start": "node ./dist/app.js",
"test": "npm i && ./node_modules/bin/ts-unused-exports ./tsconfig.json"
"test": "npm ci && ./node_modules/bin/ts-unused-exports ./tsconfig.json"
},
"dependencies": {
"ts-unused-exports": "^9.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm ci && npm test
Loading

0 comments on commit a14db2d

Please sign in to comment.