-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Externalize
next-server
from Server Builds (#11819)
* Externalize from Server Builds * Windows Compatibility for Plugins * Only check for windows path on windows * add comments
- Loading branch information
Showing
6 changed files
with
126 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
test/integration/externalize-next-server/app/node_modules/comps/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
test/integration/externalize-next-server/app/node_modules/comps/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "externalize-next-server-app", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT" | ||
} |
12 changes: 12 additions & 0 deletions
12
test/integration/externalize-next-server/app/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import MyComp from 'comps' | ||
|
||
const Page = () => ( | ||
<> | ||
<p>Hello {typeof window}</p> | ||
<MyComp /> | ||
</> | ||
) | ||
|
||
Page.getInitialProps = () => ({}) | ||
|
||
export default Page |
35 changes: 35 additions & 0 deletions
35
test/integration/externalize-next-server/test/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
import { nextBuild } from 'next-test-utils' | ||
import escapeStringRegexp from 'escape-string-regexp' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 | ||
|
||
const appDir = path.join(__dirname, '../app') | ||
let buildId | ||
|
||
describe('externalize next/dist/next-server', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir) | ||
buildId = await fs.readFile(path.join(appDir, '.next/BUILD_ID'), 'utf8') | ||
}) | ||
|
||
it('Does not bundle next/dist/next-server/lib/head.js in _error', async () => { | ||
const content = await fs.readFile( | ||
path.join(appDir, '.next/server/static', buildId, 'pages/_error.js'), | ||
'utf8' | ||
) | ||
expect(content).toMatch( | ||
new RegExp( | ||
'^' + | ||
escapeStringRegexp( | ||
`module.exports = require("next/dist/next-server/lib/head.js");` | ||
) + | ||
'$', | ||
'm' | ||
) | ||
) | ||
}) | ||
}) |