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: Nice errors for shim flag parsing #6737

Merged
merged 11 commits into from
Dec 14, 2023

Conversation

NicholasLYang
Copy link
Contributor

@NicholasLYang NicholasLYang commented Dec 7, 2023

Description

This adds nice errors for shim parsing:

Screenshot 2023-12-07 at 5 31 42 PM Screenshot 2023-12-07 at 5 38 17 PM

Testing Instructions

Added test for error output

Closes TURBO-1874

Copy link

vercel bot commented Dec 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-designsystem-docs 🔄 Building (Inspect) Visit Preview 💬 Add feedback Dec 13, 2023 5:22pm
examples-vite-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback Dec 13, 2023 5:22pm
rust-docs ❌ Failed (Inspect) Dec 13, 2023 5:22pm
8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm
examples-nonmonorepo ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm
turbo-site ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 5:22pm

Copy link
Contributor

github-actions bot commented Dec 7, 2023

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Dec 7, 2023

🟢 CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Dec 7, 2023

Linux Benchmark for 22ea3ee

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 27.01ms ± 0.84ms 26.73ms ± 0.88ms -1.03%
bench_hmr_to_eval/Turbopack CSR/1000 modules 26.46ms ± 0.92ms 26.35ms ± 0.87ms -0.39%
bench_startup/Turbopack CSR/1000 modules 1321.09ms ± 6.75ms 1323.70ms ± 11.94ms +0.20%

Copy link
Contributor

github-actions bot commented Dec 7, 2023

Linux Benchmark for 13c90b5

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 24.49ms ± 0.79ms 24.59ms ± 0.76ms +0.42%
bench_hmr_to_eval/Turbopack CSR/1000 modules 23.24ms ± 1.11ms 24.05ms ± 0.75ms +3.49%
bench_startup/Turbopack CSR/1000 modules 1285.73ms ± 2.38ms 1283.59ms ± 10.06ms -0.17%

@NicholasLYang NicholasLYang changed the title feat: Error provenance feat: Nice errors for shim flag parsing Dec 7, 2023
Copy link
Contributor

github-actions bot commented Dec 7, 2023

Linux Benchmark for 65d4d8e

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.38ms ± 0.82ms 25.49ms ± 0.87ms +0.41%
bench_hmr_to_eval/Turbopack CSR/1000 modules 24.94ms ± 0.83ms 24.98ms ± 0.80ms +0.16%
bench_startup/Turbopack CSR/1000 modules 1281.56ms ± 3.66ms 1281.97ms ± 13.82ms +0.03%

@NicholasLYang NicholasLYang marked this pull request as ready for review December 8, 2023 16:08
@NicholasLYang NicholasLYang requested review from a team as code owners December 8, 2023 16:08
Copy link
Contributor

github-actions bot commented Dec 8, 2023

Linux Benchmark for 02e3c1a

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 24.51ms ± 0.83ms 24.60ms ± 0.90ms +0.38%
bench_hmr_to_eval/Turbopack CSR/1000 modules 24.20ms ± 0.76ms 24.26ms ± 0.75ms +0.26%
bench_startup/Turbopack CSR/1000 modules 1285.64ms ± 8.46ms 1295.48ms ± 14.41ms +0.77%

Copy link
Contributor

github-actions bot commented Dec 8, 2023

Linux Benchmark for 7c45361

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.25ms ± 0.83ms 25.27ms ± 0.83ms +0.08%
bench_hmr_to_eval/Turbopack CSR/1000 modules 24.91ms ± 0.82ms 24.90ms ± 0.79ms -0.05%
bench_startup/Turbopack CSR/1000 modules 1294.04ms ± 6.30ms 1283.70ms ± 8.42ms -0.80%

Copy link
Contributor

github-actions bot commented Dec 8, 2023

Linux Benchmark for b1c68b7

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 24.31ms ± 0.79ms 24.41ms ± 0.76ms +0.41%
bench_hmr_to_eval/Turbopack CSR/1000 modules 23.91ms ± 0.78ms 23.97ms ± 0.79ms +0.25%
bench_startup/Turbopack CSR/1000 modules 1301.50ms ± 8.26ms 1305.09ms ± 11.57ms +0.28%

@NicholasLYang NicholasLYang marked this pull request as ready for review December 8, 2023 20:15
Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Nothing blocking, just a few suggestions/questions

