Skip to content

Commit

Permalink
fix: changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersayshi committed Sep 28, 2024
1 parent f0a9659 commit 3b287fb
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist
.cache
.nvmrc
.node-version
entries.gen.tsx
2 changes: 2 additions & 0 deletions e2e/fixtures/render-type/src/entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { createPages } from 'waku/router/server';

import { ServerEcho } from './ServerEcho.js';
import { ClientEcho } from './ClientEcho.js';
import { FunctionComponent } from 'react';

Check failure on line 5 in e2e/fixtures/render-type/src/entries.tsx

View workflow job for this annotation

GitHub Actions / test

'FunctionComponent' is defined but never used. Allowed unused vars must match /^_/u
import { RouteProps } from '../../../../packages/waku/dist/router/common.js';

Check failure on line 6 in e2e/fixtures/render-type/src/entries.tsx

View workflow job for this annotation

GitHub Actions / test

'RouteProps' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 6 in e2e/fixtures/render-type/src/entries.tsx

View workflow job for this annotation

GitHub Actions / test

Unable to resolve path to module '../../../../packages/waku/dist/router/common.js'

// This needs type annotations for the return type of createPages
// @see https://github.com/microsoft/TypeScript/issues/42873#issuecomment-2065572017
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/ssr-catch-error/src/pages/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export default async function RootLayout({
export const getConfig = async () => {
return {
render: 'static',
};
} as const;
};
2 changes: 1 addition & 1 deletion e2e/fixtures/ssr-catch-error/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export default async function HomePage() {
export const getConfig = async () => {
return {
render: 'static',
};
} as const;
};
2 changes: 1 addition & 1 deletion e2e/fixtures/ssr-catch-error/src/pages/invalid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default async function InvalidPage() {
export const getConfig = async () => {
return {
render: 'dynamic',
};
} as const;
};
32 changes: 0 additions & 32 deletions examples/01_template/src/entries.gen.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion examples/03_demo/src/pages/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ export const getConfig = async () => {
return {
render: 'static',
staticPaths: pokemonPaths,
};
} as const;
};
2 changes: 1 addition & 1 deletion examples/03_demo/src/pages/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ const getData = async () => {
export const getConfig = async () => {
return {
render: 'static',
};
} as const;
};
2 changes: 1 addition & 1 deletion examples/03_demo/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ export default async function HomePage() {
export const getConfig = async () => {
return {
render: 'dynamic',
};
} as const;
};
2 changes: 1 addition & 1 deletion examples/04_cssmodules/src/pages/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ const getData = async () => {
export const getConfig = async () => {
return {
render: 'static',
};
} as const;
};
2 changes: 1 addition & 1 deletion examples/04_cssmodules/src/pages/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ const getData = async () => {
export const getConfig = async () => {
return {
render: 'static',
};
} as const;
};
2 changes: 1 addition & 1 deletion examples/04_cssmodules/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ const getData = async () => {
export const getConfig = async () => {
return {
render: 'static',
};
} as const;
};
10 changes: 4 additions & 6 deletions packages/waku/src/lib/plugins/vite-plugin-fs-router-typegen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Plugin } from 'vite';
import { readdir, writeFile } from 'node:fs/promises';
import { existsSync, readFileSync } from 'node:fs';
import path from 'node:path';
import { SRC_ENTRIES } from '../constants.js';
import { SRC_ENTRIES, EXTENSIONS } from '../constants.js';
import { joinPath } from '../utils/path.js';

const SRC_PAGES = 'pages';
Expand Down Expand Up @@ -62,7 +61,7 @@ export const fsRouterTypegenPlugin = (opts: { srcDir: string }): Plugin => {
apply: 'serve',
async configResolved(config) {
pagesDir = joinPath(config.root, opts.srcDir, SRC_PAGES);
entriesFilePossibilities = ['tsx', 'ts', 'js', 'jsx'].map((ext) =>
entriesFilePossibilities = EXTENSIONS.map((ext) =>
joinPath(config.root, opts.srcDir, `${SRC_ENTRIES}.${ext}`),
);
outputFile = joinPath(config.root, opts.srcDir, `${SRC_ENTRIES}.gen.tsx`);
Expand Down Expand Up @@ -98,9 +97,8 @@ export const fsRouterTypegenPlugin = (opts: { srcDir: string }): Plugin => {
});

for (const file of files) {
const fullPath = path.join(dir, file.name);
if (fullPath.endsWith('.tsx')) {
results.push(fullPath.replace(pagesDir, ''));
if (file.name.endsWith('.tsx')) {
results.push('/' + file.name);
}
}
return results;
Expand Down

0 comments on commit 3b287fb

Please sign in to comment.