-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[v3] migrate graphiql to vite and react compiler #3826
base: main
Are you sure you want to change the base?
Conversation
The latest changes of this PR are available as canary in npm (based on the declared |
8348526
to
8410fed
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3826 +/- ##
==========================================
- Coverage 63.98% 63.96% -0.03%
==========================================
Files 35 35
Lines 3088 3086 -2
Branches 937 949 +12
==========================================
- Hits 1976 1974 -2
Misses 1107 1107
Partials 5 5
|
crossorigin | ||
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" | ||
></script> | ||
<script src="/dist/index.umd.js"></script> |
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.
this should be graphiql.js or else it will break all the unpkg implementations
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.
what do you mean by it will break all the unpkg implementations
?
/dist/index.umd.js === /graphql.js
/dist/index.umd.js === /graphql.min.js
app.use(express.static(path.join(__dirname, '..'))); | ||
} else { | ||
app.get('/', (req, res) => { | ||
res.redirect('http://localhost:5173'); |
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.
this is fine as long as it's serving the unminified umd version
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.
I made to use umd build only on CI, and you can see that all tests pass
locally I replace umd import
graphiql/packages/graphiql/index.html
Lines 26 to 37 in ad75cda
<!--vite-replace-start--> | |
<script | |
crossorigin | |
src="https://unpkg.com/react@18/umd/react.production.min.js" | |
></script> | |
<script | |
crossorigin | |
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" | |
></script> | |
<script src="/dist/index.umd.js"></script> | |
<link href="/dist/style.css" rel="stylesheet" /> | |
<!--vite-replace-end--> |
with src/cdn.ts
graphiql/packages/graphiql/vite.config.mts
Lines 102 to 111 in ad75cda
const htmlForVite = /* HTML */ ` | |
<script type="module"> | |
import React from 'react'; | |
import ReactDOM from 'react-dom/client'; | |
import GraphiQL from './src/cdn'; | |
Object.assign(globalThis, { React, ReactDOM, GraphiQL }); | |
</script> | |
<link href="/src/style.css" rel="stylesheet" /> | |
`; |
this looks good so far, but we still need |
"exports": { | ||
"./package.json": "./package.json", | ||
"./style.css": "./dist/style.css", | ||
"./graphiql.css": "./dist/style.css", |
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.
exports don't work with jsdelivr/unpkg unfortunately, we must publish to npm with these exact files
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.
this is for backward compatibility since I added exports
field
I added prepublishOnly
with the exact files
graphiql/packages/graphiql/package.json
Line 48 in ad75cda
"prepublishOnly": "cp dist/index.umd.js graphiql.js && cp dist/index.umd.js.map graphiql.js.map && cp dist/index.umd.js graphiql.min.js && cp dist/index.umd.js.map graphiql.min.js.map && cp dist/style.css graphiql.css && cp dist/style.css graphiql.min.css", |
see #3826 (comment) |
prepublishOnly
with creating "graphiql.js", "graphiql.min.js", "graphiql.min.js.map", "graphiql.css", "graphiql.min.css"