Skip to content

Commit

Permalink
Track Angular polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlj95 committed Jan 13, 2025
1 parent 5a77dcc commit 0c75e54
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 14 deletions.
6 changes: 2 additions & 4 deletions packages/knip/fixtures/plugins/angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
"outputPath": "dist/knip-angular-example",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"polyfills": "src/polyfill.js",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
Expand Down Expand Up @@ -103,4 +101,4 @@
}
}
}
}
}
Empty file.
2 changes: 1 addition & 1 deletion packages/knip/fixtures/plugins/angular2/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
}
}
}
}
}
10 changes: 7 additions & 3 deletions packages/knip/fixtures/plugins/angular3/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@
"ssr": {
"entry": "src/server.ts"
},
"server": "src/main.server-for-non-prod.ts"
"server": "src/main.server-for-non-prod.ts",
"polyfills": [
"src/polyfill.js"
]
},
"configurations": {
"production": {
"server": "src/main.server.ts",
"scripts": ["src/script.js"]
},
"development": {
"scripts": ["src/script-for-non-prod.js"]
"scripts": ["src/script-for-non-prod.js"],
"polyfills": ["src/polyfill-for-non-prod.js"]
}
}
},
Expand All @@ -43,4 +47,4 @@
}
}
}
}
}
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions packages/knip/src/plugins/angular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ const entriesByOption = (opts: TargetOptions): EntriesByOption =>
typeof scriptStringOrObject === 'string' ? scriptStringOrObject : scriptStringOrObject.input
)
: [],
polyfills:
'polyfills' in opts && opts.polyfills
? Array.isArray(opts.polyfills)
? opts.polyfills
: [opts.polyfills]
: [],
fileReplacements:
'fileReplacements' in opts && opts.fileReplacements && Array.isArray(opts.fileReplacements)
? (opts.fileReplacements as FileReplacementsBuildOption).map(fileReplacement =>
Expand Down
4 changes: 2 additions & 2 deletions packages/knip/test/plugins/angular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test('Find dependencies with the Angular plugin', async () => {
devDependencies: 1,
unlisted: 1,
unresolved: 1,
processed: 3,
total: 3,
processed: 4,
total: 4,
});
});
8 changes: 4 additions & 4 deletions packages/knip/test/plugins/angular3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ test('Find dependencies with the Angular plugin (non-production)', async () => {
assert.deepEqual(counters, {
...baseCounters,
devDependencies: 1,
processed: 8,
total: 8,
processed: 10,
total: 10,
});
});

Expand All @@ -32,7 +32,7 @@ test('Find dependencies with the Angular plugin (production)', async () => {

assert.deepEqual(counters, {
...baseCounters,
processed: 4,
total: 4,
processed: 5,
total: 5,
});
});

0 comments on commit 0c75e54

Please sign in to comment.