Commit 67510a2
fix(function): support multiline import type statements in import scanning (#4872)
* fix(function): support multiline import type statements in import scanning
The regex pattern `.*?` does not match newlines, causing multiline
`import type { X }` statements to be skipped during bind-mount file
scanning. This results in type-only imports not being mounted in
the Docker container, causing runtime errors like:
worker boot error: Module not found "file:///.../types/MyType.ts"
Changed `.*?` to `[\s\S]*?` to match any character including newlines,
consistent with the `{[^{}]+}` pattern used for braced imports.
This fix enables proper handling of Deno 2.x style multiline type imports:
```typescript
import type {
MyType,
OtherType,
} from './types.ts'
```
Includes test case to prevent regression.
* test(function): add non-braced default type import to fixture
Cover `import type Foo from '...'` pattern in the multiline import
type test. This form also routes through the `[\s\S]*?` branch and
was previously untested.
* fix(function): use (?:type\s+)? for multiline import type matching
Narrow the regex fix for multiline import type statements per PR review feedback. Instead of widening .*? to [\s\S]*? (which affects all import patterns), add (?:type\s+)? to consume the type keyword so braced imports route into the {[^{}]+} branch that already handles newlines.
---------
Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>1 parent 9efbdaa commit 67510a2
File tree
4 files changed
+49
-1
lines changed- pkg/function
- testdata
- modules
- types
4 files changed
+49
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
89 | 104 | | |
90 | 105 | | |
91 | 106 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments