-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a30b1a
commit 580554b
Showing
17 changed files
with
317 additions
and
66 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
e2e/router/src/routes/+layout.jsx → e2e/router/src/routes/+layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { PageProps } from './$types' | ||
|
||
export default function ({ HelloRouter }: PageProps) { | ||
return <div>{HelloRouter.message}!</div> | ||
} |
6 changes: 4 additions & 2 deletions
6
e2e/router/src/routes/users/[id]/+page.jsx → e2e/router/src/routes/users/[id]/+page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,3 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"useDefineForClassFields": true, | ||
"lib": ["DOM", "DOM.Iterable", "ESNext"], | ||
"allowJs": false, | ||
"skipLibCheck": true, | ||
"esModuleInterop": false, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
"paths": { | ||
"$houdini": ["./$houdini"], | ||
"$houdini/*": ["./$houdini/*"] | ||
} | ||
}, | ||
"include": ["src"], | ||
"references": [{ "path": "./tsconfig.node.json" }] | ||
"extends": "./$houdini/tsconfig.json" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,8 @@ | ||
import react from '@vitejs/plugin-react' | ||
import houdini from 'houdini/vite' | ||
import path from 'path' | ||
import { defineConfig } from 'vite' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [houdini(), react({ fastRefresh: false })], | ||
// TODO: the vite plugin should do this | ||
resolve: { | ||
alias: { | ||
$houdini: path.resolve('.', '/$houdini'), | ||
'$houdini/*': path.resolve('.', '/$houdini', '*'), | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/houdini-react/src/plugin/codegen/typeRoot.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { fs } from 'houdini' | ||
import { test, expect } from 'vitest' | ||
|
||
import { test_config } from '../config' | ||
import { load_manifest } from './manifest' | ||
import { generate_type_root } from './typeRoot' | ||
|
||
test('generates type files for pages', async function () { | ||
const config = await test_config() | ||
|
||
// create the mock filesystem | ||
await fs.mock({ | ||
[config.routesDir]: { | ||
'+layout.gql': mockQuery('LayoutQuery'), | ||
'+page.tsx': mockView(['LayoutQuery']), | ||
'(subRoute)': { | ||
'+page.tsx': mockView(['FinalQuery']), | ||
'+page.gql': mockQuery('FinalQuery', true), | ||
'+layout.gql': mockQuery('RootQuery'), | ||
}, | ||
}, | ||
}) | ||
|
||
const manifest = await load_manifest({ | ||
config, | ||
}) | ||
|
||
// generate the type rot | ||
await generate_type_root({ config, manifest }) | ||
|
||
// make sure we generated the right thing | ||
expect(fs.snapshot(config.typeRootDir)).toMatchInlineSnapshot(` | ||
{ | ||
"/src/routes/(subRoute)/$types.d.ts": "\\nimport { DocumentHandle } from '../../../../plugins/houdini-react/runtime'\\nimport React from 'react'\\n\\nimport type { LayoutQuery$result, LayoutQuery$artifact, LayoutQuery$input } from '../../../../artifacts/LayoutQuery'\\nimport type { RootQuery$result, RootQuery$artifact, RootQuery$input } from '../../../../artifacts/RootQuery'\\nimport type { FinalQuery$result, FinalQuery$artifact, FinalQuery$input } from '../../../../artifacts/FinalQuery'\\n\\n\\nexport type PageProps = {\\n LayoutQuery: LayoutQuery$result,\\n LayoutQuery$handle: DocumentHandle<LayoutQuery$artifact, LayoutQuery$result, LayoutQuery$input>,\\n RootQuery: RootQuery$result,\\n RootQuery$handle: DocumentHandle<RootQuery$artifact, RootQuery$result, RootQuery$input>,\\n FinalQuery: FinalQuery$result,\\n FinalQuery$handle: DocumentHandle<FinalQuery$artifact, FinalQuery$result, FinalQuery$input>,\\n}\\n\\n\\n\\n", | ||
"/src/routes/$types.d.ts": "\\nimport { DocumentHandle } from '../../../plugins/houdini-react/runtime'\\nimport React from 'react'\\n\\nimport type { LayoutQuery$result, LayoutQuery$artifact, LayoutQuery$input } from '../../../artifacts/LayoutQuery'\\n\\n\\nexport type PageProps = {\\n LayoutQuery: LayoutQuery$result,\\n LayoutQuery$handle: DocumentHandle<LayoutQuery$artifact, LayoutQuery$result, LayoutQuery$input>,\\n}\\n\\n\\n\\n" | ||
} | ||
`) | ||
}) | ||
|
||
function mockView(deps: string[]) { | ||
return `export default ({ ${deps.join(', ')} }) => <div>hello</div>` | ||
} | ||
|
||
function mockQuery(name: string, loading?: boolean) { | ||
return ` | ||
query ${name} ${loading ? '@loading' : ''}{ | ||
id | ||
} | ||
` | ||
} |
Oops, something went wrong.