prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
BUILD } = require('next/constants')
const { findPagesDir } = require('next/dist/lib/find-pages-dir')
const loadConfig = require('next/dist/server/config').default
const getWebpackConfig = require('next/dist/build/webpack-config').default
const CWD = process.cwd()
async function webpackFinal(config) {
const nextConf... | ...nextWebpackConfig.plugins]
config.resolve = {
...config.resolve,
...nextWebpackConfig.resolve,
}
config.module.rules = [
...filterModuleRules(config),
...nextWebpackConfig.module.rules.map((rule) => {
// we need to resolve | sDir,
entrypoints: {},
isServer: false,
target: 'server',
config: nextConfig,
buildId: 'storybook',
rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },
})
config.plugins = [...config.plugins, | {
"filepath": "packages/next-plugin-storybook/preset.js",
"language": "javascript",
"file_size": 1939,
"cut_index": 537,
"middle_length": 229
} |
{ API, FileInfo, Options } from 'jscodeshift'
import { createParserFromPath } from '../lib/parser'
export default function transformer(
file: FileInfo,
_api: API,
options: Options
) {
const j = createParserFromPath(file.path)
const root = j(file.source)
let hasChanges = false
// Before: import { ... } f... | ource: { value: '@next/font/google' },
})
.forEach((fontImport) => {
hasChanges = true
fontImport.node.source = j.stringLiteral('next/font/google')
})
// Before: import localFont from '@next/font/local'
// After: import localFo | es = true
fontImport.node.source = j.stringLiteral('next/font')
})
// Before: import { ... } from '@next/font/google'
// After: import { ... } from 'next/font/google'
root
.find(j.ImportDeclaration, {
s | {
"filepath": "packages/next-codemod/transforms/built-in-next-font.ts",
"language": "typescript",
"file_size": 1317,
"cut_index": 524,
"middle_length": 229
} |
port { createParserFromPath } from '../lib/parser'
export default function transformer(file: FileInfo, _api: API) {
const j = createParserFromPath(file.path)
const root = j(file.source)
// Find the metadata export
const metadataExport = root.find(j.ExportNamedDeclaration, {
declaration: {
type: 'Var... | let viewportProperties
let hasChanges = false
const viewport = metadataProperties.find(
(prop) => prop.key.name === 'viewport'
)
if (viewport) {
viewportProperties = viewport.value.properties
metadataProperties = metadataProperties.fi | metadataObject = metadataExport.find(j.ObjectExpression).get(0).node
if (!metadataObject) {
console.error('Could not find metadata object')
return file.source
}
let metadataProperties = metadataObject.properties
| {
"filepath": "packages/next-codemod/transforms/metadata-to-viewport-export.ts",
"language": "typescript",
"file_size": 2429,
"cut_index": 563,
"middle_length": 229
} |
STPath,
ExportDefaultDeclaration,
FileInfo,
FunctionDeclaration,
Options,
} from 'jscodeshift'
import { basename, extname } from 'path'
import { createParserFromPath } from '../lib/parser'
const camelCase = (value: string): string => {
const val = value.replace(/[-_\s.]+(.)?/g, (_match, chr) =>
chr ? chr... | node.type === 'JSXElement' ||
(node.type === 'BlockStatement' &&
j(node)
.find(j.ReturnStatement)
.some((path) => path.value.argument?.type === 'JSXElement'))
const hasRootAsParent = (path): boolean => {
const program = | ult function transformer(
file: FileInfo,
_api: API,
options: Options
) {
const j = createParserFromPath(file.path)
const root = j(file.source)
let hasModifications: boolean
const returnsJSX = (node): boolean =>
| {
"filepath": "packages/next-codemod/transforms/name-default-component.ts",
"language": "typescript",
"file_size": 2778,
"cut_index": 563,
"middle_length": 229
} |
vel turbopack
* property, with special handling for certain properties like memoryLimit, minify,
* treeShaking, and sourceMaps which become experimental.turbopack* properties instead.
*/
import type {
API as JSCodeShiftAPI,
Options as JSCodeShiftOptions,
FileInfo,
ObjectExpression,
Property,
ObjectPrope... | aps',
}
export default function transformer(
file: FileInfo,
_api: JSCodeShiftAPI,
options: JSCodeShiftOptions
): string {
const j = createParserFromPath(file.path)
const root = j(file.source)
let hasChanges = false
if (
!isNextConfigFi | that need to be moved to experimental.turbopack*
const RENAMED_EXPERIMENTAL_PROPERTIES = {
memoryLimit: 'turbopackMemoryLimit',
minify: 'turbopackMinify',
treeShaking: 'turbopackTreeShaking',
sourceMaps: 'turbopackSourceM | {
"filepath": "packages/next-codemod/transforms/next-experimental-turbo-to-turbopack.ts",
"language": "typescript",
"file_size": 8936,
"cut_index": 716,
"middle_length": 229
} |
/parser'
export default function transformer(
file: FileInfo,
_api: API,
options: Options
) {
const j = createParserFromPath(file.path)
const root = j(file.source)
// Before: import Image from "next/image"
// After: import Image from "next/legacy/image"
root
.find(j.ImportDeclaration, {
sou... | ort') {
if (
arg.arguments[0].type === 'StringLiteral' &&
arg.arguments[0].value === 'next/image'
) {
arg.arguments[0] = j.stringLiteral('next/legacy/image')
}
}
})
// Before: import Image from "next/futur | mage")
// After: const Image = await import("next/legacy/image")
root.find(j.AwaitExpression).forEach((awaitExp) => {
const arg = awaitExp.value.argument
if (arg?.type === 'CallExpression' && arg.callee.type === 'Imp | {
"filepath": "packages/next-codemod/transforms/next-image-to-legacy-image.ts",
"language": "typescript",
"file_size": 3163,
"cut_index": 614,
"middle_length": 229
} |
fo } from 'jscodeshift'
import { createParserFromPath } from '../lib/parser'
const importToChange = 'ImageResponse'
export default function transformer(file: FileInfo, _api: API) {
const j = createParserFromPath(file.path)
// Find import declarations that match the pattern
file.source = j(file.source)
.fin... | )
// If the import includes the specified import name, create a new import for it from 'next/og'
if (importNamesToChange.length > 0) {
// Replace the original import with the remaining specifiers
// path.node.specifiers = re | nge = importSpecifiers.filter(
(specifier) => specifier.local.name === importToChange
)
const importsNamesRemained = importSpecifiers.filter(
(specifier) => specifier.local.name !== importToChange
| {
"filepath": "packages/next-codemod/transforms/next-og-import.ts",
"language": "typescript",
"file_size": 1700,
"cut_index": 537,
"middle_length": 229
} |
le.path)
const root = j(file.source)
if (!root.length) {
return file.source
}
const nextReqType = root
.find(j.FunctionDeclaration)
.find(j.Identifier, (id) => {
if (id.typeAnnotation?.type !== 'TSTypeAnnotation') {
return false
}
const typeAnn = id.typeAnnotation.typeAn... | cImportNames = new Set(
vercelFuncImportSpecifiers.map((node) => node.imported.name)
)
const hasGeolocation = vercelFuncImportNames.has(GEOLOCATION)
const hasIpAddress = vercelFuncImportNames.has(IP_ADDRESS)
const hasGeoType = vercelFuncImport | vercelFuncImports = root.find(j.ImportDeclaration, {
source: {
value: '@vercel/functions',
},
})
const vercelFuncImportSpecifiers = vercelFuncImports
.find(j.ImportSpecifier)
.nodes()
const vercelFun | {
"filepath": "packages/next-codemod/transforms/next-request-geo-ip.ts",
"language": "typescript",
"file_size": 15016,
"cut_index": 921,
"middle_length": 229
} |
at we can just attach `withRouter` instead of creating a new `import` node
const originalRouterImport = root.find(j.ImportDeclaration, {
source: {
value: 'next/router',
},
})
if (originalRouterImport.length > 0) {
// Check if `withRouter` is already imported. In that case we don't have to do any... | nst withRouterImport = j.importDeclaration(
[withRouterSpecifier],
j.stringLiteral('next/router')
)
// Find the Program, this is the top level AST node
const Program = root.find(j.Program)
// Attach the import at the top of the body
Prog | existing `next/router` import node
originalRouterImport.forEach((node) => {
node.value.specifiers.push(withRouterSpecifier)
})
return
}
// Create import node
// import {withRouter} from 'next/router'
co | {
"filepath": "packages/next-codemod/transforms/url-to-withrouter.ts",
"language": "typescript",
"file_size": 12036,
"cut_index": 921,
"middle_length": 229
} |
uire('fs')
const path = require('path')
const { defineTest, defineInlineTest, runInlineTest } = require('jscodeshift/dist/testUtils')
const { readdirSync } = require('fs')
const { join } = require('path')
const possibleExtensions = ['ts', 'tsx', 'js', 'jsx']
function getSourceByInputPath(inputPath) {
let source
l... | uest-api'
const fixtureDirPath = join(__dirname, '..', '__testfixtures__', fixtureDir)
const fixtures = readdirSync(fixtureDirPath)
.filter(file => testFileRegex.test(file))
describe('next-async-request-api - dynamic-props', () => {
for (const file of | eSync(`${inputPath}.${ext}`, 'utf8')
break
}
}
return [filePath, source]
}
const testFileRegex = /\.input\.(j|t)sx?$/
const fixtureDir = 'next-async-request-api-dynamic-props'
const transformName = 'next-async-req | {
"filepath": "packages/next-codemod/transforms/__tests__/next-async-request-api-dynamic-props.test.js",
"language": "javascript",
"file_size": 2326,
"cut_index": 563,
"middle_length": 229
} |
toMockOff()
const Runner = require('jscodeshift/dist/Runner');
const { cp, mkdir, mkdtemp, rm, readdir, readFile, stat } = require('fs/promises')
const { readdirSync } = require('fs')
const { tmpdir } = require('os')
const { join } = require('path')
const fixtureDir = join(__dirname, '..', '__testfixtures__', 'next-im... | = await readFile(filePath, 'utf8')
}
}
return obj
}
// TODO: this is not working before it's built, re-enable on CI after migrating tests to defineTest
const loaders = readdirSync(fixtureDir)
for (const loader of loaders) {
it.skip(`should trans | nst files = await readdir(dir)
for (const file of files) {
const filePath = join(dir, file)
const s = await stat(filePath)
if (s.isDirectory()) {
obj[file] = await toObj(filePath)
} else {
obj[file] | {
"filepath": "packages/next-codemod/transforms/__tests__/next-image-experimental-loader.test.js",
"language": "javascript",
"file_size": 1616,
"cut_index": 537,
"middle_length": 229
} |
arentUseCallExpression,
isReactHookName,
} from './utils'
import { createParserFromPath } from '../../../lib/parser'
const DYNAMIC_IMPORT_WARN_COMMENT = ` @next-codemod-error The APIs under 'next/headers' are async now, need to be manually awaited. `
function findDynamicImportsAndComment(root: Collection<any>, j: A... | j.CallExpression, {
callee: {
type: 'Import',
},
arguments: [{ value: 'next/headers' }],
})
importPaths.forEach((path) => {
const inserted = insertCommentOnce(
path.node,
j,
DYNAMIC_IMPORT_WARN_COMMENT
)
| l the dynamic imports of `next/cookies`,
// Notice, import() is not handled as ImportExpression in current jscodeshift version,
// we need to use CallExpression to capture the dynamic imports.
const importPaths = root.find( | {
"filepath": "packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-api.ts",
"language": "typescript",
"file_size": 14455,
"cut_index": 921,
"middle_length": 229
} |
* global jest */
jest.autoMockOff()
const defineTest = require('jscodeshift/dist/testUtils').defineTest
const fixtures = [
'with-router-import',
'without-import',
'already-using-withrouter',
'using-inline-class',
'export-default-variable',
'export-default-variable-wrapping',
'no-transform',
'no-transfo... | onentdidupdate',
'componentwillreceiveprops',
'first-parameter-hoc',
'url-property-not-part-of-this-props',
]
for (const fixture of fixtures) {
defineTest(
__dirname,
'url-to-withrouter',
null,
`url-to-withrouter/${fixture}`
)
}
| ops-nested',
'with-nested-arrow-function',
'comp | {
"filepath": "packages/next-codemod/transforms/__tests__/url-to-withrouter.test.js",
"language": "javascript",
"file_size": 821,
"cut_index": 513,
"middle_length": 52
} |
Values } from './sort-fonts-variant-values'
describe('sortFontsVariantValues', () => {
it('should correctly compare and return result for plain integer values', () => {
// Testing plain integer values
expect(sortFontsVariantValues('100', '200')).toBe(-100)
expect(sortFontsVariantValues('200', '100')).toB... | 0')).toBe(-100)
expect(sortFontsVariantValues('1,200', '1,100')).toBe(100)
expect(sortFontsVariantValues('0,100', '0,200')).toBe(-100)
expect(sortFontsVariantValues('0,200', '0,100')).toBe(100)
})
it('should sort an array of plain integer | arated values', () => {
// Testing "ital,wght" format
expect(sortFontsVariantValues('1,100', '0,200')).toBe(1)
expect(sortFontsVariantValues('0,200', '1,100')).toBe(-1)
expect(sortFontsVariantValues('1,100', '1,20 | {
"filepath": "packages/font/src/google/sort-fonts-variant-values.test.ts",
"language": "typescript",
"file_size": 1566,
"cut_index": 537,
"middle_length": 229
} |
Codeshift,
Options,
} from 'jscodeshift'
import { createParserFromPath } from '../lib/parser'
function addReactImport(j: JSCodeshift, root: Collection) {
// We create an import specifier, this is the value of an import, eg:
// import React from 'react'
// The specifier would be `React`
const ReactDefaultSpec... | on't have to do anything
if (originalReactImport.find(j.ImportDefaultSpecifier).length > 0) {
return
}
// Attach `React` to the existing `react` import node
originalReactImport.forEach((node) => {
node.value.specifiers.unshift( | w `import` node
const originalReactImport = root.find(j.ImportDeclaration, {
source: {
value: 'react',
},
})
if (originalReactImport.length > 0) {
// Check if `React` is already imported. In that case we d | {
"filepath": "packages/next-codemod/transforms/add-missing-react-import.ts",
"language": "typescript",
"file_size": 2195,
"cut_index": 563,
"middle_length": 229
} |
.join('../lib/cra-to-next')
const globalCssTransformPath = require.resolve(
path.join(craTransformsPath, 'global-css-transform.js')
)
const indexTransformPath = require.resolve(
path.join(craTransformsPath, 'index-to-component.js')
)
class CraTransform {
private appDir: string
private pagesDir: string
priva... | isDryRun = flags.dry
this.jscodeShiftFlags = flags
this.appDir = this.validateAppDir(files)
this.packageJsonPath = path.join(this.appDir, 'package.json')
this.packageJsonData = this.loadPackageJson()
this.shouldLogInfo = flags.print || | string
private shouldUseTypeScript: boolean
private packageJsonData: { [key: string]: any }
private jscodeShiftFlags: { [key: string]: boolean }
constructor(files: string[], flags: { [key: string]: boolean }) {
this. | {
"filepath": "packages/next-codemod/transforms/cra-to-next.ts",
"language": "typescript",
"file_size": 18676,
"cut_index": 1331,
"middle_length": 229
} |
ProxyConfig',
}
export default function transformer(file: FileInfo) {
const j = createParserFromPath(file.path)
const root = j(file.source)
if (!root.length) {
return file.source
}
const isNextConfig =
isNextConfigFile(file) ||
(process.env.NODE_ENV === 'test' && /next-config-/.test(file.path))... | {
return file.source
}
}
let hasChanges = false
if (hasMiddlewareTypeImports) {
const typeImportChanges = transformMiddlewareTypeImports(root, j)
hasChanges = hasChanges || typeImportChanges
}
if (isMiddlewareFile) {
con | heckForNextServerTypeImports(root, j)
// In test mode, process all files. Otherwise, only process relevant files
if (process.env.NODE_ENV !== 'test') {
if (!isMiddlewareFile && !isNextConfig && !hasMiddlewareTypeImports) | {
"filepath": "packages/next-codemod/transforms/middleware-to-proxy.ts",
"language": "typescript",
"file_size": 28103,
"cut_index": 1331,
"middle_length": 229
} |
sLegacy: boolean | null
} {
const flatConfigs = [
'eslint.config.js',
'eslint.config.mjs',
'eslint.config.cjs',
'eslint.config.ts',
'eslint.config.mts',
'eslint.config.cts',
]
const legacyConfigs = [
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
'.eslintrc.yml',
'... | if (existsSync(configPath)) {
return { exists: true, path: configPath, isLegacy: true }
}
}
return { exists: false, path: null, isLegacy: null }
}
function replaceFlatCompatInConfig(configPath: string): boolean {
let configContent: stri | (existsSync(configPath)) {
return { exists: true, path: configPath, isLegacy: false }
}
}
// Check for legacy configs
for (const config of legacyConfigs) {
const configPath = path.join(projectRoot, config)
| {
"filepath": "packages/next-codemod/transforms/next-lint-to-eslint-cli.ts",
"language": "typescript",
"file_size": 39128,
"cut_index": 2151,
"middle_length": 229
} |
hould be renamed
function shouldRenameProperty(propertyName: string): boolean {
return propertyName in UNSTABLE_TO_STABLE_MAPPING
}
export default function transformer(
file: FileInfo,
_api: API,
options: Options
) {
const j = createParserFromPath(file.path)
const root = j(file.source)
let hasChanges = f... | rEach((path) => {
path.node.specifiers?.forEach((specifier) => {
if (
specifier.type === 'ImportSpecifier' &&
specifier.imported?.type === 'Identifier' &&
shouldRenameProperty(specifier.imported.name)
| che imports/requires
const cacheVariables = new Set<string>()
// Handle ES6 imports: import { unstable_cacheTag } from 'next/cache'
root
.find(j.ImportDeclaration, { source: { value: 'next/cache' } })
.fo | {
"filepath": "packages/next-codemod/transforms/remove-unstable-prefix.ts",
"language": "typescript",
"file_size": 13700,
"cut_index": 921,
"middle_length": 229
} |
uire('fs')
const path = require('path')
const { defineTest, defineInlineTest, runInlineTest } = require('jscodeshift/dist/testUtils')
const { readdirSync } = require('fs')
const { join } = require('path')
const possibleExtensions = ['ts', 'tsx', 'js', 'jsx']
function getSourceByInputPath(inputPath) {
let source = '... | -request-api'
const fixtureDirPath = join(__dirname, '..', '__testfixtures__', fixtureDir)
const fixtures = readdirSync(fixtureDirPath)
.filter(file => testFileRegex.test(file))
describe('next-async-request-api - dynamic-apis', () => {
for (const file | adFileSync(`${inputPath}.${ext}`, 'utf8')
break
}
}
return [filePath, source]
}
const testFileRegex = /\.input\.(j|t)sx?$/
const fixtureDir = 'next-async-request-api-dynamic-apis'
const transformName = 'next-async | {
"filepath": "packages/next-codemod/transforms/__tests__/next-async-request-api-dynamic-apis.test.js",
"language": "javascript",
"file_size": 2325,
"cut_index": 563,
"middle_length": 229
} |
er = require('../next-lint-to-eslint-cli.js').default
})
afterAll(() => {
// Clean up ONCE after all tests
if (isolatedDir && fs.existsSync(isolatedDir)) {
fs.rmSync(isolatedDir, { recursive: true, force: true })
}
})
describe('flat-config', () => {
it('should keep config unchanged and t... | neConfig } from 'eslint/config'
import foo from 'foo'
import bar from 'bar'
const eslintConfig = defineConfig([
foo,
bar,
{
ignores: [
'node_modules/**',
'.next/**',
| eslint.config.mjs'),
'utf8'
)
const beforePackage = fs.readFileSync(
path.join(testDir, 'package.json'),
'utf8'
)
expect(beforeConfig).toMatchInlineSnapshot(`
"import { defi | {
"filepath": "packages/next-codemod/transforms/__tests__/next-lint-to-eslint-cli.test.js",
"language": "javascript",
"file_size": 18146,
"cut_index": 1331,
"middle_length": 229
} |
Set(['params', 'searchParams'])
export function isFunctionType(
type: string
): type is
| 'FunctionDeclaration'
| 'FunctionExpression'
| 'ArrowFunctionExpression' {
return (
type === 'FunctionDeclaration' ||
type === 'FunctionExpression' ||
type === 'ArrowFunctionExpression'
)
}
export functi... | 0) {
return true
}
// Check for default export (`export default function() {}`)
const isDefaultExport = j(path).closest(j.ExportDefaultDeclaration).size() > 0
if (isDefaultExport) {
return true
}
// Look for named export elsewhere in | st directNamedExport = j(path).closest(j.ExportNamedDeclaration, {
declaration: {
type: 'FunctionDeclaration',
id: {
name: matchedFunctionNameFilter,
},
},
})
if (directNamedExport.size() > | {
"filepath": "packages/next-codemod/transforms/lib/async-request-api/utils.ts",
"language": "typescript",
"file_size": 17552,
"cut_index": 1331,
"middle_length": 229
} |
ateFontFunctionCall errors', () => {
test('Missing function name', () => {
expect(() =>
validateGoogleFontFunctionCall(
'', // default import
undefined
)
).toThrowErrorMatchingInlineSnapshot(
`"next/font/google has no default export"`
)
})
test('Unknown font', () => ... | Available weights: \`100\`, \`200\`, \`300\`, \`400\`, \`500\`, \`600\`, \`700\`, \`800\`, \`900\`, \`variable\`"
`)
})
test('Missing weight for non variable font', () => {
expect(() => validateGoogleFontFunctionCall('Abel', { subsets: | => {
expect(() =>
validateGoogleFontFunctionCall('Inter', {
weight: '123',
subsets: ['latin'],
})
).toThrowErrorMatchingInlineSnapshot(`
"Unknown weight \`123\` for font \`Inter\`.
| {
"filepath": "packages/font/src/google/validate-google-font-function-call.test.ts",
"language": "typescript",
"file_size": 3991,
"cut_index": 614,
"middle_length": 229
} |
utToStyle: Record<string, Record<string, string> | null> = {
intrinsic: { maxWidth: '100%', height: 'auto' },
responsive: { width: '100%', height: 'auto' },
fill: null,
fixed: null,
}
const layoutToSizes: Record<string, string | null> = {
intrinsic: null,
responsive: '100vw',
fill: '100v... | te | null = null
const attributes = el.node.openingElement.attributes?.filter((a) => {
if (a.type !== 'JSXAttribute') {
return true
}
if (a.name.name === 'layout' && 'value' in a.value) {
layout = String(a | el.value.openingElement.name.name === tagName
)
.forEach((el) => {
let layout = 'intrinsic'
let objectFit = null
let objectPosition = null
let styleExpProps = []
let sizesAttr: JSXAttribu | {
"filepath": "packages/next-codemod/transforms/next-image-experimental.ts",
"language": "typescript",
"file_size": 10042,
"cut_index": 921,
"middle_length": 229
} |
port { createParserFromPath } from '../lib/parser'
export default function transformer(file: FileInfo, _api: API) {
// Run on App Router page/layout/route files, except for test environment.
if (
process.env.NODE_ENV !== 'test' &&
!/[/\\]app[/\\](?:.*[/\\])?(page|layout|route)(\.[^/\\]*)?$/.test(file.path)... | rectExports.size() > 0) {
directExports.remove()
hasChanges = true
}
// Remove const experimental_ppr = boolean declarations
const variableDeclarations = root.find(j.VariableDeclaration).filter((path) =>
path.node.declarations.some((decl | nst directExports = root.find(j.ExportNamedDeclaration, {
declaration: {
type: 'VariableDeclaration',
declarations: [
{
id: { name: 'experimental_ppr' },
},
],
},
})
if (di | {
"filepath": "packages/next-codemod/transforms/remove-experimental-ppr.ts",
"language": "typescript",
"file_size": 2337,
"cut_index": 563,
"middle_length": 229
} |
ty) {
return
}
if (isParentPromiseAllCallExpression(memberAccessPath, j)) {
return
}
// check if it's already awaited
if (memberAccessPath.parentPath?.value.type === 'AwaitExpression') {
return
}
const parentScopeOfMemberAccess = findClosetParentFunctionScope(
memb... | pe is sync, await keyword can't be applied
const comment = ` ${NEXT_CODEMOD_ERROR_PREFIX} '${propIdName}.${memberProperty.name}' is accessed without awaiting.`
insertCommentOnce(member, j, comment)
return
}
const awaitedExpr = j. | s &&
!parentScopeOfMemberAccess.value?.async &&
parentScopeOfMemberAccess.node !== path.node
) {
// If it's not able to convert, add a comment to the prop access to warn the user
// e.g. the parent sco | {
"filepath": "packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-prop.ts",
"language": "typescript",
"file_size": 35665,
"cut_index": 2151,
"middle_length": 229
} |
parser'
export default function transformer(file: FileInfo, _api: API) {
if (
process.env.NODE_ENV !== 'test' &&
!/[/\\]app[/\\].*?(page|layout|route)\.[^/\\]+$/.test(file.path)
) {
return file.source
}
const j = createParserFromPath(file.path)
const root = j(file.source)
const runtimeExport ... | e.source
}
const runtimeValue = runtimeExport.find(j.StringLiteral, {
value: 'experimental-edge',
})
if (runtimeValue.size() !== 1) {
return file.source
}
runtimeValue.replaceWith(j.stringLiteral('edge'))
return root.toSource()
}
|
if (runtimeExport.size() !== 1) {
return fil | {
"filepath": "packages/next-codemod/transforms/app-dir-runtime-config-experimental-edge.ts",
"language": "typescript",
"file_size": 914,
"cut_index": 606,
"middle_length": 52
} |
bal jest */
jest.autoMockOff()
const defineTest = require('jscodeshift/dist/testUtils').defineTest
const fixtureDir = 'next-experimental-turbo-to-turbopack'
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/commonjs-var`, { parser: 'js' })
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/esm`, { parser: 'j... | y-assignment`, { parser: 'js' })
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/typescript-as-const`, { parser: 'ts' })
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/typescript`, { parser: 'ts' })
defineTest(__dirname, fixtureDir, null, `$ | (__dirname, fixtureDir, null, `${fixtureDir}/wrapped-function`, { parser: 'js' })
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/no-change`, { parser: 'js' })
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/propert | {
"filepath": "packages/next-codemod/transforms/__tests__/next-experimental-turbo-to-turbopack.test.js",
"language": "javascript",
"file_size": 1161,
"cut_index": 518,
"middle_length": 229
} |
ssues/534
import type { API, Collection, FileInfo, JSXElement } from 'jscodeshift'
import { createParserFromPath } from '../lib/parser'
import { NEXT_CODEMOD_ERROR_PREFIX } from './lib/async-request-api/utils'
export default function transformer(file: FileInfo, _api: API) {
const j = createParserFromPath(file.path)... | ariableName) {
return
}
const linkElements = $j.findJSXElements(variableName)
linkElements.forEach((linkPath) => {
const $link: Collection<JSXElement> = j(linkPath)
if ($link.size() === 0) {
return
| mportDefaultSpecifier)
if (defaultImport.size() === 0) {
return
}
const variableName = j(path)
.find(j.ImportDefaultSpecifier)
.find(j.Identifier)
.get('name').value
if (!v | {
"filepath": "packages/next-codemod/transforms/new-link.ts",
"language": "typescript",
"file_size": 4121,
"cut_index": 614,
"middle_length": 229
} |
://github.com/vercel/next.js/blob/master/packages/next-polyfill-nomodule/src/index.js
const NEXT_POLYFILLED_FEATURES = [
'Array.prototype.@@iterator',
'Array.prototype.at',
'Array.prototype.copyWithin',
'Array.prototype.fill',
'Array.prototype.find',
'Array.prototype.findIndex',
'Array.prototype.flatMap',... | ries',
'Object.getOwnPropertyDescriptor',
'Object.getOwnPropertyDescriptors',
'Object.hasOwn',
'Object.is',
'Object.keys',
'Object.values',
'Reflect',
'Set',
'Symbol',
'Symbol.asyncIterator',
'String.prototype.codePointAt',
'String. | te',
'Number.isNaN',
'Number.isInteger',
'Number.isSafeInteger',
'Number.MAX_SAFE_INTEGER',
'Number.MIN_SAFE_INTEGER',
'Number.parseFloat',
'Number.parseInt',
'Object.assign',
'Object.entries',
'Object.fromEnt | {
"filepath": "packages/eslint-plugin-next/src/rules/no-unwanted-polyfillio.ts",
"language": "typescript",
"file_size": 4854,
"cut_index": 614,
"middle_length": 229
} |
b[39m \u001b[36mreturn\u001b[39m \u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m\u001b[33m>\u001b[39m\u001b[33mWelcome to my Next.js application! This is a longer piece of text that will demonstrate text wrapping behavior in the code frame.\u001b[39m\u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mdiv\u001b[39m\u001b... |
return `\u001b[0m \u001b[90m 1 \u001b[39m ${beforeLine}\u001b[0m
\u001b[0m \u001b[90m ${markerLine - 1} \u001b[39m \u001b[36mexport\u001b[39m \u001b[36mdefault\u001b[39m \u001b[36masync\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mPage\u001b[39m() { | lumn,
afterLine = 'return <div>Hello</div>',
}: {
beforeLine: string
line: string
markerLine: number
pointerColumn: number
afterLine?: string
}) => {
const markerPadding = ' '.repeat(Math.max(pointerColumn - 1, 0))
| {
"filepath": "packages/next/.storybook/fixtures/errors.ts",
"language": "typescript",
"file_size": 22640,
"cut_index": 1331,
"middle_length": 229
} |
namespace NodeJS {
// only for rust, see https://github.com/napi-rs/napi-rs/issues/1630
interface TTY {
setBlocking(blocking: boolean): void
}
interface WriteStream {
_handle?: TTY
}
interface Process {
/**
* @deprecated Use `typeof window` instead
*/
readonly browser: boolean
... | sses: { readonly [key: string]: string }
export default classes
}
// CSS side-effect imports (non-modules)
// These are needed for `noUncheckedSideEffectImports` support
// See: https://www.typescriptlang.org/tsconfig/#noUncheckedSideEffectImports
decla | classes: { readonly [key: string]: string }
export default classes
}
declare module '*.module.sass' {
const classes: { readonly [key: string]: string }
export default classes
}
declare module '*.module.scss' {
const cla | {
"filepath": "packages/next/types/global.d.ts",
"language": "typescript",
"file_size": 4889,
"cut_index": 614,
"middle_length": 229
} |
e 'react-dom/server' {
/**
* Options for `renderToReadableStream`.
*
* https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom/src/server/ReactDOMFizzServerEdge.js#L36-L52
*/
export interface RenderToReadableStreamOptions {
unstable_externalRuntimeSrc?:
... | 1a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js#L35-L49
*/
export interface PrerenderOptions {
unstable_externalRuntimeSrc?:
| string
| import('react-dom/server').BootstrapScriptDescriptor
| act/blob/aec52 | {
"filepath": "packages/next/types/react-dom.d.ts",
"language": "typescript",
"file_size": 810,
"cut_index": 536,
"middle_length": 14
} |
/>
/// <reference types="react-dom/experimental" preserve="true" />
import type { Agent as HttpAgent } from 'http'
import type { Agent as HttpsAgent } from 'https'
import type { ParsedUrlQuery } from 'querystring'
import type { IncomingMessage, ServerResponse } from 'http'
import type {
NextPageContext,
NextCom... | NextConfig } from './server/config'
export type { NextAdapter, AdapterOutput } from './build/adapter/build-complete'
export type {
Metadata,
MetadataRoute,
ResolvedMetadata,
ResolvingMetadata,
Viewport,
ResolvingViewport,
ResolvedViewport,
| } from './server/api-utils'
import next from './server/next'
export type ServerRuntime = 'nodejs' | 'experimental-edge' | 'edge' | undefined
// @ts-ignore This path is generated at build time and conflicts otherwise
export { | {
"filepath": "packages/next/src/types.ts",
"language": "typescript",
"file_size": 9179,
"cut_index": 716,
"middle_length": 229
} |
e-path'
import { loadEnvConfig } from '@next/env'
import { isAPIRoute } from '../lib/is-api-route'
import { getPagePath } from '../server/require'
import type { Span } from '../trace'
import type { MiddlewareManifest } from '../build/webpack/plugins/middleware-plugin'
import { isAppRouteRoute } from '../lib/is-app-rout... | /lib/is-interception-route-rewrite'
import type { ActionManifest } from '../build/webpack/plugins/flight-client-entry-plugin'
import { extractInfoFromServerReferenceId } from '../shared/lib/server-reference-info'
import { convertSegmentPathToStaticExportFi | TurborepoAccessTraceResult } from '../build/turborepo-access-trace'
import { createProgress } from '../build/progress'
import type { DeepReadonly } from '../shared/lib/deep-readonly'
import { isInterceptionRouteRewrite } from '.. | {
"filepath": "packages/next/src/export/index.ts",
"language": "typescript",
"file_size": 36578,
"cut_index": 2151,
"middle_length": 229
} |
e { RenderOptsPartial as PagesRenderOptsPartial } from '../server/render'
import type {
GenericComponentMod,
LoadComponentsReturnType,
} from '../server/load-components'
import type { OutgoingHttpHeaders } from 'http'
import type { ExportPathMap, NextConfigComplete } from '../server/config-shared'
import type { Cac... | /resume-data-cache'
import type { StaticWorker } from '../build'
import type { Bundler } from '../lib/bundler'
export type ExportPathEntry = ExportPathMap[keyof ExportPathMap] & {
path: string
}
export interface ExportPagesInput {
buildId: string
d | eResult,
} from '../build/turborepo-access-trace'
import type { FetchMetrics } from '../server/base-http'
import type { RouteMetadata } from './routes/types'
import type { RenderResumeDataCache } from '../server/resume-data-cache | {
"filepath": "packages/next/src/export/types.ts",
"language": "typescript",
"file_size": 4758,
"cut_index": 614,
"middle_length": 229
} |
normalize-page-path'
import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path'
import { trace } from '../trace'
import { setHttpClientAndAgentOptions } from '../server/setup-http-agent-env'
import { addRequestMeta } from '../server/request-meta'
import { normalizeAppPath } from '../shared/lib/route... | om './routes/pages'
import { getParams } from './helpers/get-params'
import { createIncrementalCache } from './helpers/create-incremental-cache'
import { isPostpone } from '../server/lib/router-utils/is-postpone'
import { isDynamicUsageError } from './help | pRouteRoute } from '../lib/is-app-route-route'
import { hasNextSupport } from '../server/ci-info'
import { exportAppRoute } from './routes/app-route'
import { exportAppPage } from './routes/app-page'
import { exportPagesPage } fr | {
"filepath": "packages/next/src/export/worker.ts",
"language": "typescript",
"file_size": 21262,
"cut_index": 1331,
"middle_length": 229
} |
helpers/is-dynamic-usage-error'
import {
NEXT_CACHE_TAGS_HEADER,
NEXT_META_SUFFIX,
RSC_SUFFIX,
RSC_SEGMENTS_DIR_SUFFIX,
RSC_SEGMENT_SUFFIX,
} from '../../lib/constants'
import { hasNextSupport } from '../../server/ci-info'
import { lazyRenderAppPage } from '../../server/route-modules/app-page/module.render'
i... | outeParams } from '../../server/request/fallback-params'
import { AfterRunner } from '../../server/after/run-with-after'
import type { RequestLifecycleOpts } from '../../server/base-server'
import type { AppSharedContext } from '../../server/app-render/app | DER } from '../../client/components/app-router-headers'
import type { FetchMetrics } from '../../server/base-http'
import type { WorkStore } from '../../server/app-render/work-async-storage.external'
import type { OpaqueFallbackR | {
"filepath": "packages/next/src/export/routes/app-page.ts",
"language": "typescript",
"file_size": 9371,
"cut_index": 921,
"middle_length": 229
} |
dules/app-route/module'
import type { IncrementalCache } from '../../server/lib/incremental-cache'
import {
INFINITE_CACHE,
NEXT_BODY_SUFFIX,
NEXT_CACHE_TAGS_HEADER,
NEXT_META_SUFFIX,
} from '../../lib/constants'
import { NodeNextRequest } from '../../server/base-http/node'
import {
NextRequestAdapter,
sig... | type { ExperimentalConfig } from '../../server/config-shared'
import { isMetadataRoute } from '../../lib/metadata/is-metadata-route'
import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'
import type { Params } from '../../server/reque | sponse,
} from '../../server/lib/mock-request'
import { isDynamicUsageError } from '../helpers/is-dynamic-usage-error'
import { isStaticGenEnabled } from '../../server/route-modules/app-route/helpers/is-static-gen-enabled'
import | {
"filepath": "packages/next/src/export/routes/app-route.ts",
"language": "typescript",
"file_size": 6244,
"cut_index": 716,
"middle_length": 229
} |
text,
RenderOpts,
} from '../../server/render'
import type { LoadComponentsReturnType } from '../../server/load-components'
import type { NextParsedUrlQuery } from '../../server/request-meta'
import type { Params } from '../../server/request/params'
import RenderResult from '../../server/render-result'
import { join... | m '../../lib/multi-file-writer'
/**
* Renders & exports a page associated with the /pages directory
*/
export async function exportPagesPage(
req: MockedRequest,
res: MockedResponse,
path: string,
page: string,
query: NextParsedUrlQuery,
par | rom '../../lib/constants'
import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { lazyRenderPagesPage } from '../../server/route-modules/pages/module.render'
import type { MultiFileWriter } fro | {
"filepath": "packages/next/src/export/routes/pages.ts",
"language": "typescript",
"file_size": 4097,
"cut_index": 614,
"middle_length": 229
} |
from '../../server/lib/incremental-cache'
import { hasNextSupport } from '../../server/ci-info'
import { nodeFs } from '../../server/lib/node-fs-methods'
import { interopDefault } from '../../lib/interop-default'
import { formatDynamicImportPath } from '../../lib/format-dynamic-import-path'
import {
initializeCacheH... | ng, string | string[] | undefined>
cacheHandlers?: Record<string, string | undefined>
}) {
// Custom cache handler overrides.
let CacheHandler: any
if (cacheHandler) {
CacheHandler = interopDefault(
await import(formatDynamicImportPath(di | ir,
flushToDisk,
cacheHandlers,
requestHeaders,
}: {
cacheHandler?: string
cacheMaxMemorySize: number
fetchCacheKeyPrefix?: string
distDir: string
dir: string
flushToDisk?: boolean
requestHeaders?: Record<stri | {
"filepath": "packages/next/src/export/helpers/create-incremental-cache.ts",
"language": "typescript",
"file_size": 2183,
"cut_index": 563,
"middle_length": 229
} |
{
type RouteMatchFn,
getRouteMatcher,
} from '../../shared/lib/router/utils/route-matcher'
import { getRouteRegex } from '../../shared/lib/router/utils/route-regex'
// The last page and matcher that this function handled.
let last: {
page: string
matcher: RouteMatchFn
} | null = null
/**
* Gets the params f... | he RegExp for. If it matches, it'll just re-use it.
let matcher: RouteMatchFn
if (last?.page === page) {
matcher = last.matcher
} else {
matcher = getRouteMatcher(getRouteRegex(page))
}
const params = matcher(pathname)
if (!params) {
| t function getParams(page: string, pathname: string) {
// Because this is often called on the output of `getStaticPaths` or similar
// where the `page` here doesn't change, this will "remember" the last page
// it created t | {
"filepath": "packages/next/src/export/helpers/get-params.ts",
"language": "typescript",
"file_size": 1199,
"cut_index": 518,
"middle_length": 229
} |
r,operator:"deepEqual",stackStartFn:deepEqual})}};x.notDeepEqual=function notDeepEqual(e,t,r){if(arguments.length<2){throw new f("actual","expected")}if(m===undefined)lazyLoadComparison();if(m(e,t)){innerFail({actual:e,expected:t,message:r,operator:"notDeepEqual",stackStartFn:notDeepEqual})}};x.deepStrictEqual=function... | {actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:notDeepStrictEqual})}}x.strictEqual=function strictEqual(e,t,r){if(arguments.length<2){throw new f("actual","expected")}if(!d(e,t)){innerFail({actual:e,expected:t,message:r,operator: | qual",stackStartFn:deepStrictEqual})}};x.notDeepStrictEqual=notDeepStrictEqual;function notDeepStrictEqual(e,t,r){if(arguments.length<2){throw new f("actual","expected")}if(m===undefined)lazyLoadComparison();if(S(e,t)){innerFail( | {
"filepath": "packages/next/src/compiled/assert/assert.js",
"language": "javascript",
"file_size": 76222,
"cut_index": 3790,
"middle_length": 229
} |
){if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n={};!function(){var e=n;e.endianness=function(){return"LE"};e.hostname=function(){if(typeof location!=="undefined"){return location.hostname}else return""};e.loadavg=function(){return[]};e.uptime=function(){return 0};e.freemem=funct... | vigator.appVersion}return""};e.networkInterfaces=e.getNetworkInterfaces=function(){return{}};e.arch=function(){return"javascript"};e.platform=function(){return"browser"};e.tmpdir=e.tmpDir=function(){return"/tmp"};e.EOL="\n";e.homedir=function(){return"/"}} | ed"){return na | {
"filepath": "packages/next/src/compiled/os-browserify/browser.js",
"language": "javascript",
"file_size": 816,
"cut_index": 522,
"middle_length": 14
} |
28);const n=t(738);const c=t(219);const o=Symbol("findUp.stop");r.exports=async(r,e={})=>{let t=s.resolve(e.cwd||"");const{root:c}=s.parse(t);const i=[].concat(r);const runMatcher=async e=>{if(typeof r!=="function"){return n(i,e)}const t=await r(e.cwd);if(typeof t==="string"){return n([t],e)}return t};while(true){const... | urn s.resolve(t,r)}if(t===c){return}t=s.dirname(t)}};r.exports.exists=c;r.exports.sync.exists=c.sync;r.exports.stop=o},738:(r,e,t)=>{const s=t(928);const n=t(896);const{promisify:c}=t(23);const o=t(296);const i=c(n.stat);const a=c(n.lstat);const u={directo | onst i=[].concat(r);const runMatcher=e=>{if(typeof r!=="function"){return n.sync(i,e)}const t=r(e.cwd);if(typeof t==="string"){return n.sync([t],e)}return t};while(true){const r=runMatcher({...e,cwd:t});if(r===o){return}if(r){ret | {
"filepath": "packages/next/src/compiled/find-up/index.js",
"language": "javascript",
"file_size": 3019,
"cut_index": 563,
"middle_length": 229
} |
header`)}if(r.equivalents&&r.equivalents.has(f)){f=r.equivalents.get(f)}const l={token:f,pos:e,q:1};if(t&&a.has(f)){l.pref=a.get(f).pos}c.add(l.token);if(s.length===2){const e=s[1];const[t,n]=e.split("=");if(!n||t!=="q"&&t!=="Q"){throw o.badRequest(`Invalid ${r.type} header`)}const a=parseFloat(n);if(a===0){continue}i... | ef!==e.pref){if(e.pref===undefined){return n}if(t.pref===undefined){return r}return e.pref-t.pref}return e.pos-t.pos}},982:(e,t,r)=>{const n=r(817);const o=r(730);const s={options:{charset:{type:"accept-charset"},encoding:{type:"accept-encoding",default:"i | nst e of f){if(e==="*"){for(const[e,t]of a){if(!c.has(e)){l.push(t.orig)}}}else{const t=e.toLowerCase();if(a.has(t)){l.push(a.get(t).orig)}}}return l};s.sort=function(e,t){const r=-1;const n=1;if(t.q!==e.q){return t.q-e.q}if(t.pr | {
"filepath": "packages/next/src/compiled/@hapi/accept/index.js",
"language": "javascript",
"file_size": 27673,
"cut_index": 1331,
"middle_length": 229
} |
fined) "+h+" = true; else if (typeof "+R+" != 'string') "+h+" = false; else { ";m+="}"}if(p){a+=" if (!"+P+") "+h+" = true; else { ";m+="}"}a+=" var "+$+" = "+P+"("+c+", ";if(_){a+=""+R}else{a+=""+e.util.toQuotedString(o)}a+=" ); if ("+$+" === undefined) "+h+" = false; if ("+h+" === undefined) "+h+" = "+$+" "+x;if(!O)... | (_){a+="' + "+R+" + '"}else{a+=""+e.util.escapeQuotes(o)}a+="\"' "}if(e.opts.verbose){a+=" , schema: ";if(_){a+="validate.schema"+n}else{a+=""+e.util.toQuotedString(o)}a+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "}a+=" } "}e | , schemaPath: "+e.util.toQuotedString(l)+" , params: { comparison: "+D+", limit: ";if(_){a+=""+R}else{a+=""+e.util.toQuotedString(o)}a+=" , exclusive: "+O+" } ";if(e.opts.messages!==false){a+=" , message: 'should be "+j+' "';if | {
"filepath": "packages/next/src/compiled/schema-utils2/index.js",
"language": "javascript",
"file_size": 176587,
"cut_index": 7068,
"middle_length": 229
} |
("[105m","[49m"),bgCyanBright:t("[106m","[49m"),bgWhiteBright:t("[107m","[49m")}};e.exports=createColors();e.exports.createColors=createColors},754:(e,t,r)=>{let{Input:s}=r(940);let i=r(986);e.exports=function safeParse(e,t){let r=new s(e,t);let n=new i(r);n.parse();return n.root}},986:(e,t,r)=>{let s=r(892);let ... | .match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2];t.raws.left=e[1];t.raws.right=e[3]}}decl(e){if(e.length>1&&e.some((e=>e[0]==="word"))){super.decl(e)}}unclosedBracket(){}unknownWord(e){this.spaces+=e.map((e=>e[1])).join("")}unexpectedClose(){this.current.raws.af | this.input.fromOffset(this.input.css.length-1);t.source.end={offset:e[3],line:r.line,column:r.col};let s=e[1].slice(2);if(s.slice(-2)==="*/")s=s.slice(0,-2);if(/^\s*$/.test(s)){t.text="";t.raws.left=s;t.raws.right=""}else{let e=s | {
"filepath": "packages/next/src/compiled/postcss-safe-parser/safe-parse.js",
"language": "javascript",
"file_size": 35924,
"cut_index": 2151,
"middle_length": 229
} |
r s;
if (process.env.NODE_ENV === 'production') {
s = require('./cjs/react-server-dom-turbopack-server.node.production.js');
} else {
s = require('./cjs/react-server-dom-turbopack-server.node.development.js');
}
exports.renderToReadableStream = s.renderToReadableStream;
exports.renderToPipeableStream = s.renderToP... | s.decodeFormState;
exports.registerServerReference = s.registerServerReference;
exports.registerClientReference = s.registerClientReference;
exports.createClientModuleProxy = s.createClientModuleProxy;
exports.createTemporaryReferenceSet = s.createTempora | deAction = s.decodeAction;
exports.decodeFormState = | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/server.node.js",
"language": "javascript",
"file_size": 853,
"cut_index": 529,
"middle_length": 52
} |
lue);
return "Object" === value ? "{...}" : value;
case "function":
return value.$$typeof === CLIENT_REFERENCE_TAG
? "client"
: (value = value.displayName || value.name)
? "function " + value
: "function";
default:
return ... | peof) {
case REACT_FORWARD_REF_TYPE:
return describeElementType(type.render);
case REACT_MEMO_TYPE:
return describeElementType(type.type);
case REACT_LAZY_TYPE:
var payload = type._payload;
| "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
case REACT_VIEW_TRANSITION_TYPE:
return "ViewTransition";
}
if ("object" === typeof type)
switch (type.$$ty | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js",
"language": "javascript",
"file_size": 192975,
"cut_index": 7068,
"middle_length": 229
} |
g[id];
if (resolvedModuleData) name = resolvedModuleData.name;
else {
var idx = id.lastIndexOf("#");
-1 !== idx &&
((name = id.slice(idx + 1)),
(resolvedModuleData = bundlerConfig[id.slice(0, idx)]));
if (!resolvedModuleData) throw Error(formatProdErrorMessage(589, id));
}
return resolve... | e;
},
function (reason) {
promise.status = "rejected";
promise.reason = reason;
}
);
return promise;
}
var instrumentedChunks = new WeakSet(),
loadedChunks = new WeakSet();
function ignoreReject() {}
function preloadModule(met | omise = __turbopack_require__(id);
if ("function" !== typeof promise.then || "fulfilled" === promise.status)
return null;
promise.then(
function (value) {
promise.status = "fulfilled";
promise.value = valu | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.production.js",
"language": "javascript",
"file_size": 63298,
"cut_index": 2151,
"middle_length": 229
} |
!== names[i] && "ref" !== names[i]) ||
"function" !== typeof descriptor.get))
)
return !1;
}
return !0;
}
function objectName(object) {
object = Object.prototype.toString.call(object);
return object.slice(8, object.length - 1);
}
function describe... | "[...]";
if (null !== value && value.$$typeof === CLIENT_REFERENCE_TAG)
return "client";
value = objectName(value);
return "Object" === value ? "{...}" : value;
case "function":
return value.$$ty | switch (typeof value) {
case "string":
return JSON.stringify(
10 >= value.length ? value : value.slice(0, 10) + "..."
);
case "object":
if (isArrayImpl(value)) return | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js",
"language": "javascript",
"file_size": 192300,
"cut_index": 7068,
"middle_length": 229
} |
&& "function" === typeof moduleExports.then)
if ("fulfilled" === moduleExports.status)
moduleExports = moduleExports.value;
else throw moduleExports.reason;
if ("*" === metadata[2]) return moduleExports;
if ("" === metadata[2])
return moduleExports.__esModule ? moduleExports.default : moduleExport... | JSCompiler_temp_const$jscomp$1 = moduleLoading.prefix + chunks[i];
var JSCompiler_inline_result = moduleLoading.crossOrigin;
JSCompiler_inline_result =
"string" === typeof JSCompiler_inline_result
? "use-credentials" === JSCom | moduleLoading)
for (var i = 0; i < chunks.length; i++) {
var nonce = nonce$jscomp$0,
JSCompiler_temp_const = ReactDOMSharedInternals.d,
JSCompiler_temp_const$jscomp$0 = JSCompiler_temp_const.X,
| {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js",
"language": "javascript",
"file_size": 70776,
"cut_index": 3790,
"middle_length": 229
} |
getOwnPropertyDescriptor(object, names[i]);
if (
!descriptor ||
(!descriptor.enumerable &&
(("key" !== names[i] && "ref" !== names[i]) ||
"function" !== typeof descriptor.get))
)
return !1;
}
return !0;
}
function objectName(obj... | 10 >= value.length ? value : value.slice(0, 10) + "..."
);
case "object":
if (isArrayImpl(value)) return "[...]";
if (null !== value && value.$$typeof === CLIENT_REFERENCE_TAG)
return "client";
| stringify(key);
return '"' + key + '"' === encodedKey ? key : encodedKey;
}
function describeValueForErrorMessage(value) {
switch (typeof value) {
case "string":
return JSON.stringify(
| {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js",
"language": "javascript",
"file_size": 198795,
"cut_index": 7068,
"middle_length": 229
} |
if (4 === metadata.length && "function" === typeof moduleExports.then)
if ("fulfilled" === moduleExports.status)
moduleExports = moduleExports.value;
else throw moduleExports.reason;
if ("*" === metadata[2]) return moduleExports;
if ("" === metadata[2])
return moduleExports.__esModule ? moduleExpo... | ler_temp_const.X,
JSCompiler_temp_const$jscomp$1 = moduleLoading.prefix + chunks[i];
var JSCompiler_inline_result = moduleLoading.crossOrigin;
JSCompiler_inline_result =
"string" === typeof JSCompiler_inline_result
? " | jscomp$0) {
if (null !== moduleLoading)
for (var i = 0; i < chunks.length; i++) {
var nonce = nonce$jscomp$0,
JSCompiler_temp_const = ReactDOMSharedInternals.d,
JSCompiler_temp_const$jscomp$0 = JSCompi | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js",
"language": "javascript",
"file_size": 75418,
"cut_index": 3790,
"middle_length": 229
} |
Exports = {
NextRequest: require('next/dist/server/web/spec-extension/request')
.NextRequest,
NextResponse: require('next/dist/server/web/spec-extension/response')
.NextResponse,
ImageResponse: require('next/dist/server/web/spec-extension/image-response')
.ImageResponse,
userAgentFromString: require... | js-namespaces
// When importing CommonJS modules, the module.exports object is provided as the default export
module.exports = serverExports
// make import { xxx } from 'next/server' work
exports.NextRequest = serverExports.NextRequest
exports.NextRespons | dist/server/web/spec-extension/url-pattern')
.URLPattern,
after: require('next/dist/server/after').after,
connection: require('next/dist/server/request/connection').connection,
}
// https://nodejs.org/api/esm.html#common | {
"filepath": "packages/next/server.js",
"language": "javascript",
"file_size": 1328,
"cut_index": 524,
"middle_length": 229
} |
x &&
((name = modulePath.slice(idx + 1)),
(resolvedModuleData = config[modulePath.slice(0, idx)]));
if (!resolvedModuleData)
throw Error(
'Could not find the module "' +
modulePath +
'" in the React Client Manifest. This is probably a bug in ... | entReference.$$async
? [resolvedModuleData.id, resolvedModuleData.chunks, name, 1]
: [resolvedModuleData.id, resolvedModuleData.chunks, name];
}
function preload(href, as, options) {
if ("string" === typeof href) {
var | modulePath +
'" is marked as an async ESM module but was loaded as a CJS proxy. This is probably a bug in the React Server Components bundler.'
);
return !0 === resolvedModuleData.async || !0 === cli | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js",
"language": "javascript",
"file_size": 216345,
"cut_index": 7068,
"middle_length": 229
} |
) {
var args = ArraySlice.call(arguments, 1),
$$typeof = { value: SERVER_REFERENCE_TAG },
$$id = { value: this.$$id };
args = { value: this.$$bound ? this.$$bound.concat(args) : args };
return Object.defineProperties(newFn, {
$$typeof: $$typeof,
$$id: $$id,
$$bound: args,
... | case "$$id":
return target.$$id;
case "$$async":
return target.$$async;
case "name":
return target.name;
case "displayName":
return;
case "defaultProps":
return;
| urable: !0,
writable: !0
},
PROMISE_PROTOTYPE = Promise.prototype,
deepProxyHandlers = {
get: function (target, name, receiver) {
switch (name) {
case "$$typeof":
return target.$$typeof;
| {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js",
"language": "javascript",
"file_size": 113964,
"cut_index": 3790,
"middle_length": 229
} |
= clientReference.$$id,
name = "",
resolvedModuleData = config[modulePath];
if (resolvedModuleData) name = resolvedModuleData.name;
else {
var idx = modulePath.lastIndexOf("#");
-1 !== idx &&
((name = modulePath.slice(idx + 1)),
(resolvedModuleData = confi... | modulePath +
'" is marked as an async ESM module but was loaded as a CJS proxy. This is probably a bug in the React Server Components bundler.'
);
return !0 === resolvedModuleData.async || !0 === clientReference.$$async
| nt Manifest. This is probably a bug in the React Server Components bundler.'
);
}
if (!0 === resolvedModuleData.async && !0 === clientReference.$$async)
throw Error(
'The module "' +
| {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js",
"language": "javascript",
"file_size": 220492,
"cut_index": 7068,
"middle_length": 229
} |
turn Object.defineProperties(proxyImplementation, {
$$typeof: { value: CLIENT_REFERENCE_TAG$1 },
$$id: { value: id },
$$async: { value: async }
});
}
var FunctionBind = Function.prototype.bind,
ArraySlice = Array.prototype.slice;
function bind() {
var newFn = FunctionBind.apply(this, arguments);
if ... | newFn;
}
var serverReferenceToString = {
value: function () {
return "function () { [omitted code] }";
},
configurable: !0,
writable: !0
},
PROMISE_PROTOTYPE = Promise.prototype,
deepProxyHandlers = {
get: function (target, | : this.$$bound ? this.$$bound.concat(args) : args };
return Object.defineProperties(newFn, {
$$typeof: $$typeof,
$$id: $$id,
$$bound: args,
bind: { value: bind, configurable: !0 }
});
}
return | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js",
"language": "javascript",
"file_size": 119867,
"cut_index": 3790,
"middle_length": 229
} |
{},
target.$$id,
!0
),
proxy = new Proxy(clientReference, proxyHandlers$1);
target.status = "fulfilled";
target.value = proxy;
return (target.then = registerClientReferenceImpl(
function (resolve) {
r... | nceImpl(
function () {
throw Error(
"Attempted to call " +
String(name) +
"() from the server but " +
String(name) +
" is on the client. It's not possible t | "Cannot read Symbol exports. Only named exports are supported on a client module imported on the server."
);
clientReference = target[name];
clientReference ||
((clientReference = registerClientRefere | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js",
"language": "javascript",
"file_size": 252365,
"cut_index": 7068,
"middle_length": 229
} |
ay(4096)),
(writtenBytes = 0)),
writeToDestination(destination, chunk))
: ((target = currentView.length - writtenBytes),
target < chunk.byteLength &&
(0 === target
? writeToDestination(destination, currentView)
: (currentView.set(chunk.suba... | stination(destination, currentView),
(currentView = new Uint8Array(4096)),
(writtenBytes = 0))));
return destinationHasCapacity;
}
var textEncoder = new util.TextEncoder();
function byteLengthOfChunk(chunk) {
return "string" === | (currentView = new Uint8Array(4096)),
(writtenBytes = 0)),
currentView.set(chunk, writtenBytes),
(writtenBytes += chunk.byteLength),
4096 === writtenBytes &&
(writeToDe | {
"filepath": "packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js",
"language": "javascript",
"file_size": 127948,
"cut_index": 3790,
"middle_length": 229
} |
t);i.filename=n;i._compile(t,n);return i.exports}function compareIds(e,t){if(typeof e!==typeof t){return typeof e<typeof t?-1:1}if(e<t){return-1}if(e>t){return 1}return 0}function compareModulesByIdentifier(e,t){return compareIds(e.identifier(),t.identifier())}const r="css/mini-extract";t.MODULE_TYPE=r;const o="__mini_... | f e.utils!=="undefined"&&typeof e.utils.contextify==="function"){return JSON.stringify(e.utils.contextify(e.context||e.rootContext,t))}const n=t.split("!");const{context:s}=e;return JSON.stringify(n.map((e=>{const t=e.match(/^(.*?)(\?.*)/);const n=t?t[2]:" | ;t.SINGLE_DOT_PATH_SEGMENT=u;function isAbsolutePath(e){return i.default.posix.isAbsolute(e)||i.default.win32.isAbsolute(e)}const l=/^\.\.?[/\\]/;function isRelativePath(e){return l.test(e)}function stringifyRequest(e,t){if(typeo | {
"filepath": "packages/next/src/compiled/mini-css-extract-plugin/index.js",
"language": "javascript",
"file_size": 20805,
"cut_index": 1331,
"middle_length": 229
} |
339));var o=_interopRequireDefault(i(928));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function trueFn(){return true}function findModuleById(e,t){const{modules:i,chunkGraph:n}=e;for(const e of i){const i=typeof n!=="undefined"?n.getModuleId(e):e.id;if(i===t){return e}}return null}function ev... | _plugin_public_path_auto__";t.AUTO_PUBLIC_PATH=s;const a="webpack:///mini-css-extract-plugin/";t.ABSOLUTE_PUBLIC_PATH=a;const u="__mini_css_extract_plugin_single_dot_path_segment__";t.SINGLE_DOT_PATH_SEGMENT=u;function isAbsolutePath(e){return o.default.po | rn typeof e<typeof t?-1:1}if(e<t){return-1}if(e>t){return 1}return 0}function compareModulesByIdentifier(e,t){return compareIds(e.identifier(),t.identifier())}const r="css/mini-extract";t.MODULE_TYPE=r;const s="__mini_css_extract | {
"filepath": "packages/next/src/compiled/mini-css-extract-plugin/loader.js",
"language": "javascript",
"file_size": 9446,
"cut_index": 921,
"middle_length": 229
} |
="undefined";var o=Array.prototype.forEach;function debounce(e,r){var t=0;return function(){var n=this;var i=arguments;var a=function functionCall(){return e.apply(n,i)};clearTimeout(t);t=setTimeout(a,r)}}function noop(){}function getCurrentScriptUrl(e){var r=i[e];if(!r){if(document.currentScript){r=document.currentScr... | ion updateCss(e,r){if(!r){if(!e.href){return}r=e.href.split("?")[0]}if(!isUrlRequest(r)){return}if(e.isLoaded===false){return}if(!r||!(r.indexOf(".css")>-1)){return}e.visited=true;var t=e.cloneNode();t.isLoaded=false;t.addEventListener("load",(function(){i | return[r.replace(".js",".css")]}if(!e){return[r.replace(".js",".css")]}return e.split(",").map((function(e){var t=new RegExp("".concat(i,"\\.js$"),"g");return n(r.replace(t,"".concat(e.replace(/{fileName}/g,i),".css")))}))}}funct | {
"filepath": "packages/next/src/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js",
"language": "javascript",
"file_size": 3183,
"cut_index": 614,
"middle_length": 229
} |
g=function(){return Array.isArray(this.nodes)?o(this.nodes):""};ValueParser.prototype.walk=function(e,r){n(this.nodes,e,r);return this};ValueParser.unit=t(15);ValueParser.walk=n;ValueParser.stringify=o;e.exports=ValueParser},90:e=>{var r="(".charCodeAt(0);var t=")".charCodeAt(0);var a="'".charCodeAt(0);var n='"'.charCo... | =A.charCodeAt(p)}while(b<=32);y=A.slice(E,p);x=v[v.length-1];if(b===t&&P){O=y}else if(x&&x.type==="div"){x.after=y;x.sourceEndIndex+=y.length}else if(b===d||b===u||b===s&&A.charCodeAt(p+1)!==i&&(!V||V&&V.type==="function"&&V.value!=="calc")){N=y}else{v.pus | odeAt(0);var h=/^[a-f0-9?-]+$/i;e.exports=function(e){var v=[];var A=e;var p,C,x,y,g,I,_,w;var E=0;var b=A.charCodeAt(E);var k=A.length;var m=[{nodes:v}];var P=0;var V;var q="";var N="";var O="";while(E<k){if(b<=32){p=E;do{p+=1;b | {
"filepath": "packages/next/src/compiled/postcss-value-parser/index.js",
"language": "javascript",
"file_size": 5840,
"cut_index": 716,
"middle_length": 229
} |
_nccwpck_require__.ab=__dirname+"/";var e={};(()=>{var r=e;r.quote=function(e){return e.map((function(e){if(e&&typeof e==="object"){return e.op.replace(/(.)/g,"\\$1")}else if(/["\s]/.test(e)&&!/'/.test(e)){return"'"+e.replace(/(['\\])/g,"\\$1")+"'"}else if(/["'\s]/.test(e)){return'"'+e.replace(/(["\\$`!])/g,"\\$1")+'"'... | rse(e,r,t);if(typeof r!=="function")return n;return n.reduce((function(e,r){if(typeof r==="object")return e.concat(r);var t=r.split(RegExp("("+s+".*?"+s+")","g"));if(t.length===1)return e.concat(t[0]);return e.concat(t.filter(Boolean).map((function(e){if(R | +")";var n="|&;()<> \\t";var i="(\\\\['\""+n+"]|[^\\s'\""+n+"])+";var a='"((\\\\"|[^"])*?)"';var f="'((\\\\'|[^'])*?)'";var s="";for(var u=0;u<4;u++){s+=(Math.pow(16,8)*Math.random()).toString(16)}r.parse=function(e,r,t){var n=pa | {
"filepath": "packages/next/src/compiled/shell-quote/index.js",
"language": "javascript",
"file_size": 2812,
"cut_index": 563,
"middle_length": 229
} |
tateAction } from 'react'
import {
DevOverlayContext,
useDevOverlayContext,
} from '../../src/next-devtools/dev-overlay.browser'
import { RenderErrorContext } from '../../src/next-devtools/dev-overlay/dev-overlay'
import {
PanelRouterContext,
type PanelStateKind,
} from '../../src/next-devtools/dev-overlay/menu... | ntimeErrors?: ReadyRuntimeError[]
totalErrorCount?: number
panel?: PanelStateKind | null
setPanel?: Dispatch<SetStateAction<PanelStateKind | null>>
selectedIndex?: number
setSelectedIndex?: Dispatch<SetStateAction<number>>
shadowRoot?: ShadowRo | '
import type { ReadyRuntimeError } from '../../src/next-devtools/dev-overlay/utils/get-error-by-type'
interface WithDevOverlayContextsOptions {
state?: Partial<OverlayState>
dispatch?: (action: DispatcherEvent) => void
ru | {
"filepath": "packages/next/.storybook/decorators/with-dev-overlay-contexts.tsx",
"language": "tsx",
"file_size": 2759,
"cut_index": 563,
"middle_length": 229
} |
mport { defineRule } from '../utils/define-rule'
import * as path from 'path'
const url = 'https://nextjs.org/docs/messages/no-head-import-in-document'
export default defineRule({
meta: {
docs: {
description: 'Prevent usage of `next/head` in `pages/_document.js`.',
recommended: true,
url,
... | dir === '/_document' && name === 'index')
) {
context.report({
node,
message: `\`next/head\` should not be imported in \`pages${document}\`. Use \`<Head />\` from \`next/document\` instead. See: ${url}`,
| const document = context.filename.split('pages', 2)[1]
if (!document) {
return
}
const { name, dir } = path.parse(document)
if (
name.startsWith('_document') ||
( | {
"filepath": "packages/eslint-plugin-next/src/rules/no-head-import-in-document.ts",
"language": "typescript",
"file_size": 1034,
"cut_index": 513,
"middle_length": 229
} |
'
import { getRootDirs } from '../utils/get-root-dirs'
import {
getUrlFromPagesDirectories,
normalizeURL,
execOnce,
getUrlFromAppDirectory,
} from '../utils/url'
const pagesDirWarning = execOnce((pagesDirs) => {
console.warn(
`Pages directory cannot be found at ${pagesDirs.join(' or ')}. ` +
'If u... | === undefined) {
cache[key] = fn(...args)
}
return cache[key]
}
}
const cachedGetUrlFromPagesDirectories = memoize(getUrlFromPagesDirectories)
const cachedGetUrlFromAppDirectory = memoize(getUrlFromAppDirectory)
const url = 'https://nextj | t have already been calculated.
const fsExistsSyncCache = {}
const memoize = <T = any>(fn: (...args: any[]) => T) => {
const cache = {}
return (...args: any[]): T => {
const key = JSON.stringify(args)
if (cache[key] | {
"filepath": "packages/eslint-plugin-next/src/rules/no-html-link-for-pages.ts",
"language": "typescript",
"file_size": 4398,
"cut_index": 614,
"middle_length": 229
} |
location-assign-relative-destination'
const LOCATION_GLOBALS = new Set(['window', 'globalThis'])
function isLocationObject(node: any): boolean {
// `location`
if (node.type === 'Identifier' && node.name === 'location') {
return true
}
// `window.location` / `globalThis.location` (dot or bracket notation)
... | e) ||
(memberNode.computed === true &&
memberNode.property.type === 'Literal' &&
memberNode.property.value === name)
)
}
/** Returns true when the node is a string literal containing "://" (absolute URL). */
function isAbsoluteUrlLiteral | e
}
return false
}
function isPropertyNamed(memberNode: any, name: string): boolean {
return (
(memberNode.computed === false &&
memberNode.property.type === 'Identifier' &&
memberNode.property.name === nam | {
"filepath": "packages/eslint-plugin-next/src/rules/no-location-assign-relative-destination.ts",
"language": "typescript",
"file_size": 3495,
"cut_index": 614,
"middle_length": 229
} |
{ defineRule } from '../utils/define-rule'
import * as path from 'path'
const url = 'https://nextjs.org/docs/messages/no-styled-jsx-in-document'
export default defineRule({
meta: {
docs: {
description: 'Prevent usage of `styled-jsx` in `pages/_document.js`.',
recommended: true,
url,
},
... | return
}
if (
node.name.name === 'style' &&
node.attributes.find(
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'jsx'
)
) {
context.report({
n |
return
}
const { name, dir } = path.parse(document)
if (
!(
name.startsWith('_document') ||
(dir === '/_document' && name === 'index')
)
) {
| {
"filepath": "packages/eslint-plugin-next/src/rules/no-styled-jsx-in-document.ts",
"language": "typescript",
"file_size": 1151,
"cut_index": 518,
"middle_length": 229
} |
m '../utils/define-rule'
const url = 'https://nextjs.org/docs/messages/no-title-in-document-head'
export default defineRule({
meta: {
docs: {
description:
'Prevent usage of `<title>` with `Head` component from `next/document`.',
recommended: true,
url,
},
type: 'problem',
sc... | node.openingElement &&
node.openingElement.name &&
node.openingElement.name.name !== 'Head'
) {
return
}
const titleTag = node.children.find(
(child) =>
child.openingElem | cifiers.some(({ local }) => local.name === 'Head')) {
headFromNextDocument = true
}
}
},
JSXElement(node) {
if (!headFromNextDocument) {
return
}
if (
| {
"filepath": "packages/eslint-plugin-next/src/rules/no-title-in-document-head.ts",
"language": "typescript",
"file_size": 1533,
"cut_index": 537,
"middle_length": 229
} |
mport * as path from 'path'
const NEXT_EXPORT_FUNCTIONS = [
'getStaticProps',
'getStaticPaths',
'getServerSideProps',
]
// 0 is the exact match
const THRESHOLD = 1
// the minimum number of operations required to convert string a to string b.
function minDistance(a, b) {
const m = a.length
const n = b.lengt... | + Number(s1 !== s2)
currentRow.push(Math.min(insertions, deletions, substitutions))
}
previousRow = currentRow
}
return previousRow[previousRow.length - 1]
}
export default defineRule({
meta: {
docs: {
description: 'Prevent c | s1 = a[i]
let currentRow = [i + 1]
for (let j = 0; j < n; j++) {
const s2 = b[j]
const insertions = previousRow[j + 1] + 1
const deletions = currentRow[j] + 1
const substitutions = previousRow[j] | {
"filepath": "packages/eslint-plugin-next/src/rules/no-typos.ts",
"language": "typescript",
"file_size": 2662,
"cut_index": 563,
"middle_length": 229
} |
return function notAvailable() {
throw new Error(`\`${name}\` is only available in a Server Component.`)
}
}
cacheExports = {
unstable_cache: function unstable_cache(cb) {
// Legacy behavior: allow importing/using unstable_cache from client bundles
// without pulling in server internals... | refresh: notAvailableInClient('refresh'),
cacheLife: notAvailableInClient('cacheLife'),
cacheTag: notAvailableInClient('cacheTag'),
}
} else {
// Keep server requires in this branch so browser builds can DCE them.
cacheExports = {
unsta | io: require('next/dist/client/request/io.browser').io,
updateTag: notAvailableInClient('updateTag'),
revalidateTag: notAvailableInClient('revalidateTag'),
revalidatePath: notAvailableInClient('revalidatePath'),
| {
"filepath": "packages/next/cache.js",
"language": "javascript",
"file_size": 3572,
"cut_index": 614,
"middle_length": 229
} |
= require('./src/shared/lib/modern-browserslist-target')
const DevToolsIgnoreListPlugin = require('./webpack-plugins/devtools-ignore-list-plugin')
function shouldIgnorePath(modulePath) {
// For consumers, everything will be considered 3rd party dependency if they use
// the bundles we produce here.
// In other w... | WSERSLIST_TARGET.join(', ')}`
return {
entry: path.join(__dirname, 'src/next-devtools/entrypoint.ts'),
target,
mode: dev ? 'development' : 'production',
output: {
path: path.join(__dirname, 'dist/compiled/next-devtools'),
fil | ns.rest
* @returns {webpack.Configuration}
*/
module.exports = ({ dev, ...rest }) => {
const experimental = false
const bundledReactChannel = experimental ? '-experimental' : ''
const target = `browserslist:${MODERN_BRO | {
"filepath": "packages/next/next-devtools.webpack-config.js",
"language": "javascript",
"file_size": 4606,
"cut_index": 614,
"middle_length": 229
} |
s is all library code and should therefore be ignored.
return true
}
const pagesExternals = [
'react',
'react/package.json',
'react/jsx-runtime',
'react/jsx-dev-runtime',
'react/compiler-runtime',
'react-dom',
'react-dom/package.json',
'react-dom/client',
'react-dom/server',
'react-dom/server.bro... | er$': `next/dist/compiled/react${reactChannel}/react.react-server`,
'react-dom$': `next/dist/compiled/react-dom${reactChannel}`,
'react/jsx-runtime$': `next/dist/compiled/react${reactChannel}/jsx-runtime`,
'react/jsx-dev-runtime$': `next/dist/c | nst appExternals = []
function makeAppAliases({ experimental, bundler }) {
const reactChannel = experimental ? '-experimental' : ''
return {
react$: `next/dist/compiled/react${reactChannel}`,
'react/react.react-serv | {
"filepath": "packages/next/next-runtime.webpack-config.js",
"language": "javascript",
"file_size": 12371,
"cut_index": 921,
"middle_length": 229
} |
} = require('fs')
const { basename, dirname, extname, join, resolve } = require('path')
const { Module } = require('module')
// files might be lower case and not able to be found on case-sensitive
// file systems (ubuntu)
const potentialLicenseFiles = [
'LICENSE',
'license',
'LICENSE.md',
'License.md',
'lice... | }, function* (file, options) {
if (options.externals && options.packageName) {
options.externals = { ...options.externals }
delete options.externals[options.packageName]
}
let precompiled = options.precompiled !== false
delete o | bundleRequire = m.require
bundleRequire.resolve = (request, options) =>
Module._resolveFilename(request, m, false, options)
module.exports = function (task) {
// eslint-disable-next-line require-yield
task.plugin('ncc', { | {
"filepath": "packages/next/taskfile-ncc.js",
"language": "javascript",
"file_size": 3485,
"cut_index": 614,
"middle_length": 229
} |
ack instead of chokidar
https://github.com/lukeed/taskr/blob/7a50e6e8c1fb8c01c0020d9f0e4d8897ccc4cc28/license
The MIT License (MIT)
Copyright (c) 2015 Jorge Bucaran (https://github.com/JorgeBucaran)
Copyright (c) 2016 Luke Edwards (https://github.com/lukeed)
Permission is hereby granted, free of charge, to any perso... | n notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR | fy, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permissio | {
"filepath": "packages/next/taskfile-watch.js",
"language": "javascript",
"file_size": 2266,
"cut_index": 563,
"middle_length": 229
} |
node-html-parser'
export async function ncc_node_html_parser(task, opts) {
await task
.source(relative(__dirname, require.resolve('node-html-parser')))
.ncc({
packageName: 'node-html-parser',
externals,
target: 'es5',
})
.target('src/compiled/node-html-parser')
}
externals['@vercel/... | nals['busboy'] = 'next/dist/compiled/busboy'
export async function ncc_busboy(task, opts) {
await task
.source(relative(__dirname, require.resolve('busboy')))
.ncc({
packageName: 'busboy',
externals,
target: 'es5',
})
.t | equire.resolve('@vercel/routing-utils/dist/superstatic')
)
)
.ncc({
packageName: '@vercel/routing-utils',
externals,
target: 'es5',
})
.target('src/compiled/@vercel/routing-utils')
}
exter | {
"filepath": "packages/next/taskfile.js",
"language": "javascript",
"file_size": 97079,
"cut_index": 3790,
"middle_length": 229
} |
m-webpack/client.edge'
declare module 'next/dist/compiled/react-server-dom-webpack/client.browser'
declare module 'next/dist/compiled/react-server-dom-webpack/server.browser'
declare module 'next/dist/compiled/react-server-dom-webpack/server.edge'
declare module 'next/dist/compiled/react-server-dom-turbopack/client'
de... | om/server'
declare module 'next/dist/compiled/react-dom/server.edge'
declare module 'next/dist/compiled/browserslist'
declare module 'react-server-dom-webpack/client' {
import type { Options } from 'react-server-dom-webpack/client.edge'
export { Opti | server-dom-turbopack/server.browser'
declare module 'next/dist/compiled/react-server-dom-turbopack/server.edge'
declare module 'next/dist/compiled/react-server-dom-turbopack/static.edge'
declare module 'next/dist/compiled/react-d | {
"filepath": "packages/next/types/$$compiled.internal.d.ts",
"language": "typescript",
"file_size": 30059,
"cut_index": 1331,
"middle_length": 229
} |
act-webpack5'
import { join, dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(requ... | @storybook/addon-a11y'),
],
framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {
builder: {
useSWC: true,
},
},
},
swc: () => ({
jsc: {
transform: {
react: {
runtime | vtools/**/*.stories.tsx'],
addons: [
getAbsolutePath('@storybook/addon-webpack5-compiler-swc'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-interactions'),
getAbsolutePath(' | {
"filepath": "packages/next/.storybook/main.ts",
"language": "typescript",
"file_size": 2465,
"cut_index": 563,
"middle_length": 229
} |
import { useReducer } from 'react'
import {
ACTION_BEFORE_REFRESH,
ACTION_BUILD_ERROR,
ACTION_BUILD_OK,
ACTION_BUILDING_INDICATOR_HIDE,
ACTION_BUILDING_INDICATOR_SHOW,
ACTION_CACHE_INDICATOR,
ACTION_INSTANT_ERRORS_CLEAR,
ACTION_INSTANT_NAVS_TOGGLE,
ACTION_INSTANT_NAVS_RESET,
ACTION_DEBUG_INFO,
ACT... | ERROR,
ACTION_UNHANDLED_REJECTION,
ACTION_VERSION_INFO,
INITIAL_OVERLAY_STATE,
} from '../../src/next-devtools/dev-overlay/shared'
export const storybookDefaultOverlayState: OverlayState = {
...INITIAL_OVERLAY_STATE,
routerType: 'app',
isError | ALE,
ACTION_ERROR_OVERLAY_CLOSE,
ACTION_ERROR_OVERLAY_OPEN,
ACTION_ERROR_OVERLAY_TOGGLE,
ACTION_REFRESH,
ACTION_RENDERING_INDICATOR_HIDE,
ACTION_RENDERING_INDICATOR_SHOW,
ACTION_STATIC_INDICATOR,
ACTION_UNHANDLED_ | {
"filepath": "packages/next/.storybook/decorators/use-overlay-reducer.ts",
"language": "typescript",
"file_size": 3298,
"cut_index": 614,
"middle_length": 229
} |
mport { defineRule } from '../utils/define-rule'
const url = 'https://nextjs.org/docs/messages/no-img-element'
export default defineRule({
meta: {
docs: {
description:
'Prevent usage of `<img>` element due to slower LCP and higher bandwidth.',
category: 'HTML',
recommended: true,
... | if (node.attributes.length === 0) {
return
}
if (node.parent?.parent?.openingElement?.name?.name === 'picture') {
return
}
// If is metadata route files, ignore
// e.g. opengraph-image.js, twit | eplace(context.cwd, '')
.replace(/^\//, '')
const isAppDir = /^(src\/)?app\//.test(relativePath)
return {
JSXOpeningElement(node) {
if (node.name.name !== 'img') {
return
}
| {
"filepath": "packages/eslint-plugin-next/src/rules/no-img-element.ts",
"language": "typescript",
"file_size": 1523,
"cut_index": 537,
"middle_length": 229
} |
ineRule } from '../utils/define-rule'
const url = 'https://nextjs.org/docs/messages/no-script-component-in-head'
export default defineRule({
meta: {
docs: {
description: 'Prevent usage of `next/script` in `next/head` component.',
recommended: true,
url,
},
type: 'problem',
schema: [... | node.openingElement.name &&
node.openingElement.name.name !== 'Head'
) {
return
}
const scriptTag = node.children.find(
(child) =>
child.openingElement &&
child.openingElemen | }
if (node.source.value !== 'next/script') {
return
}
},
JSXElement(node) {
if (!isNextHead) {
return
}
if (
node.openingElement &&
| {
"filepath": "packages/eslint-plugin-next/src/rules/no-script-component-in-head.ts",
"language": "typescript",
"file_size": 1352,
"cut_index": 524,
"middle_length": 229
} |
ate'
export { unstable_noStore } from 'next/dist/server/web/spec-extension/unstable-no-store'
export { io } from 'next/dist/server/request/io'
import { cacheTag } from 'next/dist/server/use-cache/cache-tag'
export { cacheTag }
/**
* Cache this `"use cache"` for a timespan defined by the `"default"` profile.
* ``... | old value the next request.
*/
export function cacheLife(profile: 'default'): void
/**
* Cache this `"use cache"` for a timespan defined by the `"seconds"` profile.
* ```
* stale: 30 seconds
* revalidate: 1 second
* expire: 1 minute
| he server.
* If the server receives a new request after 15 minutes, start revalidating new values in the background.
* It lives for the maximum age of the server cache. If this entry has no traffic for a while, it may serve an | {
"filepath": "packages/next/cache.d.ts",
"language": "typescript",
"file_size": 5569,
"cut_index": 716,
"middle_length": 229
} |
const path = require('path')
const fs = require('fs/promises')
const errorsDir = path.join(__dirname, '.errors')
// This script checks for new error codes in .errors directory and consolidates them into errors.json.
// It will fail if new error codes are found, after consolidating them, to ensure error codes are
// p... |
// Calculate next error code
const nextInitialCode =
Object.keys(existingErrors).length > 0
? Math.max(...Object.keys(existingErrors).map(Number)) + 1
: 1
// Process new error files
const errorFiles = [...(await fs.readdir(errors | = {}
// Load existing errors.json if it exists
try {
existingErrors = JSON.parse(
await fs.readFile(path.join(__dirname, 'errors.json'), 'utf8')
)
} catch {
// Start fresh if errors.json doesn't exist
} | {
"filepath": "packages/next/check-error-codes.js",
"language": "javascript",
"file_size": 1869,
"cut_index": 537,
"middle_length": 229
} |
import type { AsyncLocalStorage as NodeAsyncLocalStorage } from 'async_hooks'
declare global {
var AsyncLocalStorage: typeof NodeAsyncLocalStorage
}
export { NextFetchEvent } from 'next/dist/server/web/spec-extension/fetch-event'
export { NextRequest } from 'next/dist/server/web/spec-extension/request'
export { Nex... | ImageResponse } from 'next/dist/server/web/spec-extension/image-response'
export type { ImageResponseOptions } from 'next/dist/compiled/@vercel/og/types'
export { after } from 'next/dist/server/after'
export { connection } from 'next/dist/server/request/co | tFromString } from 'next/dist/server/web/spec-extension/user-agent'
export { userAgent } from 'next/dist/server/web/spec-extension/user-agent'
export { URLPattern } from 'next/dist/compiled/@edge-runtime/primitives/url'
export { | {
"filepath": "packages/next/server.d.ts",
"language": "typescript",
"file_size": 1007,
"cut_index": 512,
"middle_length": 229
} |
k = require('@rspack/core')
module.exports = function (task) {
// eslint-disable-next-line require-yield
task.plugin('webpack', {}, function* (_, options) {
options = options || {}
const compiler = webpack(options.config)
if (options.watch) {
return compiler.watch({}, (err, stats) => {
... | ? stats.toString(),
})
}
if (stats.hasWarnings()) {
this.emit('plugin_warning', {
plugin: 'taskfile-webpack',
warning: `webpack compiled ${options.name} with warnings:\n${stats.toString('errors-w | return new Promise((resolve) => {
compiler.run((err, stats) => {
if (err || stats.hasErrors()) {
return this.emit('plugin_error', {
plugin: 'taskfile-webpack',
error: err?.message ? | {
"filepath": "packages/next/taskfile-webpack.js",
"language": "javascript",
"file_size": 1308,
"cut_index": 524,
"middle_length": 229
} |
//nextjs.org/docs/messages/no-head-element'
export default defineRule({
meta: {
docs: {
description: 'Prevent usage of `<head>` element.',
category: 'HTML',
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create(context) {
return {
JSXOpeningElement(no... | (node.name.name !== 'head' || isInAppDir()) {
return
}
context.report({
node,
message: `Do not use \`<head>\` element. Use \`<Head />\` from \`next/head\` instead. See: ${url}`,
})
},
}
},
| nt the <head> element in pages directory
if | {
"filepath": "packages/eslint-plugin-next/src/rules/no-head-element.ts",
"language": "typescript",
"file_size": 917,
"cut_index": 606,
"middle_length": 52
} |
rom '@storybook/react'
import { withDevOverlayContexts } from './decorators/with-dev-overlay-contexts'
const portalNode = document.querySelector('nextjs-portal')!
const shadowRoot = portalNode.attachShadow({ mode: 'open' })
const preview: Preview = {
parameters: {
a11y: {
element: 'nextjs-portal',
c... | // on a value below threshold.
id: 'color-contrast',
selector: '.code-frame-lines',
enabled: false,
},
],
},
},
controls: {
matchers: {
color: /(background|color)$/i,
| It's incredibly hard to find a code highlighting theme that works
// for both light and dark themes and passes WCAG color contrast.
// These kind of tests should really only fail when you regress
| {
"filepath": "packages/next/.storybook/preview.tsx",
"language": "tsx",
"file_size": 1638,
"cut_index": 537,
"middle_length": 229
} |
/docs/messages/no-page-custom-font'
function isIdentifierMatch(id1, id2) {
return (id1 === null && id2 === null) || (id1 && id2 && id1.name === id2.name)
}
export default defineRule({
meta: {
docs: {
description: 'Prevent page-only custom fonts.',
recommended: true,
url,
},
type: 'pr... | aultExportId
let exportDeclarationType
return {
ImportDeclaration(node) {
if (node.source.value === 'next/document') {
const documentImport = node.specifiers.find(
({ type }) => type === 'ImportDefaultSpecifier' | f a file within `pages`, bail
if (!page) {
return {}
}
const is_Document =
page.startsWith(`${sep}_document`) ||
page.startsWith(`${posix.sep}_document`)
let documentImportName
let localDef | {
"filepath": "packages/eslint-plugin-next/src/rules/no-page-custom-font.ts",
"language": "typescript",
"file_size": 5280,
"cut_index": 716,
"middle_length": 229
} |
h')
const transform = require('@swc/core').transform
module.exports = function (task) {
task.plugin(
'swc',
{},
function* (
file,
serverOrClient,
{ stripExtension, interopClientDefaultExport = false, esm = false } = {}
) {
// Don't compile .d.ts
if (
file.base.e... | * @type {import('@swc/core').Options} */
const swcClientOptions = {
module: esm
? {
type: 'es6',
}
: {
type: 'commonjs',
ignoreDynamic: true,
exportIntero | ...(file.base.includes('.test.') || file.base.includes('.stories.')
? []
: [[path.join(__dirname, 'next_error_code_swc_plugin.wasm'), {}]]),
]
const isClient = serverOrClient === 'client'
/* | {
"filepath": "packages/next/taskfile-swc.js",
"language": "javascript",
"file_size": 6346,
"cut_index": 716,
"middle_length": 229
} |
//nextjs.org/docs/messages/no-sync-scripts'
export default defineRule({
meta: {
docs: {
description: 'Prevent synchronous scripts.',
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create(context) {
return {
JSXOpeningElement(node) {
if (node.name.na... | => attr.name.name)
if (
attributeNames.includes('src') &&
!attributeNames.includes('async') &&
!attributeNames.includes('defer')
) {
context.report({
node,
message: `Synchronou | attr.type === 'JSXAttribute')
.map((attr) | {
"filepath": "packages/eslint-plugin-next/src/rules/no-sync-scripts.ts",
"language": "typescript",
"file_size": 980,
"cut_index": 582,
"middle_length": 52
} |
names.length;
i++
) {
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
if (
!descriptor ||
(!descriptor.enumerable &&
(("key" !== names[i] && "ref" !== names[i]) ||
"function" !== typeof descriptor.get))
)
... | lue) {
case "string":
return JSON.stringify(
10 >= value.length ? value : value.slice(0, 10) + "..."
);
case "object":
if (isArrayImpl(value)) return "[...]";
if (null !== value && value.$ | nction describeKeyForErrorMessage(key) {
var encodedKey = JSON.stringify(key);
return '"' + key + '"' === encodedKey ? key : encodedKey;
}
function describeValueForErrorMessage(value) {
switch (typeof va | {
"filepath": "packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js",
"language": "javascript",
"file_size": 198816,
"cut_index": 7068,
"middle_length": 229
} |
nse React
* react-jsx-dev-runtime.react-server.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
"use strict";
var React = require("next/dist/compiled/react"),
RE... | Key) {
var key = null;
void 0 !== maybeKey && (key = "" + maybeKey);
void 0 !== config.key && (key = "" + config.key);
if ("key" in config) {
maybeKey = {};
for (var propName in config)
"key" !== propName && (maybeKey[propName] = conf | throw Error(
'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
);
function jsxProd(type, config, maybe | {
"filepath": "packages/next/src/compiled/react/cjs/react-jsx-dev-runtime.react-server.production.js",
"language": "javascript",
"file_size": 1335,
"cut_index": 524,
"middle_length": 229
} |
if ("function" === typeof type)
return type.$$typeof === REACT_CLIENT_REFERENCE
? null
: type.displayName || type.name || null;
if ("string" === typeof type) return type;
switch (type) {
case REACT_FRAGMENT_TYPE:
return "Fragment";
case REACT_PROFILER_T... | switch (
("number" === typeof type.tag &&
console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
),
type.$$typeof)
| _LIST_TYPE:
return "SuspenseList";
case REACT_ACTIVITY_TYPE:
return "Activity";
case REACT_VIEW_TRANSITION_TYPE:
return "ViewTransition";
}
if ("object" === typeof type)
| {
"filepath": "packages/next/src/compiled/react/cjs/react-jsx-runtime.development.js",
"language": "javascript",
"file_size": 13051,
"cut_index": 921,
"middle_length": 229
} |
ht (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
"use strict";
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
functio... | == propName && (maybeKey[propName] = config[propName]);
} else maybeKey = config;
config = maybeKey.ref;
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key,
ref: void 0 !== config ? config : null,
props: maybeKey
};
}
e | = {};
for (var propName in config)
"key" ! | {
"filepath": "packages/next/src/compiled/react/cjs/react-jsx-runtime.production.js",
"language": "javascript",
"file_size": 976,
"cut_index": 582,
"middle_length": 52
} |
t (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
"use strict";
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
function... | = propName && (maybeKey[propName] = config[propName]);
} else maybeKey = config;
config = maybeKey.ref;
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key,
ref: void 0 !== config ? config : null,
props: maybeKey
};
}
ex | {};
for (var propName in config)
"key" != | {
"filepath": "packages/next/src/compiled/react/cjs/react-jsx-runtime.profiling.js",
"language": "javascript",
"file_size": 975,
"cut_index": 582,
"middle_length": 52
} |
n null;
if ("function" === typeof type)
return type.$$typeof === REACT_CLIENT_REFERENCE
? null
: type.displayName || type.name || null;
if ("string" === typeof type) return type;
switch (type) {
case REACT_FRAGMENT_TYPE:
return "Fragment";
case REA... | ypeof type)
switch (
("number" === typeof type.tag &&
console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
),
ty | EACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
case REACT_ACTIVITY_TYPE:
return "Activity";
case REACT_VIEW_TRANSITION_TYPE:
return "ViewTransition";
}
if ("object" === t | {
"filepath": "packages/next/src/compiled/react/cjs/react-jsx-runtime.react-server.development.js",
"language": "javascript",
"file_size": 14024,
"cut_index": 921,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.