Skip to content

Commit

Permalink
Don't import core-js by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Nov 15, 2019
1 parent c80e706 commit c8ff75c
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.0.0 (2019-11-15)

* Stop including core-js by default. This means that, for people using fake-indexeddb in really old environments like PhantomJS, they will now need to import core-js like `require("core-js/stable");` (or something similar) before importing fake-indexeddb.

# 2.1.1 (2019-06-05)

* #30 - Fixed typo in the name of the `Event.timeStamp` property.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ var IDBKeyRange = require("fake-indexeddb/lib/FDBKeyRange");

When importing individual classes directly (like `var IDBKeyRange = require("fake-indexeddb/lib/FDBKeyRange");` above), file names of all the objects are like the normal IndexedDB ones except with F replacing I, e.g. `FDBIndex` instead of `IDBIndex`.

#### PhantomJS and other really old environments

PhantomJS (and other really old environments) are missing tons of modern JavaScript features. In fact, that may be why you use fake-indexeddb in such an environment! Prior to v3.0.0, fake-indexeddb imported core-js and automatically applied its polyfills. However, since most fake-indexeddb users are not using really old environments, I got rid of that runtime dependency in v3.0.0. To work around that, you can import core-js yourself before you import fake-indexeddb, like:

```js
require("core-js/stable");
var indexedDB = require("fake-indexeddb");
```

## Quality

Here's a comparison of fake-indexeddb and real browser IndexedDB implementations on [the W3C IndexedDB test suite](https://github.com/w3c/web-platform-tests/tree/master/IndexedDB) as of March 18, 2019:
Expand Down
9 changes: 4 additions & 5 deletions auto.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require("core-js/shim");
var fakeIndexedDB = require("./build/fakeIndexedDB").default;
var FDBCursor = require("./build/FDBCursor").default;
var FDBCursorWithValue = require("./build/FDBCursorWithValue").default;
Expand All @@ -17,10 +16,10 @@ var globalVar =
typeof window !== "undefined"
? window
: typeof WorkerGlobalScope !== "undefined"
? self
: typeof global !== "undefined"
? global
: Function("return this;")();
? self
: typeof global !== "undefined"
? global
: Function("return this;")();

globalVar.indexedDB = fakeIndexedDB;
globalVar.IDBCursor = FDBCursor;
Expand Down
1 change: 0 additions & 1 deletion lib/FDBCursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBCursor").default;
1 change: 0 additions & 1 deletion lib/FDBCursorWithValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBCursorWithValue").default;
1 change: 0 additions & 1 deletion lib/FDBDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBDatabase").default;
1 change: 0 additions & 1 deletion lib/FDBFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBFactory").default;
1 change: 0 additions & 1 deletion lib/FDBIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBIndex").default;
1 change: 0 additions & 1 deletion lib/FDBKeyRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBKeyRange").default;
1 change: 0 additions & 1 deletion lib/FDBObjectStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBObjectStore").default;
1 change: 0 additions & 1 deletion lib/FDBOpenDBRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBOpenDBRequest").default;
1 change: 0 additions & 1 deletion lib/FDBRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBRequest").default;
1 change: 0 additions & 1 deletion lib/FDBTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBTransaction").default;
1 change: 0 additions & 1 deletion lib/FDBVersionChangeEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
// <https://github.com/Microsoft/TypeScript/issues/2719> and <http://stackoverflow.com/q/30302747/786644>. It should not
// be used internally, only externally.

require("core-js/shim");
module.exports = require("../build/FDBVersionChangeEvent").default;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
"lib"
],
"dependencies": {
"core-js": "^2.6.10",
"realistic-structured-clone": "^2.0.1",
"setimmediate": "^1.0.5"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.7",
"browserify": "^16.5.0",
"core-js": "^3.4.1",
"glob": "^7.1.6",
"husky": "^3.0.9",
"lint-staged": "^9.4.3",
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "core-js/shim";
import fakeIndexedDB from "./fakeIndexedDB";

module.exports = fakeIndexedDB;
1 change: 1 addition & 0 deletions src/test/indexedDBmock/exports-qunit-bundle.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
require("core-js/stable");
window.indexedDBmock = require("../..");
window.IDBKeyRangemock = require("../../FDBKeyRange").default;
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,16 @@ convert-source-map@~1.1.0:
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860"
integrity sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=

core-js@^2.5.3, core-js@^2.6.10:
core-js@^2.5.3:
version "2.6.10"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.10.tgz#8a5b8391f8cc7013da703411ce5b585706300d7f"
integrity sha512-I39t74+4t+zau64EN1fE5v2W31Adtc/REhzWN+gWRRXg6WH5qAsZm62DHpQ1+Yhe4047T55jvzz7MUqF/dBBlA==

core-js@^3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.4.1.tgz#76dd6828412900ab27c8ce0b22e6114d7ce21b18"
integrity sha512-KX/dnuY/J8FtEwbnrzmAjUYgLqtk+cxM86hfG60LGiW3MmltIc2yAmDgBgEkfm0blZhUrdr1Zd84J2Y14mLxzg==

core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down

0 comments on commit c8ff75c

Please sign in to comment.