Skip to content

Commit

Permalink
feat(core): cache executor information resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Aug 10, 2023
1 parent 721e4df commit 0cfd8af
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 47 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"@nx/storybook": "16.7.0-beta.3",
"@nx/web": "16.7.0-beta.3",
"@nx/webpack": "16.7.0-beta.3",
"@nx/esbuild": "16.7.0-beta.3",
"@nx/angular": "16.7.0-beta.3",
"@parcel/watcher": "2.0.4",
"@phenomnomnominal/tsquery": "~5.0.1",
"@playwright/test": "^1.36.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
"dependsOn": ["build-ng", "build-base", "^build"],
"options": {
"commands": [
{
"command": "node ./scripts/copy-readme.js angular"
},
"node ./scripts/copy-readme.js angular",
"node ./scripts/add-dependency-to-build.js angular @nrwl/angular"
],
"parallel": false
Expand Down
1 change: 1 addition & 0 deletions packages/nx/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"buildTargets": ["build-base"],
"ignoredDependencies": [
"typescript",
"@nrwl/angular",
"@angular-devkit/build-angular",
"@angular-devkit/core",
"@angular-devkit/architect",
Expand Down
18 changes: 15 additions & 3 deletions packages/nx/src/command-line/run/executor-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ export function normalizeExecutorSchema(
};
}

function cacheKey(nodeModule: string, executor: string, root: string) {
return `${root}:${nodeModule}:${executor}`;
}

const cachedExecutorInformation = {};

export function getExecutorInformation(
nodeModule: string,
executor: string,
root: string
): ExecutorConfig & { isNgCompat: boolean; isNxExecutor: boolean } {
try {
const { executorsFilePath, executorConfig, isNgCompat } = readExecutorsJson(
const key = cacheKey(nodeModule, executor, root);
if (cachedExecutorInformation[key]) return cachedExecutorInformation[key];

const { executorsFilePath, executorConfig, isNgCompat } = readExecutorJson(
nodeModule,
executor,
root
Expand Down Expand Up @@ -65,22 +74,25 @@ export function getExecutorInformation(
)
: null;

return {
const res = {
schema,
implementationFactory,
batchImplementationFactory,
hasherFactory,
isNgCompat,
isNxExecutor: !isNgCompat,
};

cachedExecutorInformation[key] = res;
return res;
} catch (e) {
throw new Error(
`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`
);
}
}

function readExecutorsJson(
function readExecutorJson(
nodeModule: string,
executor: string,
root: string
Expand Down
216 changes: 175 additions & 41 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 0cfd8af

@vercel
Copy link

@vercel vercel bot commented on 0cfd8af Aug 10, 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-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.