From 448118cbdbbcbc92900eeb0b88691351f506d05f Mon Sep 17 00:00:00 2001 From: jrandolf <86539915+jrandolf@users.noreply.github.com> Date: Thu, 10 Feb 2022 11:59:24 +0100 Subject: [PATCH] fix(puppeteer): export internals (#7991) Signed-off-by: Randolf Jung Co-authored-by: Randolf Jung --- package.json | 10 ++++++++-- scripts/test-install.sh | 9 +++++++-- utils/prepare_puppeteer_core.js | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 25c7ce6b..3699a17a 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,14 @@ "type": "commonjs", "main": "./cjs-entry.js", "exports": { - "import": "./lib/esm/puppeteer/node.js", - "require": "./cjs-entry.js" + ".": { + "import": "./lib/esm/puppeteer/node.js", + "require": "./cjs-entry.js" + }, + "./*": { + "import": "./*", + "require": "./*" + } }, "types": "lib/types.d.ts", "repository": "github:puppeteer/puppeteer", diff --git a/scripts/test-install.sh b/scripts/test-install.sh index ea42f4d7..25ab3fef 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -14,6 +14,9 @@ cd $TMPDIR # 3. Requiring Puppeteer from Node works. npm install --loglevel silent "${tarball}" node --eval="require('puppeteer')" +node --eval=" +require('puppeteer/lib/cjs/puppeteer/revisions.js'); +" ls $TMPDIR/node_modules/puppeteer/.local-chromium/ # Testing ES module features @@ -22,8 +25,9 @@ cd $TMPDIR echo '{"type":"module"}' >>$TMPDIR/package.json npm install --loglevel silent "${tarball}" node --input-type="module" --eval="import puppeteer from 'puppeteer'" -ls $TMPDIR/node_modules/puppeteer/.local-chromium/ - +node --input-type="module" --eval=" +import 'puppeteer/lib/esm/puppeteer/revisions.js'; +" node --input-type="module" --eval=" import puppeteer from 'puppeteer'; @@ -35,6 +39,7 @@ import puppeteer from 'puppeteer'; await browser.close(); })(); " +ls $TMPDIR/node_modules/puppeteer/.local-chromium/ # Again for Firefox TMPDIR="$(mktemp -d)" diff --git a/utils/prepare_puppeteer_core.js b/utils/prepare_puppeteer_core.js index 7b42cd3f..be4644ee 100755 --- a/utils/prepare_puppeteer_core.js +++ b/utils/prepare_puppeteer_core.js @@ -25,5 +25,6 @@ delete json.scripts.install; json.name = 'puppeteer-core'; json.main = './cjs-entry-core.js'; -json.exports.import = './lib/esm/puppeteer/node-puppeteer-core.js'; +json.exports['.'].imports = './lib/esm/puppeteer/node-puppeteer-core.js'; +json.exports['.'].require = './cjs-entry-core.js'; fs.writeFileSync(packagePath, JSON.stringify(json, null, ' '));