UNPKG

2.89 kBSource Map (JSON)View Raw
1{"version":3,"names":["transformFileRunner","gensync","filename","opts","options","config","loadConfig","code","fs","readFile","run","transformFile","args","errback","transformFileSync","sync","transformFileAsync","async"],"sources":["../src/transform-file.ts"],"sourcesContent":["import gensync, { type Handler } from \"gensync\";\n\nimport loadConfig from \"./config\";\nimport type { InputOptions, ResolvedConfig } from \"./config\";\nimport { run } from \"./transformation\";\nimport type { FileResult, FileResultCallback } from \"./transformation\";\nimport * as fs from \"./gensync-utils/fs\";\n\ntype transformFileBrowserType = typeof import(\"./transform-file-browser\");\ntype transformFileType = typeof import(\"./transform-file\");\n\n// Kind of gross, but essentially asserting that the exports of this module are the same as the\n// exports of transform-file-browser, since this file may be replaced at bundle time with\n// transform-file-browser.\n({} as any as transformFileBrowserType as transformFileType);\n\nconst transformFileRunner = gensync(function* (\n filename: string,\n opts?: InputOptions,\n): Handler<FileResult | null> {\n const options = { ...opts, filename };\n\n const config: ResolvedConfig | null = yield* loadConfig(options);\n if (config === null) return null;\n\n const code = yield* fs.readFile(filename, \"utf8\");\n return yield* run(config, code);\n});\n\n// @ts-expect-error TS doesn't detect that this signature is compatible\nexport function transformFile(\n filename: string,\n callback: FileResultCallback,\n): void;\nexport function transformFile(\n filename: string,\n opts: InputOptions | undefined | null,\n callback: FileResultCallback,\n): void;\nexport function transformFile(\n ...args: Parameters<typeof transformFileRunner.errback>\n) {\n return transformFileRunner.errback(...args);\n}\n\nexport function transformFileSync(\n ...args: Parameters<typeof transformFileRunner.sync>\n) {\n return transformFileRunner.sync(...args);\n}\nexport function transformFileAsync(\n ...args: Parameters<typeof transformFileRunner.async>\n) {\n return transformFileRunner.async(...args);\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AAEA;AAEA;AAQA,CAAC,CAAC,CAAC;AAEH,MAAMA,mBAAmB,GAAGC,UAAO,CAAC,WAClCC,QAAgB,EAChBC,IAAmB,EACS;EAC5B,MAAMC,OAAO,qBAAQD,IAAI;IAAED;EAAQ,EAAE;EAErC,MAAMG,MAA6B,GAAG,OAAO,IAAAC,eAAU,EAACF,OAAO,CAAC;EAChE,IAAIC,MAAM,KAAK,IAAI,EAAE,OAAO,IAAI;EAEhC,MAAME,IAAI,GAAG,OAAOC,EAAE,CAACC,QAAQ,CAACP,QAAQ,EAAE,MAAM,CAAC;EACjD,OAAO,OAAO,IAAAQ,mBAAG,EAACL,MAAM,EAAEE,IAAI,CAAC;AACjC,CAAC,CAAC;AAYK,SAASI,aAAa,CAC3B,GAAGC,IAAoD,EACvD;EACA,OAAOZ,mBAAmB,CAACa,OAAO,CAAC,GAAGD,IAAI,CAAC;AAC7C;AAEO,SAASE,iBAAiB,CAC/B,GAAGF,IAAiD,EACpD;EACA,OAAOZ,mBAAmB,CAACe,IAAI,CAAC,GAAGH,IAAI,CAAC;AAC1C;AACO,SAASI,kBAAkB,CAChC,GAAGJ,IAAkD,EACrD;EACA,OAAOZ,mBAAmB,CAACiB,KAAK,CAAC,GAAGL,IAAI,CAAC;AAC3C;AAAC"}
\No newline at end of file