parseDependency.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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: function() {
  15. return parseDependency;
  16. }
  17. });
  18. function parseDependency(contentPath) {
  19. if (contentPath.ignore) {
  20. return [];
  21. }
  22. if (!contentPath.glob) {
  23. return [
  24. {
  25. type: "dependency",
  26. file: contentPath.base
  27. }
  28. ];
  29. }
  30. if (process.env.ROLLUP_WATCH === "true") {
  31. // rollup-plugin-postcss does not support dir-dependency messages
  32. // but directories can be watched in the same way as files
  33. return [
  34. {
  35. type: "dependency",
  36. file: contentPath.base
  37. }
  38. ];
  39. }
  40. return [
  41. {
  42. type: "dir-dependency",
  43. dir: contentPath.base,
  44. glob: contentPath.glob
  45. }
  46. ];
  47. }