crates/turborepo-lib/src/lib.rs Show resolved Hide resolved
crates/turborepo-lib/src/lib.rs Show resolved Hide resolved
crates/turborepo-lib/src/shim.rs Outdated Show resolved Hide resolved
crates/turborepo-lib/src/shim.rs Outdated Show resolved Hide resolved
flag2: Option<SourceSpan>,
#[label("and here")]
flag3: Option<SourceSpan>,
// The user should get the idea after the first 4 examples
Copy link
Member

Choose a reason for hiding this comment

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

Haha, I would hope so. I would hope 2 examples would be enough.

) -> Vec<usize> {
// Sort the indices to keep the invariant
// that if i > j then output[i] > output[j]
args_indices.sort();
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to require callers to keep up this invariant? e.g. If I pass in vec![2, 1] and get out vec![3, 6] would I be in a bad state when I try to map the indices to the args.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I think the idea is you shouldn't be mapping these to args, since they're now indices into the string. And unless you parse the string it's not really easy to map the indices to the args.

Comment on lines 232 to 235
pub(crate) fn get_indices_in_args_string(
mut args_indices: Vec<usize>,
args: impl Iterator<Item = impl Into<String>>,
) -> Vec<usize> {
Copy link
Member

Choose a reason for hiding this comment

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

This feels like a "sharp" interface and I have a few suggestions:

  • Make this a private function
  • Since this is only used for making pretty error messages, I don't think we need to make this as perf sensitive as it currently is. We can generate the indices into the arg strings for all args and not just ones passed in as arg_indices.
  • Based on how we're using this. Do we just want to calculate the spans here instead of having callers do stuff like (idx, "--flag".len())?

Co-authored-by: Chris Olszewski <chris.olszewski@vercel.com>
@NicholasLYang NicholasLYang merged commit 7d458ce into main Dec 14, 2023
60 of 61 checks passed
@NicholasLYang NicholasLYang deleted the nicholasyang/error-provenance branch December 14, 2023 16:20
kdy1 added a commit to vercel/next.js that referenced this pull request Jan 2, 2024
### What?

Update SWC crates

### Why?

It's required to fix some next.js isssues

### How?

Closes PACK-2174
Turbopack counterpart: vercel/turborepo#6843

---


# Turbopack

* vercel/turborepo#6737 <!-- Nicholas Yang - feat:
Nice errors for shim flag parsing -->
* vercel/turborepo#6494 <!-- Justin Ridgewell -
Trace output's source maps through input's source map -->
* vercel/turborepo#6778 <!-- Will Binns-Smith -
turbopack-css: fix rule duplication -->
* vercel/turborepo#6807 <!-- Mehul Kar - fix: add
missing dependency to cargo lockfile -->
* vercel/turborepo#6809 <!-- Nicholas Yang -
refactor: Remove bookkeeping abstraction from turbo config -->
* vercel/turborepo#6838 <!-- Nicholas Yang - fix:
Allow for long symlinks by using append_link -->
* vercel/turborepo#6845 <!-- Donny/강동윤 - perf: Use
`&'static str` instead of `String` if possible -->
* vercel/turborepo#6843 <!-- Donny/강동윤 - Update
`swc_core` to `v0.87.10` -->
agustints pushed a commit to agustints/next.js that referenced this pull request Jan 6, 2024
### What?

Update SWC crates

### Why?

It's required to fix some next.js isssues

### How?

Closes PACK-2174
Turbopack counterpart: vercel/turborepo#6843

---


# Turbopack

* vercel/turborepo#6737 <!-- Nicholas Yang - feat:
Nice errors for shim flag parsing -->
* vercel/turborepo#6494 <!-- Justin Ridgewell -
Trace output's source maps through input's source map -->
* vercel/turborepo#6778 <!-- Will Binns-Smith -
turbopack-css: fix rule duplication -->
* vercel/turborepo#6807 <!-- Mehul Kar - fix: add
missing dependency to cargo lockfile -->
* vercel/turborepo#6809 <!-- Nicholas Yang -
refactor: Remove bookkeeping abstraction from turbo config -->
* vercel/turborepo#6838 <!-- Nicholas Yang - fix:
Allow for long symlinks by using append_link -->
* vercel/turborepo#6845 <!-- Donny/강동윤 - perf: Use
`&'static str` instead of `String` if possible -->
* vercel/turborepo#6843 <!-- Donny/강동윤 - Update
`swc_core` to `v0.87.10` -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants