Skip to content

Commit

Permalink
Define package.json exports and corresponding modules, kriszyp#9
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Feb 1, 2021
1 parent fd6423f commit b325180
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports.encode = packModule.pack
exports.useRecords = false
exports.mapsAsObjects = true
Object.assign(exports, {
ALWAYS:1,
ALWAYS: 1,
DECIMAL_ROUND: 3,
DECIMAL_FIT: 4
})
Expand Down
1 change: 1 addition & 0 deletions pack.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Packr, Encoder, pack, encode, addExtension, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT } from './pack.js'
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "msgpackr",
"author": "Kris Zyp",
"version": "1.1.3",
"version": "1.1.4",
"description": "Ultra-fast MessagePack implementation with extensions for records and structured cloning",
"license": "MIT",
"types": "./index.d.ts",
Expand All @@ -24,11 +24,19 @@
"module": "./index.mjs",
"main": "./index.js",
"exports": {
"import": "./index.mjs",
"require": "./index.js"
"import": {
".": "./index.mjs",
"./pack": "./pack.mjs",
"./unpack": "./unpack.mjs"
},
"require": {
".": "./index.js",
"./pack": "./pack.js",
"./unpack": "./unpack.js"
}
},
"optionalDependencies": {
"msgpackr-extract": "^1.0.4"
"msgpackr-extract": "^1.0.5"
},
"devDependencies": {
"@types/node": "latest",
Expand Down
4 changes: 1 addition & 3 deletions unpack.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export const ALWAYS = 1
export const DECIMAL_ROUND = 3
export const DECIMAL_FIT = 4
interface Options {
useFloat32?: 0 | typeof ALWAYS | typeof DECIMAL_ROUND | typeof DECIMAL_FIT
useRecords?: boolean
Expand Down Expand Up @@ -29,3 +26,4 @@ export class Decoder extends Unpackr {}
export function unpack(messagePack: Buffer): any
export function decode(messagePack: Buffer): any
export function addExtension(extension: Extension)
export const C1: {}
1 change: 1 addition & 0 deletions unpack.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Unpackr, Decoder, unpack, decode, addExtension, C1 } from './unpack.js'

0 comments on commit b325180

Please sign in to comment.