/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/react-loadable-plugin.js.map (12655B)
{"version":3,"sources":["../../../../src/build/babel/plugins/react-loadable-plugin.ts"],"sourcesContent":["/**\nCOPYRIGHT (c) 2017-present James Kyle \n MIT License\n Permission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n The above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR\n*/\n// This file is https://github.com/jamiebuilds/react-loadable/blob/master/src/babel.js\n// - Modified to also look for `next/dynamic`\n// - Modified to put `webpack` and `modules` under `loadableGenerated` to be\n// backwards compatible with next/dynamic which has a `modules` key\n// - Modified to support `dynamic(import('something'))` and\n// `dynamic(import('something'), options)\n// - Removed `Loadable.Map` support, `next/dynamic` uses overloaded arguments\n// instead of a separate API\n\nimport type {\n NodePath,\n types as BabelTypes,\n} from 'next/dist/compiled/babel/core'\nimport type { PluginObj } from 'next/dist/compiled/babel/core'\n\nimport { relative as relativePath } from 'path'\n\nexport default function ({\n types: t,\n}: {\n types: typeof BabelTypes\n}): PluginObj {\n return {\n visitor: {\n ImportDeclaration(\n path: NodePath,\n state: any\n ) {\n let source = path.node.source.value\n if (source !== 'next/dynamic') return\n\n let defaultSpecifier = path.get('specifiers').find((specifier) => {\n return specifier.isImportDefaultSpecifier()\n })\n\n if (!defaultSpecifier) return\n\n const bindingName = defaultSpecifier.node.local.name\n const binding = path.scope.getBinding(bindingName)\n\n if (!binding) {\n return\n }\n\n binding.referencePaths.forEach((refPath) => {\n let callExpression = refPath.parentPath\n if (!callExpression?.isCallExpression()) return\n\n let args = callExpression.get('arguments')\n if (args.length > 2) {\n throw callExpression.buildCodeFrameError(\n 'next/dynamic only accepts 2 arguments'\n )\n }\n\n if (!args[0]) {\n return\n }\n\n let loader\n let options\n\n if (args[0].isObjectExpression()) {\n options = args[0]\n } else {\n if (!args[1]) {\n callExpression.node.arguments.push(t.objectExpression([]))\n }\n // This is needed as the code is modified above\n args = callExpression.get('arguments')\n loader = args[0]\n options = args[1]\n }\n\n if (!options.isObjectExpression()) return\n const options_ = options as NodePath\n\n let properties = options_.get('properties')\n let propertiesMap: {\n [key: string]: NodePath<\n | BabelTypes.ObjectProperty\n | BabelTypes.ObjectMethod\n | BabelTypes.SpreadElement\n | BabelTypes.BooleanLiteral\n >\n } = {}\n\n properties.forEach((property) => {\n const key: any = property.get('key')\n propertiesMap[key.node.name] = property\n })\n\n if (propertiesMap.loadableGenerated) {\n return\n }\n\n if (propertiesMap.loader) {\n loader = propertiesMap.loader.get('value')\n }\n\n if (propertiesMap.modules) {\n loader = propertiesMap.modules.get('value')\n }\n\n if (!loader || Array.isArray(loader)) {\n return\n }\n const dynamicImports: BabelTypes.Expression[] = []\n const dynamicKeys: BabelTypes.Expression[] = []\n\n if (propertiesMap.ssr) {\n const ssr = propertiesMap.ssr.get('value')\n const nodePath = Array.isArray(ssr) ? undefined : ssr\n\n if (nodePath) {\n const nonSSR =\n nodePath.node.type === 'BooleanLiteral' &&\n nodePath.node.value === false\n // If `ssr` is set to `false`, erase the loader for server side\n if (nonSSR && loader && state.file.opts.caller?.isServer) {\n loader.replaceWith(\n t.arrowFunctionExpression([], t.nullLiteral(), true)\n )\n }\n }\n }\n\n loader.traverse({\n Import(importPath) {\n const importArguments = importPath.parentPath.get('arguments')\n if (!Array.isArray(importArguments)) return\n const node: any = importArguments[0].node\n dynamicImports.push(node)\n dynamicKeys.push(\n t.binaryExpression(\n '+',\n t.stringLiteral(\n (state.file.opts.caller?.srcDir\n ? relativePath(\n state.file.opts.caller.srcDir,\n state.file.opts.filename\n )\n : state.file.opts.filename) + ' -> '\n ),\n node\n )\n )\n },\n })\n\n if (!dynamicImports.length) return\n\n options.node.properties.push(\n t.objectProperty(\n t.identifier('loadableGenerated'),\n t.objectExpression(\n state.file.opts.caller?.isDev ||\n state.file.opts.caller?.isServer\n ? [\n t.objectProperty(\n t.identifier('modules'),\n t.arrayExpression(dynamicKeys)\n ),\n ]\n : [\n t.objectProperty(\n t.identifier('webpack'),\n t.arrowFunctionExpression(\n [],\n t.arrayExpression(\n dynamicImports.map((dynamicImport) => {\n return t.callExpression(\n t.memberExpression(\n t.identifier('require'),\n t.identifier('resolveWeak')\n ),\n [dynamicImport]\n )\n })\n )\n )\n ),\n ]\n )\n )\n )\n\n // Turns `dynamic(import('something'))` into `dynamic(() => import('something'))` for backwards compat.\n // This is the replicate the behavior in versions below Next.js 7 where we magically handled not executing the `import()` too.\n // We'll deprecate this behavior and provide a codemod for it in 7.1.\n if (loader.isCallExpression()) {\n const arrowFunction = t.arrowFunctionExpression([], loader.node)\n loader.replaceWith(arrowFunction)\n }\n })\n },\n },\n }\n}\n"],"names":["relative","relativePath","types","t","visitor","ImportDeclaration","path","state","source","node","value","defaultSpecifier","get","find","specifier","isImportDefaultSpecifier","bindingName","local","name","binding","scope","getBinding","referencePaths","forEach","refPath","callExpression","parentPath","isCallExpression","args","length","buildCodeFrameError","loader","options","isObjectExpression","arguments","push","objectExpression","options_","properties","propertiesMap","property","key","loadableGenerated","modules","Array","isArray","dynamicImports","dynamicKeys","ssr","nodePath","undefined","nonSSR","type","file","opts","caller","isServer","replaceWith","arrowFunctionExpression","nullLiteral","traverse","Import","importPath","importArguments","binaryExpression","stringLiteral","srcDir","filename","objectProperty","identifier","isDev","arrayExpression","map","dynamicImport","memberExpression","arrowFunction"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;AAmBA,GACA,sFAAsF;AACtF,6CAA6C;AAC7C,4EAA4E;AAC5E,qEAAqE;AACrE,2DAA2D;AAC3D,2CAA2C;AAC3C,6EAA6E;AAC7E,8BAA8B;AAQ9B,SAASA,YAAYC,YAAY,QAAQ,OAAM;AAE/C,eAAe,SAAU,EACvBC,OAAOC,CAAC,EAGT;IACC,OAAO;QACLC,SAAS;YACPC,mBACEC,IAA4C,EAC5CC,KAAU;gBAEV,IAAIC,SAASF,KAAKG,IAAI,CAACD,MAAM,CAACE,KAAK;gBACnC,IAAIF,WAAW,gBAAgB;gBAE/B,IAAIG,mBAAmBL,KAAKM,GAAG,CAAC,cAAcC,IAAI,CAAC,CAACC;oBAClD,OAAOA,UAAUC,wBAAwB;gBAC3C;gBAEA,IAAI,CAACJ,kBAAkB;gBAEvB,MAAMK,cAAcL,iBAAiBF,IAAI,CAACQ,KAAK,CAACC,IAAI;gBACpD,MAAMC,UAAUb,KAAKc,KAA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