Skip to content

Reproduce the issue with jsnext:main and Lodash for Redux #1

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

Closed
wants to merge 1 commit into from
Closed
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
41 changes: 2 additions & 39 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,2 @@
/*
* This is the main entry point for your package.
*
* You can import other modules here, including external packages. When
* bundling using rollup you can mark those modules as external and have them
* excluded or, if they have a jsnext:main entry in their package.json (like
* this package does), let rollup bundle them into your dist file.
*/

import { add } from './utils';

/**
* Multiply two numbers together, returning the product.
*
* This function illustrates an export from an entry point that uses imports
* from other files. It also illustrates tail-call optimizations in ES6,
* otherwise the `negative` parameter wouldn't be here.
*/
export function multiply(n, m, negative=false) {
if (n === 0 || m === 0) {
return 0;
} else if (n === 1) {
return m;
} else if (m === 1) {
return n;
} else if (n < 0 && m < 0) {
return multiply(-n, -m);
} else if (n < 0) {
return multiply(-n, m, !negative);
} else if (m < 0) {
return multiply(n, -m, !negative);
}

let result = n;
while (--m) {
result = add(result, n);
}
return negative ? -result : result;
}
import { createStore } from 'redux';
createStore(function () { })
6 changes: 0 additions & 6 deletions lib/utils.js

This file was deleted.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
"rollup": "^0.24.1",
"rollup-plugin-babel": "^2.3.9",
"rollup-plugin-multi-entry": "^1.1.0",
"rollup-plugin-npm": "^1.4.0",
"source-map-support": "^0.4.0"
},
"dependencies": {
"redux": "^3.2.1"
}
}
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import babel from 'rollup-plugin-babel';
import npm from 'rollup-plugin-npm';

export default {
entry: 'lib/index.js',
sourceMap: true,
plugins: [babel()]
plugins: [babel(), npm({ jsnext: true })]
};
28 changes: 0 additions & 28 deletions test/index_test.js
Original file line number Diff line number Diff line change
@@ -1,28 +0,0 @@
import { multiply } from '../lib/index';
import { strictEqual } from 'assert';

describe('multiply', () => {
it('returns 0 when either argument is 0', () => {
strictEqual(multiply(0, 2), 0);
strictEqual(multiply(4, 0), 0);
});

it('returns the value of one number if the other is 1', () => {
strictEqual(multiply(1, 8), 8);
strictEqual(multiply(5, 1), 5);
});

it('is commutative', () => {
strictEqual(multiply(2, 4), multiply(4, 2));
});

it('returns the product of the two numbers', () => {
strictEqual(multiply(11, 9), 99);
});

it('handles negative numbers', () => {
strictEqual(multiply(-2, 2), -4);
strictEqual(multiply(2, -2), -4);
strictEqual(multiply(-2, -2), 4);
});
});