Skip to content

Commit 47ff09c

Browse files
update to next v11
1 parent e65fe05 commit 47ff09c

13 files changed

+2047
-2222
lines changed

.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next", "plugin:tailwind/recommended"]
3+
}

.eslintrc.js

-24
This file was deleted.

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2012-2021 Scott Chacon and others
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

next.config.js

+41-46
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
55

66
const withOffline = require('next-offline')
77

8+
// esbuild to speed up dev
89
function esbuildLoader(config, options) {
910
const jsLoader = config.module.rules.find(
1011
(rule) => rule.test && rule.test.test('.js')
@@ -22,55 +23,49 @@ function esbuildLoader(config, options) {
2223
}
2324
}
2425

25-
// the config break if we use next export
26-
const nextConfig =
27-
process.env.EXPORT !== 'true'
28-
? {
29-
webpack5: true,
30-
webpack(config, { webpack, dev, isServer }) {
31-
config.plugins.push(
32-
new webpack.ProvidePlugin({
33-
React: 'react',
34-
})
35-
)
36-
// use esbuild in dev for faster HMR
37-
if (dev) {
38-
esbuildLoader(config, {
39-
loader: 'jsx',
40-
target: 'es2017',
41-
})
42-
// config.optimization.minimizer.shift()
43-
}
26+
const nextConfig = {
27+
webpack(config, { webpack, dev, isServer }) {
28+
config.plugins.push(
29+
new webpack.ProvidePlugin({
30+
React: 'react',
31+
})
32+
)
33+
// use esbuild in dev for faster HMR
34+
if (dev) {
35+
esbuildLoader(config, {
36+
loader: 'jsx',
37+
target: 'es2017',
38+
})
39+
}
4440

45-
// audio support
46-
config.module.rules.push({
47-
test: /\.(ogg|mp3|wav|mpe?g)$/i,
48-
exclude: config.exclude,
49-
use: [
50-
{
51-
loader: require.resolve('url-loader'),
52-
options: {
53-
limit: config.inlineImageLimit,
54-
fallback: require.resolve('file-loader'),
55-
publicPath: `${config.assetPrefix}/_next/static/images/`,
56-
outputPath: `${isServer ? '../' : ''}static/images/`,
57-
name: '[name]-[hash].[ext]',
58-
esModule: config.esModule || false,
59-
},
60-
},
61-
],
62-
})
41+
// audio support
42+
config.module.rules.push({
43+
test: /\.(ogg|mp3|wav|mpe?g)$/i,
44+
exclude: config.exclude,
45+
use: [
46+
{
47+
loader: require.resolve('url-loader'),
48+
options: {
49+
limit: config.inlineImageLimit,
50+
fallback: require.resolve('file-loader'),
51+
publicPath: `${config.assetPrefix}/_next/static/images/`,
52+
outputPath: `${isServer ? '../' : ''}static/images/`,
53+
name: '[name]-[hash].[ext]',
54+
esModule: config.esModule || false,
55+
},
56+
},
57+
],
58+
})
6359

64-
config.module.rules.push({
65-
test: /\.(glsl|vs|fs|vert|frag)$/,
66-
exclude: /node_modules/,
67-
use: ['raw-loader', 'glslify-loader'],
68-
})
60+
config.module.rules.push({
61+
test: /\.(glsl|vs|fs|vert|frag)$/,
62+
exclude: /node_modules/,
63+
use: ['raw-loader', 'glslify-loader'],
64+
})
6965

70-
return config
71-
},
72-
}
73-
: {}
66+
return config
67+
},
68+
}
7469

7570
// manage i18n
7671
if (process.env.EXPORT !== 'true') {

package.json

+11-28
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,47 @@
44
"authors": [
55
"Renaud ROHLINGER <https://twitter.com/onirenaud>"
66
],
7-
"private": false,
7+
"license": "MIT",
8+
"private": true,
89
"scripts": {
910
"lint": "yarn prettier && yarn eslint",
10-
"eslint": "eslint --fix \"src/**/*.{js,jsx}\" --ext jsconfig.json",
11-
"prettier": "prettier --list-different '**/*.{js,jsx,md}'",
11+
"eslint": "eslint --fix \"./src/**/*.{js,jsx}\" --ext jsconfig.json",
12+
"prettier": "prettier --list-different \"./src/**/*.{js,jsx,md}\"",
1213
"dev": "next dev",
1314
"build": "next build",
1415
"export": "EXPORT=true next build && EXPORT=true next export",
1516
"analyze": "ANALYZE=true next build",
1617
"start": "next start"
1718
},
18-
"lint-staged": {
19-
"*.{js,jsx,json,md}": [
20-
"prettier --write"
21-
],
22-
"*.{js,jsx}": [
23-
"eslint --fix"
24-
]
25-
},
2619
"dependencies": {
2720
"@react-three/a11y": "^2.0.2",
2821
"@react-three/drei": "^6.1.2",
2922
"@react-three/fiber": "^7.0.1",
30-
"esbuild-loader": "^2.13.1",
3123
"next": "^11.0.0",
32-
"react": "^0.0.0-experimental-dbe3363cc",
24+
"react": "^18.0.0-alpha-dbe3363cc",
3325
"react-dom": "^17.0.2",
3426
"three": "^0.129.0",
3527
"three-stdlib": "^2.2.0"
3628
},
3729
"devDependencies": {
3830
"@babel/core": "^7.12.17",
39-
"@next/bundle-analyzer": "^10.0.7",
31+
"@next/bundle-analyzer": "^11.0.0",
4032
"autoprefixer": "^10.2.6",
41-
"babel-eslint": "^10.1.0",
4233
"babel-plugin-glsl": "^1.0.0",
43-
"eslint": "^7.27.0",
44-
"eslint-config-prettier": "^8.3.0",
45-
"eslint-config-react-app": "^6.0.0",
46-
"eslint-plugin-flowtype": "^5.2.2",
47-
"eslint-plugin-import": "^2.22.1",
48-
"eslint-plugin-jsx-a11y": "^6.4.1",
49-
"eslint-plugin-prettier": "^3.1.4",
50-
"eslint-plugin-react": "^7.23.2",
51-
"eslint-plugin-react-hooks": "^4.2.0",
34+
"esbuild-loader": "^2.13.1",
35+
"eslint": "^7.28.0",
36+
"eslint-config-next": "^11.0.0",
5237
"eslint-plugin-tailwind": "^0.2.1",
5338
"file-loader": "^6.2.0",
5439
"glslify": "^7.1.1",
5540
"glslify-loader": "^2.0.0",
56-
"lint-staged": "^10.5.4",
5741
"next-compose-plugins": "^2.2.1",
5842
"next-offline": "^5.0.5",
5943
"postcss": "^8.3.0",
6044
"prettier": "^2.3.0",
6145
"raw-loader": "^4.0.2",
6246
"tailwindcss": "^2.1.2",
6347
"url-loader": "^4.1.1",
64-
"webpack": "^5.38.1"
65-
},
66-
"license": "MIT"
48+
"webpack": "^5.39.0"
49+
}
6750
}

