(options${optionalIfVariableFont}: {
weight${optionalIfVariableFont}:${formatUnion(
weightTypes
)} | Array<${formatUnion(
@@ -67,7 +65,7 @@ const fetch = require('node-fetch')
)}>
style?: ${formatUnion(styleTypes)} | Array<${formatUnion(styleTypes)}>
display?:Display
- variable?: CssVariable
+ variable?: T
preload?:boolean
fallback?: string[]
adjustFontFallback?: boolean
@@ -77,7 +75,7 @@ const fetch = require('node-fetch')
? `axes?:(${formatUnion(optionalAxes.map(({ tag }) => tag))})[]`
: ''
}
- }):FontModule
+ }): T extends undefined ? NextFont : NextFontWithVariable
`
}
diff --git a/test/e2e/app-dir/rsc-external.test.ts b/test/e2e/app-dir/app-external.test.ts
similarity index 83%
rename from test/e2e/app-dir/rsc-external.test.ts
rename to test/e2e/app-dir/app-external.test.ts
index 7eb2160ea56ee9..f80c78aacc879d 100644
--- a/test/e2e/app-dir/rsc-external.test.ts
+++ b/test/e2e/app-dir/app-external.test.ts
@@ -18,7 +18,7 @@ async function resolveStreamResponse(response: any, onData?: any) {
return result
}
-describe('app dir - rsc external dependency', () => {
+describe('app dir - external dependency', () => {
let next: NextInstance
if ((global as any).isNextDeploy) {
@@ -28,7 +28,7 @@ describe('app dir - rsc external dependency', () => {
beforeAll(async () => {
next = await createNext({
- files: new FileRef(path.join(__dirname, './rsc-external')),
+ files: new FileRef(path.join(__dirname, './app-external')),
dependencies: {
'@next/font': 'canary',
react: 'latest',
@@ -90,9 +90,9 @@ describe('app dir - rsc external dependency', () => {
containClientContent(browserClientText)
// support esm module imports on server side, and indirect imports from shared components
- expect(serverHtml).toContain('random-module-instance')
+ expect(serverHtml).toContain('pure-esm-module')
expect(sharedHtml).toContain(
- 'node_modules instance from client module random-module-instance'
+ 'node_modules instance from client module pure-esm-module'
)
})
@@ -166,4 +166,30 @@ describe('app dir - rsc external dependency', () => {
)
).toMatch(/^__myFont_.{6}, __myFont_Fallback_.{6}$/)
})
+
+ describe('react in external esm packages', () => {
+ it('should use the same react in client app', async () => {
+ const html = await renderViaHTTP(next.url, '/esm/client')
+
+ const v1 = html.match(/App React Version: ([^<]+))[1]
+ const v2 = html.match(/External React Version: ([^<]+))[1]
+ expect(v1).toBe(v2)
+ })
+
+ it('should use the same react in server app', async () => {
+ const html = await renderViaHTTP(next.url, '/esm/server')
+
+ const v1 = html.match(/App React Version: ([^<]+))[1]
+ const v2 = html.match(/External React Version: ([^<]+))[1]
+ expect(v1).toBe(v2)
+ })
+
+ it('should use the same react in pages', async () => {
+ const html = await renderViaHTTP(next.url, '/test-pages-esm')
+
+ const v1 = html.match(/App React Version: ([^<]+))[1]
+ const v2 = html.match(/External React Version: ([^<]+))[1]
+ expect(v1).toBe(v2)
+ })
+ })
})
diff --git a/test/e2e/app-dir/rsc-external/app/css/[...slug]/page.js b/test/e2e/app-dir/app-external/app/css/[...slug]/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/css/[...slug]/page.js
rename to test/e2e/app-dir/app-external/app/css/[...slug]/page.js
diff --git a/test/e2e/app-dir/rsc-external/app/css/modules/page.js b/test/e2e/app-dir/app-external/app/css/modules/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/css/modules/page.js
rename to test/e2e/app-dir/app-external/app/css/modules/page.js
diff --git a/test/e2e/app-dir/app-external/app/esm/client/page.js b/test/e2e/app-dir/app-external/app/esm/client/page.js
new file mode 100644
index 00000000000000..c768fe9d4716d9
--- /dev/null
+++ b/test/e2e/app-dir/app-external/app/esm/client/page.js
@@ -0,0 +1,15 @@
+'use client'
+import { version, useValue } from 'esm-with-react'
+
+import React from 'react'
+
+export default function Index() {
+ const value = useValue()
+ return (
+
+
{'App React Version: ' + React.version}
+ {'External React Version: ' + version}
+ {'Test: ' + value}
+
+ )
+}
diff --git a/test/e2e/app-dir/app-external/app/esm/server/page.js b/test/e2e/app-dir/app-external/app/esm/server/page.js
new file mode 100644
index 00000000000000..fc89753d16a570
--- /dev/null
+++ b/test/e2e/app-dir/app-external/app/esm/server/page.js
@@ -0,0 +1,12 @@
+import { version } from 'esm-with-react'
+
+import React from 'react'
+
+export default function Index() {
+ return (
+
+
{'App React Version: ' + React.version}
+ {'External React Version: ' + version}
+
+ )
+}
diff --git a/test/e2e/app-dir/rsc-external/app/external-imports/client/page.js b/test/e2e/app-dir/app-external/app/external-imports/client/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/external-imports/client/page.js
rename to test/e2e/app-dir/app-external/app/external-imports/client/page.js
diff --git a/test/e2e/app-dir/rsc-external/app/external-imports/server/page.js b/test/e2e/app-dir/app-external/app/external-imports/server/page.js
similarity index 66%
rename from test/e2e/app-dir/rsc-external/app/external-imports/server/page.js
rename to test/e2e/app-dir/app-external/app/external-imports/server/page.js
index 902dee4d254918..f28f309b74bb8f 100644
--- a/test/e2e/app-dir/rsc-external/app/external-imports/server/page.js
+++ b/test/e2e/app-dir/app-external/app/external-imports/server/page.js
@@ -1,4 +1,4 @@
-import { name } from 'random-module-instance'
+import { name } from 'pure-esm-module'
export default function Page() {
return (
diff --git a/test/e2e/app-dir/rsc-external/app/font/page.js b/test/e2e/app-dir/app-external/app/font/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/font/page.js
rename to test/e2e/app-dir/app-external/app/font/page.js
diff --git a/test/e2e/app-dir/rsc-external/app/layout.js b/test/e2e/app-dir/app-external/app/layout.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/layout.js
rename to test/e2e/app-dir/app-external/app/layout.js
diff --git a/test/e2e/app-dir/rsc-external/app/react-server/3rd-party-package/client.js b/test/e2e/app-dir/app-external/app/react-server/3rd-party-package/client.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/react-server/3rd-party-package/client.js
rename to test/e2e/app-dir/app-external/app/react-server/3rd-party-package/client.js
diff --git a/test/e2e/app-dir/rsc-external/app/react-server/3rd-party-package/page.js b/test/e2e/app-dir/app-external/app/react-server/3rd-party-package/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/react-server/3rd-party-package/page.js
rename to test/e2e/app-dir/app-external/app/react-server/3rd-party-package/page.js
diff --git a/test/e2e/app-dir/rsc-external/app/react-server/client-detector.js b/test/e2e/app-dir/app-external/app/react-server/client-detector.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/react-server/client-detector.js
rename to test/e2e/app-dir/app-external/app/react-server/client-detector.js
diff --git a/test/e2e/app-dir/rsc-external/app/react-server/detector.js b/test/e2e/app-dir/app-external/app/react-server/detector.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/react-server/detector.js
rename to test/e2e/app-dir/app-external/app/react-server/detector.js
diff --git a/test/e2e/app-dir/rsc-external/app/react-server/optout/client.js b/test/e2e/app-dir/app-external/app/react-server/optout/client.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/react-server/optout/client.js
rename to test/e2e/app-dir/app-external/app/react-server/optout/client.js
diff --git a/test/e2e/app-dir/rsc-external/app/react-server/optout/page.js b/test/e2e/app-dir/app-external/app/react-server/optout/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/react-server/optout/page.js
rename to test/e2e/app-dir/app-external/app/react-server/optout/page.js
diff --git a/test/e2e/app-dir/rsc-external/app/react-server/page.js b/test/e2e/app-dir/app-external/app/react-server/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/react-server/page.js
rename to test/e2e/app-dir/app-external/app/react-server/page.js
diff --git a/test/e2e/app-dir/rsc-external/app/shared-esm-dep/page.js b/test/e2e/app-dir/app-external/app/shared-esm-dep/page.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/app/shared-esm-dep/page.js
rename to test/e2e/app-dir/app-external/app/shared-esm-dep/page.js
diff --git a/test/e2e/app-dir/rsc-external/components/random-module-instance.js b/test/e2e/app-dir/app-external/components/random-module-instance.js
similarity index 69%
rename from test/e2e/app-dir/rsc-external/components/random-module-instance.js
rename to test/e2e/app-dir/app-external/components/random-module-instance.js
index 29a407eaef6b5e..3b8e0496319a85 100644
--- a/test/e2e/app-dir/rsc-external/components/random-module-instance.js
+++ b/test/e2e/app-dir/app-external/components/random-module-instance.js
@@ -1,6 +1,6 @@
'use client'
-import { name } from 'random-module-instance'
+import { name } from 'pure-esm-module'
export default function () {
return `node_modules instance from client module ${name}`
diff --git a/test/e2e/app-dir/rsc-external/next.config.js b/test/e2e/app-dir/app-external/next.config.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/next.config.js
rename to test/e2e/app-dir/app-external/next.config.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/index.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/index.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/index.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/index.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/index.server.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/index.server.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/index.server.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/index.server.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/package.json b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/package.json
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/package.json
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/package.json
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/subpath.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/subpath.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/subpath.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/subpath.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/subpath.server.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/subpath.server.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports-optout/subpath.server.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports-optout/subpath.server.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/dep.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/dep.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/dep.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/dep.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/dep.server.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/dep.server.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/dep.server.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/dep.server.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/index.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/index.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/index.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/index.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/index.server.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/index.server.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/index.server.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/index.server.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/package.json b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/package.json
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/package.json
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/package.json
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/subpath.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/subpath.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/subpath.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/subpath.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/subpath.server.js b/test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/subpath.server.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/conditional-exports/subpath.server.js
rename to test/e2e/app-dir/app-external/node_modules_bak/conditional-exports/subpath.server.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/css/index.js b/test/e2e/app-dir/app-external/node_modules_bak/css/index.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/css/index.js
rename to test/e2e/app-dir/app-external/node_modules_bak/css/index.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/css/module.js b/test/e2e/app-dir/app-external/node_modules_bak/css/module.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/css/module.js
rename to test/e2e/app-dir/app-external/node_modules_bak/css/module.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/css/package.json b/test/e2e/app-dir/app-external/node_modules_bak/css/package.json
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/css/package.json
rename to test/e2e/app-dir/app-external/node_modules_bak/css/package.json
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/css/style.css b/test/e2e/app-dir/app-external/node_modules_bak/css/style.css
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/css/style.css
rename to test/e2e/app-dir/app-external/node_modules_bak/css/style.css
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/css/styles.module.css b/test/e2e/app-dir/app-external/node_modules_bak/css/styles.module.css
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/css/styles.module.css
rename to test/e2e/app-dir/app-external/node_modules_bak/css/styles.module.css
diff --git a/test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/index.js b/test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/index.js
new file mode 100644
index 00000000000000..a82da124dde342
--- /dev/null
+++ b/test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/index.js
@@ -0,0 +1,6 @@
+import React from 'react'
+
+const Context = React.createContext ? React.createContext('hello') : null
+
+export const version = React.version
+export const useValue = () => React.useContext(Context)
diff --git a/test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/package.json b/test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/package.json
new file mode 100644
index 00000000000000..54a365f710e061
--- /dev/null
+++ b/test/e2e/app-dir/app-external/node_modules_bak/esm-with-react/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "esm-with-react",
+ "type": "module",
+ "exports": "./index.js",
+ "dependencies": {
+ "react": "^18",
+ "react-dom": "^18"
+ }
+}
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/font/index.ts b/test/e2e/app-dir/app-external/node_modules_bak/font/index.ts
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/font/index.ts
rename to test/e2e/app-dir/app-external/node_modules_bak/font/index.ts
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/font/my-font.woff2 b/test/e2e/app-dir/app-external/node_modules_bak/font/my-font.woff2
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/font/my-font.woff2
rename to test/e2e/app-dir/app-external/node_modules_bak/font/my-font.woff2
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/font/package.json b/test/e2e/app-dir/app-external/node_modules_bak/font/package.json
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/font/package.json
rename to test/e2e/app-dir/app-external/node_modules_bak/font/package.json
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/browser.js b/test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/browser.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/browser.js
rename to test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/browser.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/index.js b/test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/index.js
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/index.js
rename to test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/index.js
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/index.mjs b/test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/index.mjs
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/index.mjs
rename to test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/index.mjs
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/package.json b/test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/package.json
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/non-isomorphic-text/package.json
rename to test/e2e/app-dir/app-external/node_modules_bak/non-isomorphic-text/package.json
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/random-module-instance/index.js b/test/e2e/app-dir/app-external/node_modules_bak/pure-esm-module/index.js
similarity index 50%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/random-module-instance/index.js
rename to test/e2e/app-dir/app-external/node_modules_bak/pure-esm-module/index.js
index 5b16eaa4944375..e8d8aece913eff 100644
--- a/test/e2e/app-dir/rsc-external/node_modules_bak/random-module-instance/index.js
+++ b/test/e2e/app-dir/app-external/node_modules_bak/pure-esm-module/index.js
@@ -1,2 +1,2 @@
export const random = ~~(Math.random() * 1e5)
-export const name = 'random-module-instance'
+export const name = 'pure-esm-module'
diff --git a/test/e2e/app-dir/app-external/node_modules_bak/pure-esm-module/package.json b/test/e2e/app-dir/app-external/node_modules_bak/pure-esm-module/package.json
new file mode 100644
index 00000000000000..5e19d0f7c55f58
--- /dev/null
+++ b/test/e2e/app-dir/app-external/node_modules_bak/pure-esm-module/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "pure-esm-module",
+ "type": "module",
+ "exports": {
+ "import": "./index.js"
+ }
+}
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/untranspiled-module/index.ts b/test/e2e/app-dir/app-external/node_modules_bak/untranspiled-module/index.ts
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/untranspiled-module/index.ts
rename to test/e2e/app-dir/app-external/node_modules_bak/untranspiled-module/index.ts
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/untranspiled-module/package.json b/test/e2e/app-dir/app-external/node_modules_bak/untranspiled-module/package.json
similarity index 100%
rename from test/e2e/app-dir/rsc-external/node_modules_bak/untranspiled-module/package.json
rename to test/e2e/app-dir/app-external/node_modules_bak/untranspiled-module/package.json
diff --git a/test/e2e/app-dir/app-external/pages/test-pages-esm.jsx b/test/e2e/app-dir/app-external/pages/test-pages-esm.jsx
new file mode 100644
index 00000000000000..2a8d016df9225f
--- /dev/null
+++ b/test/e2e/app-dir/app-external/pages/test-pages-esm.jsx
@@ -0,0 +1,14 @@
+import { version, useValue } from 'esm-with-react'
+
+import React from 'react'
+
+export default function Index() {
+ const value = useValue()
+ return (
+
+
{'App React Version: ' + React.version}
+ {'External React Version: ' + version}
+ {'Test: ' + value}
+
+ )
+}
diff --git a/test/e2e/app-dir/rsc-external/pages/test-pages.jsx b/test/e2e/app-dir/app-external/pages/test-pages.jsx
similarity index 100%
rename from test/e2e/app-dir/rsc-external/pages/test-pages.jsx
rename to test/e2e/app-dir/app-external/pages/test-pages.jsx
diff --git a/test/e2e/app-dir/app-static.test.ts b/test/e2e/app-dir/app-static.test.ts
index 4d256d73ea5ac8..21c8dd59da1457 100644
--- a/test/e2e/app-dir/app-static.test.ts
+++ b/test/e2e/app-dir/app-static.test.ts
@@ -4,7 +4,7 @@ import { promisify } from 'util'
import path, { join } from 'path'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
-import { check, fetchViaHTTP, normalizeRegEx } from 'next-test-utils'
+import { check, fetchViaHTTP, normalizeRegEx, waitFor } from 'next-test-utils'
import webdriver from 'next-webdriver'
const glob = promisify(globOrig)
@@ -452,5 +452,17 @@ describe('app-dir static/dynamic handling', () => {
)
})
}
+
+ it('should keep querystring on static page', async () => {
+ const browser = await webdriver(next.url, '/blog/tim?message=hello-world')
+ const checkUrl = async () =>
+ expect(await browser.url()).toBe(
+ next.url + '/blog/tim?message=hello-world'
+ )
+
+ checkUrl()
+ await waitFor(1000)
+ checkUrl()
+ })
})
})
diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts
index 8e91c7a4b6a6b6..14a1da1c295daf 100644
--- a/test/e2e/app-dir/index.test.ts
+++ b/test/e2e/app-dir/index.test.ts
@@ -2135,6 +2135,29 @@ describe('app dir', () => {
.text()
).toBe(`About page`)
})
+ it('should not do additional pushState when already on the page', async () => {
+ const browser = await webdriver(next.url, '/linking/about')
+ const goToLinkingPage = async () => {
+ expect(
+ await browser
+ .elementByCss('a[href="/linking"]')
+ .click()
+ .waitForElementByCss('#home-page')
+ .text()
+ ).toBe(`Home page`)
+ }
+
+ await goToLinkingPage()
+ await waitFor(1000)
+ await goToLinkingPage()
+ await waitFor(1000)
+ await goToLinkingPage()
+ await waitFor(1000)
+
+ expect(
+ await browser.back().waitForElementByCss('#about-page', 2000).text()
+ ).toBe(`About page`)
+ })
})
describe('not-found', () => {
diff --git a/test/e2e/app-dir/rsc-basic/app/shared/page.js b/test/e2e/app-dir/rsc-basic/app/shared/page.js
index c0f3712250cbd5..56bfb4075272a1 100644
--- a/test/e2e/app-dir/rsc-basic/app/shared/page.js
+++ b/test/e2e/app-dir/rsc-basic/app/shared/page.js
@@ -1,7 +1,6 @@
import ClientFromDirect from '../../components/client'
import ClientFromShared from '../../components/shared'
import SharedFromClient from '../../components/shared-client'
-// import Random from '../../components/random-module-instance'
import Bar from '../../components/bar'
export default function Page() {
diff --git a/test/e2e/app-dir/rsc-external/node_modules_bak/random-module-instance/package.json b/test/e2e/app-dir/rsc-external/node_modules_bak/random-module-instance/package.json
deleted file mode 100644
index d34ce9aac07c12..00000000000000
--- a/test/e2e/app-dir/rsc-external/node_modules_bak/random-module-instance/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "random-module-instance",
- "type": "module",
- "exports": "./index.js"
-}
diff --git a/test/integration/image-generation/app/pages/api/image.jsx b/test/integration/image-generation/app/pages/api/image.jsx
new file mode 100644
index 00000000000000..518c3d654e00dc
--- /dev/null
+++ b/test/integration/image-generation/app/pages/api/image.jsx
@@ -0,0 +1,9 @@
+import { ImageResponse } from '@vercel/og'
+
+export default async () => {
+ return new ImageResponse(hello
)
+}
+
+export const config = {
+ runtime: 'experimental-edge',
+}
diff --git a/test/integration/image-generation/test/index.test.ts b/test/integration/image-generation/test/index.test.ts
new file mode 100644
index 00000000000000..519274524cdaec
--- /dev/null
+++ b/test/integration/image-generation/test/index.test.ts
@@ -0,0 +1,42 @@
+/* eslint-env jest */
+import {
+ fetchViaHTTP,
+ findPort,
+ killApp,
+ nextBuild,
+ nextStart,
+} from 'next-test-utils'
+import { join } from 'path'
+
+const appDir = join(__dirname, '../app')
+
+describe('Image Generation', () => {
+ describe('Prod', () => {
+ let app
+ let appPort
+
+ beforeAll(async () => {
+ await nextBuild(appDir)
+ appPort = await findPort()
+ app = await nextStart(appDir, appPort)
+ })
+ afterAll(async () => {
+ await killApp(app)
+ })
+
+ it('should generate the image without errors', async () => {
+ const res = await fetchViaHTTP(appPort, '/api/image')
+ expect(res.status).toBe(200)
+ expect(res.headers.get('Content-Type')).toBe('image/png')
+
+ const buffer = await res.buffer()
+
+ // It should be a PNG
+ expect(
+ [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a].every(
+ (b, i) => buffer[i] === b
+ )
+ ).toBeTrue()
+ })
+ })
+})
diff --git a/test/integration/telemetry/pages/api/og.jsx b/test/integration/telemetry/pages/api/og.jsx
new file mode 100644
index 00000000000000..518c3d654e00dc
--- /dev/null
+++ b/test/integration/telemetry/pages/api/og.jsx
@@ -0,0 +1,9 @@
+import { ImageResponse } from '@vercel/og'
+
+export default async () => {
+ return new ImageResponse(hello
)
+}
+
+export const config = {
+ runtime: 'experimental-edge',
+}
diff --git a/test/integration/telemetry/pages/edge.js b/test/integration/telemetry/pages/edge.js
new file mode 100644
index 00000000000000..6d0a32122c75e6
--- /dev/null
+++ b/test/integration/telemetry/pages/edge.js
@@ -0,0 +1,23 @@
+import Image from 'next/image'
+import LegacyImage from 'next/legacy/image'
+import profilePic from '../public/small.jpg'
+
+export const config = {
+ runtime: 'experimental-edge',
+}
+
+function About() {
+ return (
+ <>
+ My Homepage
+
+ Welcome to my homepage!
+ >
+ )
+}
+
+export default About
+
+export function AboutFutureImage() {
+ return
+}
diff --git a/test/integration/telemetry/test/index.test.js b/test/integration/telemetry/test/index.test.js
index 5b2b9d1da6499e..3558f6360ab492 100644
--- a/test/integration/telemetry/test/index.test.js
+++ b/test/integration/telemetry/test/index.test.js
@@ -331,9 +331,14 @@ describe('Telemetry CLI', () => {
const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/.exec(stderr).pop()
expect(event1).toMatch(/"staticPropsPageCount": 2/)
expect(event1).toMatch(/"serverPropsPageCount": 2/)
- expect(event1).toMatch(/"ssrPageCount": 1/)
+ expect(event1).toMatch(/"ssrPageCount": 3/)
expect(event1).toMatch(/"staticPageCount": 4/)
- expect(event1).toMatch(/"totalPageCount": 9/)
+ expect(event1).toMatch(/"totalPageCount": 11/)
+ expect(event1).toMatch(/"totalAppPagesCount": 0/)
+ expect(event1).toMatch(/"staticAppPagesCount": 0/)
+ expect(event1).toMatch(/"serverAppPagesCount": 0/)
+ expect(event1).toMatch(/"edgeRuntimeAppCount": 0/)
+ expect(event1).toMatch(/"edgeRuntimePagesCount": 2/)
})
it('detects isSrcDir dir correctly for `next dev`', async () => {
@@ -377,7 +382,19 @@ describe('Telemetry CLI', () => {
)
await fs.mkdir(path.join(__dirname, '../app'))
await fs.writeFile(
- path.join(__dirname, '../app/page.js'),
+ path.join(__dirname, '../app/layout.js'),
+ `
+ export default function RootLayout({ children }) {
+ return
+
+ {children}
+
+ }
+ `
+ )
+ await fs.ensureFile(path.join(__dirname, '../app/hello/page.js'))
+ await fs.writeFile(
+ path.join(__dirname, '../app/hello/page.js'),
'export default function Page() { return "hello world" }'
)
@@ -490,6 +507,73 @@ describe('Telemetry CLI', () => {
}
})
+ it('should detect app page counts', async () => {
+ const teardown = await setupAppDir()
+
+ try {
+ await fs.ensureFile(path.join(__dirname, '../app/ssr/page.js'))
+ await fs.writeFile(
+ path.join(__dirname, '../app/ssr/page.js'),
+ `
+ export const revalidate = 0
+ export default function Page() {
+ return