Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from preact-cli -> WMR #793

Draft
wants to merge 71 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
a593073
Add basic wmr setup
marvinhagemeister Aug 29, 2021
0473832
Remove ~less alias
marvinhagemeister Aug 29, 2021
b688518
Remove unneeded aliasing
marvinhagemeister Aug 29, 2021
80708e6
Replace async! loader with `preact-iso`
marvinhagemeister Aug 30, 2021
f072720
Replace webpack workerize loader
marvinhagemeister Aug 31, 2021
73aaa80
Update globals usage
marvinhagemeister Aug 31, 2021
7bdd1c3
Move assets to public
marvinhagemeister Aug 31, 2021
149715b
Fix nothing rendered
marvinhagemeister Aug 31, 2021
a0911ec
Fix marked worker not working
marvinhagemeister Aug 31, 2021
fd4f895
Add basic markdown middleware
marvinhagemeister Aug 31, 2021
3310dcb
Switch to preact-iso
marvinhagemeister Aug 31, 2021
c8d52c9
Add react aliasing
marvinhagemeister Aug 31, 2021
c7d4a78
Patch incorrect Preact import in unistore
marvinhagemeister Aug 31, 2021
6518357
Patch htm to ignore JS-style comments
marvinhagemeister Sep 1, 2021
b9b6658
Fix duplicate container ids
marvinhagemeister Sep 1, 2021
b59f5ea
Fix prism worker
marvinhagemeister Sep 1, 2021
c79f813
Fix prism CSS not loading
marvinhagemeister Sep 1, 2021
ab71e33
Remove preact-router
marvinhagemeister Sep 1, 2021
1688a40
Fix wrong JS entry path on nested routes
marvinhagemeister Sep 2, 2021
1db4564
Add basic WMR setup
marvinhagemeister Sep 3, 2021
9afc921
Don't throw if docs page is not found
marvinhagemeister Sep 3, 2021
747dc3c
Use nested routes for doc page navigation
marvinhagemeister Sep 3, 2021
2c37723
Fix incorrect content type
marvinhagemeister Sep 3, 2021
5667c57
Simplify code highlighting code
marvinhagemeister Sep 3, 2021
55b21c9
Prototype meta route handling
marvinhagemeister Sep 3, 2021
6299300
Add support for bash language
marvinhagemeister Sep 3, 2021
22e02f6
Fix content middleware not returning when no front matter
marvinhagemeister Sep 4, 2021
f612152
Fix double escaping in code block fallback
marvinhagemeister Sep 4, 2021
76fca5c
Add basic netlify middleware
marvinhagemeister Sep 4, 2021
21ae525
Improve routes loading state
marvinhagemeister Sep 4, 2021
4bfbb3b
Remove unnecessary partial route match
marvinhagemeister Sep 4, 2021
6074821
Add netlify lambda middleware
marvinhagemeister Sep 4, 2021
ad9b6aa
Update redirects
marvinhagemeister Sep 4, 2021
c8859b6
Update github function url
marvinhagemeister Sep 4, 2021
6e24049
Refactor doc page handling
marvinhagemeister Sep 4, 2021
557ebd4
Remove unused controllers index file
marvinhagemeister Sep 4, 2021
ee0a487
Fix doc version fallback redirect
marvinhagemeister Sep 4, 2021
033938a
Fix resource refcounting
marvinhagemeister Sep 4, 2021
ed66155
Remove unnecessary controller in config.json
marvinhagemeister Sep 4, 2021
8cf3515
Rework page handling
marvinhagemeister Sep 4, 2021
b30c591
Fix Edit button not showing
marvinhagemeister Sep 4, 2021
7a822f1
Fix header not in sync with preact-iso
marvinhagemeister Sep 4, 2021
0dad9bc
Fix incorrect url handling in useLanguage
marvinhagemeister Sep 4, 2021
802972b
Remove unused old Page code
marvinhagemeister Sep 4, 2021
1e22c8d
Use proper url from router in Footer
marvinhagemeister Sep 4, 2021
87a4bcd
Remove unistore
marvinhagemeister Sep 4, 2021
b66bd2f
Catch netlify errors
marvinhagemeister Sep 4, 2021
91ede8d
Fix CSS module warning
marvinhagemeister Sep 4, 2021
608e664
Use non-module worker for marked
marvinhagemeister Sep 4, 2021
b0db29e
Fix unable to build with fresh node_modules
marvinhagemeister Sep 4, 2021
02a2802
Cleanup more dependencies
marvinhagemeister Sep 4, 2021
57530d2
Inline decko
marvinhagemeister Sep 4, 2021
13eeb06
Fix unable to load examples
marvinhagemeister Sep 4, 2021
0cc58e9
Disable repl worker to workaround crash during build
marvinhagemeister Sep 4, 2021
536f52e
Update build commands
marvinhagemeister Sep 5, 2021
7776562
Update wmr related dependencies
marvinhagemeister Sep 5, 2021
2b3806e
Update browserlist
marvinhagemeister Sep 5, 2021
083cdbf
Fix missing favicon
marvinhagemeister Sep 5, 2021
a3c0e9a
Add back missing meta tags
marvinhagemeister Sep 5, 2021
1be2798
Copy over markdown files for prod builds
marvinhagemeister Sep 5, 2021
1847791
Copy over netlify specific files for prod builds
marvinhagemeister Sep 5, 2021
4b973fb
Remove unused dependencies
marvinhagemeister Sep 5, 2021
203559c
Fix missing ending newline in gitignore
marvinhagemeister Sep 5, 2021
ffcb71f
Rename script server2 -> server
marvinhagemeister Sep 5, 2021
5a27eea
Update netlify lambda
marvinhagemeister Sep 5, 2021
91394bf
Resolve prerendering errors
marvinhagemeister Sep 6, 2021
05b4d59
Upgrade WMR
marvinhagemeister Sep 8, 2021
142f0d7
Remove debug logs
marvinhagemeister Sep 8, 2021
5128b3d
Disable analytics for now
marvinhagemeister Sep 8, 2021
fb4e21a
Drop old polyfills
marvinhagemeister Sep 8, 2021
fe53670
Bring back repl code editor
marvinhagemeister Sep 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.DS_Store
dist
*.sw[op]
.cache/
38,694 changes: 24,205 additions & 14,489 deletions package-lock.json

