@nx/remix
Version:
73 lines (72 loc) • 2.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.remixLibraryGenerator = remixLibraryGenerator;
exports.remixLibraryGeneratorInternal = remixLibraryGeneratorInternal;
const devkit_1 = require("@nx/devkit");
const js_1 = require("@nx/js");
const react_1 = require("@nx/react");
const lib_1 = require("./lib");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
const update_dependencies_1 = require("../utils/update-dependencies");
async function remixLibraryGenerator(tree, schema) {
return remixLibraryGeneratorInternal(tree, {
addPlugin: false,
useProjectJson: true,
...schema,
});
}
async function remixLibraryGeneratorInternal(tree, schema) {
const tasks = [];
const addTsPlugin = (0, ts_solution_setup_1.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin);
const installTask = (0, update_dependencies_1.updateDependencies)(tree);
tasks.push(installTask);
const jsInitTask = await (0, js_1.initGenerator)(tree, {
js: schema.js,
addTsPlugin,
skipFormat: true,
});
tasks.push(jsInitTask);
const options = await (0, lib_1.normalizeOptions)(tree, schema);
if (options.isUsingTsSolutionConfig) {
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
}
const libGenTask = await (0, react_1.libraryGenerator)(tree, {
directory: options.directory,
name: options.name,
style: options.style,
unitTestRunner: options.unitTestRunner,
tags: options.tags,
importPath: options.importPath,
skipFormat: true,
skipTsConfig: false,
linter: options.linter,
component: true,
buildable: options.buildable,
bundler: options.bundler,
addPlugin: options.addPlugin,
useProjectJson: options.useProjectJson,
});
tasks.push(libGenTask);
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
const pkgInstallTask = (0, lib_1.addUnitTestingSetup)(tree, options);
tasks.push(pkgInstallTask);
}
(0, lib_1.addTsconfigEntryPoints)(tree, options);
if (options.bundler === 'rollup' || options.buildable) {
(0, lib_1.updateBuildableConfig)(tree, options);
}
(0, ts_solution_setup_1.updateTsconfigFiles)(tree, options.projectRoot, 'tsconfig.lib.json', {
jsx: 'react-jsx',
module: 'esnext',
moduleResolution: 'bundler',
}, options.linter === 'eslint'
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
: undefined);
(0, sort_fields_1.sortPackageJsonFields)(tree, options.projectRoot);
if (!options.skipFormat) {
await (0, devkit_1.formatFiles)(tree);
}
return (0, devkit_1.runTasksInSerial)(...tasks);
}
exports.default = remixLibraryGenerator;