Skip to content
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

fix: move up prod check in tsPath #858

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/config/ts-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ export async function tsPath(root: string, orig: string | undefined, plugin?: Pl

const isProduction = isProd()

// Do not skip ts-node registration if the plugin is linked
if (settings.tsnodeEnabled === undefined && isProduction && plugin?.type !== 'link') {
debug(`Skipping ts-node registration for ${root} because NODE_ENV is NOT "test" or "development"`)
return orig
}

if (cannotTranspileEsm(rootPlugin, plugin, isProduction)) {
debug(
`Skipping ts-node registration for ${root} because it's an ESM module (NODE_ENV: ${process.env.NODE_ENV}, root plugin module type: ${rootPlugin?.moduleType})`,
Expand All @@ -214,12 +220,6 @@ export async function tsPath(root: string, orig: string | undefined, plugin?: Pl
return orig
}

// Do not skip ts-node registration if the plugin is linked
if (settings.tsnodeEnabled === undefined && isProduction && plugin?.type !== 'link') {
debug(`Skipping ts-node registration for ${root} because NODE_ENV is NOT "test" or "development"`)
return orig
}

if (cannotUseTsNode(root, plugin, isProduction)) {
debug(`Skipping ts-node registration for ${root} because ts-node is run in node version ${process.version}"`)
memoizedWarn(
Expand Down
13 changes: 12 additions & 1 deletion src/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,15 @@ export class Performance {
if (!Performance.enabled) return

const oclifDebug = require('debug')('oclif-perf')
oclifDebug('Total Time: %sms', Performance.oclifPerf['oclif.runMs'].toFixed(4))
const processUpTime = (process.uptime() * 1000).toFixed(4)
oclifDebug('Process Uptime: %sms', processUpTime)
oclifDebug('Oclif Time: %sms', Performance.oclifPerf['oclif.runMs'].toFixed(4))
oclifDebug('Init Time: %sms', Performance.oclifPerf['oclif.initMs'].toFixed(4))
oclifDebug('Config Load Time: %sms', Performance.oclifPerf['oclif.configLoadMs'].toFixed(4))
oclifDebug(
' • Root Plugin Load Time: %sms',
Performance.getResult(OCLIF_MARKER_OWNER, 'plugin.load#root')?.duration.toFixed(4) ?? 0,
)
oclifDebug(
' • Plugins Load Time: %sms',
Performance.getResult(OCLIF_MARKER_OWNER, 'config.loadAllPlugins')?.duration.toFixed(4) ?? 0,
Expand Down Expand Up @@ -227,6 +233,11 @@ export class Performance {

oclifDebug('Command Load Time: %sms', Performance.oclifPerf['oclif.commandLoadMs'].toFixed(4))
oclifDebug('Command Run Time: %sms', Performance.oclifPerf['oclif.commandRunMs'].toFixed(4))
if (Performance.oclifPerf['oclif.configLoadMs'] > Performance.oclifPerf['oclif.runMs']) {
oclifDebug(
'! Config load time is greater than total oclif time. This might mean that Config was instantiated before oclif was run.',
)
}

const nonCoreDebug = require('debug')('non-oclif-perf')

Expand Down
2 changes: 1 addition & 1 deletion test/perf/parser.perf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ suite
.add('multiple async flags that take time', {
defer: true,
fn(deferred: {resolve: () => any}) {
parse(['--flagA', 'foo', '--flagA', 'bar'], {
parse(['--flagA', 'foo', '--flagB', 'bar'], {
flags: {
flagA: Flags.string({
async parse(input) {
Expand Down