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

feat(node): Add a function to resolve entry point type #14352

Merged
merged 7 commits into from
Nov 28, 2024

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Nov 18, 2024

/**
 * Gets the current entry point type.
 *
 * `app` means this function was most likely called via the app entry point.
 * `import` means this function was most likely called from an --import cli arg.
 * `require` means this function was most likely called from a --require cli arg.
 * `unknown` means we couldn't determine for sure.
 */
export function getEntryPointType(): 'import' | 'require' | 'app' | 'unknown' {

Can be used to:

The code makes a point of returning unknown rather than giving false positives. For example, it returns unknown in these cases:

  • Users pass paths to the Node CLI without file extensions
  • There are filenames in the stack trace that match both the app entry point and --import/--require

@timfish timfish requested a review from mydea November 18, 2024 23:13
@@ -4,7 +4,7 @@
"include": ["src/**/*"],

"compilerOptions": {
"lib": ["es2018"],
"lib": ["es2018", "es2020.string"],
Copy link
Collaborator Author

@timfish timfish Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to use string.matchAll and it turns out everything in es2020.string is fully supported by all the Node versions we support.

Copy link

codecov bot commented Nov 18, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
205 1 204 9
View the top 1 failed tests by shortest run time
client-app-routing-instrumentation.test.ts Creates a navigation transaction for app router routes
Stack Traces | 30s run time
client-app-routing-instrumentation.test.ts:19:5 Creates a navigation transaction for app router routes

To view more test analytics, go to the Test Analytics Dashboard
Got feedback? Let us know on Github

Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@timfish timfish marked this pull request as ready for review November 19, 2024 08:11
@lforst lforst merged commit cfb68ca into develop Nov 28, 2024
109 checks passed
@lforst lforst deleted the timfish/feat/getExecutionContext branch November 28, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants