Skip to content

Commit

Permalink
Merge pull request #26 from magne4000/vike-renaming
Browse files Browse the repository at this point in the history
refactor: Vike renaming
  • Loading branch information
magne4000 authored Sep 25, 2023
2 parents ea68ccb + 0c2e577 commit 1af3245
Show file tree
Hide file tree
Showing 54 changed files with 159 additions and 167 deletions.
4 changes: 2 additions & 2 deletions examples/demo-vps-0.4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test:02": "vitest run --dir tests/02-additional-endpoints --config tests/02-additional-endpoints/vitest.config.ts",
"test:03": "vitest run --dir tests/03-prerender --config tests/03-prerender/vitest.config.ts",
"test:04": "vitest run --dir tests/04-isr --config tests/04-isr/vitest.config.ts",
"test:05": "vite build && vitest run --dir tests/05-vite-plugin-ssr --config tests/05-vite-plugin-ssr/vitest.config.ts"
"test:05": "vite build && vitest run --dir tests/05-vike --config tests/05-vike/vitest.config.ts"
},
"license": "MIT",
"devDependencies": {
Expand All @@ -37,7 +37,7 @@
"react-dom": "^18.2.0",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-ssr": "^0.4.141",
"vike": "^0.4.142",
"vite-plugin-vercel": "workspace:*"
},
"version": null
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-vps-0.4/pages/function/index.page.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import { PageContextBuiltInServer } from 'vike/types';

