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

fix: Solved issue with importing @pollyjs projects in TypesScript #500

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"rollup-plugin-alias": "^1.5.2",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-builtins": "^2.1.2",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/adapter-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "Fetch adapter for @pollyjs",
"main": "dist/cjs/pollyjs-adapter-fetch.js",
"module": "dist/es/pollyjs-adapter-fetch.js",
"module": "dist/es/pollyjs-adapter-fetch.mjs",
"browser": "dist/umd/pollyjs-adapter-fetch.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-adapter-fetch.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-adapter-fetch.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/adapter-node-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
"version": "6.0.6",
"description": "Node HTTP adapter for @pollyjs",
"main": "dist/cjs/pollyjs-adapter-node-http.js",
"module": "dist/es/pollyjs-adapter-node-http.js",
"types": "types.d.ts",
"module": "dist/es/pollyjs-adapter-node-http.mjs",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-adapter-node-http.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-adapter-node-http.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/adapter-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
"version": "6.0.6",
"description": "File system persister for @pollyjs",
"main": "dist/cjs/pollyjs-adapter-puppeteer.js",
"module": "dist/es/pollyjs-adapter-puppeteer.js",
"types": "types.d.ts",
"module": "dist/es/pollyjs-adapter-puppeteer.mjs",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-adapter-puppeteer.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-adapter-puppeteer.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/adapter-xhr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "XHR adapter for @pollyjs",
"main": "dist/cjs/pollyjs-adapter-xhr.js",
"module": "dist/es/pollyjs-adapter-xhr.js",
"module": "dist/es/pollyjs-adapter-xhr.mjs",
"browser": "dist/umd/pollyjs-adapter-xhr.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-adapter-xhr.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-adapter-xhr.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "Extendable base adapter class used by @pollyjs",
"main": "dist/cjs/pollyjs-adapter.js",
"module": "dist/es/pollyjs-adapter.js",
"module": "dist/es/pollyjs-adapter.mjs",
"browser": "dist/umd/pollyjs-adapter.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-adapter.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-adapter.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "Record, replay, and stub HTTP Interactions",
"main": "dist/cjs/pollyjs-core.js",
"module": "dist/es/pollyjs-core.js",
"module": "dist/es/pollyjs-core.mjs",
"browser": "dist/umd/pollyjs-core.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-core.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-core.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/node-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
"version": "6.0.6",
"description": "Standalone node server and express integration for @pollyjs",
"main": "dist/cjs/pollyjs-node-server.js",
"module": "dist/es/pollyjs-node-server.js",
"types": "types.d.ts",
"module": "dist/es/pollyjs-node-server.mjs",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-node-server.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-node-server.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/persister-fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
"version": "6.0.6",
"description": "File system persister for @pollyjs",
"main": "dist/cjs/pollyjs-persister-fs.js",
"module": "dist/es/pollyjs-persister-fs.js",
"types": "types.d.ts",
"module": "dist/es/pollyjs-persister-fs.mjs",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-persister-fs.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-persister-fs.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/persister-in-memory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@
"private": true,
"description": "In memory storage persister for @pollyjs",
"main": "dist/cjs/pollyjs-persister-in-memory.js",
"module": "dist/es/pollyjs-persister-in-memory.js",
"module": "dist/es/pollyjs-persister-in-memory.mjs",
"browser": "dist/umd/pollyjs-persister-in-memory.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-persister-in-memory.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-persister-in-memory.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/persister-local-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "Local storage persister for @pollyjs",
"main": "dist/cjs/pollyjs-persister-local-storage.js",
"module": "dist/es/pollyjs-persister-local-storage.js",
"module": "dist/es/pollyjs-persister-local-storage.mjs",
"browser": "dist/umd/pollyjs-persister-local-storage.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-persister-local-storage.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-persister-local-storage.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/persister-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "REST persister for @pollyjs",
"main": "dist/cjs/pollyjs-persister-rest.js",
"module": "dist/es/pollyjs-persister-rest.js",
"module": "dist/es/pollyjs-persister-rest.mjs",
"browser": "dist/umd/pollyjs-persister-rest.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-persister-rest.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-persister-rest.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/persister/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "Extendable base persister class used by @pollyjs",
"main": "dist/cjs/pollyjs-persister.js",
"module": "dist/es/pollyjs-persister.js",
"module": "dist/es/pollyjs-persister.mjs",
"browser": "dist/umd/pollyjs-persister.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-persister.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-persister.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
16 changes: 14 additions & 2 deletions packages/@pollyjs/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"version": "6.0.6",
"description": "Shared utilities and constants between @pollyjs packages",
"main": "dist/cjs/pollyjs-utils.js",
"module": "dist/es/pollyjs-utils.js",
"module": "dist/es/pollyjs-utils.mjs",
"browser": "dist/umd/pollyjs-utils.js",
"types": "types.d.ts",
"types": "dist/cjs/types.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/cjs/types.d.ts",
"default": "./dist/cjs/pollyjs-utils.js"
},
"import": {
"types": "./dist/es/types.d.mts",
"default": "./dist/es/pollyjs-utils.mjs"
}
}
},
"files": [
"src",
"dist",
Expand Down
11 changes: 9 additions & 2 deletions scripts/rollup/node.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import copy from 'rollup-plugin-copy';

import { input, output, pkg, minify } from './utils';

Expand All @@ -13,7 +14,7 @@ export default function createNodeConfig(options = {}) {
return deepmerge(
{
input,
output: [output('cjs'), output('es')],
output: [output('cjs'), output('es', 'mjs')],
external,
plugins: [
json(),
Expand All @@ -40,7 +41,13 @@ export default function createNodeConfig(options = {}) {
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }]
]
}),
minify && terser()
minify && terser(),
copy({
targets: [
{ src: 'types.d.ts', dest: 'dist/cjs' },
{ src: 'types.d.ts', dest: 'dist/es', rename: 'types.d.mts' }
]
})
]
},
options
Expand Down
4 changes: 2 additions & 2 deletions scripts/rollup/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const banner = `/**
*/`;

export const input = './src/index.js';
export const output = (format) => {
export const output = (format, ext = 'js') => {
return {
format,
file: `./dist/${format}/${pkg.name.replace('@pollyjs/', 'pollyjs-')}.${
minify ? 'min.js' : 'js'
minify ? `min.${ext}` : ext
}`,
sourcemap: production,
banner
Expand Down
Loading