fix(puppeteer): export internals (#7991)

Signed-off-by: Randolf Jung <jrandolf@chromium.org>

Co-authored-by: Randolf Jung <jrandolf@chromium.org>
This commit is contained in:
jrandolf 2022-02-10 11:59:24 +01:00 committed by GitHub
parent 1b120b2c36
commit 448118cbdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -5,8 +5,14 @@
"type": "commonjs", "type": "commonjs",
"main": "./cjs-entry.js", "main": "./cjs-entry.js",
"exports": { "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", "types": "lib/types.d.ts",
"repository": "github:puppeteer/puppeteer", "repository": "github:puppeteer/puppeteer",

View File

@ -14,6 +14,9 @@ cd $TMPDIR
# 3. Requiring Puppeteer from Node works. # 3. Requiring Puppeteer from Node works.
npm install --loglevel silent "${tarball}" npm install --loglevel silent "${tarball}"
node --eval="require('puppeteer')" node --eval="require('puppeteer')"
node --eval="
require('puppeteer/lib/cjs/puppeteer/revisions.js');
"
ls $TMPDIR/node_modules/puppeteer/.local-chromium/ ls $TMPDIR/node_modules/puppeteer/.local-chromium/
# Testing ES module features # Testing ES module features
@ -22,8 +25,9 @@ cd $TMPDIR
echo '{"type":"module"}' >>$TMPDIR/package.json echo '{"type":"module"}' >>$TMPDIR/package.json
npm install --loglevel silent "${tarball}" npm install --loglevel silent "${tarball}"
node --input-type="module" --eval="import puppeteer from 'puppeteer'" 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=" node --input-type="module" --eval="
import puppeteer from 'puppeteer'; import puppeteer from 'puppeteer';
@ -35,6 +39,7 @@ import puppeteer from 'puppeteer';
await browser.close(); await browser.close();
})(); })();
" "
ls $TMPDIR/node_modules/puppeteer/.local-chromium/
# Again for Firefox # Again for Firefox
TMPDIR="$(mktemp -d)" TMPDIR="$(mktemp -d)"

View File

@ -25,5 +25,6 @@ delete json.scripts.install;
json.name = 'puppeteer-core'; json.name = 'puppeteer-core';
json.main = './cjs-entry-core.js'; 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, ' ')); fs.writeFileSync(packagePath, JSON.stringify(json, null, ' '));