Skip to content

Commit

Permalink
Enable dynamicImport plugin in babylon (#27)
Browse files Browse the repository at this point in the history
Currently i18n-extract crashes on files which use dynamic import
statements. This can be fixed by activating the corresponding babylon
plugin.
  • Loading branch information
ctavan authored and oliviertassinari committed May 31, 2017
1 parent 5218fe7 commit f3437aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/extractFromCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default function extractFromCode(code, options = {}) {
'asyncGenerators',
'functionBind',
'functionSent',
'dynamicImport',
],
});

Expand Down
8 changes: 8 additions & 0 deletions src/extractFromCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ describe('#extractFromCode()', () => {
'*',
], keys, 'Should return one key.');
});

it('should return the right key with dynamic import in code', () => {
const keys = extractFromCode(getCode('dynamicImport.js'));

assert.deepEqual([
'key',
], keys, 'Should return only one key.');
});
});

describe('dynamic keys', () => {
Expand Down
7 changes: 7 additions & 0 deletions src/extractFromCodeFixtures/dynamicImport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable */

import i18n from 'i18n';

import('other/file');

i18n(`key`);

0 comments on commit f3437aa

Please sign in to comment.