Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = splitExportDeclaration;
  6. var t = require("@babel/types");
  7. function splitExportDeclaration(exportDeclaration) {
  8. if (!exportDeclaration.isExportDeclaration()) {
  9. throw new Error("Only export declarations can be split.");
  10. }
  11. const isDefault = exportDeclaration.isExportDefaultDeclaration();
  12. const declaration = exportDeclaration.get("declaration");
  13. const isClassDeclaration = declaration.isClassDeclaration();
  14. if (isDefault) {
  15. const standaloneDeclaration = declaration.isFunctionDeclaration() || isClassDeclaration;
  16. const scope = declaration.isScope() ? declaration.scope.parent : declaration.scope;
  17. let id = declaration.node.id;
  18. let needBindingRegistration = false;
  19. if (!id) {
  20. needBindingRegistration = true;
  21. id = scope.generateUidIdentifier("default");
  22. if (standaloneDeclaration || declaration.isFunctionExpression() || declaration.isClassExpression()) {
  23. declaration.node.id = t.cloneNode(id);
  24. }
  25. }
  26. const updatedDeclaration = standaloneDeclaration ? declaration : t.variableDeclaration("var", [t.variableDeclarator(t.cloneNode(id), declaration.node)]);
  27. const updatedExportDeclaration = t.exportNamedDeclaration(null, [t.exportSpecifier(t.cloneNode(id), t.identifier("default"))]);
  28. exportDeclaration.insertAfter(updatedExportDeclaration);
  29. exportDeclaration.replaceWith(updatedDeclaration);
  30. if (needBindingRegistration) {
  31. scope.registerDeclaration(exportDeclaration);
  32. }
  33. return exportDeclaration;
  34. }
  35. if (exportDeclaration.get("specifiers").length > 0) {
  36. throw new Error("It doesn't make sense to split exported specifiers.");
  37. }
  38. const bindingIdentifiers = declaration.getOuterBindingIdentifiers();
  39. const specifiers = Object.keys(bindingIdentifiers).map(name => {
  40. return t.exportSpecifier(t.identifier(name), t.identifier(name));
  41. });
  42. const aliasDeclar = t.exportNamedDeclaration(null, specifiers);
  43. exportDeclaration.insertAfter(aliasDeclar);
  44. exportDeclaration.replaceWith(declaration.node);
  45. return exportDeclaration;
  46. }