diff --git a/package.json b/package.json index fa83f6b..3fe7d39 100644 --- a/package.json +++ b/package.json @@ -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 ", @@ -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", diff --git a/src/acorn-jsx-walk.js b/src/acorn-jsx-walk.js index 20e7392..b749774 100644 --- a/src/acorn-jsx-walk.js +++ b/src/acorn-jsx-walk.js @@ -1,11 +1,7 @@ // 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) { @@ -13,6 +9,14 @@ Object.assign(base, { } }, + // 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);