Skip to content
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

Add next pages dev project #730

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion design-system/docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import withPreconstruct from '@preconstruct/next';
const nextConfig = {
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
experimental: { appDir: true, serverComponentsExternalPackages: ['esbuild'] },
experimental: { serverComponentsExternalPackages: ['esbuild'] },
// reactStrictMode: true,
// webpack: config => ({
// ...config,
Expand Down
1 change: 0 additions & 1 deletion dev-projects/next-app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const nextConfig = {
ignoreBuildErrors: true,
tsconfigPath: './tsconfig-for-next/tsconfig.json',
},
experimental: { appDir: true },
reactStrictMode: false,
async redirects() {
return [
Expand Down
4 changes: 4 additions & 0 deletions dev-projects/next-pages/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
5 changes: 5 additions & 0 deletions dev-projects/next-pages/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
42 changes: 42 additions & 0 deletions dev-projects/next-pages/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const withPreconstruct = require('@preconstruct/next');
const compiler = require('@ts-gql/compiler');
const path = require('path');

const withTsGql =
(internalConfig = {}) =>
(phase, thing) => {
if (phase === 'phase-development-server') {
compiler
.watch(path.resolve(__dirname, '../../packages/keystatic'))
.catch(err => {
console.error(err.toString());
process.exit(1);
});
}
let internalConfigObj =
typeof internalConfig === 'function'
? internalConfig(phase, thing)
: internalConfig;
return internalConfigObj;
};

/** @type {import('next').NextConfig} */
const nextConfig = {
eslint: { ignoreDuringBuilds: true },
typescript: {
ignoreBuildErrors: true,
tsconfigPath: './tsconfig-for-next/tsconfig.json',
},
reactStrictMode: false,
async redirects() {
return [
{
source: '/',
destination: '/keystatic',
permanent: false,
},
];
},
};

module.exports = withTsGql(withPreconstruct(nextConfig));
29 changes: 29 additions & 0 deletions dev-projects/next-pages/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@example/next-pages",
"version": "0.0.91",
"license": "MIT",
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev",
"start": "next start"
},
"dependencies": {
"@babel/runtime": "^7.18.3",
"@keystar/ui": "^0.4.0",
"@keystatic/core": "^0.1.9",
"@keystatic/next": "^1.0.0",
"@preconstruct/next": "^4.0.0",
"@types/react": "^18.2.8",
"graphql": "^16.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@ts-gql/compiler": "^0.16.1",
"@ts-gql/next": "^17.0.0",
"next": "^14.0.0",
"tsx": "^3.8.0",
"typescript": "^5.2.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { makeAPIRouteHandler } from '@keystatic/next/api';
import keystaticConfig from '../../../../next-app/keystatic.config';

export default makeAPIRouteHandler({ config: keystaticConfig });
4 changes: 4 additions & 0 deletions dev-projects/next-pages/pages/keystatic/[[...params]].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { makePage } from '@keystatic/next/ui/pages';
import keystaticConfig from '../../../next-app/keystatic.config';

export default makePage(keystaticConfig);
28 changes: 28 additions & 0 deletions dev-projects/next-pages/tsconfig-for-next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// next forcing specific tsconfig options is annoying
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": false,
"esModuleInterop": true,
"declaration": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"downlevelIteration": true,
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
21 changes: 21 additions & 0 deletions dev-projects/next-pages/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"declaration": true,
"downlevelIteration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"module": "esnext",
"moduleResolution": "bundler",
"noEmit": true,
"noUnusedLocals": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"types": ["node", "jest"]
},
"include": ["**/*"],
"exclude": ["**/dist/**/*", "**/node_modules/**/*"]
}
33 changes: 33 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.