Skip to content

Commit e5c5619

Browse files
authored
Merge pull request #15 from bem/yarastqt.issue-14.fix-next-12
Check entries for patch require
2 parents 8281fc0 + 4af4e9c commit e5c5619

File tree

11 files changed

+58
-3
lines changed

11 files changed

+58
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { withGlobalCss } = require('../../lib')
2+
3+
module.exports = withGlobalCss()()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "next-10-local",
3+
"version": "0.0.1",
4+
"private": "true",
5+
"scripts": {
6+
"build": "next build",
7+
"dev": "next dev"
8+
},
9+
"dependencies": {
10+
"3d-party-library": "file:../__fixtures__/3d-party-library/3d-party-library-0.0.1.tgz",
11+
"next": "^12.1.4",
12+
"react": "^18.0.0",
13+
"react-dom": "^18.0.0",
14+
"sass": "^1.34.0"
15+
}
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react'
2+
3+
export default function MyApp({ Component, pageProps }) {
4+
return <Component {...pageProps} />
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component } from '3d-party-library/component'
2+
import { ScssComponent } from '../src/components/scss-component'
3+
import { CssComponent } from '../src/components/css-component'
4+
5+
export default function Home() {
6+
return (
7+
<>
8+
<Component />
9+
<ScssComponent />
10+
<CssComponent />
11+
</>
12+
)
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './styles.css'
2+
3+
export const CssComponent = () => {
4+
return <button className="css-button">CssComponent</button>
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.css-button {
2+
color: red;
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './styles.scss'
2+
3+
export const ScssComponent = () => {
4+
return <button className="scss-button">ScssComponent</button>
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.scss-button {
2+
color: red;
3+
}

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ function patchServerWebpackConfig(config) {
66
const entry = await originalEntry()
77
const patchPath = require.resolve('./patch-global-require')
88
// Prepend module with patched `require` for ignore load css files.
9-
if (!entry['pages/_app'].includes(patchPath)) {
9+
if (entry['pages/_app'] && !entry['pages/_app'].includes(patchPath)) {
1010
entry['pages/_app'].unshift(patchPath)
1111
}
12-
if (!entry['pages/_document'].includes(patchPath)) {
12+
if (entry['pages/_document'] && !entry['pages/_document'].includes(patchPath)) {
1313
entry['pages/_document'].unshift(patchPath)
1414
}
1515
return entry

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"test-next-10-local": "node ./__tests__/index.test.js --version=10-local",
1919
"test-next-10-ssr": "node ./__tests__/index.test.js --version=10-ssr",
2020
"test-next-10": "node ./__tests__/index.test.js --version=10",
21-
"test": "npm run test-next-10-local && npm run test-next-10-ssr && npm run test-next-10"
21+
"test-next-12-react-18-local": "node ./__tests__/index.test.js --version=12-react-18-local",
22+
"test": "npm run test-next-10-local && npm run test-next-10-ssr && npm run test-next-10 && npm run test-next-12-react-18-local"
2223
}
2324
}

0 commit comments

Comments
 (0)