Skip to content

Commit

Permalink
Merge pull request #387 from marvinhagemeister/next-plugin-preact
Browse files Browse the repository at this point in the history
fix(deps): switch to next-plugin-react
  • Loading branch information
ljosberinn authored Jan 22, 2021
2 parents b1ec0e6 + eea87fa commit 1e8c93f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 78 deletions.
43 changes: 4 additions & 39 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,8 @@
* replaces React with Preact in prod
* this reduces the bundle size by approx. 32 kB
*/
const withPreact = (config, options) => {
if (!options.dev) {
const splitChunks = config.optimization && config.optimization.splitChunks;
const withPreact = require('next-plugin-preact');

if (splitChunks) {
const { cacheGroups } = splitChunks;
const test = /[\\/]node_modules[\\/](preact|preact-render-to-string|preact-context-provider)[\\/]/u;
if (cacheGroups.framework) {
cacheGroups.preact = {
...cacheGroups.framework,
test,
};

cacheGroups.commons.name = 'framework';
} else {
cacheGroups.preact = {
chunks: 'all',
name: 'commons',
test,
};
}
}

const aliases = config.resolve.alias || (config.resolve.alias = {});
// eslint-disable-next-line no-multi-assign
aliases.react = aliases['react-dom'] = 'preact/compat';
aliases['react-ssr-prepass'] = 'preact-ssr-prepass';
}
};

