Skip to content

Commit

Permalink
Merge pull request #2804 from newoga/es6-module-exports-fix
Browse files Browse the repository at this point in the history
[Babel] Fix imports using require() style syntax
  • Loading branch information
alitaheri committed Jan 6, 2016
2 parents 6bb6f19 + f86ec20 commit 0dee01c
Show file tree
Hide file tree
Showing 7 changed files with 1,871 additions and 924 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"presets": ["es2015", "stage-1", "react"],
"plugins": [
"transform-decorators-legacy",
"transform-dev-warning"
"transform-dev-warning",
"add-module-exports"
],
"env": {
"docs-production": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"babel-core": "^6.3.21",
"babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-dev-warning": "^0.1.0",
"babel-plugin-transform-react-constant-elements": "^6.3.13",
Expand Down
5 changes: 4 additions & 1 deletion src/styles/raw-themes/dark-raw-theme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export {default} from '../baseThemes/darkBaseTheme';
import darkBaseTheme from '../baseThemes/darkBaseTheme';

export default darkBaseTheme;

// import deprecatedExport from '../../utils/deprecatedExport';

// export default deprecatedExport(
Expand Down
5 changes: 4 additions & 1 deletion src/styles/raw-themes/light-raw-theme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export {default} from '../baseThemes/lightBaseTheme';
import lightBaseTheme from '../baseThemes/lightBaseTheme';

export default lightBaseTheme;

// import deprecatedExport from '../../utils/deprecatedExport';

// export default deprecatedExport(
Expand Down
2 changes: 1 addition & 1 deletion src/svg-icons/index-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rrs('./').forEach((file) => {
const moduleName = fileLines[index].split(' ')[2].replace(';', '').trim();
const modulePath = file.substring(0, file.length - 4);

outArray.push(`export {default as ${moduleName}} from './${modulePath}';\n`);
outArray.push(`import ${moduleName} from './${modulePath}';\nexport { ${moduleName} };\n`);

found = true;
} else {
Expand Down
2,760 changes: 1,840 additions & 920 deletions src/svg-icons/index.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions test/es6-module-exports-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';

const Divider = require('divider');
const ActionAccessibility = require('svg-icons').ActionAccessibility;

describe('require() style import of a component', () => {
it(`should not fail when rendering (Divider)`, () => {
expect(() => {
TestUtils.renderIntoDocument(<Divider />);
}).to.not.throw(Error);
});

it(`should not fail when rendering (ActionAccessibility)`, () => {
expect(() => {
TestUtils.renderIntoDocument(<ActionAccessibility />);
}).to.not.throw(Error);
});
});

0 comments on commit 0dee01c

Please sign in to comment.