UNPKG

1.05 kBJavaScriptView Raw
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.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.ExportStringRef = void 0;
11const path_1 = require("path");
12class ExportStringRef {
13 constructor(ref, parentPath = process.cwd(), inner = true) {
14 const [path, name] = ref.split('#', 2);
15 this._module = path[0] == '.' ? (0, path_1.resolve)(parentPath, path) : path;
16 this._module = require.resolve(this._module);
17 this._path = (0, path_1.dirname)(this._module);
18 if (inner) {
19 this._ref = require(this._module)[name || 'default'];
20 }
21 else {
22 this._ref = require(this._module);
23 }
24 }
25 get ref() {
26 return this._ref;
27 }
28 get module() {
29 return this._module;
30 }
31 get path() {
32 return this._path;
33 }
34}
35exports.ExportStringRef = ExportStringRef;