-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate eui.d.ts after generating during build #1366
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ const path = require('path'); | |
const dtsGenerator = require('dts-generator').default; | ||
|
||
const baseDir = path.resolve(__dirname, '..'); | ||
const srcDir = path.resolve(baseDir, 'src'); | ||
|
||
const generator = dtsGenerator({ | ||
name: '@elastic/eui', | ||
|
@@ -23,16 +22,22 @@ const generator = dtsGenerator({ | |
const isRelativeImport = params.importedModuleId[0] === '.'; | ||
|
||
if (isRelativeImport) { | ||
// path to the import target, assuming it's a `.d.ts` file | ||
const importTargetDTs = `${path.resolve(srcDir, path.dirname(params.currentModuleId), params.importedModuleId)}.d.ts`; | ||
|
||
// if importing an `index` file | ||
const isModuleIndex = path.basename(params.importedModuleId) === 'index'; | ||
let isModuleIndex = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. our structure of means that index.ts should import from |
||
if (path.basename(params.importedModuleId) === 'index') { | ||
isModuleIndex = true; | ||
} else { | ||
const basePath = path.resolve(baseDir, path.dirname(params.currentModuleId)); | ||
// check if the imported module resolves to ${importedModuleId}/index.ts | ||
if (!fs.existsSync(path.resolve(basePath, `${params.importedModuleId}.ts`))) { | ||
// not pointing at ${importedModuleId}.ts, check if it's a directory with `index.ts` | ||
if (fs.existsSync(path.resolve(basePath, `${params.importedModuleId}/index.ts`))) { | ||
isModuleIndex = true; | ||
} | ||
} | ||
} | ||
|
||
if (fs.existsSync(importTargetDTs)) { | ||
// the import target is a `.d.ts` file which means it is hand-crafted and already added to the right places, don't modify | ||
return path.join('@elastic/eui', params.importedModuleId); | ||
} else if (isModuleIndex) { | ||
if (isModuleIndex) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
// importing an `index` file, in `resolveModuleId` above we change those modules to '@elastic/eui' | ||
return '@elastic/eui'; | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": [ | ||
"eui.d.ts" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
stdio: 'inherit'
here to give more visibility if any errors occur