Playwright: [BUG] playwright-core has no main entry

Created on 11 Jun 2020  路  10Comments  路  Source: microsoft/playwright

Context:

  • Playwright Version: 1.1.1
  • Operating System: MacOS
  • Node version: 14
  • Browser: playwright-core

Describe the bug

The playwright-core package does not contain anymore a valid index.js / entrypoint.

1.0.2: https://unpkg.com/[email protected]/index.js <-- expected
1.1.0: https://unpkg.com/[email protected]/index.js <-- actual

Is this expected? Because it's still referenced in the package.json>main.

Workaround:

"playwright-core": "npm:[email protected]",

Most helpful comment

Thanks everybody!

The fix should be published already at playwright-core@next and will be part of our next release.

All 10 comments

We cannot currently use playwright-core. Repro:

const { devices } = require("playwright-core");
console.log("devices", devices);

Error:

internal/modules/cjs/loader.js:331
      throw err;
      ^

Error: Cannot find module '/Users/jon/dev/examples/pw-core/node_modules/playwright-core/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:323:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:681:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:944:27)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/Users/jon/dev/examples/pw-core/test.js:1:21)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/jon/dev/examples/pw-core/node_modules/playwright-core/package.json',
  requestPath: 'playwright-core'
}

What is the status of this? We are using playwright-core with https://github.com/JupiterOne/playwright-aws-lambda and multiple users have now reported this issue. https://github.com/JupiterOne/playwright-aws-lambda/issues/9.

Thoughts @pavelfeldman @dgozman @aslushnikov @yury-s?

@austinkelleher @jperl Ah! Sorry for this! I've submitted a PR to address this.

While we are here - can you please share how exactly you use playwright-core? It'll be very helpful
to understand your use cases.

@aslushnikov Huge thanks for the quick follow-up! Love what you all are doing with Playwright

@aslushnikov Whoops submitted too soon...We are running Playwright on AWS Lambda by shipping a chrome binary with the package (we don't want to auto-install at runtime). Here is the usage: https://github.com/JupiterOne/playwright-aws-lambda/blob/master/src/chromium.ts#L102.

Also leveraging some TypeScript typings e.g. https://github.com/JupiterOne/playwright-aws-lambda/blob/master/src/chromium.ts#L8

Thanks for fixing it @aslushnikov. In playwright-video we depend on playwright-core for types.

That way a user can depend on playwright-video and playwright-chromium, or playwright-video and playwright and their types will build properly, since they are compatible (at least in 1.0.x this was the case).

Thanks everybody!

The fix should be published already at playwright-core@next and will be part of our next release.

@aslushnikov so to summarize, playwright-core works again but we have to include it as a dependency since types are now included in every package. Is this intention correct?
cc @jperl

so to summarize, playwright-core works again but we have to include it as a dependency since types are now included in every package. Is this intention correct?

@mxschmitt I'm not sure I understand. Can you please elaborate?

@aslushnikov Before on jest-playwright e.g. or playwright-video the types where imported from playwright-core since it was automatically installed as a dependency if you have used playwright or the browser specific NPM packages. Since it's not installing it automatically anymore, we on our side have to add it as a dependency, which will then work.

As we did here for reference: https://github.com/playwright-community/jest-playwright/pull/202

TL;DR libraries have to use playwright-core and add it as a dependency. So all good 馃憤

Was this page helpful?
0 / 5 - 0 ratings