export-ref.js 971 B

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