Skip to content

Commit

Permalink
fix(misc): misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed May 15, 2022
1 parent c0d1591 commit e6f73a8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
32 changes: 32 additions & 0 deletions notes.txt
@@ -0,0 +1,32 @@



1. nx build web (find the set of tasks it needs to run)
2. for each task it will compute the hash
3. it checks if the outputs are already in the right place
4. it checks the cache (local and then remote)
5. run it and store it the cache
6. Nx Cloud provides remote caching


Use static serve to max cache hits:
nx serve myapp (they run webpack-dev-server)
nx serve-static myapp (build + http-server dist)

Imagine you don't have serve-static:
nx affected --target=build & nx affected --target=e2e

If you have static serve:
nx affected --target=build && nx affected --target=e2e
nx affected --target=e2e (where e2e has a dependOn on static-serve/build)

Your case is perfect for caching :)


Distribution is the only way to make your CI really fast consistenlty.






15 changes: 10 additions & 5 deletions packages/add-nx-to-monorepo/src/add-nx-to-monorepo.ts
Expand Up @@ -187,10 +187,8 @@ function detectWorkspaceScope(repoRoot: string) {
}

function createNxJsonFile(repoRoot: string) {
const scope = detectWorkspaceScope(repoRoot);
const res = {
extends: 'nx/presets/npm.json',
npmScope: scope,
tasksRunnerOptions: {
default: {
runner: 'nx/tasks-runners/default',
Expand Down Expand Up @@ -252,12 +250,19 @@ function deduceDefaultBase() {
return 'dev';
} catch (e) {
try {
execSync(`git rev-parse --verify next`, {
execSync(`git rev-parse --verify develop`, {
stdio: ['ignore', 'ignore', 'ignore'],
});
return 'next';
return 'develop';
} catch (e) {
return 'master';
try {
execSync(`git rev-parse --verify next`, {
stdio: ['ignore', 'ignore', 'ignore'],
});
return 'next';
} catch (e) {
return 'master';
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions packages/nx/src/project-graph/build-nodes/workspace-projects.ts
Expand Up @@ -8,6 +8,8 @@ import {
import { ProjectGraphProcessorContext } from 'nx/src/config/project-graph';
import { mergeNpmScriptsWithTargets } from 'nx/src/utils/project-graph-utils';
import { ProjectGraphBuilder } from '../project-graph-builder';
import { PackageJson } from 'nx/src/utils/package-json';
import { readJsonFile } from 'nx/src/utils/fileutils';

export function buildWorkspaceProjectNodes(
ctx: ProjectGraphProcessorContext,
Expand All @@ -19,6 +21,19 @@ export function buildWorkspaceProjectNodes(
const projectRoot = join(workspaceRoot, p.root);
if (existsSync(join(projectRoot, 'package.json'))) {
p.targets = mergeNpmScriptsWithTargets(projectRoot, p.targets);

const { nx }: PackageJson = readJsonFile(
join(projectRoot, 'package.json')
);
if (nx?.tags) {
p.tags = [...(p.tags || []), ...nx.tags];
}
if (nx?.implicitDependencies) {
p.implicitDependencies = [
...(p.implicitDependencies || []),
...nx.implicitDependencies,
];
}
}
p.targets = mergePluginTargetsWithNxTargets(
p.root,
Expand Down
2 changes: 2 additions & 0 deletions packages/nx/src/utils/package-json.ts
Expand Up @@ -6,6 +6,8 @@ export type PackageJsonTargetConfiguration = Omit<
>;

export interface NxProjectPackageJsonConfiguration {
implicitDependencies?: string[];
tags?: string[];
targets?: Record<string, PackageJsonTargetConfiguration>;
}

Expand Down

1 comment on commit e6f73a8

@vercel
Copy link

@vercel vercel bot commented on e6f73a8 May 15, 2022

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.