Skip to content

Commit

Permalink
chore: update examples to use import.meta.dirname (Node v21.2+)
Browse files Browse the repository at this point in the history
  • Loading branch information
galvez committed Oct 13, 2024
1 parent a709654 commit 172ac43
Show file tree
Hide file tree
Showing 28 changed files with 164 additions and 229 deletions.
4 changes: 1 addition & 3 deletions examples/react-hydration/server.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import test from 'node:test'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('react-hydration', async (t) => {
await t.test('render index page in development', makeIndexTest({ main, dev: true }))
Expand Down
20 changes: 7 additions & 13 deletions examples/react-hydration/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { viteFastify } from '@fastify/vite/plugin'
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import viteReact from '@vitejs/plugin-react'

const path = fileURLToPath(import.meta.url)
const root = resolve(dirname(path), 'client')

const plugins = [
viteFastify(),
viteReact({ jsxRuntime: 'classic' })
]

export default {
root,
plugins,
root: join(import.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteReact({ jsxRuntime: 'classic' })
],
ssr: {
external: ['fastify']
}
Expand Down
12 changes: 6 additions & 6 deletions examples/react-next/server.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import test from 'node:test'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('render index page in development', makeIndexTest({ main, dev: true }))
test('build production bundle', makeSSRBuildTest({ cwd }))
test('render index page in production', makeIndexTest({ main }))
test('react-next', async (t) => {
await t.test('render index page in development', makeIndexTest({ main, dev: true }))
await t.test('build production bundle', makeSSRBuildTest({ cwd }))
await t.test('render index page in production', makeIndexTest({ main }))
})
24 changes: 9 additions & 15 deletions examples/react-next/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import viteReact from "@vitejs/plugin-react";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [viteFastify(), viteReact({ jsxRuntime: "classic" })];
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import viteReact from '@vitejs/plugin-react'

export default {
root,
plugins,
server: {
hmr: !!process.env.TEST,
},
};
root: join(importa.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteReact({ jsxRuntime: "classic" })
],
}
12 changes: 6 additions & 6 deletions examples/react-streaming/server.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import test from 'node:test'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('render index page in development', makeIndexTest({ main, dev: true }))
test('build production bundle', makeSSRBuildTest({ cwd }))
test('render index page in production', makeIndexTest({ main }))
test('react-streaming', async (t) => {
await t.test('render index page in development', makeIndexTest({ main, dev: true }))
await t.test('build production bundle', makeSSRBuildTest({ cwd }))
await t.test('render index page in production', makeIndexTest({ main }))
})
21 changes: 9 additions & 12 deletions examples/react-streaming/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import viteReact from "@vitejs/plugin-react";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [viteFastify(), viteReact({ jsxRuntime: "classic" })];
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import viteReact from '@vitejs/plugin-react'

export default {
root,
plugins,
};
root: join(importa.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteReact({ jsxRuntime: 'classic' })
],
}
2 changes: 1 addition & 1 deletion examples/react-vanilla-spa/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'
import { makeIndexTest, makeSPABuildTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('react-vanilla-spa', async (t) => {
await t.test('build production bundle', makeSPABuildTest({ cwd }))
Expand Down
21 changes: 9 additions & 12 deletions examples/react-vanilla-spa/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import viteReact from "@vitejs/plugin-react";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [viteFastify(), viteReact({ jsxRuntime: "classic" })];
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import viteReact from '@vitejs/plugin-react'

export default {
root,
plugins,
};
root: join(importa.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteReact({ jsxRuntime: "classic" })
],
}
2 changes: 1 addition & 1 deletion examples/react-vanilla/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'
import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('react-vanilla', async (t) => {
await t.test('render index page in development', makeIndexTest({ main, dev: true }))
Expand Down
21 changes: 9 additions & 12 deletions examples/react-vanilla/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import viteReact from "@vitejs/plugin-react";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [viteFastify(), viteReact({ jsxRuntime: "classic" })];
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import viteReact from '@vitejs/plugin-react'

export default {
root,
plugins,
};
root: join(importa.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteReact({ jsxRuntime: 'classic' })
],
}
12 changes: 6 additions & 6 deletions examples/solid-hydration/server.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import test from 'node:test'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('render index page in development', makeIndexTest({ main, dev: true }))
test('build production bundle', makeSSRBuildTest({ cwd }))
test('render index page in production', makeIndexTest({ main }))
test('solid-hydration', async (t) => {
await t.test('render index page in development', makeIndexTest({ main, dev: true }))
await t.test('build production bundle', makeSSRBuildTest({ cwd }))
await t.test('render index page in production', makeIndexTest({ main }))
})
29 changes: 12 additions & 17 deletions examples/solid-hydration/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import viteSolid from "vite-plugin-solid";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [viteFastify(), viteSolid({ ssr: true })];

const ssr = {
noExternal: ["@solidjs/router"],
};
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import viteSolid from 'vite-plugin-solid'

export default {
root,
plugins,
ssr,
};
root: join(import.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteSolid({ ssr: true })
],
ssr: {
noExternal: ['@solidjs/router'],
},
}
12 changes: 6 additions & 6 deletions examples/solid-vanilla/server.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import test from 'node:test'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('render index page in development', makeIndexTest({ main, dev: true }))
test('build production bundle', makeSSRBuildTest({ cwd }))
test('render index page in production', makeIndexTest({ main }))
test('solid-vanilla', async (t) => {
await t.test('render index page in development', makeIndexTest({ main, dev: true }))
await t.test('build production bundle', makeSSRBuildTest({ cwd }))
await t.test('render index page in production', makeIndexTest({ main }))
})
21 changes: 9 additions & 12 deletions examples/solid-vanilla/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import viteSolid from "vite-plugin-solid";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [viteFastify(), viteSolid({ ssr: true })];
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import viteSolid from 'vite-plugin-solid'

export default {
root,
plugins,
};
root: join(import.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteSolid({ ssr: true })
],
}
5 changes: 2 additions & 3 deletions examples/svelte-hydration/server.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import test from 'node:test'
import { setTimeout } from 'node:timers/promises'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'

import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('svelte-hydration', async (t) => {
await t.test('build production bundle', makeSSRBuildTest({ cwd }))
Expand Down
32 changes: 13 additions & 19 deletions examples/svelte-hydration/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import { svelte as viteSvelte } from "@sveltejs/vite-plugin-svelte";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [
viteFastify(),
viteSvelte({
compilerOptions: {
hydratable: true,
},
}),
];
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import { svelte as viteSvelte } from '@sveltejs/vite-plugin-svelte'

export default {
root,
plugins,
};
root: join(import.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteSvelte({
compilerOptions: {
hydratable: true,
},
}),
],
}
4 changes: 1 addition & 3 deletions examples/svelte-vanilla/server.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import test from 'node:test'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { makeSSRBuildTest, makeIndexTest } from '../test-factories.mjs'
import { main } from './server.js'

const cwd = dirname(fileURLToPath(import.meta.url))
const cwd = import.meta.dirname

test('build production bundle', makeSSRBuildTest({ cwd }))
test('render index page in development', makeIndexTest({ main, dev: true }))
Expand Down
21 changes: 9 additions & 12 deletions examples/svelte-vanilla/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { viteFastify } from "@fastify/vite/plugin";
import { svelte as viteSvelte } from "@sveltejs/vite-plugin-svelte";

const path = fileURLToPath(import.meta.url);
const root = resolve(dirname(path), "client");

const plugins = [viteFastify(), viteSvelte()];
import { join } from 'node:path'
import viteFastify from '@fastify/vite/plugin'
import { svelte as viteSvelte } from '@sveltejs/vite-plugin-svelte'

export default {
root,
plugins,
};
root: join(import.meta.dirname, 'client'),
plugins: [
viteFastify(),
viteSvelte()
],
}
16 changes: 9 additions & 7 deletions examples/typescript-vanilla/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { resolve } from "node:path";
import { viteFastify } from "@fastify/vite/plugin";
import viteReact from "@vitejs/plugin-react";
import { join } from 'node:path'
import { viteFastify } from '@fastify/vite/plugin'
import viteReact from '@vitejs/plugin-react'

/** @type {import('vite').UserConfig} */
export default {
root: resolve(import.meta.dirname, "src/client"),
plugins: [viteReact(), viteFastify()],
root: join(import.meta.dirname, 'src/client'),
plugins: [
viteReact(),
viteFastify()
],
build: {
emptyOutDir: true,
outDir: resolve(import.meta.dirname, "dist/client"),
outDir: join(import.meta.dirname, 'dist/client'),
},
};
Loading

0 comments on commit 172ac43

Please sign in to comment.