diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000000000..cffd7f77d40aa --- /dev/null +++ b/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. + + + + + + diff --git a/packages/add-nx-to-monorepo/src/add-nx-to-monorepo.ts b/packages/add-nx-to-monorepo/src/add-nx-to-monorepo.ts index 3e0e017155333..44f7cf333393f 100644 --- a/packages/add-nx-to-monorepo/src/add-nx-to-monorepo.ts +++ b/packages/add-nx-to-monorepo/src/add-nx-to-monorepo.ts @@ -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', @@ -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'; + } } } } diff --git a/packages/nx/src/project-graph/build-nodes/workspace-projects.ts b/packages/nx/src/project-graph/build-nodes/workspace-projects.ts index 673bc089efc76..b4014daecd910 100644 --- a/packages/nx/src/project-graph/build-nodes/workspace-projects.ts +++ b/packages/nx/src/project-graph/build-nodes/workspace-projects.ts @@ -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, @@ -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, diff --git a/packages/nx/src/utils/package-json.ts b/packages/nx/src/utils/package-json.ts index cec3395bdf0ef..d9381dfc79961 100644 --- a/packages/nx/src/utils/package-json.ts +++ b/packages/nx/src/utils/package-json.ts @@ -6,6 +6,8 @@ export type PackageJsonTargetConfiguration = Omit< >; export interface NxProjectPackageJsonConfiguration { + implicitDependencies?: string[]; + tags?: string[]; targets?: Record; }