Skip to content

Commit 8675610

Browse files
authored
Merge pull request #21 from dumlj/fix/windows
Fix/windows
2 parents 4a0c12e + 97e6ec5 commit 8675610

File tree

15 files changed

+141
-18
lines changed

15 files changed

+141
-18
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ module.exports = {
4040
},
4141
overrides: [
4242
{
43-
files: ['**/*.ts'],
43+
files: ['**/*.ts', '**/*.tsx'],
4444
extends: ['./public/eslintrc/ts.js'],
4545
},
4646
{
47-
files: ['**/*.js'],
47+
files: ['**/*.js', '**/*.jsx'],
4848
extends: ['./public/eslintrc/cjs.js'],
4949
},
5050
{

.lintstagedrc.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
'**/*.{js,jsx,ts,tsx,d.tsx,md,yml,yaml,json,css,less,scss,sass,html,ejs,hbs}': (files) => {
2+
'**/*.{js,jsx,ts,tsx,d.ts,md,yml,yaml,json,css,less,scss,sass,html,ejs,hbs}': (files) => {
33
return ['prettier', '--config .prettierrc.js', '--write', ...files].join(' ')
44
},
55
'**/*.{ts,tsx,d.ts}': async (files) => {

@next-plugin/next-auto-dynamic/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ module.exports = withDynamicClient(nextConfig)
5252

5353
## LIVE DEMO
5454

55+
You can view static file loading by refreshing the page and opening the console.
56+
5557
<dumlj-stackblitz height="47vw" src="@dumlj-example/next-auto-dynamic"></dumlj-stackblitz>
5658

5759
## INTERNAL DEPENDENCIES

@next-plugin/next-auto-dynamic/__example__/app/layout.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '@/style.css'
2+
13
export interface LayoutProps {
24
children: React.ReactNode
35
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import SSR from '../components/SSR'
22

33
export default function Index() {
4-
return (
5-
<div>
6-
Hello World <SSR />
7-
</div>
8-
)
4+
return <SSR />
95
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import A from '../snippets/A'
22
import B from '@/snippets/B'
3+
import C from '../snippets/C'
34

45
export default async function SSR() {
56
return (
67
<>
78
<A />
89
<B />
10+
<C />
911
</>
1012
)
1113
}

@next-plugin/next-auto-dynamic/__example__/next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const { nextDynamicClient } = require('@dumlj/next-auto-dynamic')
44
const withDynamicClient = nextDynamicClient({
55
src: './snippets',
6+
exclude: ['C.tsx'],
67
})
78

89
/** @type {import('next').NextConfig} */

@next-plugin/next-auto-dynamic/__example__/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"next": "latest"
1212
},
1313
"devDependencies": {
14+
"@types/react": "latest",
1415
"@dumlj/next-auto-dynamic": "workspace:*"
1516
}
1617
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
'use client'
22

3+
import { useEffect, useState } from 'react'
4+
35
export default function A() {
4-
return <div>A</div>
6+
const [moduleId, setModuleId] = useState<string>()
7+
const [parents, setParents] = useState<string[]>()
8+
9+
useEffect(() => {
10+
setModuleId(__webpack_module__.id)
11+
setParents(__webpack_module__.parents)
12+
}, [])
13+
14+
return (
15+
<section>
16+
<h2>
17+
A <span>{moduleId}</span>
18+
</h2>
19+
<p>Import "./A"</p>
20+
<pre>
21+
Parents:
22+
<br />
23+
{JSON.stringify(parents, null, 2)}
24+
</pre>
25+
</section>
26+
)
527
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
'use client'
22

3+
import { useEffect, useState } from 'react'
4+
35
export default function B() {
4-
return <div>B</div>
6+
const [moduleId, setModuleId] = useState<string>()
7+
const [parents, setParents] = useState<string[]>()
8+
9+
useEffect(() => {
10+
setModuleId(__webpack_module__.id)
11+
setParents(__webpack_module__.parents)
12+
}, [])
13+
14+
return (
15+
<section>
16+
<h2>
17+
B <span>{moduleId}</span>
18+
</h2>
19+
<p>Import "@/B"</p>
20+
<pre>
21+
Parents:
22+
<br />
23+
{JSON.stringify(parents, null, 2)}
24+
</pre>
25+
</section>
26+
)
527
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use client'
2+
3+
import { useEffect, useState } from 'react'
4+
5+
export default function C() {
6+
const [moduleId, setModuleId] = useState<string>()
7+
const [parents, setParents] = useState<string[]>()
8+
9+
useEffect(() => {
10+
setModuleId(__webpack_module__.id)
11+
setParents(__webpack_module__.parents)
12+
}, [])
13+
14+
return (
15+
<section>
16+
<h2>
17+
C <span>{moduleId}</span>
18+
</h2>
19+
<p>No automatic dynamic import by exclude option of plugin.</p>
20+
<pre>
21+
Parents:
22+
<br />
23+
{JSON.stringify(parents, null, 2)}
24+
</pre>
25+
</section>
26+
)
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
html,
6+
body {
7+
margin: 0;
8+
padding: 0;
9+
width: 100%;
10+
}
11+
12+
h2 {
13+
display: flex;
14+
align-items: center;
15+
margin-bottom: 10px;
16+
font-size: 16px;
17+
font-weight: bold;
18+
}
19+
20+
h2 > span {
21+
margin-left: 10px;
22+
font-weight: normal;
23+
}
24+
25+
p {
26+
margin-bottom: 10px;
27+
}
28+
29+
section {
30+
display: flex;
31+
flex-direction: column;
32+
margin: 20px;
33+
padding: 20px;
34+
border: 1px solid #999;
35+
border-radius: 10px;
36+
box-shadow: 0px 1px 4px #ccc;
37+
}
38+
39+
pre {
40+
line-height: 1.8;
41+
word-break: keep-all;
42+
white-space: break-spaces;
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare const __webpack_module__: {
2+
id: string
3+
parents: string[]
4+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
## LIVE DEMO
22

3+
You can view static file loading by refreshing the page and opening the console.
4+
35
<dumlj-stackblitz height="47vw" src="@dumlj-example/next-auto-dynamic"></dumlj-stackblitz>

pnpm-lock.yaml

+7-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)