@nx/playwright 22.7.0-pr.35019.f500fd7 → 22.7.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/playwright",
3
- "version": "22.7.0-pr.35019.f500fd7",
3
+ "version": "22.7.0-rc.0",
4
4
  "type": "commonjs",
5
5
  "homepage": "https://nx.dev",
6
6
  "private": false,
@@ -22,7 +22,7 @@
22
22
  "Front-end"
23
23
  ],
24
24
  "main": "./index.js",
25
- "typings": "./index.d.ts",
25
+ "types": "./index.d.ts",
26
26
  "author": "Victor Savkin",
27
27
  "license": "MIT",
28
28
  "bugs": {
@@ -34,14 +34,14 @@
34
34
  "directory": "packages/playwright"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "22.7.0-pr.35019.f500fd7",
38
- "@nx/eslint": "22.7.0-pr.35019.f500fd7",
39
- "@nx/js": "22.7.0-pr.35019.f500fd7",
37
+ "@nx/devkit": "22.7.0-rc.0",
38
+ "@nx/eslint": "22.7.0-rc.0",
39
+ "@nx/js": "22.7.0-rc.0",
40
40
  "tslib": "^2.3.0",
41
41
  "minimatch": "10.2.4"
42
42
  },
43
43
  "devDependencies": {
44
- "nx": "22.7.0-pr.35019.f500fd7"
44
+ "nx": "22.7.0-rc.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@playwright/test": "^1.36.0"
@@ -68,6 +68,5 @@
68
68
  },
69
69
  "nx-migrations": {
70
70
  "migrations": "./migrations.json"
71
- },
72
- "types": "./index.d.ts"
71
+ }
73
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/playwright/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAQnB,MAAM,YAAY,CAAC;AAiBpB,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAWD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,uBAAuB,CAqB9D,CAAC;AAEF,eAAO,MAAM,aAAa,wCAAc,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/playwright/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAQnB,MAAM,YAAY,CAAC;AAgBpB,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAWD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,uBAAuB,CAwB9D,CAAC;AAEF,eAAO,MAAM,aAAa,wCAAc,CAAC"}
@@ -6,6 +6,7 @@ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculat
6
6
  const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
7
7
  const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
8
  const js_1 = require("@nx/js");
9
+ const internal_1 = require("@nx/js/src/internal");
9
10
  const minimatch_1 = require("minimatch");
10
11
  const node_fs_1 = require("node:fs");
11
12
  const node_path_1 = require("node:path");
@@ -14,7 +15,6 @@ const cache_directory_1 = require("nx/src/utils/cache-directory");
14
15
  const plugin_cache_utils_1 = require("nx/src/utils/plugin-cache-utils");
15
16
  const workspace_context_1 = require("nx/src/utils/workspace-context");
16
17
  const reporters_1 = require("../utils/reporters");
17
- const pmc = (0, devkit_1.getPackageManagerCommand)();
18
18
  const playwrightConfigGlob = '**/playwright.config.{js,ts,cjs,cts,mjs,mts}';
19
19
  exports.createNodes = [
20
20
  playwrightConfigGlob,
@@ -22,8 +22,9 @@ exports.createNodes = [
22
22
  const optionsHash = (0, file_hasher_1.hashObject)(options);
23
23
  const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `playwright-${optionsHash}.hash`);
24
24
  const pluginCache = new plugin_cache_utils_1.PluginCache(cachePath);
25
+ const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
25
26
  try {
26
- return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, pluginCache), configFilePaths, options, context);
27
+ return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, pluginCache, pmc), configFilePaths, options, context);
27
28
  }
28
29
  finally {
29
30
  pluginCache.writeToDisk(cachePath);
@@ -31,7 +32,7 @@ exports.createNodes = [
31
32
  },
32
33
  ];
33
34
  exports.createNodesV2 = exports.createNodes;
34
- async function createNodesInternal(configFilePath, options, context, pluginCache) {
35
+ async function createNodesInternal(configFilePath, options, context, pluginCache, pmc) {
35
36
  const projectRoot = (0, node_path_1.dirname)(configFilePath);
36
37
  // Do not create a project if package.json and project.json isn't there.
37
38
  const siblingFiles = (0, node_fs_1.readdirSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot));
@@ -40,12 +41,16 @@ async function createNodesInternal(configFilePath, options, context, pluginCache
40
41
  return {};
41
42
  }
42
43
  const normalizedOptions = normalizeOptions(options);
44
+ const externalTsconfigInputs = collectExternalTsconfigInputs(projectRoot, context.workspaceRoot);
43
45
  const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, {
44
46
  ...normalizedOptions,
45
47
  CI: process.env.CI,
46
- }, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
48
+ }, context, [
49
+ (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
50
+ ...externalTsconfigInputs,
51
+ ]);
47
52
  if (!pluginCache.has(hash)) {
48
- pluginCache.set(hash, await buildPlaywrightTargets(configFilePath, projectRoot, normalizedOptions, context));
53
+ pluginCache.set(hash, await buildPlaywrightTargets(configFilePath, projectRoot, normalizedOptions, context, pmc, externalTsconfigInputs));
49
54
  }
