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
Copy file name to clipboardExpand all lines: docs/PLATFORM_ISOLATION.md
+44-25Lines changed: 44 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,21 +4,27 @@
4
4
5
5
This project supports multiple runtime platforms (Browser, Node.js, React Native, and Universal), with separate entry points for each. To ensure the build artifacts work correctly, platform-specific code must not be mixed.
6
6
7
-
## Naming Convention
7
+
## Platform Declaration
8
8
9
-
Platform-specific files can be identified in two ways:
9
+
**Every non-test source file MUST export a `__platforms` array** to declare which platforms it supports. This is enforced by ESLint and validated at build time.
10
10
11
-
### 1. File Naming Convention (Single Platform)
11
+
### Export Declaration (Required)
12
12
13
-
For files specific to a single platform, use a suffix pattern:
If a file has both a platform suffix in its name AND a `__platforms` export, the `__platforms` export **takes priority**. This allows you to keep the `.browser.ts` naming convention while expanding support to additional platforms like React Native.
43
+
While not enforced, you may optionally use file name suffixes for clarity:
44
+
-`.browser.ts` - Typically browser-specific
45
+
-`.node.ts` - Typically Node.js-specific
46
+
-`.react_native.ts` - Typically React Native-specific
47
+
-`.ts` (no suffix) - Typically universal
48
+
49
+
**Note:** The validator currently enforces only the `__platforms` export declaration. File naming is informational and not validated. The `__platforms` export is the source of truth.
38
50
39
51
## Import Rules
40
52
@@ -51,9 +63,9 @@ A file is compatible if:
51
63
52
64
### Compatibility Examples
53
65
54
-
**Single Platform File (`.browser.ts` or `__platforms = ['browser']`)**
55
-
- ✅ Can import from: universal files, `.browser.ts` files, files with `['browser']` or `['browser', 'react_native']`
56
-
- ❌ Cannot import from: `.node.ts` files, files with `['node']` or `['react_native']` only
4. Validates that each import is compatible with the file's declared platforms
29
+
5. Fails with exit code 1 if any violations are found or if `__platforms` export is missing
30
+
31
+
**Note:** The validator can theoretically support file naming conventions (`.browser.ts`, etc.) in addition to `__platforms` exports, but currently enforces only the `__platforms` export. File naming is not validated and is considered redundant.
0 commit comments