public/robots.txt

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

src/config.js src/config.jsx

File renamed without changes.

src/pages/404.jsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// custom pages/404.js !! Do not remove please or it will break build
1+
// custom pages/404.jsx !! Do not remove please or it will break build
22
export default function Error() {
3-
return <h1>404 - Page Not Found</h1>
3+
return (
4+
<>
5+
<h1>404 - Something went wrong</h1>
6+
</>
7+
)
48
}

src/pages/500.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// custom pages/500.js !! Do not remove please or it will break build
22
export default function Error() {
3-
return <h1>500 - Something went wrong</h1>
3+
return (
4+
<>
5+
<h1>500 - Something went wrong</h1>
6+
</>
7+
)
48
}

src/pages/_app.jsx

+23-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { useRouter } from 'next/router'
22
import useStore from '@/helpers/store'
3-
import { useEffect, Children } from 'react'
3+
import { useEffect, Children, Component } from 'react'
44
import Header from '../config'
55
import dynamic from 'next/dynamic'
6-
import Dom from '@/components/layout/_dom'
6+
import Dom from '@/components/layout/dom'
77

88
import '@/styles/index.css'
99

1010
let LCanvas = null
1111
if (process.env.NODE_ENV === 'production') {
12-
LCanvas = dynamic(() => import('@/components/layout/_canvas'), {
12+
LCanvas = dynamic(() => import('@/components/layout/canvas'), {
1313
ssr: false,
1414
})
1515
} else {
16-
LCanvas = require('@/components/layout/_canvas').default
16+
LCanvas = require('@/components/layout/canvas').default
1717
}
1818

1919
function Layout({ dom }) {
@@ -24,20 +24,25 @@ const ForwardPropsToR3fComponent = ({ comp, pageProps }) => {
2424
let r3fArr = []
2525
let compArr = []
2626

27-
Children.forEach(comp(pageProps).props.children, (child) => {
28-
if (child?.props && child.props.r3f) {
29-
r3fArr.push(child)
30-
} else {
31-
compArr.push(child)
32-
}
33-
})
34-
35-
return (
36-
<>
37-
{compArr && <Layout dom={compArr} />}
38-
{r3fArr && <LCanvas>{r3fArr}</LCanvas>}
39-
</>
40-
)
27+
try {
28+
Children.forEach(comp(pageProps).props.children, (child) => {
29+
if (child?.props && child.props.r3f) {
30+
r3fArr.push(child)
31+
} else {
32+
compArr.push(child)
33+
}
34+
})
35+
36+
return (
37+
<>
38+
{compArr && <Layout dom={compArr} />}
39+
{r3fArr && <LCanvas>{r3fArr}</LCanvas>}
40+
</>
41+
)
42+
} catch (error) {
43+
// fallback security for SSG
44+
return <comp {...pageProps} />
45+
}
4146
}
4247

4348
function App({ Component, pageProps = {} }) {

0 commit comments

Comments
 (0)