module.exports = {
images: {
domains: ['avatars3.githubusercontent.com'],
},
webpack: (config, options) => {
withPreact(config, options);

return config;
},
};
module.exports = withPreact({
/* regular next.js config options here */
});
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
"dom-parser": "0.1.6",
"i18next": "19.8.4",
"i18next-browser-languagedetector": "6.0.1",
"next": "10.0.5",
"next": "^10.0.5",
"next-plugin-preact": "^3.0.3",
"preact": "^10.5.11",
"preact-render-to-string": "^5.1.12",
"preact-ssr-prepass": "1.1.3",
"react": "npm:@preact/compat",
"react-debounce-input": "3.2.3",
"react-dom": "npm:@preact/compat",
"react-i18next": "11.8.5",
"react-icons": "4.1.0",
"preact": "10.5.11",
"preact-render-to-string": "5.1.12",
"preact-ssr-prepass": "1.1.3"
"react-ssr-prepass": "npm:preact-ssr-prepass"
},
"devDependencies": {
"@commitlint/cli": "11.0.0",
Expand All @@ -31,9 +35,7 @@
"husky": "4.3.8",
"lint-staged": "10.5.3",
"prettier": "2.2.1",
"typescript": "4.1.3",
"react": "16.14.0",
"react-dom": "16.14.0"
"typescript": "4.1.3"
},
"commitlint": {
"extends": [
Expand Down
88 changes: 56 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,39 @@
resolved "https://registry.yarnpkg.com/@opentelemetry/context-base/-/context-base-0.14.0.tgz#c67fc20a4d891447ca1a855d7d70fa79a3533001"
integrity sha512-sDOAZcYwynHFTbLo6n8kIbLiVF3a3BLkrmehJUyEbT9F+Smbi47kLGS2gG2g0fjBLR/Lr1InPD7kXL7FaTqEkw==

"@prefresh/[email protected]":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@prefresh/babel-plugin/-/babel-plugin-0.4.0.tgz#78ca60adb51095b20e6afdaadc1015e549ae89c9"
integrity sha512-fFwyfIHm/B8BBY7HL4j9iJl7KFk/5yVIWE+aozRRPPxI8lRFkyXMAgUFtTSmP3/jiMA6jyOcBeYUhWsyEUynpQ==

"@prefresh/core@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@prefresh/core/-/core-1.3.0.tgz#90d27e9ee4ddfeef46d120dfbe70b259770731ee"
integrity sha512-8upcMgA2143mGP0ZCX4Qrt4P+uco5y4KBfDWUVbX4XheGhTk1EbGfdZcdXaHsT8VhnlJem0PWeVDD/f3PijFqA==

"@prefresh/next@^1.3.0":
version "1.4.4"
resolved "https://registry.yarnpkg.com/@prefresh/next/-/next-1.4.4.tgz#ac0c503266259447f780ccfc7419c93607a1fede"
integrity sha512-SzSw3QnPztWiypTvK/aaAF4GVKx/7A3eQtPWv9BFt0TGjHBChh22KUpHsJh8/nW148vUzXWHye3UoIRQNYdkKg==
dependencies:
"@prefresh/babel-plugin" "0.4.0"
"@prefresh/core" "^1.3.0"
"@prefresh/utils" "^1.0.0"
"@prefresh/webpack" "^3.0.0"

"@prefresh/utils@^1.0.0", "@prefresh/utils@^1.1.0":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@prefresh/utils/-/utils-1.1.1.tgz#ffe7f2e6bd48a0633631a3d92c0ee4bdeb0ac330"
integrity sha512-MUhT5m2XNN5NsZl4GnpuvlzLo6VSTa/+wBfBd3fiWUvHGhv0GF9hnA1pd//v0uJaKwUnVRQ1hYElxCV7DtYsCQ==

"@prefresh/webpack@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@prefresh/webpack/-/webpack-3.0.0.tgz#309391e07b34446c8d17c6776e179c68cd5cbea0"
integrity sha512-0Bb2/vgmItPQqbAFXcramGthxGSYs5Zf+6+A1KgIFQeIggd2FO9r2zOX8Gwb1SnKH19rdOtfIQaNwWPqavt/zA==
dependencies:
"@prefresh/core" "^1.3.0"
"@prefresh/utils" "^1.1.0"

"@testing-library/dom@^7.28.1":
version "7.29.4"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.4.tgz#1647c2b478789621ead7a50614ad81ab5ae5b86c"
Expand Down Expand Up @@ -3939,7 +3972,7 @@ log-update@^4.0.0:
slice-ansi "^4.0.0"
wrap-ansi "^6.2.0"

loose-envify@^1.1.0, loose-envify@^1.4.0:
loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
Expand Down Expand Up @@ -4176,6 +4209,11 @@ mkdirp@^0.5.1, mkdirp@^0.5.3:
dependencies:
minimist "^1.2.5"

module-alias@^2.0.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0"
integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==

move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
Expand Down Expand Up @@ -4252,12 +4290,20 @@ neo-async@^2.5.0, neo-async@^2.6.1, neo-async@^2.6.2:
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==

next-plugin-preact@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/next-plugin-preact/-/next-plugin-preact-3.0.3.tgz#59af6b809e3ba2baf454f469c19c5a7173741d01"
integrity sha512-A3vfyqnsJHXKTuhT4jYFYzXvE4RS6kYraReuVlnVxz5veX6CqtKHikvZcmeKEtB1BQeNmoBZviJ8S/ZpuENmuw==
dependencies:
"@prefresh/next" "^1.3.0"
module-alias "^2.0.0"

next-tick@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=

[email protected]:
next@^10.0.5:
version "10.0.5"
resolved "https://registry.yarnpkg.com/next/-/next-10.0.5.tgz#8071e0aa1883266c91943aa7c6b73deadb064793"
integrity sha512-yr7ap2TLugf0aMHz+3JoKFP9CCkFE+k6jCfdUymORhptjLYZbD3YGlTcUC1CRl+b5Phlbl7m/WUIPde0VcguiA==
Expand Down Expand Up @@ -4894,19 +4940,19 @@ postcss@^7.0.14, postcss@^7.0.26, postcss@^7.0.32, postcss@^7.0.5, postcss@^7.0.
source-map "^0.6.1"
supports-color "^6.1.0"

[email protected]:
preact-render-to-string@^5.1.12:
version "5.1.12"
resolved "https://registry.yarnpkg.com/preact-render-to-string/-/preact-render-to-string-5.1.12.tgz#3d258a177ef8947f768dd0f2c56629e7fda2dc39"
integrity sha512-nXVCOpvepSk9AfPwqS08rf9NDOCs8eeYYlG+7tE85iP5jVyjz+aYb1BYaP5SPdfVWVrzI9L5NzxozUvKaD96tA==
dependencies:
pretty-format "^3.8.0"

[email protected]:
[email protected], "react-ssr-prepass@npm:preact-ssr-prepass":
version "1.1.3"
resolved "https://registry.yarnpkg.com/preact-ssr-prepass/-/preact-ssr-prepass-1.1.3.tgz#ba56926a4d9660da2079f90d91b033483e2ebf20"
integrity sha512-pDWwj88IPz9fUFEuPv9HfRsVlovf6a8eLgQDrNnksxfUeI1bHekNhDesDQXVq0L1XovZAzmfmIjwWDKo4gtoYQ==

[email protected]:
preact@^10.5.11:
version "10.5.11"
resolved "https://registry.yarnpkg.com/preact/-/preact-10.5.11.tgz#2c8a431f16613e442901068175771806cf1cc0f6"
integrity sha512-BdtFePVilR1430kDuzh3VkkZktCmp8RTqHOjG8qesyGZXHNYJjdrjEBuc2f7O/vthhVENxJd0/aTjWtYeH46aw==
Expand Down Expand Up @@ -4984,7 +5030,7 @@ promise-inflight@^1.0.1:
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

[email protected], prop-types@^15.6.2, prop-types@^15.7.2:
[email protected], prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -5113,15 +5159,10 @@ [email protected]:
lodash.debounce "^4"
prop-types "^15.7.2"

[email protected]:
version "16.14.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.14.0.tgz#7ad838ec29a777fb3c75c3a190f661cf92ab8b89"
integrity sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.19.1"
"react-dom@npm:@preact/compat", "react@npm:@preact/compat":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@preact/compat/-/compat-0.0.4.tgz#f329e41caa330199eaf779c9bc9cf9556e3984a0"
integrity sha512-NdazvKTisqbua54srMCVGuPwae53SM3u85yxrTymT+eJnScJOIAybDEzyOcAOpJsvo6vnGOiSyxmID7rlGw3nw==

[email protected]:
version "11.8.5"
Expand Down Expand Up @@ -5151,15 +5192,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f"
integrity sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==

[email protected]:
version "16.14.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"

[email protected], read-pkg-up@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507"
Expand Down Expand Up @@ -5476,14 +5508,6 @@ [email protected]:
schema-utils "^3.0.0"
semver "^7.3.2"

scheduler@^0.19.1:
version "0.19.1"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196"
integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"

[email protected], schema-utils@^2.6.6, schema-utils@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
Expand Down

1 comment on commit 1e8c93f

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for gerritalex-de ready!

✅ Preview
https://gerritalex-de-qtwomemgv.vercel.app

Built with commit 1e8c93f.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.