@nxext/stencil
Version:
Nx plugin for stenciljs
54 lines • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addProject = addProject;
const devkit_1 = require("@nx/devkit");
const common_1 = require("@nxext/common");
const targets_1 = require("../../../utils/targets");
const stencil_core_utils_1 = require("../../../stencil-core-utils");
const path_1 = require("path");
function addProject(host, options) {
const targets = (0, targets_1.getDefaultTargets)('application', options);
const generators = {
'@nxext/stencil:component': {
style: options.style,
},
};
// Registers the project (project.json in legacy mode, package.json (+
// nx.targets/nx.generators) in TS-solution mode) - mirrors
// @nxext/svelte's own application/lib/add-project.ts 1:1.
(0, common_1.addProjectPackageJson)(host, {
projectName: options.name,
projectRoot: options.projectRoot,
importPath: options.importPath,
isUsingTsSolutionConfig: options.isUsingTsSolutionConfig,
useProjectJson: options.useProjectJson,
projectType: 'application',
parsedTags: options.parsedTags,
});
// Patch in the real lint target + component-generator defaults directly
// on whichever file backs this project. Deliberately NOT
// readProjectConfiguration + updateProjectConfiguration: their
// project-graph discovery for package.json-backed (TS-solution) projects
// depends on the pnpm-workspace.yaml registration that only happens
// later (wireTsSolutionProject, called once the runtime tsconfig.app.json
// exists - see generator.ts) - calling them this early throws "Cannot
// find configuration for '<name>'".
if (options.useProjectJson) {
(0, devkit_1.updateJson)(host, `${options.projectRoot}/project.json`, (json) => {
json.targets = targets;
json.generators = generators;
return json;
});
}
else {
(0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
var _a;
(_a = json.nx) !== null && _a !== void 0 ? _a : (json.nx = {});
json.nx.targets = targets;
json.nx.generators = generators;
return json;
});
}
(0, stencil_core_utils_1.addStylePluginToConfig)(host, (0, path_1.join)(options.projectRoot, 'stencil.config.ts'), options.style);
}
//# sourceMappingURL=add-project.js.map