parseDependency.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // @ts-check
  2. /**
  3. * @typedef {{type: 'dependency', file: string} | {type: 'dir-dependency', dir: string, glob: string}} Dependency
  4. */ /**
  5. *
  6. * @param {import('../lib/content.js').ContentPath} contentPath
  7. * @returns {Dependency[]}
  8. */ "use strict";
  9. Object.defineProperty(exports, "__esModule", {
  10. value: true
  11. });
  12. Object.defineProperty(exports, "default", {
  13. enumerable: true,
  14. get: ()=>parseDependency
  15. });
  16. function parseDependency(contentPath) {
  17. if (contentPath.ignore) {
  18. return [];
  19. }
  20. if (!contentPath.glob) {
  21. return [
  22. {
  23. type: "dependency",
  24. file: contentPath.base
  25. }
  26. ];
  27. }
  28. if (process.env.ROLLUP_WATCH === "true") {
  29. // rollup-plugin-postcss does not support dir-dependency messages
  30. // but directories can be watched in the same way as files
  31. return [
  32. {
  33. type: "dependency",
  34. file: contentPath.base
  35. }
  36. ];
  37. }
  38. return [
  39. {
  40. type: "dir-dependency",
  41. dir: contentPath.base,
  42. glob: contentPath.glob
  43. }
  44. ];
  45. }