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

add esm exports #84

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
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
"name": "bloom-filters",
"version": "3.0.4",
"description": "JS implementation of probabilistic data structures: Bloom Filter (and its derived), HyperLogLog, Count-Min Sketch, Top-K and MinHash",
"main": "dist/api.js",
"main": "dist/cjs/api.js",
"module": "dist/esm/api.js",
"types": "dist/esm/api.d.ts",
"exports": {
".": {
"require": "./dist/cjs/api.js",
"import": "./dist/esm/api.js",
"types": "./dist/esm/api.d.ts"
}
},
"type": "commonjs",
"scripts": {
"build": "tsc",
"build": "yarn build:cjs && yarn build:esm",
"build:cjs": "tsc -p tsconfig.json",
"build:esm": "tsc -p tsconfig.esm.json",
"pretest": "yarn lint && yarn build",
"test": "mocha test/**/*-test.js --trace-deprecation --timeout=60000",
"doc": "typedoc --sort alphabetical --out docs/ --emit both --includeVersion src/api.ts",
Expand Down
2 changes: 1 addition & 1 deletion test/bit-set-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {BitSet} = require('../dist/api')
const {BitSet} = require('../dist/cjs/api.js')

describe('BitSet', () => {
it('is initially clear', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/bloom-filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {BloomFilter} = require('../dist/api.js')
const {BloomFilter} = require('../dist/cjs/api.js')

describe('BloomFilter', () => {
const targetRate = 0.1
Expand Down
2 changes: 1 addition & 1 deletion test/bucket-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const Bucket = require('../dist/cuckoo/bucket.js').default
const Bucket = require('../dist/cjs/cuckoo/bucket.js').default

describe('Bucket', () => {
describe('#isFree', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/compatibility-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

require('chai').should()
const {expect} = require('chai')
const {BloomFilter, DeprecatedHashing} = require('../dist/api.js')
const {BloomFilter, DeprecatedHashing} = require('../dist/cjs/api.js')

describe('BloomFilter Compatibility (only) between versions', () => {
it('1.3.4 compatibility (issue #49)', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/count-min-sketch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {CountMinSketch} = require('../dist/api.js')
const {CountMinSketch} = require('../dist/cjs/api.js')

describe('CountMinSketch', () => {
const delta = 0.999
Expand Down
2 changes: 1 addition & 1 deletion test/counting-bloom-filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {CountingBloomFilter} = require('../dist/api.js')
const {CountingBloomFilter} = require('../dist/cjs/api.js')

describe('CountingBloomFilter', () => {
const targetRate = 0.1
Expand Down
2 changes: 1 addition & 1 deletion test/cuckoo-filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE.
const chai = require('chai')
chai.should()
chai.expect()
const {CuckooFilter} = require('../dist/api.js')
const {CuckooFilter} = require('../dist/cjs/api.js')

describe('CuckooFilter', () => {
describe('#_locations', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/hyperloglog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {HyperLogLog} = require('../dist/api.js')
const {HyperLogLog} = require('../dist/cjs/api.js')

describe('HyperLogLog', () => {
describe('#update', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/iblt-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

require('chai').should()
require('chai').expect()
const {InvertibleBloomFilter} = require('../dist/api.js')
const {InvertibleBloomFilter} = require('../dist/cjs/api.js')
const random = require('random')
const seedrandom = require('seedrandom')

Expand Down
2 changes: 1 addition & 1 deletion test/min-hash-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {MinHashFactory, MinHash} = require('../dist/api.js')
const {MinHashFactory, MinHash} = require('../dist/cjs/api.js')
const range = require('lodash/range')
const intersection = require('lodash/intersection')
const union = require('lodash/union')
Expand Down
2 changes: 1 addition & 1 deletion test/partitioned-bloom-filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {PartitionedBloomFilter} = require('../dist/api.js')
const {PartitionedBloomFilter} = require('../dist/cjs/api.js')

describe('PartitionedBloomFilter', () => {
const targetRate = 0.001
Expand Down
2 changes: 1 addition & 1 deletion test/scalable-bloom-filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

require('chai').should()
const {expect} = require('chai')
const {ScalableBloomFilter} = require('../dist/api.js')
const {ScalableBloomFilter} = require('../dist/cjs/api.js')

describe('ScalableBloomFilter', () => {
const targetRate = 0.1
Expand Down
2 changes: 1 addition & 1 deletion test/topk-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {TopK} = require('../dist/api.js')
const {TopK} = require('../dist/cjs/api.js')

describe('TopK', () => {
const lessThanOrEqualTestCaseItems = [
Expand Down
6 changes: 3 additions & 3 deletions test/utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ const {
xorBuffer,
getDefaultSeed,
isEmptyBuffer,
} = require('../dist/utils')
const {BloomFilter, BaseFilter} = require('../dist/api.js')
} = require('../dist/cjs/utils.js')
const {BloomFilter, BaseFilter} = require('../dist/cjs/api.js')
const XXH = require('xxhashjs')
const range = require('lodash/range')
const seed = getDefaultSeed()
const {Hashing} = require('../dist/api')
const {Hashing} = require('../dist/cjs/api.js')

describe('Utils', () => {
describe('#allocateArray', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/xor-filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

require('chai').should()
const {XorFilter} = require('../dist/api.js')
const {XorFilter} = require('../dist/cjs/api.js')

describe('XorFilter', () => {
const elements = ['1']
Expand Down
12 changes: 12 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
"outDir": "./dist/esm",
"target": "es2015",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true
}
}
10 changes: 6 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"compilerOptions": {
"rootDir": "./src",
"target": "es5",
"outDir": "./dist",
"outDir": "./dist/cjs",
"module": "commonjs",
"lib": [ "ES2015" ],
"declaration": true,
"lib": [
"ES2015"
],
"declaration": false,
"strict": true,
"allowJs": true,
"esModuleInterop": true,
Expand All @@ -14,7 +16,7 @@
"downlevelIteration": true
},
"include": [
"./src/**/*"
"./src/**/*"
],
"exclude": [
"node_modules/",
Expand Down