Skip to content

Commit

Permalink
drop create-react-app + swc in-repository test (#9060)
Browse files Browse the repository at this point in the history
Co-authored-by: YassinEldeeb <yassineldeeb94@gmail.com>
  • Loading branch information
n1ru4l and YassinEldeeb authored Mar 1, 2023
1 parent efa38a0 commit 03cdf02
Show file tree
Hide file tree
Showing 117 changed files with 661 additions and 6,286 deletions.
8 changes: 7 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": ["website", "example-*", "@graphql-codegen/client-preset-swc-plugin"],
"ignore": [
"website",
"example-*",
"@graphql-codegen/client-preset-swc-plugin",
"example-apollo-client-swc-plugin",
"example-react-nextjs-swr"
],
"changelog": [
"@changesets/changelog-github",
{
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ module.exports = {
],
ignorePatterns: [
'dev-test',
'examples/front-end',
'website',
'examples/**/gql/**',
'**/react-app-env.d.ts',
'packages/presets/swc-plugin/tests/fixtures/simple-uppercase-operation-name.js',
'packages/presets/swc-plugin/tests/fixtures/simple-uppercase-operation-name.other-dir.js',
'**/build/**/*',
'**/dist/**/*',
],
};
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ jobs:
uses: the-guild-org/shared-config/setup@main
with:
nodeVersion: 16
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.65.0
target: wasm32-wasi
override: true
- name: Build SWC plugin
working-directory: ./packages/presets/swc-plugin
run: |
npm run build-wasm
- name: Build
run: yarn build
env:
Expand Down Expand Up @@ -143,7 +152,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.65.0
target: wasm32-wasi
override: true
- uses: marcopolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ jobs:
githubToken: ${{ secrets.GUILD_BOT_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}

publish-rust-swc-plugin:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- uses: marcopolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139
with:
working-directory: ./packages/presets/swc-plugin
command: build
args: --target wasm32-wasi --release
- name: Publish SWC plugin
working-directory: ./packages/presets/swc-plugin
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

algolia:
uses: the-guild-org/shared-config/.github/workflows/algolia-publish.yml@main
secrets:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.65.0
target: wasm32-wasi
override: true
- name: Publish SWC plugin
- name: Build SWC plugin
working-directory: ./packages/presets/swc-plugin
run: |
npm run build-wasm
- name: Publish SWC plugin
working-directory: ./packages/presets/swc-plugin
run: |
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.swc
7 changes: 7 additions & 0 deletions examples/react/apollo-client-swc-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Apollo Client Vite SWR Example

Example of using the SWC plugin for smaller bundle size.

```bash
yarn dev
```
File renamed without changes.
13 changes: 13 additions & 0 deletions examples/react/apollo-client-swc-plugin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions examples/react/apollo-client-swc-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "example-apollo-client-swc-plugin",
"version": "0.1.0",
"private": true,
"dependencies": {
"@apollo/client": "^3.6.9",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@graphql-codegen/client-preset-swc-plugin": "0.1.1",
"@graphql-codegen/client-preset": "^2.0.0",
"@graphql-codegen/cli": "^3.0.0",
"@vitejs/plugin-react-swc": "^3.2.0",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"typescript": "4.9.5",
"vite": "^4.1.0"
},
"scripts": {
"dev": "vite",
"build": "vite build",
"test": "node scripts/test.js",
"test:end2end": "exit 0",
"codegen": "graphql-codegen --config codegen.ts"
}
}
1 change: 1 addition & 0 deletions examples/react/apollo-client-swc-plugin/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import './main.css';
import App from './App';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';

Expand All @@ -9,7 +9,7 @@ const client = new ApolloClient({
cache: new InMemoryCache(),
});

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
const root = ReactDOM.createRoot(document.getElementById('app') as HTMLElement);
root.render(
<React.StrictMode>
<ApolloProvider client={client}>
Expand Down
18 changes: 18 additions & 0 deletions examples/react/apollo-client-swc-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"noEmit": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions examples/react/apollo-client-swc-plugin/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
14 changes: 14 additions & 0 deletions examples/react/apollo-client-swc-plugin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react({
plugins: [
['@graphql-codegen/client-preset-swc-plugin', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }],
],
}),
],
});
13 changes: 13 additions & 0 deletions examples/react/apollo-client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
24 changes: 6 additions & 18 deletions examples/react/apollo-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,23 @@
"devDependencies": {
"@graphql-codegen/cli": "^3.2.1",
"@graphql-codegen/client-preset": "^2.1.0",
"@vitejs/plugin-react": "^3.1.0",
"@types/jest": "^27.5.2",
"@types/node": "^18.11.18",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.10",
"react-scripts": "^5.0.1",
"typescript": "4.9.5",
"serve": "14.2.0",
"cypress": "12.6.0",
"start-server-and-test": "2.0.0"
"start-server-and-test": "2.0.0",
"vite": "^4.1.0"
},
"scripts": {
"dev": "react-scripts start",
"build": "react-scripts build",
"start": "serve -s build",
"dev": "vite",
"build": "vite build",
"start": "serve -s dist",
"test": "cypress run",
"test:end2end": "start-server-and-test start http://localhost:3000 test",
"eject": "react-scripts eject",
"codegen": "graphql-codegen --config codegen.ts"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file removed examples/react/apollo-client/public/favicon.ico
Binary file not shown.
40 changes: 0 additions & 40 deletions examples/react/apollo-client/public/index.html

This file was deleted.

Binary file removed examples/react/apollo-client/public/logo192.png
Binary file not shown.
Binary file removed examples/react/apollo-client/public/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions examples/react/apollo-client/public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions examples/react/apollo-client/public/robots.txt

This file was deleted.

1 change: 1 addition & 0 deletions examples/react/apollo-client/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import './main.css';
import App from './App';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';

Expand All @@ -9,7 +9,7 @@ const client = new ApolloClient({
cache: new InMemoryCache(),
});

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
const root = ReactDOM.createRoot(document.getElementById('app') as HTMLElement);
root.render(
<React.StrictMode>
<ApolloProvider client={client}>
Expand Down
1 change: 0 additions & 1 deletion examples/react/apollo-client/src/react-app-env.d.ts

This file was deleted.

23 changes: 11 additions & 12 deletions examples/react/apollo-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"noEmit": true
},
"include": ["src"]
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
Loading

0 comments on commit 03cdf02

Please sign in to comment.