Skip to content

Commit

Permalink
feat(core): track project changes in source map when applying plugins (
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKless committed Nov 16, 2023
1 parent 0787c0a commit 13f33ea
Show file tree
Hide file tree
Showing 6 changed files with 719 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
import { performance } from 'perf_hooks';
import { readNxJson } from '../../config/nx-json';
import {
FileData,
FileMap,
ProjectFileMap,
ProjectGraph,
ProjectGraphExternalNode,
} from '../../config/project-graph';
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
import { hashArray } from '../../hasher/file-hasher';
import { buildProjectGraphUsingProjectFileMap as buildProjectGraphUsingFileMap } from '../../project-graph/build-project-graph';
import { updateFileMap } from '../../project-graph/file-map-utils';
import {
nxProjectGraph,
FileMapCache,
nxProjectGraph,
readFileMapCache,
} from '../../project-graph/nx-deps-cache';
import { fileExists } from '../../utils/fileutils';
import { notifyFileWatcherSockets } from './file-watching/file-watcher-sockets';
import { serverLogger } from './logger';
import { workspaceRoot } from '../../utils/workspace-root';
import { execSync } from 'child_process';
import { hashArray } from '../../hasher/file-hasher';
import {
retrieveWorkspaceFiles,
retrieveProjectConfigurations,
retrieveWorkspaceFiles,
} from '../../project-graph/utils/retrieve-workspace-files';
import {
ProjectConfiguration,
ProjectsConfigurations,
} from '../../config/workspace-json-project-json';
import { readNxJson } from '../../config/nx-json';
import { fileExists } from '../../utils/fileutils';
import { writeSourceMaps } from '../../utils/source-maps';
import {
resetWorkspaceContext,
updateFilesInContext,
} from '../../utils/workspace-context';
import { workspaceRoot } from '../../utils/workspace-root';
import { notifyFileWatcherSockets } from './file-watching/file-watcher-sockets';
import { serverLogger } from './logger';

let cachedSerializedProjectGraphPromise: Promise<{
error: Error | null;
Expand Down Expand Up @@ -278,6 +274,8 @@ async function createAndSerializeProjectGraph(): Promise<{
'json-stringify-end'
);

writeSourceMaps(projectConfigurations.sourceMaps);

return {
error: null,
projectGraph,
Expand Down
12 changes: 10 additions & 2 deletions packages/nx/src/project-graph/project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { performance } from 'perf_hooks';
import { retrieveWorkspaceFiles } from './utils/retrieve-workspace-files';
import { readNxJson } from '../config/nx-json';
import { unregisterPluginTSTranspiler } from '../utils/nx-plugin';
import { writeSourceMaps } from '../utils/source-maps';

/**
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
Expand Down Expand Up @@ -77,8 +78,13 @@ export function readProjectsConfigurationFromProjectGraph(
export async function buildProjectGraphWithoutDaemon() {
const nxJson = readNxJson();

const { allWorkspaceFiles, fileMap, projectConfigurations, externalNodes } =
await retrieveWorkspaceFiles(workspaceRoot, nxJson);
const {
allWorkspaceFiles,
fileMap,
projectConfigurations,
externalNodes,
sourceMaps,
} = await retrieveWorkspaceFiles(workspaceRoot, nxJson);

const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false';
const projectGraph = (
Expand All @@ -92,6 +98,8 @@ export async function buildProjectGraphWithoutDaemon() {
)
).projectGraph;

writeSourceMaps(sourceMaps);

unregisterPluginTSTranspiler();

return projectGraph;
Expand Down

0 comments on commit 13f33ea

Please sign in to comment.