/opt/canhelp/node_modules/next/dist/esm/build/babel/plugins
NameSizeModeActions
amp-attributes.js8430644editdlrm
amp-attributes.js.map15170644editdlrm
commonjs.js10130644editdlrm
commonjs.js.map18490644editdlrm
jsx-pragma.js33120644editdlrm
jsx-pragma.js.map64040644editdlrm
next-font-unsupported.js12270644editdlrm
next-font-unsupported.js.map17770644editdlrm
next-page-config.js88370644editdlrm
next-page-config.js.map124240644editdlrm
next-page-disallow-re-export-all-exports.js9680644editdlrm
next-page-disallow-re-export-all-exports.js.map14770644editdlrm
next-ssg-transform.js159830644editdlrm
next-ssg-transform.js.map248310644editdlrm
optimize-hook-destructuring.js22880644editdlrm
optimize-hook-destructuring.js.map46090644editdlrm
react-loadable-plugin.js77770644editdlrm
react-loadable-plugin.js.map126550644editdlrm
Edit: /opt/canhelp/node_modules/next/dist/esm/build/babel/plugins/next-page-config.js.map (12424B)
{"version":3,"sources":["../../../../src/build/babel/plugins/next-page-config.ts"],"sourcesContent":["import { types as BabelTypes } from 'next/dist/compiled/babel/core'\nimport type {\n PluginObj,\n PluginPass,\n Visitor,\n NodePath,\n} from 'next/dist/compiled/babel/core'\nimport type { PageConfig } from '../../../types'\nimport { STRING_LITERAL_DROP_BUNDLE } from '../../../shared/lib/constants'\n\nconst CONFIG_KEY = 'config'\n\n// replace program path with just a variable with the drop identifier\nfunction replaceBundle(path: any, t: typeof BabelTypes): void {\n path.parentPath.replaceWith(\n t.program(\n [\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(STRING_LITERAL_DROP_BUNDLE),\n t.stringLiteral(`${STRING_LITERAL_DROP_BUNDLE} ${Date.now()}`)\n ),\n ]),\n ],\n []\n )\n )\n}\n\nfunction errorMessage(state: any, details: string): string {\n const pageName =\n (state.filename || '').split(state.cwd || '').pop() || 'unknown'\n return `Invalid page config export found. ${details} in file ${pageName}. See: https://nextjs.org/docs/messages/invalid-page-config`\n}\n\ninterface ConfigState extends PluginPass {\n bundleDropped?: boolean\n}\n\n// config to parsing pageConfig for client bundles\nexport default function nextPageConfig({\n types: t,\n}: {\n types: typeof BabelTypes\n}): PluginObj {\n return {\n visitor: {\n Program: {\n enter(path, state) {\n path.traverse(\n {\n ExportDeclaration(exportPath, exportState) {\n if (\n BabelTypes.isExportNamedDeclaration(exportPath.node) &&\n exportPath.node.specifiers?.some((specifier) => {\n return (\n (t.isIdentifier(specifier.exported)\n ? specifier.exported.name\n : specifier.exported.value) === CONFIG_KEY\n )\n }) &&\n BabelTypes.isStringLiteral(\n (exportPath.node as BabelTypes.ExportNamedDeclaration)\n .source\n )\n ) {\n throw new Error(\n errorMessage(\n exportState,\n 'Expected object but got export from'\n )\n )\n }\n },\n ExportNamedDeclaration(\n exportPath: NodePath,\n exportState: any\n ) {\n if (\n exportState.bundleDropped ||\n (!exportPath.node.declaration &&\n exportPath.node.specifiers.length === 0)\n ) {\n return\n }\n\n const config: PageConfig = {}\n const declarations: BabelTypes.VariableDeclarator[] = [\n ...((\n exportPath.node\n .declaration as BabelTypes.VariableDeclaration\n )?.declarations || []),\n exportPath.scope.getBinding(CONFIG_KEY)?.path\n .node as BabelTypes.VariableDeclarator,\n ].filter(Boolean)\n\n for (const specifier of exportPath.node.specifiers) {\n if (\n (t.isIdentifier(specifier.exported)\n ? specifier.exported.name\n : specifier.exported.value) === CONFIG_KEY\n ) {\n // export {} from 'somewhere'\n if (BabelTypes.isStringLiteral(exportPath.node.source)) {\n throw new Error(\n errorMessage(\n exportState,\n `Expected object but got import`\n )\n )\n // import hello from 'world'\n // export { hello as config }\n } else if (\n BabelTypes.isIdentifier(\n (specifier as BabelTypes.ExportSpecifier).local\n )\n ) {\n if (\n BabelTypes.isImportSpecifier(\n exportPath.scope.getBinding(\n (specifier as BabelTypes.ExportSpecifier).local.name\n )?.path.node\n )\n ) {\n throw new Error(\n errorMessage(\n exportState,\n `Expected object but got import`\n )\n )\n }\n }\n }\n }\n\n for (const declaration of declarations) {\n if (\n !BabelTypes.isIdentifier(declaration.id, {\n name: CONFIG_KEY,\n })\n ) {\n continue\n }\n\n let { init } = declaration\n if (BabelTypes.isTSAsExpression(init)) {\n init = init.expression\n }\n\n if (!BabelTypes.isObjectExpression(init)) {\n const got = init ? init.type : 'undefined'\n throw new Error(\n errorMessage(\n exportState,\n `Expected object but got ${got}`\n )\n )\n }\n\n for (const prop of init.properties) {\n if (BabelTypes.isSpreadElement(prop)) {\n throw new Error(\n errorMessage(\n exportState,\n `Property spread is not allowed`\n )\n )\n }\n const { name } = prop.key as BabelTypes.Identifier\n if (BabelTypes.isIdentifier(prop.key, { name: 'amp' })) {\n if (!BabelTypes.isObjectProperty(prop)) {\n throw new Error(\n errorMessage(\n exportState,\n `Invalid property \"${name}\"`\n )\n )\n }\n if (\n !BabelTypes.isBooleanLiteral(prop.value) &&\n !BabelTypes.isStringLiteral(prop.value)\n ) {\n throw new Error(\n errorMessage(\n exportState,\n `Invalid value for \"${name}\"`\n )\n )\n }\n config.amp = prop.value.value as PageConfig['amp']\n }\n }\n }\n\n if (config.amp === true) {\n if (!exportState.file?.opts?.caller.isDev) {\n // don't replace bundle in development so HMR can track\n // dependencies and trigger reload when they are changed\n replaceBundle(exportPath, t)\n }\n exportState.bundleDropped = true\n return\n }\n },\n },\n state\n )\n },\n },\n } as Visitor,\n }\n}\n"],"names":["types","BabelTypes","STRING_LITERAL_DROP_BUNDLE","CONFIG_KEY","replaceBundle","path","t","parentPath","replaceWith","program","variableDeclaration","variableDeclarator","identifier","stringLiteral","Date","now","errorMessage","state","details","pageName","filename","split","cwd","pop","nextPageConfig","visitor","Program","enter","traverse","ExportDeclaration","exportPath","exportState","isExportNamedDeclaration","node","specifiers","some","specifier","isIdentifier","exported","name","value","isStringLiteral","source","Error","ExportNamedDeclaration","bundleDropped","declaration","length","config","declarations","scope","getBinding","filter","Boolean","local","isImportSpecifier","id","init","isTSAsExpression","expression","isObjectExpression","got","type","prop","properties","isSpreadElement","key","isObjectProperty","isBooleanLiteral","amp","file","opts","caller","isDev"],"mappings":"AAAA,SAASA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