Skip to content

Commit

Permalink
feat!: switch to node es module support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Jun 6, 2020
1 parent 54be44c commit 6e21733
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions base.d.ts
@@ -0,0 +1,2 @@
// For TypeScript that it doesn't understand the Node 13+ "exports" field
export * from './out/base'
15 changes: 13 additions & 2 deletions package.json
Expand Up @@ -3,8 +3,19 @@
"version": "1.0.4",
"type": "module",
"description": "A lightweight JSON RPC server & client",
"main": "out/index.js",
"module": "out/index.js",
"main": "out/full.cjs",
"module": "out/full.mjs",
"types": "./out/full.es.d.ts",
"exports": {
".": {
"require": "./out/full.cjs",
"import": "./out/full.mjs"
},
"./base": {
"require": "./out/base.cjs",
"import": "./out/base.mjs"
}
},
"scripts": {
"release": "rimraf ./out && standard-version",
"start": "node ./watch.js",
Expand Down
11 changes: 6 additions & 5 deletions rollup.config.js
Expand Up @@ -25,28 +25,29 @@ const full = {
const dtsConfig = [
{
input: './es/Async-Call.d.ts',
output: [{ file: './out/base.es.d.ts', format: 'es' }],
output: [{ file: './out/base.d.ts', format: 'es' }],
plugins: [dts()],
},
{
input: './es/index.d.ts',
output: [{ file: './out/full.es.d.ts', format: 'es' }],
output: [{ file: './out/full.d.ts', format: 'es' }],
plugins: [dts()],
},
]
export default [base, full, ...dtsConfig]

/**
* @param {string} name
* @param {rollup.ModuleFormat[]} format
* @param {('es' | 'umd')[]} format
* @returns {rollup.OutputOptions[]}
*/
function outputMatrix(name, format) {
return format.map((f) => ({
file: `./out/${name}.${f}.js`,
file: `./out/${name}.${f === 'es' ? 'm' : 'c'}js`,
name: 'AsyncCall',
sourcemap: true,
banner: '/// <reference types="./full.es.d.ts" />',
format: f,
banner: `/// <reference types="./${name}.d.ts" />`,
plugins: [
terser({
compress: {
Expand Down

0 comments on commit 6e21733

Please sign in to comment.