-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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' of github.com:vercel/next.js into 05-02-Change_…
…create-next-app_defaults
- Loading branch information
Showing
50 changed files
with
749 additions
and
130 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
7 changes: 7 additions & 0 deletions
7
packages/next-swc/crates/next-dev-tests/tests/integration/next/env/basic/input/.env
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 @@ | ||
STRING_ENV_VAR_FROM_DOT_ENV="Hello World" | ||
NUMBER_ENV_VAR_FROM_DOT_ENV=123 | ||
BOOLEAN_ENV_VAR_FROM_DOT_ENV=true | ||
|
||
NEXT_PUBLIC_STRING_ENV_VAR_FROM_DOT_ENV="Hello World" | ||
NEXT_PUBLIC_NUMBER_ENV_VAR_FROM_DOT_ENV=123 | ||
NEXT_PUBLIC_BOOLEAN_ENV_VAR_FROM_DOT_ENV=true |
7 changes: 7 additions & 0 deletions
7
...ages/next-swc/crates/next-dev-tests/tests/integration/next/env/basic/input/next.config.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,7 @@ | ||
module.exports = { | ||
env: { | ||
STRING_ENV_VAR_FROM_CONFIG: 'Hello World', | ||
NUMBER_ENV_VAR_FROM_CONFIG: 123, | ||
BOOLEAN_ENV_VAR_FROM_CONFIG: true, | ||
}, | ||
} |
30 changes: 30 additions & 0 deletions
30
...ages/next-swc/crates/next-dev-tests/tests/integration/next/env/basic/input/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,30 @@ | ||
import { useEffect } from 'react' | ||
|
||
export default function Page() { | ||
useEffect(() => { | ||
// Only run on client | ||
import('@turbo/pack-test-harness').then(runTests) | ||
}) | ||
} | ||
|
||
function runTests() { | ||
it('should support env vars from config', () => { | ||
expect(process.env.STRING_ENV_VAR_FROM_CONFIG).toBe('Hello World') | ||
expect(process.env.BOOLEAN_ENV_VAR_FROM_CONFIG).toBe('true') | ||
expect(process.env.NUMBER_ENV_VAR_FROM_CONFIG).toBe('123') | ||
}) | ||
|
||
it('should support env vars from .env', () => { | ||
expect(process.env.NEXT_PUBLIC_STRING_ENV_VAR_FROM_DOT_ENV).toBe( | ||
'Hello World' | ||
) | ||
expect(process.env.NEXT_PUBLIC_BOOLEAN_ENV_VAR_FROM_DOT_ENV).toBe('true') | ||
expect(process.env.NEXT_PUBLIC_NUMBER_ENV_VAR_FROM_DOT_ENV).toBe('123') | ||
}) | ||
|
||
it('should not support env vars from .env without NEXT_PUBLIC prefix', () => { | ||
expect(process.env.STRING_ENV_VAR_FROM_DOT_ENV).toBeUndefined() | ||
expect(process.env.BOOLEAN_ENV_VAR_FROM_DOT_ENV).toBeUndefined() | ||
expect(process.env.NUMBER_ENV_VAR_FROM_DOT_ENV).toBeUndefined() | ||
}) | ||
} |
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 @@ | ||
export { unstable_cache } from 'next/dist/server/web/spec-extension/unstable-cache' | ||
export { unstable_revalidatePath } from 'next/dist/server/web/spec-extension/unstable-revalidate-path' | ||
export { unstable_revalidateTag } from 'next/dist/server/web/spec-extension/unstable-revalidate-tag' |
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,19 @@ | ||
const cacheExports = { | ||
unstable_cache: require('next/dist/server/web/spec-extension/unstable-cache') | ||
.unstable_cache, | ||
unstable_revalidateTag: | ||
require('next/dist/server/web/spec-extension/unstable-revalidate-tag') | ||
.unstable_revalidateTag, | ||
unstable_revalidatePath: | ||
require('next/dist/server/web/spec-extension/unstable-revalidate-path') | ||
.unstable_revalidatePath, | ||
} | ||
|
||
// https://nodejs.org/api/esm.html#commonjs-namespaces | ||
// When importing CommonJS modules, the module.exports object is provided as the default export | ||
module.exports = cacheExports | ||
|
||
// make import { xxx } from 'next/server' work | ||
exports.unstable_cache = cacheExports.unstable_cache | ||
exports.unstable_revalidatePath = cacheExports.unstable_revalidatePath | ||
exports.unstable_revalidateTag = cacheExports.unstable_revalidateTag |
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
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
Oops, something went wrong.