Skip to content

Commit

Permalink
refactor: Remove Preact v8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Feb 1, 2022
1 parent ff12b91 commit 9305abe
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 170 deletions.
36 changes: 0 additions & 36 deletions packages/async-loader/async-legacy.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/async-loader/legacy.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/async-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"node": ">=8"
},
"dependencies": {
"kleur": "^4.1.4",
"loader-utils": "^2.0.0"
},
"peerDependencies": {
Expand Down
6 changes: 0 additions & 6 deletions packages/async-loader/utils.js

This file was deleted.

16 changes: 0 additions & 16 deletions packages/cli/lib/lib/webpack/utils.js

This file was deleted.

8 changes: 3 additions & 5 deletions packages/cli/lib/lib/webpack/webpack-base-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const webpack = require('webpack');
const path = require('path');
const { resolve, dirname } = require('path');
const { readFileSync, existsSync } = require('fs');
const { isInstalledVersionPreactXOrAbove } = require('./utils');
const autoprefixer = require('autoprefixer');
const browserslist = require('browserslist');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
Expand Down Expand Up @@ -72,7 +71,6 @@ function getSassConfiguration(...includePaths) {
module.exports = function createBaseConfig(env) {
const { cwd, isProd, isWatch, src, source } = env;
const babelConfigFile = env.babelConfig || '.babelrc';
const IS_SOURCE_PREACT_X_OR_ABOVE = isInstalledVersionPreactXOrAbove(cwd);
// Apply base-level `env` values
env.dest = resolve(cwd, env.dest || 'build');
env.manifest = readJson(source('manifest.json')) || {};
Expand Down Expand Up @@ -153,9 +151,9 @@ module.exports = function createBaseConfig(env) {
'react-dom': compat,
'preact-compat': compat,
'react-addons-css-transition-group': 'preact-css-transition-group',
'preact-cli/async-component': IS_SOURCE_PREACT_X_OR_ABOVE
? require.resolve('@preact/async-loader/async')
: require.resolve('@preact/async-loader/async-legacy'),
'preact-cli/async-component': require.resolve(
'@preact/async-loader/async'
),
},
},

Expand Down
11 changes: 5 additions & 6 deletions packages/cli/lib/lib/webpack/webpack-client-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const webpack = require('webpack');
const { resolve, join } = require('path');
const { existsSync } = require('fs');
const { isInstalledVersionPreactXOrAbove } = require('./utils');
const { merge } = require('webpack-merge');
const { filter } = require('minimatch');
const SizePlugin = require('size-plugin');
Expand All @@ -25,12 +24,12 @@ const cleanFilename = name =>
''
);

/**
* @returns {Promise<import('webpack').Configuration>}
*/
async function clientConfig(env) {
const { isProd, source, src, cwd /*, port? */ } = env;
const IS_SOURCE_PREACT_X_OR_ABOVE = isInstalledVersionPreactXOrAbove(cwd);
const asyncLoader = IS_SOURCE_PREACT_X_OR_ABOVE
? require.resolve('@preact/async-loader')
: require.resolve('@preact/async-loader/legacy');
const { isProd, source, src } = env;
const asyncLoader = require.resolve('@preact/async-loader');

let entry = {
bundle: resolve(__dirname, './../entry'),
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
},
"peerDependencies": {
"less-loader": "^7.3.0",
"preact": "*",
"preact-render-to-string": "*",
"preact": "^10.0.0",
"preact-render-to-string": "^5.0.0",
"sass-loader": "^10.2.0",
"stylus-loader": "^4.3.3"
},
Expand Down
29 changes: 0 additions & 29 deletions packages/cli/tests/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,6 @@ describe('client-side tests', () => {
server.server.close();
});

it('should hydrate routes progressively with preact8.', async () => {
let dir = await subject('progressive-hydration-preact8');
await build(dir, {}, true);
const server = getServer(join(dir, 'build'), PORT);

// let page = await loadPage(chrome, `http://127.0.0.1:${PORT}/`);
const page = await chrome.newPage();

page.on('console', consoleMessage => {
// eslint-disable-next-line
console[consoleMessage.type()](consoleMessage.text());
});

await page.goto(`http://127.0.0.1:${PORT}/`);

// await waitUntilExpression(page, `window.booted`);
await sleep(500);

const mutations = await page.evaluate('window.ROOT_MUTATION_COUNT');

expect(mutations).toEqual(0);

expect(await page.evaluate('window.CHANGED_VAR')).toEqual(undefined);
await page.click('button');
expect(await page.evaluate('window.CHANGED_VAR')).toEqual(1);

server.server.close();
});

it('should hydrate for pre-rendered URLs only', async () => {
let dir = await subject('prerendering-hydration');
await build(dir, {});
Expand Down
19 changes: 0 additions & 19 deletions packages/cli/tests/subjects/progressive-hydration-preact8/index.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 9305abe

Please sign in to comment.