Repository navigation
Commit efecdab
committed
fix(typesync): make dynamic import work on Windows
Problem
-------
`@effect/sql`’s File-system loader passes a raw Win32 path such as
C:\project\apps\typesync\src\migrations\1_create_table__app.js
directly to `import()`.
On Windows the Node ESM loader interprets the leading
“C:” as a URL scheme and throws:
Only URLs with a scheme in: file, data, and node are supported …
Received protocol 'c:'
(Linux and macOS do not throw because the path starts with '/'.)
See Node issue: nodejs/node#31710
See Effect issue: Effect-TS/effect#4297
Fix
---
1. Keep `dir` as a *plain OS path* when calling
`FileSystem.readDirectory(dir)` (still required by platform-fs).
2. Convert the specifier used by the dynamic `import()` to a **file URL**
with `pathToFileURL(...).href`.
3. Extend the filename RegExp to accept both “/” and “\” separators.
Result
------
• Behaviour on POSIX remains unchanged.
• Migrations now load correctly on Windows.
• No other library code is touched; the change can be removed once the
upstream patch is released.
Affected files:
• apps/typesync/src/Database.ts – use fromFileSystem() helper
• apps/typesync/src/Utils.ts – add fromFileSystem() helper1 parent b043cf2 commit efecdab
2 files changed
Lines changed: 55 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | | - | |
15 | | - | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
0 commit comments