Skip to content

Commit

Permalink
fix(js): generate correct standalone setup (#18355)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo authored Jul 27, 2023
1 parent 9aad21d commit 4c2f98e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export async function addLint(
options: NormalizedSchema
): Promise<GeneratorCallback> {
const { lintProjectGenerator } = ensurePackage('@nx/linter', nxVersion);
return lintProjectGenerator(tree, {
const task = lintProjectGenerator(tree, {
project: options.name,
linter: options.linter,
skipFormat: true,
Expand All @@ -252,6 +252,22 @@ export async function addLint(
setParserOptionsProject: options.setParserOptionsProject,
rootProject: options.rootProject,
});
// Also update the root .eslintrc.json lintProjectGenerator will not generate it for root projects.
// But we need to set the package.json checks.
if (options.rootProject) {
updateJson(tree, '.eslintrc.json', (json) => {
json.overrides ??= [];
json.overrides.push({
files: ['*.json'],
parser: 'jsonc-eslint-parser',
rules: {
'@nx/dependency-checks': 'error',
},
});
return json;
});
}
return task;
}

function addBundlerDependencies(tree: Tree, options: NormalizedSchema) {
Expand Down Expand Up @@ -351,8 +367,8 @@ function createFiles(tree: Tree, options: NormalizedSchema, filesDir: string) {
updateJson<PackageJson>(tree, packageJsonPath, (json) => {
json.name = options.importPath;
json.version = '0.0.1';
// If the package is publishable, we should remove the private field.
if (json.private && options.publishable) {
// If the package is publishable or root/standalone, we should remove the private field.
if (json.private && (options.publishable || options.rootProject)) {
delete json.private;
}
return {
Expand Down

1 comment on commit 4c2f98e

@vercel
Copy link

@vercel vercel bot commented on 4c2f98e Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.