@nxext/stencil
Version:
Nx plugin for stenciljs
43 lines • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateTsConfig = updateTsConfig;
const devkit_1 = require("@nx/devkit");
const js_1 = require("@nx/js");
const common_1 = require("@nxext/common");
const generator_1 = require("../../storybook-configuration/generator");
function updateTsConfig(host, options) {
// TS-solution mode never writes a `paths` entry (Design 1.6): cross-project
// resolution happens via package-manager workspace symlinks + project
// references instead - see `wireTsSolutionProject`/`maybeAddTsConfigPath`
// in `@nxext/common`. `getRootTsConfigPathInTree` still resolves to
// `tsconfig.base.json` in both modes, but only the legacy mode wants this
// function's writes.
if ((0, common_1.isUsingTsSolutionSetup)(host)) {
return;
}
(0, devkit_1.updateJson)(host, (0, js_1.getRootTsConfigPathInTree)(host), (json) => {
const c = json.compilerOptions;
const tsBasePathKey = options.importPath || (0, generator_1.getProjectTsImportPath)(host, options.name);
// Project-Crystal-inferred builds run Stencil's CLI directly with no Nx
// rootDir override, so all output targets (see make-lib-buildable.ts)
// resolve relative to the project's own root (`options.projectRoot`),
// not a `dist/libs/<lib>` workspace-level convention - the previous
// hardcoded `dist/libs/${options.name}` ignored `options.projectRoot`
// entirely (pre-existing bug, unrelated to TS-solution, fixed here).
delete c.paths[`${tsBasePathKey}`];
c.paths[`${tsBasePathKey}`] = [`${options.projectRoot}/dist`];
// Point at the concrete entry file, not the bare directory: the loader
// output has no package.json, so Vite/Rollup's ESM resolution (unlike
// Node's CJS require()) won't imply `/index.js` for a directory import.
delete c.paths[`${tsBasePathKey}/loader`];
c.paths[`${tsBasePathKey}/loader`] = [
`${options.projectRoot}/loader/index.js`,
];
delete c.paths[`${tsBasePathKey}/*`];
c.paths[`${tsBasePathKey}/*`] = [
`${options.projectRoot}/dist/components/*`,
];
return json;
});
}
//# sourceMappingURL=update-tsconfig.js.map