Skip to content

[v3] migrate graphiql to vite and react compiler#3826

Merged
dimaMachina merged 80 commits intomainfrom
react-compiler2
Apr 25, 2025
Merged

[v3] migrate graphiql to vite and react compiler#3826
dimaMachina merged 80 commits intomainfrom
react-compiler2

Conversation

@dimaMachina
Copy link
Collaborator

  • I took my changes from GraphiQL v4 new tabs look for graphiql v4 #3685
  • added prepublishOnly with creating "graphiql.js", "graphiql.min.js", "graphiql.min.js.map", "graphiql.css", "graphiql.min.css"

crossorigin
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
></script>
<script src="/dist/index.umd.js"></script>
Copy link
Member

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

Copy link
Collaborator Author

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');
Copy link
Member

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

Copy link
Collaborator Author

@dimaMachina dimaMachina Dec 15, 2024

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

<!--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

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" />
`;

@acao
Copy link
Member

acao commented Dec 14, 2024

this looks good so far, but we still need graphiql.min.js and graphiql.js as the UMD versions or it will break all the many unpkg/jsdelivr implementations, just do a github code search and you'll see thousands. the benefits of consistent naming here are much less important than this pivotal backwards compatibility for our majority of users.

"exports": {
"./package.json": "./package.json",
"./style.css": "./dist/style.css",
"./graphiql.css": "./dist/style.css",
Copy link
Member

@acao acao Dec 14, 2024

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

Copy link
Collaborator Author

@dimaMachina dimaMachina Dec 15, 2024

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

"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",

@dimaMachina
Copy link
Collaborator Author

this looks good so far, but we still need graphiql.min.js and graphiql.js as the UMD versions or it will break all the many unpkg/jsdelivr implementations, just do a github code search and you'll see thousands. the benefits of consistent naming here are much less important than this pivotal backwards compatibility for our majority of users.

see #3826 (comment)

@dimaMachina dimaMachina requested a review from acao December 15, 2024 15:15
@dimaMachina dimaMachina mentioned this pull request Mar 6, 2025
30 tasks
dimaMachina and others added 3 commits April 25, 2025 19:03
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
@dimaMachina dimaMachina merged commit cb29e9f into main Apr 25, 2025
14 checks passed
@dimaMachina dimaMachina deleted the react-compiler2 branch April 25, 2025 22:07
@acao acao mentioned this pull request Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants