New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(standalone): support type: "module"
#41268
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
477e71e
fix(standalone): support `type: "module"`
balazsorban44 943ac7e
test(standalone): add `type: "module"` test
balazsorban44 9398b80
chore: group `output: "standalone"` tests
balazsorban44 216068a
move
balazsorban44 e514e6d
move
balazsorban44 2495184
change log message
balazsorban44 bae6c84
move
balazsorban44 9869406
Merge branch 'canary' into fix/issue-41258
balazsorban44 8825c4c
Merge branch 'canary' into fix/issue-41258
balazsorban44 8fd1d91
fall back to CJS if no `package.json` found
balazsorban44 6eb5682
Merge branch 'fix/issue-41258' of github.com:vercel/next.js into fix/…
balazsorban44 e68278b
always use `server.js` since copy `package.json`
balazsorban44 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,55 @@ | ||
import { createNext } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import { join } from 'path' | ||
import fs from 'fs-extra' | ||
import { | ||
fetchViaHTTP, | ||
findPort, | ||
initNextServerScript, | ||
killApp, | ||
} from 'next-test-utils' | ||
|
||
describe('type-module', () => { | ||
let next: NextInstance | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
'pages/index.js': ` | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} | ||
`, | ||
'next.config.mjs': `export default ${JSON.stringify({ | ||
output: 'standalone', | ||
})}`, | ||
}, | ||
packageJson: { type: 'module' }, | ||
}) | ||
await next.stop() | ||
}) | ||
|
||
afterAll(() => next.destroy()) | ||
|
||
it('should work', async () => { | ||
const standalonePath = join(next.testDir, '.next/standalone') | ||
const staticSrc = join(next.testDir, '.next/static') | ||
|
||
const staticDest = join(standalonePath, '.next/static') | ||
|
||
await fs.move(staticSrc, staticDest) | ||
|
||
const serverFile = join(standalonePath, 'server.js') | ||
const appPort = await findPort() | ||
const server = await initNextServerScript( | ||
serverFile, | ||
/Listening on/, | ||
{ ...process.env, PORT: appPort }, | ||
undefined, | ||
{ cwd: next.testDir } | ||
) | ||
const res = await fetchViaHTTP(appPort, '/') | ||
expect(await res.text()).toContain('hello world') | ||
await killApp(server) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept wanting to click on a link after server startup, so I added this similar to
next start
.