Commit 89fa680
feat(typescript): process .js when allowJs is enabled (#1920)
* feat(typescript): honor allowJs and transform .js files\n\n- Expand default include to JS/JSX/MJS/CJS when is enabled\n- Avoid TS5055 by redirecting JS emit to a temp outDir when none is set\n- Add tests for downleveling JS (direct entry and TS->JS import)\n- Document behavior in README
* feat(typescript): auto-include JS when allowJs is set; use temp outDir and clean up\n\n- Use brace expansion in default include glob\n- Create per-build temp outDir under os.tmpdir(), exclude it from filter, and remove on build end\n- Document behavior in README
* fix(typescript): exclude effective outDir from filter to avoid re-processing outputs\n\n- Exclude user-configured or auto temp outDir from the plugin filter\n- Guard against excluding sources when outDir contains the filter root (e.g., outDir='.' with rootDir='src')\n\nImplements review feedback to avoid feedback loops with allowJs and user outDir.
* fix(typescript): use path.relative for robust outDir containment check
- Replace brittle startsWith-based check with path.relative to detect containment
- Address ESLint prefer-template with template literal
Refs #1920
* test(typescript): add regression ensuring user-configured outDir is excluded with allowJs
* fix(typescript): gate temp outDir cleanup to non-watch; cleanup in closeWatcher; harden outDir exclusion\n\n- Clean temp outDir only when not watching; perform final cleanup in closeWatcher to avoid watch-mode churn\n- Robust containment check for excluding outDir using drive-root equality + path.relative + !isAbsolute (handles Windows cross-drive)\n- When filterRoot=false, use CWD fallback for containment to avoid over-excluding sources (e.g., outDir='.')\n- Docs: clarify cleanup timing in README (non-watch vs watch)
* test(typescript): harden user outDir exclusion test (robust path check, guaranteed cleanup)
* fix(typescript): robust outDir containment; gate temp outDir cleanup in watch mode\n\n- Guard containment with cross-drive root check and absolute-relative detection\n- Skip over-exclusion when filterRoot is false by falling back to process.cwd()\n- Delete temp outDir only for non-watch builds; clean up in closeWatcher for watch\n- Docs: clarify effective outDir exclusion and watch-mode cleanup timing\n\nRefs #1920
# Conflicts:
# packages/typescript/README.md
# packages/typescript/src/index.ts
* test(typescript): make isInside helper treat equal path as inside; mirror plugin containment semantics
* test(typescript): remove REBUILD_WITH_WATCH_OFF from incremental-watch-off fixture
Drop the unused export from the fixture. It was only there to force a change and is no longer needed. No behavior change; keeps the test fixture minimal and avoids pointless noise.
* fix(typescript): guard string-only filterRoot base; close watch program on shutdown\n\n- Treat only string values of as a base path; fall back to tsconfig otherwise to avoid resolving boolean to 'true'\n- Align 's option with the same guard to prevent passing non-string truthy values\n- Close the TypeScript watch program in to release resources in watch mode\n\nRefs #1920
* fix(typescript): normalize Windows drive roots in containment; exclude node_modules by default when auto‑including JS\n\n- Normalize drive‑letter case when comparing roots in outDir containment (win32)\n- When allowJs expands include and user did not set include/exclude, add '**/node_modules/**' to exclude to avoid transforming third‑party code\n\nRefs #1920
* docs(typescript): note default node_modules exclusion when allowJs expands include
* fix(typescript): default filter resolve to cwd when rootDir unset\n\n- Align runtime with README for default: when is not a string and resolution is enabled\n- Prevents from receiving base in edge configs\n\nRefs #1920
* refactor(typescript): centralize temp outDir cleanup into a helper
- Deduplicate try/catch cleanup in buildEnd and closeWatcher via local function
- No behavior change; preserves watch vs non-watch cleanup semantics
Refs #1920
* refactor(typescript): unify program close + temp outDir cleanup via helper
- Add local closeProgramAndCleanup() that always cleans in finally
- Use in buildEnd (non-watch) and closeWatcher (watch)
Refs #1920
---------
Co-authored-by: CharlieHelps <[email protected]>1 parent 8851ea4 commit 89fa680
File tree
9 files changed
+210
-7
lines changed- packages/typescript
- src
- test
- fixtures
- allow-js-downlevel
- src
- allow-js-from-ts
- src
- incremental-single
9 files changed
+210
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
43 | 67 | | |
44 | 68 | | |
45 | | - | |
46 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
47 | 140 | | |
48 | 141 | | |
49 | 142 | | |
| |||
100 | 193 | | |
101 | 194 | | |
102 | 195 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 196 | + | |
106 | 197 | | |
107 | 198 | | |
108 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
109 | 205 | | |
110 | 206 | | |
111 | 207 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1629 | 1629 | | |
1630 | 1630 | | |
1631 | 1631 | | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
0 commit comments