Commit ece319f
authored
fix(preview): support generating preview for envs without a compiler (#10406)
## Problem
Running `bit build` on a component whose env has a bundler/preview but
**no compiler** failed during the
`teambit.preview/preview:GeneratePreview` task. An env without a
compiler became possible a while back, but it was only tested with the
preview disabled (e.g. `EmptyEnv` e2e tests, where the env has no
bundler so the preview task bails out early). When the preview is
actually needed, two issues surfaced:
1. `context.env.getCompiler is not a function` — the component bundling
strategy called `getCompiler()` directly, unlike every sibling call site
which already uses optional chaining.
2. After guarding that, `ENOENT` when writing the preview link file — it
targets the compiler's `dist` dir, which a compiler-less env never
creates.
## Fix
- Guard the `getCompiler()` call in
`ComponentBundlingStrategy.getComponentOutputPath`, matching the other
call sites.
- `ensureDirSync(targetDir)` before writing the preview link in
`writeLinkContents`, so a missing dist dir is created.
Verified end-to-end: a component on a bundler-but-no-compiler env now
builds through `GeneratePreview` and `PreBundlePreview` successfully.1 parent 743fe6b commit ece319f
5 files changed
Lines changed: 61 additions & 2 deletions
File tree
- components/legacy/e2e-helper/excluded-fixtures/extensions/react-no-compiler-env
- e2e/harmony
- scopes/preview/preview
- strategies
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
639 | 666 | | |
640 | 667 | | |
641 | 668 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
812 | 815 | | |
813 | 816 | | |
814 | 817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
385 | | - | |
386 | | - | |
| 385 | + | |
| 386 | + | |
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
| |||
0 commit comments