transform-file-browser.ts 844 B

123456789101112131415161718192021222324252627282930313233
  1. /* c8 ignore start */
  2. // duplicated from transform-file so we do not have to import anything here
  3. type TransformFile = {
  4. (filename: string, callback: (error: Error, file: null) => void): void;
  5. (
  6. filename: string,
  7. opts: any,
  8. callback: (error: Error, file: null) => void,
  9. ): void;
  10. };
  11. export const transformFile: TransformFile = function transformFile(
  12. filename,
  13. opts,
  14. callback?: (error: Error, file: null) => void,
  15. ) {
  16. if (typeof opts === "function") {
  17. callback = opts;
  18. }
  19. callback(new Error("Transforming files is not supported in browsers"), null);
  20. };
  21. export function transformFileSync(): never {
  22. throw new Error("Transforming files is not supported in browsers");
  23. }
  24. export function transformFileAsync() {
  25. return Promise.reject(
  26. new Error("Transforming files is not supported in browsers"),
  27. );
  28. }