challenge-algorithms-v2.0-u.../node_modules/@babel/helper-module-transforms/lib/get-module-name.js.map

1 line
3.6 KiB
Plaintext
Raw Normal View History

{"version":3,"names":["originalGetModuleName","getModuleName","rootOpts","pluginOpts","moduleId","moduleIds","getModuleId","moduleRoot","filename","filenameRelative","sourceRoot","moduleName","sourceRootReplacer","RegExp","replace"],"sources":["../src/get-module-name.ts"],"sourcesContent":["type RootOptions = {\n filename?: string;\n filenameRelative?: string;\n sourceRoot?: string;\n};\n\nexport type PluginOptions = {\n moduleId?: string;\n moduleIds?: boolean;\n getModuleId?: (moduleName: string) => string | null | undefined;\n moduleRoot?: string;\n};\n\nif (!process.env.BABEL_8_BREAKING) {\n const originalGetModuleName = getModuleName;\n\n // @ts-expect-error TS doesn't like reassigning a function.\n // eslint-disable-next-line no-func-assign\n getModuleName = function getModuleName(\n rootOpts: RootOptions & PluginOptions,\n pluginOpts: PluginOptions,\n ): string | null {\n return originalGetModuleName(rootOpts, {\n moduleId: pluginOpts.moduleId ?? rootOpts.moduleId,\n moduleIds: pluginOpts.moduleIds ?? rootOpts.moduleIds,\n getModuleId: pluginOpts.getModuleId ?? rootOpts.getModuleId,\n moduleRoot: pluginOpts.moduleRoot ?? rootOpts.moduleRoot,\n });\n };\n}\n\nexport default function getModuleName(\n rootOpts: RootOptions,\n pluginOpts: PluginOptions,\n): string | null {\n const {\n filename,\n filenameRelative = filename,\n sourceRoot = pluginOpts.moduleRoot,\n } = rootOpts;\n\n const {\n moduleId,\n moduleIds = !!moduleId,\n\n getModuleId,\n\n moduleRoot = sourceRoot,\n } = pluginOpts;\n\n if (!moduleIds) return null;\n\n // moduleId is n/a if a `getModuleId()` is provided\n if (moduleId != null && !getModuleId) {\n return moduleId;\n }\n\n let moduleName = moduleRoot != null ? moduleRoot + \"/\" : \"\";\n\n if (filenameRelative) {\n const sourceRootReplacer =\n sourceRoot != null ? new RegExp(\"^\" + sourceRoot + \"/?\") : \"\";\n\n moduleName += filenameRelative\n // remove sourceRoot from filename\n .replace(sourceRootReplacer, \"\")\n // remove extension\n .replace(/\\.(\\w*?)$/, \"\");\n }\n\n // normalize path separators\n moduleName = moduleName.replace(/\\\\/g, \"/\");\n\n if (getModuleId) {\n // If return is falsy, assume they want us to use our generated default name\n return getModuleId(moduleName) || moduleName;\n } else {\n return moduleName;\n }\n}\n"],"mappings":";;;;;;AAamC;EACjC,MAAMA,qBAAqB,GAAGC,aAA9B;;EAIA,kBAAAA,aAAa,GAAG,SAASA,aAAT,CACdC,QADc,EAEdC,UAFc,EAGC;IAAA;;IACf,OAAOH,qBAAqB,CAACE,QAAD,EAAW;MACrCE,QAAQ,0BAAED,UAAU,CAACC,QAAb,mCAAyBF,QAAQ,CAACE,QADL;MAErCC,SAAS,2BAAEF,UAAU,CAACE,SAAb,oCAA0BH,QAAQ,CAACG,SAFP;MAGrCC,WAAW,2BAAEH,UAAU,CAACG,WAAb,oCAA4BJ,QAAQ,CAACI,WAHX;MAIrCC,UAAU,2BAAEJ,UAAU,CAACI,UAAb,oCAA2BL,QAAQ,CAACK;IAJT,CAAX,CAA5B;EAMD,CAVD;AAWD;;AAEc,SAASN,aAAT,CACbC,QADa,EAEbC,UAFa,EAGE;EACf,MAAM;IACJK,QADI;IAEJC,gBAAgB,GAAGD,QAFf;IAGJE,UAAU,GAAGP,UAAU,CAACI;EAHpB,IAIFL,QAJJ;EAMA,MAAM;IACJE,QADI;IAEJC,SAAS,GAAG,CAAC,CAACD,QAFV;IAIJE,WAJI;IAMJC,UAAU,GAAGG;EANT,IAOFP,UAPJ;EASA,IAAI,CAACE,SAAL,EAAgB,OAAO,IAAP;;EAGhB,IAAID,QAAQ,IAAI,IAAZ,IAAoB,CAACE,WAAzB,EAAsC;IACpC,OAAOF,QAAP;EACD;;EAED,IAAIO,UAAU,GAAGJ,UAAU,IAAI,IAAd,GAAqBA,UAAU,GAAG,GAAlC,GAAwC,EAAzD;;EAEA,IAAIE,gBAAJ,EAAsB;IACpB,MAAMG,kBAAkB,GACtBF,UAAU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