-
Notifications
You must be signed in to change notification settings - Fork 83
[FSSDK-12092] add platform verification for imports #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a comprehensive platform isolation system for a multi-platform JavaScript SDK that supports Browser, Node.js, and React Native. The system enforces that platform-specific code cannot be imported by incompatible platforms, preventing runtime errors when bundling for different targets.
Key changes:
- Adds validation scripts that check
__platformsexports and import compatibility - Integrates ESLint rule to enforce platform declarations at development time
- Adds extensive documentation and troubleshooting guides
- Updates all source files to include
__platformsexports
Reviewed changes
Copilot reviewed 141 out of 142 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/validate-platform-isolation.js |
Main validation script that enforces platform isolation rules |
scripts/platform-utils.js |
Shared utilities for platform extraction and validation |
scripts/test-validator.js |
Test suite for platform compatibility rules |
scripts/add-platform-exports.js |
Auto-fix script to add missing __platforms exports |
.platform-isolation.config.js |
Configuration for include/exclude patterns |
eslint-local-rules/require-platform-declaration.js |
ESLint rule enforcing __platforms exports |
lib/platform_support.ts |
Type definition for valid platforms |
vitest.config.mts |
Adds coverage configuration |
docs/PLATFORM_ISOLATION.md |
Comprehensive platform isolation documentation |
package.json |
Adds validation scripts and new dependencies |
lib/**/*.ts |
Adds __platforms exports to all source files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR implements a comprehensive platform isolation system for a multi-platform JavaScript SDK that supports Browser, Node.js, and React Native. The system enforces that platform-specific code cannot be imported by incompatible platforms, preventing runtime errors when bundling for different targets.
Key changes:
__platformsexports and import compatibility__platformsexports based on file name__platformsexportsTest plan
Issues