-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdts-config.js
42 lines (36 loc) · 1.34 KB
/
dts-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const path = require('path')
const fs = require('fs')
const NGX_META_DIR = path.join('.', 'projects', 'ngx-meta')
const NGX_META_SRC_DIR = path.join(NGX_META_DIR, 'src')
const getDirectories = (source) =>
fs
.readdirSync(source, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
const getFiles = (source) => fs.readdirSync(source)
console.info('ℹ️ Looking for entry points')
const NG_PACKAGE_JSON_FILENAME = 'ng-package.json'
const ngxMetaSrcSubdirectories = getDirectories(NGX_META_SRC_DIR)
const ngxMetaEntrypoints = ngxMetaSrcSubdirectories.filter((subDirectory) => {
const ngxMetaSrcSubdirectory = path.join(NGX_META_SRC_DIR, subDirectory)
const files = getFiles(ngxMetaSrcSubdirectory)
return files.includes(NG_PACKAGE_JSON_FILENAME)
})
ngxMetaEntrypoints.forEach((entrypoint) => {
console.info('- ', entrypoint)
})
const NGX_META_DIST_DIR = path.join(NGX_META_DIR, 'dist')
const entries = ngxMetaEntrypoints.map((entrypoint) => ({
filePath: path.join(NGX_META_DIST_DIR, entrypoint, 'index.d.ts'),
outFile: path.join(NGX_META_DIST_DIR, entrypoint, 'bundled.d.ts'),
output: {
exportReferencedTypes: false,
},
}))
const config = {
compilationOptions: {
preferredConfigPath: path.join(NGX_META_SRC_DIR, 'tsconfig.lib.prod.json'),
},
entries,
}
module.exports = config