Skip to content

Commit

Permalink
Switch to using rollup builds for CJS support
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Sep 7, 2021
1 parent 52d6341 commit 4f3a59d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
File renamed without changes.
2 changes: 0 additions & 2 deletions index.cjs

This file was deleted.

10 changes: 5 additions & 5 deletions main.mjs → index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LRFUExpirer, EXPIRED_ENTRY } from './LRFUExpirer.mjs'
export { LRFUExpirer } from './LRFUExpirer.mjs'
import { LRFUExpirer, EXPIRED_ENTRY } from './LRFUExpirer.js'
export { LRFUExpirer } from './LRFUExpirer.js'

let defaultExpirer
export class WeakLRUCache extends Map {
constructor(options) {
super()
Expand Down Expand Up @@ -114,6 +116,4 @@ class NoLRUExpirer {
// nothing to do here, we don't have a separate cache here
}
}
const defaultNoLRUExpirer = new NoLRUExpirer()

let defaultExpirer
const defaultNoLRUExpirer = new NoLRUExpirer()
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "weak-lru-cache",
"author": "Kris Zyp",
"version": "1.1.0",
"version": "1.1.2",
"description": "An LRU cache of weak references",
"license": "MIT",
"types": "./index.d.ts",
Expand All @@ -17,17 +17,26 @@
"url": "http://github.com/kriszyp/weak-lru-cache"
},
"type": "module",
"main": "index.cjs",
"module": "main.mjs",
"module": "index.js",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./index.js"
},
"./index.js": {
"require": "./dist/index.cjs",
"import": "./index.js"
}
},
"scripts": {
"build": "rollup -c",
"prepare": "rollup -c",
"test": "./node_modules/.bin/mocha tests/test*.js -u tdd"
},
"dependencies": {
"esm": "^3.2.25"
},
"devDependencies": {
"benchmark": "^2.1.4",
"chai": "^4",
"mocha": "^8"
"mocha": "^8",
"rollup": "^1.20.3"
}
}
11 changes: 11 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default [
{
input: "index.js",
output: [
{
file: "dist/index.cjs",
format: "cjs"
}
]
}
];
6 changes: 2 additions & 4 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const { WeakLRUCache } = require('..')
const chai = require('chai')
import { WeakLRUCache } from '../index.js'
import chai from 'chai'
const assert = chai.assert
let cache = new WeakLRUCache()
var inspector = require('inspector')
//inspector.open(9330, null, true)

suite('WeakLRUCache basic tests', function(){
test('add entries', function(){
Expand Down

0 comments on commit 4f3a59d

Please sign in to comment.