-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: read extended tsconfigs #845
Conversation
This issue has been linked to a new work item: W-14388909 |
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.
requested changes are the public api questions and interface stuff
src/config/plugin.ts
Outdated
return ids | ||
} | ||
|
||
public async getCommandsDir(): Promise<string | undefined> { |
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.
do consumers of Plugin need this method publicly exposed?
src/config/plugin.ts
Outdated
@@ -162,8 +150,25 @@ export class Plugin implements IPlugin { | |||
return cmd | |||
} | |||
|
|||
public async getCommandIDs(): Promise<string[]> { |
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.
do consumers of Plugin need this method publicly exposed? Or is the commandIDs property enough?
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.
they're not in the interface so maybe private
or #getCommandIDs
is appropriate?
or a function that takes the name
and commandsDir
?
src/config/ts-node.ts
Outdated
const final = {...result.tsconfig, 'ts-node': tsNodeOpts} | ||
|
||
TS_CONFIGS[root] = final |
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.
const final = {...result.tsconfig, 'ts-node': tsNodeOpts} | |
TS_CONFIGS[root] = final | |
TS_CONFIGS[root] = {...result.tsconfig, 'ts-node': tsNodeOpts} |
@@ -38,7 +38,7 @@ export async function load<T = any>(config: IConfig | IPlugin, modulePath: strin | |||
let filePath: string | undefined | |||
let isESM: boolean | undefined | |||
try { | |||
;({filePath, isESM} = resolvePath(config, modulePath)) | |||
;({filePath, isESM} = await resolvePath(config, modulePath)) |
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.
what's the semicolon for?
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.
Not sure to be honest - it's a default prettier thing
test/integration/esm-cjs.ts
Outdated
await test('Install CJS plugin to CJS root plugin', async () => { | ||
await installTest(PLUGINS.cjs2, cjsExecutor) | ||
}) | ||
// await test('Install CJS plugin to CJS root plugin', async () => { |
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.
why are these commented out?
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.
Commented out for iterating on tests - thanks for catching!
src/config/plugin.ts
Outdated
export class Plugin implements IPlugin { | ||
alias!: string | ||
|
||
alreadyLoaded = false | ||
|
||
children: Plugin[] = [] | ||
|
||
commandIDs!: string[] |
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.
doesn't the code below break the interface? When it was a getter, it would always return something. The !
means that it's not possible to have a Plugin (class) without commandIDs, but without calling load()
you would.
Maybe init them as empty arrays and then load can fix them if it runs?
src/config/ts-node.ts
Outdated
let tsNodeOpts = {} | ||
for (const extended of (result.extended ?? []).reverse()) { | ||
if (extended.tsconfig['ts-node']) { | ||
tsNodeOpts = {...tsNodeOpts, ...extended.tsconfig['ts-node']} | ||
} | ||
} |
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.
not 100% sure this works, but fromEntries() is LWW so you don't have to reverse the array to get the last ones in first for Object.assign.
const tsNodeOpts = Object.fromEntries(
(result.extended ?? [])
.map((e) => Object.entries(e.tsconfig['ts-node'] ?? {}))
)
src/config/plugin.ts
Outdated
commands!: Command.Loadable[] | ||
|
||
commandsDir!: string | undefined |
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.
I don't understand what !
means if there's also string | undefined
. Seems like an contradiction?
src/config/plugin.ts
Outdated
this.hooks = {} | ||
for (const [k, v] of Object.entries(this.pjson.oclif.hooks ?? {})) { | ||
// eslint-disable-next-line no-await-in-loop | ||
this.hooks[k] = await Promise.all(castArray(v).map(async (i) => tsPath(this.root, i, this))) |
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.
I don't have a good sense for how long tsPath
takes to run, or how many hooks there could be per plugin, but what's the reason for not parallelizing these?
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.
this.hooks = Object.fromEntries(await Promise.all(
Object.entries(this.pjson.oclif.hooks ?? {})
.map(async ([k, v]) => [k, await Promise.all(
castArray(v).map(async (i) => tsPath(this.root, i, this))
)])
))
QA notes: linked this PR into plugin-user to use bin/dev (cjs),
set {
"ts-node": {
"transpileOnly": true
}
}
in main/top-level tsconfig, showConfig:true. In what it extends (
I think I was expecting true...like the top-level one extends other ones, and should override them. So maybe that one needs to get added to the |
QA round 2: linked into plugin-user. All permutations of top-level tsconfig, plus local modifications to dev-config/tsconfig-strict which extends dev-config/tsconfig. ✅ all working with proper results when toggling a single ts-node prop (showConfig)
linked plugin into |
tsconfig
totsNode.register
tsconfck
instead oftypescript
for reading/merging extended tsconfigs