@nxext/stencil
Version:
Nx plugin for stenciljs
51 lines • 2.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addProject = addProject;
const devkit_1 = require("@nx/devkit");
const common_1 = require("@nxext/common");
function addProject(tree, options) {
// `test` (and `build`/`serve`/`e2e` for buildable libs) is inferred by
// `@nxext/stencil/plugin` from the presence of `stencil.config.ts`. Plain
// libraries without a stencil config get no runtime targets here — just
// project metadata + the component-generator defaults.
const generators = {
'@nxext/stencil:component': {
style: options.style,
},
};
const isBuildableOrPublishable = !!(options.buildable || options.publishable);
// Registers the project (project.json in legacy mode, package.json (+
// nx.generators) in TS-solution mode) - mirrors @nxext/svelte's own
// library/lib/add-project.ts.
(0, common_1.addProjectPackageJson)(tree, Object.assign({ projectName: options.name, projectRoot: options.projectRoot, importPath: options.importPath, isUsingTsSolutionConfig: options.isUsingTsSolutionConfig, useProjectJson: options.useProjectJson, projectType: 'library', parsedTags: options.parsedTags }, (options.isUsingTsSolutionConfig && !isBuildableOrPublishable
? {
main: './src/index.ts',
exports: {
'.': {
types: './src/index.ts',
import: './src/index.ts',
default: './src/index.ts',
},
'./package.json': './package.json',
},
}
: {})));
// Patch in the component-generator defaults directly on whichever file
// backs this project. Deliberately NOT readProjectConfiguration +
// updateProjectConfiguration - see application/lib/add-project.ts for why.
if (options.useProjectJson) {
(0, devkit_1.updateJson)(tree, `${options.projectRoot}/project.json`, (json) => {
json.generators = generators;
return json;
});
}
else {
(0, devkit_1.updateJson)(tree, `${options.projectRoot}/package.json`, (json) => {
var _a;
(_a = json.nx) !== null && _a !== void 0 ? _a : (json.nx = {});
json.nx.generators = generators;
return json;
});
}
}
//# sourceMappingURL=add-project.js.map