cjs-proxy.cjs 632 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. const babelP = import("./lib/index.js");
  3. const functionNames = [
  4. "createConfigItem",
  5. "loadPartialConfig",
  6. "loadOptions",
  7. "transform",
  8. "transformFile",
  9. "transformFromAst",
  10. "parse",
  11. ];
  12. for (const name of functionNames) {
  13. exports[`${name}Sync`] = function () {
  14. throw new Error(
  15. `"${name}Sync" is not supported when loading @babel/core using require()`
  16. );
  17. };
  18. exports[name] = function (...args) {
  19. babelP.then(babel => {
  20. babel[name](...args);
  21. });
  22. };
  23. exports[`${name}Async`] = function (...args) {
  24. return babelP.then(babel => babel[`${name}Async`](...args));
  25. };
  26. }