@nx-plugins/vite
Version:
The Nx Plugin for Vite that contains executors, generators, and utilities for managing Vite applications and libraries within an Nx workspace.
21 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addExportsToBarrel = void 0;
const devkit_1 = require("@nrwl/devkit");
const ts = require("typescript");
const utils_1 = require("../../../utils");
function addExportsToBarrel(host, options) {
const workspace = (0, devkit_1.getProjects)(host);
const isApp = workspace.get(options.project).projectType === 'application';
if (options.export && !isApp) {
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
const indexSource = host.read(indexFilePath, 'utf-8');
if (indexSource !== null) {
const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, utils_1.addImport)(indexSourceFile, `export * from './${options.directoryFormatted}/${options.fileName}';`));
host.write(indexFilePath, changes);
}
}
}
exports.addExportsToBarrel = addExportsToBarrel;
//# sourceMappingURL=add-exports-barrel.js.map