Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): track project changes in source map when applying plugins #19955

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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