50
55
  const { targets, metadata } = pluginCache.get(hash);
51
56
  return {
@@ -58,13 +63,17 @@ async function createNodesInternal(configFilePath, options, context, pluginCache
58
63
  },
59
64
  };
60
65
  }
61
- async function buildPlaywrightTargets(configFilePath, projectRoot, options, context) {
66
+ async function buildPlaywrightTargets(configFilePath, projectRoot, options, context, pmc, externalTsconfigInputs) {
62
67
  // Playwright forbids importing the `@playwright/test` module twice. This would affect running the tests,
63
68
  // but we're just reading the config so let's delete the variable they are using to detect this.
64
69
  // See: https://github.com/microsoft/playwright/pull/11218/files
65
70
  delete process['__pw_initiator__'];
66
71
  const playwrightConfig = await (0, config_utils_1.loadConfigFile)((0, node_path_1.join)(context.workspaceRoot, configFilePath));
67
72
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
73
+ const tsconfigJsonInputs = externalTsconfigInputs.map((file) => ({
74
+ json: `{workspaceRoot}/${file}`,
75
+ fields: ['compilerOptions', 'extends', 'files', 'include'],
76
+ }));
68
77
  const targets = {};
69
78
  let metadata;
70
79
  const testOutput = getTestOutput(playwrightConfig);
@@ -99,8 +108,9 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
99
108
  cache: true,
100
109
  inputs: [
101
110
  ...('production' in namedInputs
102
- ? ['default', '^{projectRoot}/tsconfig*.json', '^production']
111
+ ? ['default', '^production', '^{projectRoot}/tsconfig*.json']
103
112
  : ['default', '^default']),
113
+ ...tsconfigJsonInputs,
104
114
  { externalDependencies: ['@playwright/test'] },
105
115
  ],
106
116
  outputs: getTargetOutputs(testOutput, reporterOutputs, context.workspaceRoot, projectRoot),
@@ -116,8 +126,9 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
116
126
  cache: true,
117
127
  inputs: [
118
128
  ...('production' in namedInputs
119
- ? ['default', '^{projectRoot}/tsconfig*.json', '^production']
129
+ ? ['default', '^production', '^{projectRoot}/tsconfig*.json']
120
130
  : ['default', '^default']),
131
+ ...tsconfigJsonInputs,
121
132
  { externalDependencies: ['@playwright/test'] },
122
133
  ],
123
134
  outputs: getTargetOutputs(testOutput, ciReporterOutputs, context.workspaceRoot, projectRoot),
@@ -160,7 +171,7 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
160
171
  env: getAtomizedTaskEnvVars(reporterOutputs, outputSubfolder),
161
172
  },
162
173
  outputs: getAtomizedTaskOutputs(testOutput, reporterOutputs, context.workspaceRoot, projectRoot, outputSubfolder),
163
- command: `${baseTargetConfig.command} ${relativeSpecFilePath} --output=${(0, node_path_1.join)(testOutput, outputSubfolder)}`,
174
+ command: `${baseTargetConfig.command} ${relativeSpecFilePath} --output=${(0, devkit_1.joinPathFragments)(testOutput, outputSubfolder)}`,
164
175
  metadata: {
165
176
  technologies: ['playwright'],
166
177
  description: `Runs Playwright Tests in ${relativeSpecFilePath} in CI`,
@@ -219,7 +230,7 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
219
230
  inputs: ciBaseTargetConfig.inputs,
220
231
  outputs: Array.from(mergeReportsTargetOutputs),
221
232
  options: {
222
- config: node_path_1.posix.relative(projectRoot, configFilePath),
233
+ config: (0, devkit_1.normalizePath)((0, node_path_1.relative)(projectRoot, configFilePath)),
223
234
  expectedSuites: dependsOn.length,
224
235
  },
225
236
  metadata: {
@@ -306,9 +317,9 @@ function getAtomizedTaskOutputs(testOutput, reporterOutputs, workspaceRoot, proj
306
317
  function addSubfolderToOutput(output, subfolder) {
307
318
  const parts = (0, node_path_1.parse)(output);
308
319
  if (parts.ext !== '') {
309
- return (0, node_path_1.join)(parts.dir, subfolder, parts.base);
320
+ return (0, devkit_1.joinPathFragments)(parts.dir, subfolder, parts.base);
310
321
  }
311
- return (0, node_path_1.join)(output, subfolder);
322
+ return (0, devkit_1.joinPathFragments)(output, subfolder);
312
323
  }
313
324
  function getWebserverCommandTasks(playwrightConfig) {
314
325
  if (!playwrightConfig.webServer) {
@@ -395,6 +406,59 @@ function getAtomizedTaskEnvVars(reporterOutputs, outputSubfolder) {
395
406
  function normalizeAtomizedTaskBlobReportOutput(output, subfolder) {
396
407
  // set unique name for the blob report file
397
408
  return output.endsWith('.zip')
398
- ? (0, node_path_1.join)((0, node_path_1.dirname)(output), `${subfolder}.zip`)
399
- : (0, node_path_1.join)(output, `${subfolder}.zip`);
409
+ ? (0, devkit_1.joinPathFragments)((0, node_path_1.dirname)(output), `${subfolder}.zip`)
410
+ : (0, devkit_1.joinPathFragments)(output, `${subfolder}.zip`);
411
+ }
412
+ /**
413
+ * Collects tsconfig files read by the Playwright task that are NOT already
414
+ * covered by other inputs, returned as workspace-relative paths.
415
+ *
416
+ * Sources:
417
+ * - The project tsconfig's `extends` chain (compile-time config loading)
418
+ * - The workspace root `tsconfig.json` (read at runtime by
419
+ * `isUsingTsSolutionSetup`, which `nxE2EPreset` calls from the Playwright
420
+ * worker to pick the output directory convention)
421
+ *
422
+ * Exclusions:
423
+ * - Files inside the project root — covered by `default`
424
+ * - The native `TsConfiguration` hash instruction file at the workspace
425
+ * root (`tsconfig.base.json` when it exists, otherwise `tsconfig.json`)
426
+ * - Files under `node_modules` — invalidated via the lockfile
427
+ * - Paths outside the workspace — cannot be expressed as inputs
428
+ */
429
+ function collectExternalTsconfigInputs(projectRoot, workspaceRoot) {
430
+ const rootTsConfigName = (0, js_1.getRootTsConfigFileName)();
431
+ const projectPrefix = `${projectRoot}/`;
432
+ const collected = [];
433
+ const seen = new Set();
434
+ const visit = (absolutePath) => {
435
+ const wsRelative = (0, node_path_1.relative)(workspaceRoot, absolutePath)
436
+ .split(node_path_1.sep)
437
+ .join('/');
438
+ if (seen.has(wsRelative))
439
+ return 'continue';
440
+ seen.add(wsRelative);
441
+ if (wsRelative.startsWith('../') || wsRelative === '..')
442
+ return 'continue';
443
+ if (wsRelative.startsWith('node_modules/') ||
444
+ wsRelative.includes('/node_modules/')) {
445
+ return 'continue';
446
+ }
447
+ if (wsRelative === projectRoot || wsRelative.startsWith(projectPrefix)) {
448
+ return 'continue';
449
+ }
450
+ if (wsRelative === rootTsConfigName)
451
+ return 'continue';
452
+ collected.push(wsRelative);
453
+ return 'continue';
454
+ };
455
+ const projectTsconfig = (0, node_path_1.join)(workspaceRoot, projectRoot, 'tsconfig.json');
456
+ if ((0, node_fs_1.existsSync)(projectTsconfig)) {
457
+ (0, internal_1.walkTsconfigExtendsChain)(projectTsconfig, visit);
458
+ }
459
+ const rootTsconfig = (0, node_path_1.join)(workspaceRoot, 'tsconfig.json');
460
+ if ((0, node_fs_1.existsSync)(rootTsconfig)) {
461
+ (0, internal_1.walkTsconfigExtendsChain)(rootTsconfig, visit);
462
+ }
463
+ return collected;
400
464
  }
package/project.json DELETED
@@ -1,58 +0,0 @@
1
- {
2
- "name": "playwright",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/playwright",
5
- "projectType": "library",
6
- "targets": {
7
- "build": {
8
- "outputs": ["{workspaceRoot}/dist/packages/playwright/README.md"],
9
- "commands": ["node ./scripts/copy-readme.js playwright"]
10
- },
11
- "legacy-post-build": {
12
- "executor": "@nx/workspace-plugin:legacy-post-build",
13
- "options": {
14
- "tsConfig": "./tsconfig.lib.json",
15
- "assets": [
16
- {
17
- "input": "packages/playwright",
18
- "glob": "**/files/**",
19
- "output": "/"
20
- },
21
- {
22
- "input": "packages/playwright",
23
- "glob": "**/files/**/.gitkeep",
24
- "output": "/"
25
- },
26
- {
27
- "input": "packages/playwright",
28
- "glob": "**/*.json",
29
- "ignore": ["**/tsconfig*.json", "project.json", ".eslintrc.json"],
30
- "output": "/"
31
- },
32
- {
33
- "input": "packages/playwright",
34
- "glob": "**/*.js",
35
- "ignore": ["**/jest.config.js"],
36
- "output": "/"
37
- },
38
- {
39
- "input": "packages/playwright",
40
- "glob": "**/*.d.ts",
41
- "output": "/"
42
- },
43
- {
44
- "input": "packages/playwright",
45
- "glob": "PLUGIN.md",
46
- "output": "/"
47
- },
48
- {
49
- "input": "",
50
- "glob": "LICENSE",
51
- "output": "/"
52
- }
53
- ]
54
- }
55
- }
56
- },
57
- "tags": []
58
- }