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

experimental: Using preact-iso to lazy load components #1731

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9d7c6b2
Chore: Updating html-webpack-plugin to v4 (#1608)
rschristian Feb 2, 2022
7197d73
chore: Correcting changeset
rschristian Jan 31, 2022
1100829
feat: webpack v5 (#1645)
rschristian Jul 8, 2022
6046a26
refactor: Determine CSS module by filename, not directory (#1714)
rschristian Jul 25, 2022
0dbec73
refactor: Extracting project creation out to own package (#1708)
rschristian Jul 25, 2022
f17f631
refactor: Drop Preact 8 support (#1716)
rschristian Jul 25, 2022
cc4a627
refactor: Switch to automatic runtime JSX transform (#1725)
rschristian Aug 4, 2022
1f1d857
docs: Adding readme for create-cli (#1728)
rschristian Aug 8, 2022
da67715
refactor: Disable hashing ssr-build's css (#1733)
rschristian Aug 13, 2022
0aef273
refactor: Remove `--preload` flag (#1737)
rschristian Aug 18, 2022
bcb80fa
refactor: Separate internal concepts of config and env (#1734)
rschristian Nov 18, 2022
3d1b920
refactor: prune flags (#1752)
rschristian Dec 13, 2022
4e60144
feat: Improved errors and warnings (#1758)
rschristian Dec 20, 2022
60633fb
refactor: Bump Node version, remove `src` arg in build & watch, and m…
rschristian Dec 21, 2022
c79eeab
refactor: Move EJS into user templates (`template.html`) (#1768)
rschristian Jan 7, 2023
12e5ea6
chore: Publishing cli & create-cli
rschristian Jan 9, 2023
1fc4600
Refactor: Enable Prefresh by Default (#1772)
rschristian Jan 11, 2023
cf768ad
refactor: Remove Critters (perhaps temporarily) (#1778)
rschristian Jan 26, 2023
a80c02a
chore: Publish v4.0.0-next.2
rschristian Jan 26, 2023
714923d
refactor: Vendor Critters so that 7c811ac can be reverted (#1780)
rschristian Jan 31, 2023
3640922
refactor: Swapping async-loader for preact-iso's `lazy`
rschristian Aug 18, 2022
0746309
test: Updating test suite
rschristian Aug 18, 2022
695bc10
docs: Changeset and README
rschristian Aug 25, 2022
a2fdd40
refactor: Minor adjustments to entry point / client script
rschristian Dec 22, 2022
076d599
test: Updating tests to account for entry edits
rschristian Dec 22, 2022
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
6 changes: 6 additions & 0 deletions .changeset/cuddly-ducks-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@preact/async-loader': major
'preact-cli': major
---

Drops support for Preact v8
11 changes: 11 additions & 0 deletions .changeset/cyan-tomatoes-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'preact-cli': major
---

Alters CSS Module detection to instead rely upon file names, rather than directory names.

Treating all CSS files found within `routes/` and `components/` as CSS Modules was not obvious, nor did it offer an easy way to opt out (or in) without editing the Webpack config itself.

This change makes is so that users can opt into CSS Modules from anywhere in their app by instead naming their CSS files according to the pattern `*.module.css`.

Anyone using CSS Modules within `routes/` or `components/` will need to alter their CSS files to be `x.module.css`. If you've disabled CSS Modules in your `preact.config.js`, you can remove that bit of configuration and use file names to instead determine behavior.
9 changes: 9 additions & 0 deletions .changeset/great-dryers-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'preact-cli': major
---

Reduces the `env` parameter of `preact.config.js` to only contain 3 values: `isProd`, `isWatch`, and `isServer`.

Previously, `env` contained many semi-duplicated values (`production` and `isProd`, etc) as well as values that were unlikely to be of much use to many users (what flags were set, for instance). Because of this, the signal-to-noise ratio was rather low which we didn't like. As such, we reduced `env` down to the most basic environment info: what type of build is `preact-cli` doing and for which environement?

If you customize your Webpack config using a `preact.config.js`, please be aware that you may need to update which values you consume from `env`.
9 changes: 9 additions & 0 deletions .changeset/hungry-peas-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'preact-cli': major
---

To increase transparency and user control over the `template.html`, `<% preact.headEnd %>` and `<% preact.bodyEnd %>` will no longer be supported; instead, users should directly adopt the EJS and keep it in their templates.

In the past, these were abstracted away as they were a bit unwieldy; EJS might be unfamiliar with users and the way data was retrieved from `html-webpack-plugin` was somewhat less than elegant. However, this has much improved over the years and the abstraction only makes simple edits less than obvious, so it is no longer fulfilling it's purpose.

New projects will have a `template.ejs` created in place of the old `template.html`, containing the full EJS template. For existing projects, you can copy [the default `template.ejs`](https://github.com/preactjs/preact-cli/blob/master/packages/cli/src/resources/template.ejs) into your project or adapt it as you wish.
5 changes: 5 additions & 0 deletions .changeset/lucky-lizards-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': major
---

HMR / the `--refresh` flag is now enabled by default in dev mode.
7 changes: 7 additions & 0 deletions .changeset/metal-roses-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'preact-cli': major
---

Changes the JSX transform from 'classic' to the newer 'automatic'

Users will no longer need to add `import { h } from 'preact'` in their components; it will be done automatically for them.
5 changes: 5 additions & 0 deletions .changeset/poor-sloths-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': major
---

Removes `--preload` flag and functionality from build command.
5 changes: 5 additions & 0 deletions .changeset/popular-zebras-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Disables hash in CSS file names for the SSR build
5 changes: 5 additions & 0 deletions .changeset/quiet-eels-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': major
---

Removes `--json` & `--brotli` flags from `preact build`. Also removes `--rhl` alias for `--refresh` from `preact watch`.
6 changes: 6 additions & 0 deletions .changeset/rude-walls-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'preact-cli': major
'@preact/prerender-data-provider': major
---

Updates to use html-webpack-plugin v4
12 changes: 12 additions & 0 deletions .changeset/sweet-snakes-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'preact-cli': major
---

- Upgrades to Webpack v5
- Any custom configuration you do in your `preact.config.js` may need to be altered to account for this. Plugins may need replacements or different option formats.

- `--esm` flag has been removed
- Dual output is now enabled by default in production builds.

- `.babelrc` no longer overwrites matching keys
- Instead, the config will be merged in to the default. The default still takes precedence when there are conflicts, so you will still need to use your `preact.config.js` if you want to edit or remove default plugins or presets.
9 changes: 9 additions & 0 deletions .changeset/tender-lamps-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'preact-cli': major
---

Minimum supported Node version for `preact-cli` is now v14.14.0. Please upgrade if you are on an older version.

`build` and `watch` commands will no longer take an optional `src` directory argument; if you want to change the source directory from the default (`./src`), please instead use the `--src` flag (i.e., `--src differentSrc`).

Upon rebuild, the output directory will no longer be outright deleted; instead, it will be emptied. This has the benefit of better supporting containerized environments where specific directories are mounted. Emptying the directory, rather than deleting and recreating it, ensures a stable reference for those tools.
14 changes: 14 additions & 0 deletions .changeset/tiny-garlics-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'preact-cli': major
'create-preact-cli': major
---

Extracts project creation functionality from `preact-cli` into `create-preact-cli`

Setting up new `preact-cli` projects with `npx` is slow, as all dependencies of `preact-cli` would need to be installed, even though only a handful are used for project initialization. On the other hand, suggesting global installs is less than attractive due to NPM's poor default install location (requires `sudo`) and this can get out of sync over time.

By extracting project initialization into its own package, we can provide much, much faster project setup times.

To setup a new project, users will use `npm init preact-cli ...` or `yarn create preact-cli ...`.

Additionally, the `--yarn` flag has been removed in favour of using the yarn initializer (`yarn create`).
18 changes: 18 additions & 0 deletions .changeset/wild-lizards-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'preact-cli': major
---

Removes support for automatic async routes via `@preact/async-loader`.

Instead of magic directories, users can use `preact-iso`'s `lazy()` to split routes & components as they wish from anywhere.

This should be a lot more powerful and transparent compared to the previous setup.

```js
// before
import Home from './routes/home';

// after
import { lazy } from 'preact-iso';
const Home = lazy(() => import('./routes/home.js'));
```
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/node_modules
**/tests/output
**/tests/subjects/*/preact.config.js
**/*.d.ts
18 changes: 9 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
{
"extends": [
"eslint:recommended",
"prettier"
],
"extends": ["eslint:recommended", "prettier"],
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": [
"babel",
"react",
"prettier"
],
"plugins": ["babel", "react", "prettier"],
"settings": {
"react": {
"pragma": "h",
Expand All @@ -29,6 +22,13 @@
"rules": {
"no-console": 1,
"no-empty": 0,
"no-unused-vars": [
2,
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"semi": 2,
"keyword-spacing": 2,
"require-atomic-updates": 0,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
with:
Expand Down
Loading