UNPKG

1.92 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../../../build/babel/plugins/commonjs.ts"],"names":["NextToNextServer","args","commonjs","visitor","Program","exit","path","state","foundModuleExports","traverse","MemberExpression","expressionPath","node","object","name","property","call"],"mappings":"sEACA,kI,mFAEA;AACe,QAASA,CAAAA,gBAAT,CAA0B,GAAGC,IAA7B,CAAmD,CAChE,KAAMC,CAAAA,QAAQ,CAAG,4CAAe,GAAGD,IAAlB,CAAjB,CACA,MAAO,CACLE,OAAO,CAAE,CACPC,OAAO,CAAE,CACPC,IAAI,CAACC,IAAD,CAAgCC,KAAhC,CAAuC,CACzC,GAAIC,CAAAA,kBAAkB,CAAG,KAAzB,CACAF,IAAI,CAACG,QAAL,CAAc,CACZC,gBAAgB,CAACC,cAAD,CAAsB,CACpC,GAAIA,cAAc,CAACC,IAAf,CAAoBC,MAApB,CAA2BC,IAA3B,GAAoC,QAAxC,CAAkD,OAClD,GAAIH,cAAc,CAACC,IAAf,CAAoBG,QAApB,CAA6BD,IAA7B,GAAsC,SAA1C,CAAqD,OACrDN,kBAAkB,CAAG,IAArB,CACD,CALW,CAAd,EAQA,GAAI,CAACA,kBAAL,CAAyB,CACvB,OACD,CAEDN,QAAQ,CAACC,OAAT,CAAiBC,OAAjB,CAAyBC,IAAzB,CAA8BW,IAA9B,CAAmC,IAAnC,CAAyCV,IAAzC,CAA+CC,KAA/C,EACD,CAhBM,CADF,CADJ,CAAP,CAsBD","sourcesContent":["import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core'\nimport commonjsPlugin from 'next/dist/compiled/babel/plugin-transform-modules-commonjs'\n\n// Rewrite imports using next/<something> to next-server/<something>\nexport default function NextToNextServer(...args: any): PluginObj {\n const commonjs = commonjsPlugin(...args)\n return {\n visitor: {\n Program: {\n exit(path: NodePath<types.Program>, state) {\n let foundModuleExports = false\n path.traverse({\n MemberExpression(expressionPath: any) {\n if (expressionPath.node.object.name !== 'module') return\n if (expressionPath.node.property.name !== 'exports') return\n foundModuleExports = true\n },\n })\n\n if (!foundModuleExports) {\n return\n }\n\n commonjs.visitor.Program.exit.call(this, path, state)\n },\n },\n },\n }\n}\n"]}
\No newline at end of file