Installations
npm install vite-plugin-relay
Developer
oscartbeaumont
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
18.19.0
NPM Version
10.2.3
Statistics
81 Stars
247 Commits
14 Forks
4 Watching
9 Branches
8 Contributors
Updated on 18 Oct 2024
Languages
TypeScript (91.79%)
Shell (8.21%)
Total Downloads
Cumulative downloads
Total Downloads
803,696
Last day
-10.8%
4,053
Compared to previous day
Last week
22.2%
22,653
Compared to previous week
Last month
60.2%
86,544
Compared to previous month
Last year
116.2%
518,474
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
2
Vite Plugin Relay
❤️ Special thanks to:
- @Brendonovich for general help
- @kesne for adding pnpm support
- @tobias-tengler for adding Vite 3 support
I do not actively use this project anymore, however, it will still receive periodic updates.
Usage
Follow Relay's guide on how to add Relay to your project.
⚠️ Note: Install
babel-plugin-relay
(>= 13.0.1) as devDependencies as instructed, but skip its configuration.vite-plugin-relay
will invoke the babel plugin for you!
Add vite-plugin-relay
to your devDependencies
:
1yarn add vite-plugin-relay -D
Add vite-plugin-relay
to your Vite configuration (vite.config.ts
or vite.config.js
):
1import { defineConfig } from "vite"; 2import relay from "vite-plugin-relay"; 3 4export default defineConfig({ 5 plugins: [..., relay], 6});
Configure relay-compiler
to output artifacts with export default
syntax, by setting eagerEsModules
to true
:
1{ 2 "relay": { 3 "src": "./src", 4 "schema": "./src/schema.graphql", 5 "language": "typescript", 6 "eagerEsModules": true, 7 "exclude": ["**/node_modules/**", "**/__mocks__/**", "**/__generated__/**"] 8 } 9}
Now your project is setup to use Relay with Vite!
How this plugin works
Under the hood we are invoking the official babel-plugin-relay
. This ensures that our plugin and babel-plugin-relay
do not get out of sync over time and also reduces the maintainance costs of this project.
Since v13 babel-plugin-relay
automatically gets its configuration from either the package.json
, relay.config.js
or relay.config.json
, so our plugin also doesn't have to expose a configuration API.
Common Issues
Uncaught ReferenceError: global is not defined
If you experience this error in your browser console when using the plugin add the following define to your index.html
file before importing your Javascript:
1<script> 2 let global = globalThis; 3</script>
Server Side Rendering
If you are planning to use this plugin with server side rendering you may need to define window
. You could do this by putting the following snippet in your entry-server.js
file.
1if (typeof (window as any).global === 'undefined') { 2 (window as any).global = globalThis; 3}
Contributing
git clone ...
pnpm i
# If you have never run Playwright run `npx playwright install` to setup your system.
cd examples/vite-3
pnpm dev
pnpm format # Do this before doing a commit
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
4 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
Reason
Found 6/11 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/release.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/oscartbeaumont/vite-plugin-relay/release.yml/main?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 3 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 27 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More