Large diffs are not rendered by default.

60 changes: 27 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
"url": "https://github.com/preactjs/preact-www.git"
},
"scripts": {
"dev": "concurrently \"npm run dev:client\" \"npm run dev:lambda\"",
"dev:client": "preact watch --template src/template.html",
"dev:lambda": "netlify-lambda serve src/lambda",
"start": "npm run -s server",
"dev": "wmr start",
"start": "npm run -s server2",
"prestart": "npm run -s build",
"server": "superstatic build -p ${PORT:-8080} --host 0.0.0.0 --gzip -c '{\"rewrites\": [{\"source\":\"**\",\"destination\":\"index.html\"}],\"headers\":[{\"source\":\"**\",\"headers\":[{\"key\":\"Cache-Control\",\"value\":\"max-age=31536000\"}]}]}'",
"build": "netlify-lambda build src/lambda && preact build --prerenderUrls src/prerender.js --template src/template.html",
"prebuild": "rimraf build/assets && rimraf build/content",
"server": "wmr serve --out './build'",
"build": "netlify-lambda build src/lambda && wmr build --out './build'",
"pretest": "npm run -s lint && npm run -s build",
"test": "cross-env JEST_PUPPETEER_CONFIG=test/jest-puppeteer.config.js jest --runInBand --no-coverage test/browser/.*\\.js",
"lint": "eslint src test",
Expand Down Expand Up @@ -67,62 +64,59 @@
},
"lint-staged": {
"{src,test}/**/*.{less,js,json}": [
"prettier --write",
"git add"
"prettier --write"
]
},
"license": "MIT",
"author": "Preact Authors <[email protected]>",
"devDependencies": {
"@babel/polyfill": "^7.7.0",
"concurrently": "^5.2.0",
"critters-webpack-plugin": "^2.5.0",
"cross-env": "^7.0.3",
"dlv": "^1.1.3",
"encoding": "^0.1.13",
"eslint": "^6.8.0",
"eslint-config-developit": "^1.1.1",
"husky": "^4.0.0",
"glob": "^7.1.6",
"husky": "^7.0.2",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest-puppeteer": "^4.4.0",
"jsdom": "^15.2.1",
"less-loader": "^5.0.0",
"lint-staged": "^9.5.0",
"netlify-lambda": "^1.6.3",
"less": "^4.1.1",
"lint-staged": "^11.1.2",
"netlify-lambda": "^2.0.14",
"per-env": "^1.0.2",
"postcss-custom-properties": "^9.0.2",
"preact-cli": "^3.0.0-rc.16",
"preact-cli-plugin-netlify": "^1.5.0",
"preact-render-spy": "^1.3.0",
"prettier": "^1.19.1",
"promise-polyfill": "^8.1.3",
"puppeteer": "^2.0.0",
"rimraf": "^3.0.2",
"size-plugin": "^2.0.1",
"workerize-loader": "^1.1.0"
"wmr": "^3.7.1"
},
"dependencies": {
"@codemirror/basic-setup": "^0.19.0",
"@codemirror/commands": "^0.19.2",
"@codemirror/gutter": "^0.19.1",
"@codemirror/highlight": "^0.19.4",
"@codemirror/history": "^0.19.0",
"@codemirror/lang-html": "^0.19.1",
"@codemirror/lang-javascript": "^0.19.1",
"@codemirror/state": "^0.19.1",
"@codemirror/view": "^0.19.4",
"babel-plugin-transform-jsx-to-htm": "^2.2.0",
"babel-standalone": "^6.26.0",
"classnames": "^2.2.6",
"codemirror": "^5.50.2",
"decko": "^1.2.0",
"encoding": "^0.1.13",
"flatmap": "0.0.3",
"comlink": "^4.3.1",
"escorn": "^0.5.1",
"hoofd": "^1.4.0",
"htm": "^2.2.1",
"less": "^3.10.3",
"linkstate": "^1.1.1",
"marked": "^0.8.0",
"node-fetch": "^2.6.1",
"preact": "^10.4.4",
"preact-custom-element": "^4.0.0",
"preact-iso": "^2.2.0",
"preact-markup": "^2.0.0",
"preact-render-to-string": "^5.1.9",
"preact-router": "^3.1.0",
"sucrase": "^3.12.0",
"superstatic": "^6.0.4",
"unistore": "^3.5.1",
"window-or-global": "^1.0.1",
"worker-loader": "^2.0.0",
"sucrase": "^3.20.1",
"yaml": "^1.7.2"
}
}
127 changes: 0 additions & 127 deletions preact.config.js

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
66 changes: 66 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Preact</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimal-ui"
/>
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta
name="apple-touch-icon"
content="/assets/app-icon.png"
sizes="512x512"
/>
<!-- <link
rel="manifest"
href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json"
/> -->
<meta
name="description"
content="Preact is a fast 3kB alternative to React with the same modern API."
/>
<meta name="theme-color" content="#673AB8" />
<meta name="twitter:card" content="summary" />
<meta property="og:url" content="https://preactjs.com" />
<meta property="og:title" content="Preact" />
<meta
property="og:description"
content="Preact is a fast 3kB alternative to React with the same modern API."
/>
<meta
property="og:image"
content="https://preactjs.com/assets/app-icon.png"
/>
<!-- <script>
ga =
window.ga ||
function() {
(ga.q = ga.q || []).push(arguments);
};
ga('set', 'dimension1', '<%= process.env.BRANCH %>');
onerror = function(e, f, l, c) {
ga('send', 'event', 'exception', e, f + ':' + l + ':' + c);
};
</script> -->

