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 support for ESM modules #139

Open
wants to merge 2 commits 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
17 changes: 12 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ var doT = require('dot');
doT.templateSettings.strip = false;

var jst = doT.compile(fs.readFileSync('./src/index.jst', 'utf8'));
fs.writeFileSync('./index.js', jst({es6: false}));
fs.writeFileSync('./react.js', jst({es6: false, react: true}));
try { fs.mkdirSync('./es6'); } catch(e) {}
fs.writeFileSync('./es6/index.js', jst({es6: true}));
fs.writeFileSync('./es6/react.js', jst({es6: true, react: true}));
fs.writeFileSync('./index.js', jst({ es6: false }));
fs.writeFileSync('./react.js', jst({ es6: false, react: true }));
try {
fs.mkdirSync('./es6');
} catch (e) {}
fs.writeFileSync('./es6/index.js', jst({ es6: true }));
fs.writeFileSync('./es6/react.js', jst({ es6: true, react: true }));
try {
fs.mkdirSync('./esm');
} catch (e) {}
fs.writeFileSync('./esm/index.js', jst({ es6: true, esm: true }));
fs.writeFileSync('./esm/react.js', jst({ es6: true, esm: true, react: true }));
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "fast-deep-equal",
"version": "3.1.3",
"name": "@appbaseio/fast-deep-equal",
"version": "1.0.0-alpha.1",
"description": "Fast deep equal",
"main": "index.js",
"module": "esm/index.js",
"private": false,
"scripts": {
"eslint": "eslint *.js benchmark/*.js spec/*.js",
"build": "node build",
Expand Down Expand Up @@ -55,7 +57,8 @@
"index.d.ts",
"react.js",
"react.d.ts",
"es6/"
"es6/",
"esm/"
],
"types": "index.d.ts"
}
7 changes: 6 additions & 1 deletion src/index.jst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';
{{?}}

{{? it.esm }}
export default function equal(a, b) {
{{?}}
{{? !it.esm }}
module.exports = function equal(a, b) {
{{?}}
if (a === b) return true;

if (a && b && typeof a == 'object' && typeof b == 'object') {
Expand Down Expand Up @@ -76,4 +81,4 @@ module.exports = function equal(a, b) {

// true if both NaN, false otherwise
return a!==a && b!==b;
};
};