export-ref.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright Google LLC All Rights Reserved.
  5. *
  6. * Use of this source code is governed by an MIT-style license that can be
  7. * found in the LICENSE file at https://angular.dev/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. exports.ExportStringRef = void 0;
  11. const path_1 = require("path");
  12. class ExportStringRef {
  13. _ref;
  14. _module;
  15. _path;
  16. constructor(ref, parentPath = process.cwd(), inner = true) {
  17. const [path, name] = ref.split('#', 2);
  18. this._module = path[0] == '.' ? (0, path_1.resolve)(parentPath, path) : path;
  19. this._module = require.resolve(this._module);
  20. this._path = (0, path_1.dirname)(this._module);
  21. if (inner) {
  22. this._ref = require(this._module)[name || 'default'];
  23. }
  24. else {
  25. this._ref = require(this._module);
  26. }
  27. }
  28. get ref() {
  29. return this._ref;
  30. }
  31. get module() {
  32. return this._module;
  33. }
  34. get path() {
  35. return this._path;
  36. }
  37. }
  38. exports.ExportStringRef = ExportStringRef;