@nx/playwright 23.0.0-beta.14 → 23.0.0-beta.16

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": "23.0.0-beta.14",
3
+ "version": "23.0.0-beta.16",
4
4
  "type": "commonjs",
5
5
  "homepage": "https://nx.dev",
6
6
  "private": false,
@@ -34,15 +34,15 @@
34
34
  "directory": "packages/playwright"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "23.0.0-beta.14",
38
- "@nx/eslint": "23.0.0-beta.14",
39
- "@nx/js": "23.0.0-beta.14",
37
+ "@nx/devkit": "23.0.0-beta.16",
38
+ "@nx/eslint": "23.0.0-beta.16",
39
+ "@nx/js": "23.0.0-beta.16",
40
40
  "tslib": "^2.3.0",
41
41
  "minimatch": "10.2.5",
42
42
  "semver": "^7.6.3"
43
43
  },
44
44
  "devDependencies": {
45
- "nx": "23.0.0-beta.14"
45
+ "nx": "23.0.0-beta.16"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@playwright/test": "^1.36.0"
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/playwright/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,iBAAiB,EAWjB,IAAI,EAML,MAAM,YAAY,CAAC;AAiBpB,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,UAAU,CAAC;AAGlB,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,8BAGtC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,4BAA4B,8BAkNzC;AAyKD,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/playwright/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,iBAAiB,EAWjB,IAAI,EAML,MAAM,YAAY,CAAC;AAiBpB,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,UAAU,CAAC;AAGlB,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,8BAGtC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,4BAA4B,8BA6NzC;AA2KD,eAAe,sBAAsB,CAAC"}
@@ -29,14 +29,25 @@ async function configurationGeneratorInternal(tree, rawOptions) {
29
29
  }));
30
30
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
31
31
  const offsetFromProjectRoot = (0, devkit_1.offsetFromRoot)(projectConfig.root);
32
+ const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
33
+ // Always emit `playwright.config.mts`. Node forces `.mts` to ESM
34
+ // regardless of workspace `type`, so Playwright's runtime routes it
35
+ // through the ESM loader (`requireOrImport` -> dynamic `import()`),
36
+ // bypassing the pirates CJS-compile path that breaks ESM-shape `.ts`
37
+ // configs. Nx's native TS strip loads `.mts` directly via `loadTsFile`.
38
+ // Playwright's configLoader auto-discovers `.mts` (extension list at
39
+ // configLoader.js:313 is `.ts/.js/.mts/.mjs/.cts/.cjs`).
32
40
  (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), projectConfig.root, {
33
41
  offsetFromRoot: offsetFromProjectRoot,
34
42
  projectRoot: projectConfig.root,
35
43
  webServerCommand: options.webServerCommand ?? null,
36
44
  webServerAddress: options.webServerAddress ?? null,
45
+ isTsSolutionSetup,
37
46
  ...options,
38
47
  });
39
- const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
48
+ const playwrightConfigFile = options.js
49
+ ? 'playwright.config.mjs'
50
+ : 'playwright.config.mts';
40
51
  const tsconfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json');
41
52
  if (tree.exists(tsconfigPath)) {
42
53
  if (isTsSolutionSetup) {
@@ -50,7 +61,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
50
61
  include: [
51
62
  (0, devkit_1.joinPathFragments)(options.directory, '**/*.ts'),
52
63
  (0, devkit_1.joinPathFragments)(options.directory, '**/*.js'),
53
- 'playwright.config.ts',
64
+ playwrightConfigFile,
54
65
  ],
55
66
  exclude: ['out-tsc', 'test-output'],
56
67
  };
@@ -78,7 +89,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
78
89
  include: [
79
90
  '**/*.ts',
80
91
  '**/*.js',
81
- 'playwright.config.ts',
92
+ playwrightConfigFile,
82
93
  'src/**/*.spec.ts',
83
94
  'src/**/*.spec.js',
84
95
  'src/**/*.test.ts',
@@ -144,7 +155,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
144
155
  }));
