Skip to content

Commit

Permalink
fix: support typescript commonjs modules using moduleresolution noden…
Browse files Browse the repository at this point in the history
…ext (#401)

* Use separate type file for the CJS module

* Fix typo - use .cts for types
  • Loading branch information
thovden committed Dec 6, 2022
1 parent cba2278 commit 67c5b23
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
"bin": "lib/cli.js",
"exports": {
".": {
"types": "./lib/main.d.ts",
"import": "./lib/main.js",
"require": "./lib/cjs/main.cjs"
"import": {
"types": "./lib/main.d.ts",
"default": "./lib/main.js"
},
"require": {
"types": "./lib/cjs/main.d.cts",
"default": "./lib/cjs/main.cjs"
}
}
},
"repository": "github:puppeteer/replay",
Expand Down Expand Up @@ -37,7 +42,8 @@
"lib",
"!lib/**/*.d.ts",
"!lib/**/*.d.ts.map",
"lib/main.d.ts"
"lib/main.d.ts",
"lib/cjs/main.d.cts"
],
"author": "Chrome DevTools authors",
"license": "Apache-2.0",
Expand Down
14 changes: 10 additions & 4 deletions rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ module.exports = [
},
{
input: 'src/main.ts',
output: {
file: 'lib/main.d.ts',
format: 'es',
},
output: [
{
file: 'lib/main.d.ts',
format: 'es',
},
{
file: 'lib/cjs/main.d.cts',
format: 'cjs',
},
],
external: [
'devtools-protocol',
'devtools-protocol/types/protocol-mapping.js',
Expand Down

0 comments on commit 67c5b23

Please sign in to comment.