Skip to content

Commit 31bed82

Browse files
committed
fix(nx-plugin): use wildcard path imports to prevent CJS runtime errors
1 parent e324f39 commit 31bed82

File tree

8 files changed

+12
-7
lines changed

8 files changed

+12
-7
lines changed

packages/nx-plugin/eslint.config.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ module.exports = tseslint.config(
2929
'warn',
3030
{ fixMixedExportsWithInlineTypeSpecifier: true },
3131
],
32+
// `import path from 'node:path'` incompatible with CJS runtime, prefer `import * as path from 'node:path'`
33+
'unicorn/import-style': [
34+
'warn',
35+
{ styles: { 'node:path': { namespace: true } } },
36+
],
3237
},
3338
},
3439
{

packages/nx-plugin/src/executors/internal/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'node:path';
1+
import * as path from 'node:path';
22
import type { PersistConfig, UploadConfig } from '@code-pushup/models';
33
import { parseEnv } from './env.js';
44
import type {

packages/nx-plugin/src/generators/configuration/code-pushup-config.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as devKit from '@nx/devkit';
22
import { formatFiles } from '@nx/devkit';
33
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
4-
import path from 'node:path';
4+
import * as path from 'node:path';
55
import { describe, expect, it } from 'vitest';
66
import { generateCodePushupConfig } from './code-pushup-config.js';
77

packages/nx-plugin/src/generators/configuration/code-pushup-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Tree, generateFiles, logger } from '@nx/devkit';
2-
import path from 'node:path';
2+
import * as path from 'node:path';
33
import type { PersistConfig, UploadConfig } from '@code-pushup/models';
44
import type { ItemOrArray } from '@code-pushup/utils';
55
import type { ExecutableCode } from './types.js';

packages/nx-plugin/src/generators/configuration/code-pushup-config.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as devKit from '@nx/devkit';
22
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3-
import path from 'node:path';
3+
import * as path from 'node:path';
44
import { afterEach, describe, expect, it } from 'vitest';
55
import { removeColorCodes } from '@code-pushup/test-utils';
66
import {

packages/nx-plugin/src/generators/configuration/generator.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
readProjectConfiguration,
66
} from '@nx/devkit';
77
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
8-
import path from 'node:path';
8+
import * as path from 'node:path';
99
import { afterEach, describe, expect, it, vi } from 'vitest';
1010
import { DEFAULT_TARGET_NAME, PACKAGE_NAME } from '../../internal/constants.js';
1111
import { addTargetToProject, configurationGenerator } from './generator.js';

packages/nx-plugin/src/internal/versions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readJsonFile } from '@nx/devkit';
2-
import path from 'node:path';
2+
import * as path from 'node:path';
33
import type { PackageJson } from 'nx/src/utils/package-json';
44

55
const workspaceRoot = path.join(__dirname, '../../');

packages/nx-plugin/src/plugin/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CreateNodesContext } from '@nx/devkit';
22
import { readFile } from 'node:fs/promises';
3-
import path from 'node:path';
3+
import * as path from 'node:path';
44
import { CP_TARGET_NAME } from './constants.js';
55
import type {
66
CreateNodesOptions,

0 commit comments

Comments
 (0)