You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c4256c2
Browse filesBrowse the repository at this point in the historyBrowse files
Ignore fully type-only imports and re-exports when collecting import-protection sources so type-only references to protected modules do not trigger violations.
Copy file name to clipboardExpand all lines: docs/start/framework/react/guide/import-protection.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,24 @@ By default, files inside `node_modules` are excluded from resolved-target deny c
42
42
43
43
These defaults mean you can use the `.server.ts` / `.client.ts` naming convention to restrict files to a single environment without any configuration. To also deny entire directories (e.g. `server/` or `client/`), add them via `files` in your [deny rules configuration](#configuring-deny-rules) — for example `files: ['**/*.server.*', '**/server/**']` for the client environment.
44
44
45
+
## Type-Only Imports
46
+
47
+
Type-only imports and re-exports are ignored by import protection because they are erased from the runtime bundle and cannot leak environment-specific code.
Mixed imports still count when they include at least one runtime value. Split the type and value imports if only the type is safe to cross the environment boundary.
57
+
58
+
```ts
59
+
// This is still checked because `getUsers` is a runtime value.
60
+
import { typeUser, getUsers } from'./db.server'
61
+
```
62
+
45
63
## File Markers
46
64
47
65
You can explicitly mark a module as server-only or client-only by adding a side-effect import at the top of the file:
0 commit comments