Skip to content

Commit

Permalink
Upgrade to Qwik v0.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed Nov 4, 2022
1 parent f20d870 commit d03f25e
Show file tree
Hide file tree
Showing 9 changed files with 452 additions and 304 deletions.
19 changes: 19 additions & 0 deletions adaptors/express/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expressAdaptor } from '@builder.io/qwik-city/adaptors/express/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ['src/entry.express.tsx', '@qwik-city-plan'],
},
},
plugins: [
expressAdaptor({
staticGenerate: true,
}),
],
};
});
19 changes: 19 additions & 0 deletions adaptors/static/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { staticAdaptor } from '@builder.io/qwik-city/adaptors/static/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ['@qwik-city-plan'],
},
},
plugins: [
staticAdaptor({
origin: 'http://localhost:8080/',
}),
],
};
});
642 changes: 370 additions & 272 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
"build.tools": "vite build --mode lib --config tools/vite.config.inline.ts && vite build --mode lib --config tools/vite.config.extract.ts && tsc --project tools/tsconfig.json && api-extractor run --local --config tools/api-extractor.inline.json && api-extractor run --local --config tools/api-extractor.extract.json",
"build.app": "qwik build",
"build.client": "vite build",
"build.server": "vite build --ssr src/entry.express.tsx",
"build.static": "vite build --ssr src/entry.static.tsx",
"build.server": "vite build -c adaptors/express/vite.config.ts",
"build.types": "tsc --incremental --noEmit",
"dev": "vite --mode ssr",
"dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
"lint": "eslint \"src/**/*.ts*\" \"tools/**/*.ts*\"",
"lint": "eslint src/**/*.ts* tools/**/*.ts*",
"release": "npm run build && np",
"serve": "node server/entry.express",
"serve.ssg": "npx http-server ./dist -a localhost",
"ssg": "node server/entry.static",
"ssg": "vite build -c adaptors/static/vite.config.ts",
"start": "vite --open --mode ssr",
"test": "jest ./src/tests ./tools/tests",
"test.e2e": "playwright test",
Expand All @@ -27,20 +26,22 @@
"qwik-speak-extract": "./extract/cli.js"
},
"peerDependencies": {
"@builder.io/qwik": ">=0.11.0"
"@builder.io/qwik": ">=0.12.1"
},
"devDependencies": {
"@builder.io/qwik": "0.11.0",
"@builder.io/qwik-city": "0.0.112",
"@builder.io/qwik": "0.12.1",
"@builder.io/qwik-city": "0.0.118",
"@microsoft/api-extractor": "^7.32.0",
"@playwright/test": "^1.24.0",
"@types/eslint": "8.4.6",
"@types/compression": "^1.7.2",
"@types/eslint": "8.4.8",
"@types/express": "4.17.13",
"@types/jest": "latest",
"@types/node": "latest",
"@typescript-eslint/eslint-plugin": "5.37.0",
"@typescript-eslint/parser": "5.37.0",
"eslint": "8.23.1",
"@typescript-eslint/eslint-plugin": "5.41.0",
"@typescript-eslint/parser": "5.41.0",
"compression": "^1.7.4",
"eslint": "8.26.0",
"eslint-plugin-qwik": "latest",
"express": "4.17.3",
"jest": "^29.1.1",
Expand All @@ -49,7 +50,7 @@
"ts-jest": "^29.0.3",
"typescript": "4.8.4",
"vite-plugin-static-copy": "^0.9.0",
"vite": "3.1.7",
"vite": "3.2.0",
"vite-tsconfig-paths": "3.5.0"
},
"engines": {
Expand Down
9 changes: 9 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
"name": "qwik-speak-app",
"short_name": "Qwik Speak",
"start_url": ".",
"display": "standalone",
"background_color": "#fff",
"description": "Internationalization (i18n) library to translate texts, dates and numbers in Qwik apps"
}
24 changes: 16 additions & 8 deletions src/entry.express.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import { qwikCity } from '@builder.io/qwik-city/middleware/node';
import express from 'express';
import { fileURLToPath } from 'url';
import { join } from 'path';
import { createQwikCity } from '@builder.io/qwik-city/middleware/node';
import qwikCityPlan from '@qwik-city-plan';
import render from './entry.ssr';
import express from 'express';
import { fileURLToPath } from 'node:url';
import { join } from 'node:path';
import compression from 'compression';

// Directories where the static assets are located
const distDir = join(fileURLToPath(import.meta.url), '..', '..', 'dist');
const buildDir = join(distDir, 'build');

// Allow for dynamic port
const PORT = process.env.PORT ?? 8080;

// Create the Qwik City express middleware
const { router, notFound } = qwikCity(render);
const { router, notFound } = createQwikCity({ render, qwikCityPlan });

// Create the express server
// https://expressjs.com/
const app = express();

// Enable gzip compression
app.use(compression());

// Static asset handlers
// https://expressjs.com/en/starter/static-files.html
app.use('/build', express.static(buildDir, { immutable: true, maxAge: '1y' }));
app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: '1y' }));
app.use(express.static(distDir, { redirect: false }));

// Use Qwik City's page and endpoint request handler
Expand All @@ -27,7 +35,7 @@ app.use(router);
app.use(notFound);

// Start the express server
app.listen(8080, () => {
app.listen(PORT, () => {
/* eslint-disable */
console.log(`http://localhost:8080/`);
console.log(`Server starter: http://localhost:${PORT}/`);
});
10 changes: 0 additions & 10 deletions src/entry.static.tsx

This file was deleted.

7 changes: 5 additions & 2 deletions src/root.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { component$ } from '@builder.io/qwik';
import { component$, useStyles$ } from '@builder.io/qwik';
import { QwikCity, RouterOutlet, ServiceWorkerRegister } from '@builder.io/qwik-city';
import { QwikSpeak } from 'qwik-speak';

import { RouterHead } from './app/components/router-head/router-head';
import { config, translateFn } from './app/speak-config';

import './global.css';
import globalStyles from './global.css?inline';

export default component$(() => {
useStyles$(globalStyles);

return (
/**
* Init Qwik Speak (only available in child components)
Expand All @@ -16,6 +18,7 @@ export default component$(() => {
<QwikCity>
<head>
<meta charSet="utf-8" />
<link rel="manifest" href="/manifest.json" />
<RouterHead />
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"skipLibCheck": true,
"incremental": true,
"isolatedModules": true,
"outDir": "tmp",
"types": [
"node",
"vite/client",
Expand Down

0 comments on commit d03f25e

Please sign in to comment.