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

chore(agnostic): ship CJS and ESM builds #6095

Merged
merged 5 commits into from Jun 25, 2020
Merged

Commits on Jun 25, 2020

  1. chore(agnostic): ship CJS and ESM builds

    For our work to enable Puppeteer in other environments (e.g. a browser)
    we need to ship an ESM build. This commit changes our config to ship to
    `lib/cjs` and `lib/esm` accordingly. The majority of our code stays the
    same, with one small fix for the CJS build to ensure that we ship a
    version that lets you `require('puppeteer')` rather than have to
    `require('puppeteer').default`. We do this with the `cjs-entry.js` which
    is what the `main` field in our `package.json` points to.
    
    We also swap to `read-pkg-up` to find the `package.json` file. This is
    because the folder structure of `lib/` does not match `src/` now we ship
    to `cjs` and `esm`, so you cannot rely on exact paths. This module works
    up from the file to find the nearest `package.json` so it will always
    find Puppeteer's `package.json`.
    
    Note that we *do not* point any users to the ESM build. We happen to
    ship those files so people who know about them can get at them but it's
    not expected (nor will we actively support) that people will rely on
    them. The CommonJS build is considered our main build.
    
    We may make breaking changes to the structure of the ESM build which we
    will do without requiring new major versions. For example the ESM build
    currently ships all files that the CJS build does, but given we are
    working on the ESM build being able to run in the browser this may
    change over time.
    
    Long term once the Node versions catch up we can ditch CJS and ship
    exclusively ESM but we are not there yet.
    jackfranklin authored and mathiasbynens committed Jun 25, 2020
    Copy the full SHA
    c28c6f6 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    1b4e7a1 View commit details
    Browse the repository at this point in the history
  3. check chromium downloaded

    jackfranklin authored and mathiasbynens committed Jun 25, 2020
    Copy the full SHA
    b0c895f View commit details
    Browse the repository at this point in the history
  4. doclint

    jackfranklin committed Jun 25, 2020
    Copy the full SHA
    ffe89da View commit details
    Browse the repository at this point in the history
  5. fix path

    jackfranklin committed Jun 25, 2020
    Copy the full SHA
    655e110 View commit details
    Browse the repository at this point in the history