-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into add/manifest-check
- Loading branch information
Showing
11 changed files
with
206 additions
and
30 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
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
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
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
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
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,3 @@ | ||
#!/usr/env node | ||
|
||
module.exports = 789 |
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,3 @@ | ||
#!/usr/env node | ||
|
||
module.exports = 123 |
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,3 @@ | ||
#!/usr/env node | ||
|
||
export default 456 |
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,20 @@ | ||
/** | ||
* Import hashbang modules. | ||
*/ | ||
import js from '../cases/js.js' | ||
import cjs from '../cases/cjs.cjs' | ||
import mjs from '../cases/mjs.mjs' | ||
|
||
const jsMsg = `JS: ${js}` | ||
const mjsMsg = `MJS: ${mjs}` | ||
const cjsMsg = `CJS: ${cjs}` | ||
|
||
const Page = () => ( | ||
<div> | ||
<h3>{jsMsg}</h3> | ||
<h3>{mjsMsg}</h3> | ||
<h3>{cjsMsg}</h3> | ||
</div> | ||
) | ||
|
||
export default Page |
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,63 @@ | ||
/* eslint-env jest */ | ||
|
||
import { join } from 'path' | ||
import fs from 'fs-extra' | ||
import { | ||
renderViaHTTP, | ||
findPort, | ||
launchApp, | ||
killApp, | ||
nextBuild, | ||
nextStart, | ||
} from 'next-test-utils' | ||
|
||
jest.setTimeout(1000 * 60 * 2) | ||
|
||
let app | ||
let appPort | ||
const appDir = join(__dirname, '../') | ||
|
||
function runTests() { | ||
describe('first-line hashbang (#!) parse', () => { | ||
it('should work for .js files', async () => { | ||
const html = await renderViaHTTP(appPort, '/') | ||
expect(html).toMatch('JS: 123') | ||
}) | ||
|
||
it('should work for .mjs files', async () => { | ||
const html = await renderViaHTTP(appPort, '/') | ||
expect(html).toMatch('MJS: 456') | ||
}) | ||
|
||
it('should work for .cjs files', async () => { | ||
const html = await renderViaHTTP(appPort, '/') | ||
expect(html).toMatch('CJS: 789') | ||
}) | ||
}) | ||
} | ||
|
||
const nextConfig = join(appDir, 'next.config.js') | ||
|
||
describe('Hashbang', () => { | ||
describe('dev mode', () => { | ||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort) | ||
}) | ||
afterAll(() => killApp(app)) | ||
|
||
runTests(true) | ||
}) | ||
|
||
describe('production mode', () => { | ||
beforeAll(async () => { | ||
await fs.remove(nextConfig) | ||
await nextBuild(appDir) | ||
appPort = await findPort() | ||
app = await nextStart(appDir, appPort) | ||
}) | ||
afterAll(() => killApp(app)) | ||
|
||
runTests() | ||
}) | ||
}) |
Oops, something went wrong.