Skip to content

Commit

Permalink
meta: fix js2ts script
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 30, 2023
1 parent df6043d commit 8130b88
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/@uppy/core/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"rootDir": "./src",
"resolveJsonModule": false,
"noImplicitAny": false,
"paths": {
"@uppy/store-default": ["../store-default/src/index.js"],
"@uppy/store-default/lib/*": ["../store-default/src/*"],
"@uppy/utils/lib/*": ["../utils/src/*"]
},
"skipLibCheck": true
},
"include": ["./src/**/*.*"],
Expand Down
7 changes: 6 additions & 1 deletion packages/@uppy/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"extends": "../../../tsconfig.shared",
"compilerOptions": {
"emitDeclarationOnly": false,
"noEmit": true
"noEmit": true,
"paths": {
"@uppy/store-default": ["../store-default/src/index.js"],
"@uppy/store-default/lib/*": ["../store-default/src/*"],
"@uppy/utils/lib/*": ["../utils/src/*"]
}
},
"include": ["./package.json", "./src/**/*.*"],
"references": [
Expand Down
3 changes: 3 additions & 0 deletions packages/@uppy/locales/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"compilerOptions": {
"outDir": "./lib",
"rootDir": "./src",
"paths": {
"@uppy/utils/lib/*": ["../utils/src/*"]
},
"skipLibCheck": true
},
"include": ["./src/**/*.*"],
Expand Down
3 changes: 3 additions & 0 deletions packages/@uppy/locales/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"extends": "../../../tsconfig.shared",
"compilerOptions": {
"emitDeclarationOnly": false,
"paths": {
"@uppy/utils/lib/*": ["../utils/src/*"]
},
"noEmit": true
},
"include": ["./package.json", "./src/**/*.*"],
Expand Down
12 changes: 7 additions & 5 deletions private/js2ts/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ const uppyDeps = Object.keys(packageJSON.dependencies || {})
.concat(Object.keys(packageJSON.devDependencies || {}))
.filter((pkg) => pkg.startsWith('@uppy/'))

// We want TS to check the source files so it doesn't use outdated (or missing) types:
const paths = Object.fromEntries(
(function* generatePaths() {
const require = createRequire(packageRoot)
for (const pkg of uppyDeps) {
const nickname = pkg.slice('@uppy/'.length)
// eslint-disable-next-line import/no-dynamic-require
const pkgJson = require(`../${nickname}/package.json`)
if (pkgJson.exports?.['.']) {
yield [pkg, [`../${nickname}/${pkgJson.exports['.']}`]]
} else if (pkgJson.main) {
yield [pkg, [`../${nickname}/${pkgJson.main}`]]
if (pkgJson.main) {
yield [
pkg,
[`../${nickname}/${pkgJson.main.replace(/^(\.\/)?lib\//, 'src/')}`],
]
}
yield [`${pkg}/*`, [`../${nickname}/*`]]
yield [`${pkg}/lib/*`, [`../${nickname}/src/*`]]
}
})(),
)
Expand Down

0 comments on commit 8130b88

Please sign in to comment.