-
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.
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Root({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
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,15 @@ | ||
import { GetObjectCommand } from '@aws-sdk/client-s3' | ||
import { isObject } from 'lodash' | ||
|
||
export default function Page() { | ||
const command = new GetObjectCommand({ | ||
Bucket: 'bucket', | ||
Key: 'key1', | ||
}) | ||
return ( | ||
<div> | ||
<div id="key">Key: {command.input.Key}</div> | ||
<div id="isObject">isObject: {String(isObject(command))}</div> | ||
</div> | ||
) | ||
} |
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,8 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
transpilePackages: ['@aws-sdk/client-s3'], | ||
} | ||
|
||
module.exports = nextConfig |
29 changes: 29 additions & 0 deletions
29
test/production/transpile-packages/transpile-packages.test.ts
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,29 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'app fetch build cache', | ||
{ | ||
files: __dirname, | ||
dependencies: { | ||
'@aws-sdk/client-s3': 'latest', | ||
lodash: 'latest', | ||
}, | ||
}, | ||
({ next }) => { | ||
it('should render page with dependencies', async () => { | ||
const $ = await next.render$('/') | ||
expect($('#key').text()).toBe('Key: key1') | ||
expect($('#isObject').text()).toBe('isObject: true') | ||
}) | ||
|
||
it('should treat lodash as an external package', async () => { | ||
const output = await next.readFile('.next/server/app/page.js') | ||
expect(output).toContain('require("lodash') | ||
}) | ||
|
||
it('should bundle @aws-sdk/client-s3 as a transpiled package', async () => { | ||
const output = await next.readFile('.next/server/app/page.js') | ||
expect(output).not.toContain('require("@aws-sdk/client-s3")') | ||
}) | ||
} | ||
) |