Skip to content

Commit

Permalink
Workaround with acorn and acorn-dynamic-import (#147) (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton authored May 23, 2019
1 parent 707c748 commit eac86df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "i18next-scanner",
"version": "2.10.1",
"version": "2.10.2",
"description": "Scan your code, extract translation keys/values, and merge them into i18n resource files.",
"homepage": "https://github.com/i18next/i18next-scanner",
"author": "Cheton Wu <[email protected]>",
Expand Down Expand Up @@ -50,6 +50,7 @@
],
"dependencies": {
"acorn": "^6.1.1",
"acorn-dynamic-import": "^4.0.0",
"acorn-jsx": "^5.0.1",
"acorn-stage3": "^2.0.0",
"acorn-walk": "^6.1.1",
Expand Down
14 changes: 9 additions & 5 deletions src/acorn-jsx-walk.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// Originally from: https://github.com/sderosiaux/acorn-jsx-walk
import { simple as walk, base } from 'acorn-walk';
import { DynamicImportKey } from 'acorn-dynamic-import';

//
// Extends acorn walk with JSX elements
//

// See: https://github.com/RReverser/acorn-jsx/issues/23#issuecomment-403753801
Object.assign(base, {
FieldDefinition(node, state, callback) {
if (node.value !== null) {
callback(node.value, state);
}
},

// Workaround with `acorn` and `acorn-dynamic-import`
// https://github.com/kristoferbaxter/dynamic-walk/blob/master/workaround.js
[DynamicImportKey]: () => {},
});

// Extends acorn walk with JSX elements
// https://github.com/RReverser/acorn-jsx/issues/23#issuecomment-403753801
Object.assign(base, {
JSXAttribute(node, state, callback) {
if (node.value !== null) {
callback(node.value, state);
Expand Down

0 comments on commit eac86df

Please sign in to comment.