145
156
  if (options.js) {
146
157
  const { ModuleKind } = (0, internal_2.ensureTypescript)();
147
- (0, devkit_1.toJS)(tree, { extension: '.cjs', module: ModuleKind.CommonJS });
158
+ (0, devkit_1.toJS)(tree, { extension: '.mjs', module: ModuleKind.ESNext });
148
159
  }
149
160
  recommendVsCodeExtensions(tree);
150
161
  if (!options.skipPackageJson) {
@@ -279,7 +290,9 @@ Rename or remove the existing e2e target.`);
279
290
  executor: '@nx/playwright:playwright',
280
291
  outputs: [`{workspaceRoot}/dist/.playwright/${projectConfig.root}`],
281
292
  options: {
282
- config: `${projectConfig.root}/playwright.config.${options.js ? 'cjs' : 'ts'}`,
293
+ // Generator emits `playwright.config.mts` (`.mjs` for `--js`) so the
294
+ // legacy executor's `--config` flag must point at the same extension.
295
+ config: `${projectConfig.root}/playwright.config.${options.js ? 'mjs' : 'mts'}`,
283
296
  },
284
297
  };
285
298
  (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
@@ -9,13 +9,20 @@ const baseURL = process.env['BASE_URL'] || '<% if(webServerAddress) {%><%= webSe
9
9
  * Read environment variables from file.
10
10
  * https://github.com/motdotla/dotenv
11
11
  */
12
- // require('dotenv').config();
12
+ // import 'dotenv/config';
13
13
 
14
14
  /**
15
15
  * See https://playwright.dev/docs/test-configuration.
16
+ *
17
+ * Generated as a .mts file so Node forces ESM regardless of workspace
18
+ * `type`. Playwright routes `.mts` through its ESM loader (dynamic import,
19
+ * bypassing the pirates CJS-compile path), and Nx's native TS strip loads
20
+ * `.mts` directly. Playwright's configLoader auto-discovers
21
+ * `playwright.config.mts` via its extension list
22
+ * (.ts/.js/.mts/.mjs/.cts/.cjs).
16
23
  */
17
24
  export default defineConfig({
18
- ...nxE2EPreset(__filename, { testDir: './<%= directory %>' }),
25
+ ...nxE2EPreset(import.meta.dirname, { testDir: './<%= directory %>' }),
19
26
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
20
27
  use: {
21
28
  baseURL,
@@ -50,7 +57,7 @@ export default defineConfig({
50
57
  name: "webkit",
51
58
  use: { ...devices["Desktop Safari"] },
52
59
  },
53
-
60
+
54
61
  // Uncomment for mobile browsers support
55
62
  /* {
56
63
  name: 'Mobile Chrome',
@@ -30,8 +30,11 @@ export interface NxPlaywrightOptions {
30
30
  *
31
31
  * you can easily extend this within your playwright config via spreading the preset
32
32
  * @example
33
+ * // Nx generates `playwright.config.mts` (ESM). Pass `import.meta.dirname`.
34
+ * // For hand-written CJS configs (`.cts` or `.ts` outside a `type: "module"`
35
+ * // workspace), pass `__filename` instead.
33
36
  * export default defineConfig({
34
- * ...nxE2EPreset(__filename, options)
37
+ * ...nxE2EPreset(import.meta.dirname, options)
35
38
  * // add your own config here
36
39
  * })
37
40
  *
@@ -1 +1 @@
1
- {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../../../../packages/playwright/src/utils/preset.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC;;;QAGI;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;IACnD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,2DA2D9B"}
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../../../../packages/playwright/src/utils/preset.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC;;;QAGI;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;IACnD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,2DA2D9B"}
@@ -23,8 +23,11 @@ const versions_1 = require("./versions");
23
23
  *
24
24
  * you can easily extend this within your playwright config via spreading the preset
25
25
  * @example
26
+ * // Nx generates `playwright.config.mts` (ESM). Pass `import.meta.dirname`.
27
+ * // For hand-written CJS configs (`.cts` or `.ts` outside a `type: "module"`
28
+ * // workspace), pass `__filename` instead.
26
29
  * export default defineConfig({
27
- * ...nxE2EPreset(__filename, options)
30
+ * ...nxE2EPreset(import.meta.dirname, options)
28
31
  * // add your own config here
29
32
  * })
30
33
  *