export default (pageContext: PageContextBuiltInServer) => {
if (!pageContext.urlOriginal.startsWith('/function/')) return false;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-vps-0.4/pages/named/index.page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import { PageContextBuiltInServer } from 'vike/types';

export function onBeforeRender(pageContext: PageContextBuiltInServer) {
return {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-vps-0.4/renderer/_default.page.client.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { createRoot, hydrateRoot, Root } from 'react-dom/client';
import type { PageContextBuiltInClientWithClientRouting as PageContextBuiltInClient } from 'vite-plugin-ssr/types';
import type { PageContextBuiltInClientWithClientRouting as PageContextBuiltInClient } from 'vike/types';
import { PageWrapper } from './PageWrapper';
import type { PageContext } from './types';

Expand Down
11 changes: 5 additions & 6 deletions examples/demo-vps-0.4/renderer/_default.page.server.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import ReactDOMServer from 'react-dom/server';
import React from 'react';
import { PageWrapper } from './PageWrapper';
import { escapeInject, dangerouslySkipEscape } from 'vite-plugin-ssr/server';
import { escapeInject, dangerouslySkipEscape } from 'vike/server';
import logoUrl from './logo.svg';
import type { PageContext } from './types';
import type { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import type { PageContextBuiltInServer } from 'vike/types';

export { render };

// See https://vite-plugin-ssr.com/data-fetching
// See https://vike.dev/data-fetching
export const passToClient = ['pageProps', 'urlPathname', 'documentProps'];

async function render(pageContext: PageContextBuiltInServer & PageContext) {
Expand All @@ -19,12 +19,11 @@ async function render(pageContext: PageContextBuiltInServer & PageContext) {
</PageWrapper>,
);

// See https://vite-plugin-ssr.com/html-head
// See https://vike.dev/html-head
const { documentProps } = pageContext;
const title = (documentProps && documentProps.title) || 'Vite SSR app';
const desc =
(documentProps && documentProps.description) ||
'App using Vite + vite-plugin-ssr';
(documentProps && documentProps.description) || 'App using Vite + vike';

const injected = escapeInject`<!DOCTYPE html>
<html lang="en">
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-vps-0.4/renderer/usePageContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// `usePageContext` allows us to access `pageContext` in any React component.
// More infos: https://vite-plugin-ssr.com/pageContext-anywhere
// More infos: https://vike.dev/pageContext-anywhere

import React, { useContext } from 'react';
import type { PageContext } from './types';
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-vps-0.4/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="vite/client" />

import express from 'express';
import { renderPage } from 'vite-plugin-ssr/server';
import { renderPage } from 'vike/server';
import * as vite from 'vite';
import { fileURLToPath } from 'url';
import path from 'path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import glob from 'fast-glob';
import { describe, expect, it } from 'vitest';

describe('fs', function () {
const buildManifest = require('../../dist/client/manifest.json');
const buildManifest = require('../../dist/assets.json');

const generatedFiles = Array.from(
new Set(
Expand All @@ -23,8 +23,7 @@ describe('fs', function () {
'/functions/api/post.func/.vc-config.json',
'/functions/edge.func/index.js',
'/functions/edge.func/.vc-config.json',
'/static/vite-plugin-ssr.json',
'/static/manifest.json',
'/static/vike.json',
// ISR + Static pages
'/functions/ssr_.func/index.js',
'/functions/ssr_.func/.vc-config.json',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import react from '@vitejs/plugin-react';
import ssr from 'vite-plugin-ssr/plugin';
import ssr from 'vike/plugin';
import vercel from 'vite-plugin-vercel';

export default {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-vps-0.4/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import ssr from 'vite-plugin-ssr/plugin';
import ssr from 'vike/plugin';
import vercel from 'vite-plugin-vercel';

export default defineConfig(async () => {
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test:02": "vitest run --dir tests/02-additional-endpoints --config tests/02-additional-endpoints/vitest.config.ts",
"test:03": "vitest run --dir tests/03-prerender --config tests/03-prerender/vitest.config.ts",
"test:04": "vitest run --dir tests/04-isr --config tests/04-isr/vitest.config.ts",
"test:05": "vite build && vitest run --dir tests/05-vite-plugin-ssr --config tests/05-vite-plugin-ssr/vitest.config.ts"
"test:05": "vite build && vitest run --dir tests/05-vike --config tests/05-vike/vitest.config.ts"
},
"dependencies": {
"@mdx-js/mdx": "^2.3.0",
Expand All @@ -31,7 +31,7 @@
"react-dom": "^18.2.0",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-ssr": "^0.4.141",
"vike": "^0.4.142",
"vite-plugin-vercel": "workspace:*"
},
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/pages/catch-all/+config.h.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Config } from 'vite-plugin-ssr/types';
import { Config } from 'vike/types';

export default {
isr: { expiration: 15 },
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/pages/catch-all/+onBeforeRender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import { PageContextBuiltInServer } from 'vike/types';

// https://vite-plugin-ssr.com/onBeforeRender
// https://vike.dev/onBeforeRender
export default function onBeforeRender() {
return {
pageContext: {
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/pages/dynamic/+onBeforeRender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import { PageContextBuiltInServer } from 'vike/types';

// https://vite-plugin-ssr.com/onBeforeRender
// https://vike.dev/onBeforeRender
export default function onBeforeRender() {
return {
pageContext: {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/pages/function/+config.h.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Config } from 'vite-plugin-ssr/types';
import { Config } from 'vike/types';

export default {
// Should warn when building because it's incompatible with route function
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/pages/function/+onBeforeRender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import { PageContextBuiltInServer } from 'vike/types';

// https://vite-plugin-ssr.com/onBeforeRender
// https://vike.dev/onBeforeRender
export default function onBeforeRender() {
return {
pageContext: {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/pages/function/+route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import { PageContextBuiltInServer } from 'vike/types';

export default function (pageContext: PageContextBuiltInServer) {
if (!pageContext.urlPathname.startsWith('/function/')) return false;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/pages/isr/+config.h.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Config } from 'vite-plugin-ssr/types';
import { Config } from 'vike/types';

export default {
isr: { expiration: 15 },
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/pages/isr/+onBeforeRender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://vite-plugin-ssr.com/onBeforeRender
// https://vike.dev/onBeforeRender
export default function onBeforeRender() {
return {
pageContext: {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/pages/named/+config.h.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Config } from 'vite-plugin-ssr/types';
import { Config } from 'vike/types';

export default {
isr: true,
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/pages/named/+onBeforeRender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageContextBuiltInServer } from 'vite-plugin-ssr/types';
import { PageContextBuiltInServer } from 'vike/types';

// https://vite-plugin-ssr.com/onBeforeRender
// https://vike.dev/onBeforeRender
export default function onBeforeRender(pageContext: PageContextBuiltInServer) {
return {
pageContext: {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/pages/static/+onBeforeRender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://vite-plugin-ssr.com/onBeforeRender
// https://vike.dev/onBeforeRender
export default function onBeforeRender() {
return {
pageContext: {
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/renderer/+config.h.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Config } from 'vite-plugin-ssr/types';
import type { Config } from 'vike/types';
import config from '@vite-plugin-vercel/vike/config';

// https://vite-plugin-ssr.com/config
// https://vike.dev/config
export default {
passToClient: ['pageProps', 'title', 'someAsyncProps'],
clientRouting: true,
hydrationCanBeAborted: true,
// https://vite-plugin-ssr.com/meta
// https://vike.dev/meta
meta: {
// Create new config 'title'
title: {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/renderer/+onRenderClient.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://vite-plugin-ssr.com/onRenderClient
// https://vike.dev/onRenderClient
export default onRenderClient;

import './css/index.css';
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/renderer/+onRenderHtml.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// https://vite-plugin-ssr.com/onRenderHtml
// https://vike.dev/onRenderHtml
export default onRenderHtml;

import ReactDOMServer from 'react-dom/server';
import React from 'react';
import { escapeInject } from 'vite-plugin-ssr/server';
import { escapeInject } from 'vike/server';
import { PageShell } from './PageShell';
import { getPageTitle } from './getPageTitle';
import type { PageContextServer } from './types';
Expand Down Expand Up @@ -31,7 +31,7 @@ async function onRenderHtml(pageContext: PageContextServer) {

return {
documentHtml,
// See https://vite-plugin-ssr.com/stream#initial-data-after-stream-end
// See https://vike.dev/stream#initial-data-after-stream-end
pageContext: async () => {
return {
someAsyncProps: 42,
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/renderer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export type { PageProps };
import type {
PageContextBuiltInServer,
//*
// When using Client Routing https://vite-plugin-ssr.com/clientRouting
// When using Client Routing https://vike.dev/clientRouting
PageContextBuiltInClientWithClientRouting as PageContextBuiltInClient,
/*/
// When using Server Routing
PageContextBuiltInClientWithServerRouting as PageContextBuiltInClient
//*/
} from 'vite-plugin-ssr/types';
} from 'vike/types';

type Page = (pageProps: PageProps) => React.ReactElement;
type PageProps = Record<string, unknown>;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import glob from 'fast-glob';
import { describe, expect, it } from 'vitest';

describe('fs', function () {
const buildManifest = require('../../dist/client/manifest.json');
const buildManifest = require('../../dist/assets.json');

const generatedFiles = Array.from(
new Set(
Expand All @@ -28,8 +28,7 @@ describe('fs', function () {
new RegExp('/functions/og.func/.*.ttf'),
'/functions/og.func/resvg.wasm',
'/functions/og.func/yoga.wasm',
'/static/vite-plugin-ssr.json',
'/static/manifest.json',
'/static/vike.json',
// ISR + Static pages
'/functions/ssr_.func/index.js',
'/functions/ssr_.func/.vc-config.json',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import react from '@vitejs/plugin-react';
import ssr from 'vite-plugin-ssr/plugin';
import ssr from 'vike/plugin';
import vercel from 'vite-plugin-vercel';

export default {
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import react from '@vitejs/plugin-react-swc';
import ssr from 'vite-plugin-ssr/plugin';
import ssr from 'vike/plugin';
import vercel from 'vite-plugin-vercel';
import { UserConfig } from 'vite';

Expand Down Expand Up @@ -28,7 +28,7 @@ export default {
},
],
},
// We manually add a list of dependencies to be pre-bundled, in order to avoid a page reload at dev start which breaks vite-plugin-ssr's CI
// We manually add a list of dependencies to be pre-bundled, in order to avoid a page reload at dev start which breaks vike's CI
// (The 'react/jsx-runtime' entry is not needed in Vite 3 anymore.)
optimizeDeps: { include: ['cross-fetch', 'react/jsx-runtime'] },
} as UserConfig;
6 changes: 3 additions & 3 deletions packages/vercel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

### Patch Changes

- Add support for vite-plugin-ssr V1 design
- Add support for vike V1 design
- Updated dependencies
- @vite-plugin-vercel/vike@0.3.3

Expand Down Expand Up @@ -44,7 +44,7 @@

### Patch Changes

- fix use case without vite-plugin-ssr
- fix use case without vike

## 0.2.0

Expand Down Expand Up @@ -96,7 +96,7 @@

### Patch Changes

- Create a dedicated package for vite-plugin-ssr integration
- Create a dedicated package for vike integration

## 0.1.0

Expand Down
Loading

1 comment on commit 1af3245

@vercel
Copy link

@vercel vercel bot commented on 1af3245 Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.