<link rel="shortcut icon" href="/favicon.ico" />

<link
href="https://cdn.jsdelivr.net"
rel="preconnect"
crossorigin="anonymous"
/>
</head>
<body>
<div id="root"></div>
<script
async
defer
src="https://www.google-analytics.com/analytics.js"
></script>
<script type="module" src="/main.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions public/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'preact/devtools';
import { hydrate } from 'preact-iso';
import * as preact from 'preact';
import * as hooks from 'preact/hooks';
import { App } from '../src/index.js';

// allows users to play with preact in the browser developer console
globalThis.preact = { ...preact, ...hooks };

// Install JSDOM's DOMParser globally. Used by <Markup> component's parser.
if (import.meta.env.PRERENDER) {
const jsdom = __non_webpack_require__('jsdom');
globalThis.DOMParser = new jsdom.JSDOM().window.DOMParser;
}

if (typeof document !== 'undefined') {
hydrate(<App />, document.getElementById('root'));
}

export async function prerender(data) {
return (await import('../src/prerender.js')).prerender(<App {...data} />);
}
4 changes: 3 additions & 1 deletion src/_redirects
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/guide /guide/v10/getting-started
/guide/v8 /guide/v8/getting-started
/guide/v10 /guide/v10/getting-started
/guide/getting-started /guide/v10/getting-started
/guide/differences-to-react /guide/v10/differences-to-react
/guide/switching-to-preact /guide/v10/switching-to-preact
Expand All @@ -9,4 +12,3 @@
/guide/extending-component /guide/v8/extending-component
/guide/unit-testing-with-enzyme /guide/v10/unit-testing-with-enzyme
/guide/progressive-web-apps /guide/v10/progressive-web-apps
/content/* /content/*
2 changes: 1 addition & 1 deletion src/analytics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (!PRERENDER) {
if (false) {
const ga = (window.ga =
window.ga || ((...args) => (ga.q = ga.q || []).push(args)));

Expand Down
Loading