Skip to content

Commit

Permalink
edge case: the __esModule field gets read
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyan Zhang committed Aug 3, 2016
1 parent 5de4976 commit f69879b
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "es2015", "stage-0" ],
}
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "airbnb-base/legacy",
"extends": "airbnb-base",
"env": {
"browser": true,
"node": true,
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"harmony-reflect": "^1.4.6"
},
"devDependencies": {
"babel-core": "^6.11.4",
"babel-jest": "^14.1.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"coveralls": "^2.11.9",
"eslint": "^2.11.0",
"eslint-config-airbnb-base": "^3.0.1",
Expand Down
3 changes: 3 additions & 0 deletions src/__tests__/idObjES6Export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const idObj = require('..');

export default idObj;
3 changes: 3 additions & 0 deletions src/__tests__/idObjES6Import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import idObj from '..';

module.exports = idObj;
3 changes: 3 additions & 0 deletions src/__tests__/idObjES6ImportExport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import idObj from '..';

export default idObj;
13 changes: 13 additions & 0 deletions src/__tests__/import-es6-export-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import idObj from './idObjES6Export';

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
13 changes: 13 additions & 0 deletions src/__tests__/import-es6-import-export-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import idObj from './idObjES6ImportExport';

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
13 changes: 13 additions & 0 deletions src/__tests__/import-es6-import-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import idObj from './idObjES6Import';

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
13 changes: 13 additions & 0 deletions src/__tests__/import-vanilla-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import idObj from '..';

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
11 changes: 5 additions & 6 deletions src/__tests__/index-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* eslint-disable space-before-function-paren, func-names */
var idObj = require('..');
const idObj = require('..');

describe('idObj', function() {
it('should return the key as a string', function() {
describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', function() {
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', function() {
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
13 changes: 13 additions & 0 deletions src/__tests__/require-es6-export-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const idObj = require('./idObjES6Export').default;

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
13 changes: 13 additions & 0 deletions src/__tests__/require-es6-import-export-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const idObj = require('./idObjES6ImportExport').default;

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
13 changes: 13 additions & 0 deletions src/__tests__/require-es6-import-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const idObj = require('./idObjES6Import');

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
13 changes: 13 additions & 0 deletions src/__tests__/require-vanilla-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const idObj = require('..');

describe('idObj', () => {
it('should return the key as a string', () => {
expect(idObj.foo).toBe('foo');
});
it('should support dot notation', () => {
expect(idObj.bar).toBe('bar');
});
it('should support bracket notation', () => {
expect(idObj[1]).toBe('1');
});
});
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-var, comma-dangle */
var Reflect; // eslint-disable-line no-unused-vars
var idObj;

Expand All @@ -15,6 +16,9 @@ if (!checkIsNodeV6OrAbove()) {

idObj = new Proxy({}, {
get: function getter(target, key) {
if (key === '__esModule') {
return false;
}
return key;
}
});
Expand Down

0 comments on commit f69879b

Please sign in to comment.