forsartis/vue-cli-plugin-tailwind

Error: did not recognize object of type "ImportExpression"

Closed this issue · 3 comments

Hello,
after I select with type of tailwind config file I want (minimal)
i get this error:

Invoking generator for vue-cli-plugin-tailwind.
ERROR Error: did not recognize object of type "ImportExpression"
Error: did not recognize object of type "ImportExpression"

What should I do?

Sorry, I couldn’t reproduce the error on a Mac or Windows. Perhaps updating node can solve the issue.

You might have a dynamic import expression in src/index.js.
It could be caused by this line:

api.injectImports(api.entryFile, `import './assets/tailwind.css'`);

Vue CLI implements the injectImports utility with jscodeshift and recast underlyingly. And there was a bug in recast that it failed to print ImportExpression. It wasn't fixed until days ago benjamn/recast@aac6d75

One solution is to reinstall @vue/cli globally in the hope that the transitive recast dependency will resolve to the latest version.
If that doesn't work out, comment out the dynamic import expressions in src/index.js, run vue invoke tailwind or vue add tailwind, then uncomment the expressions after the generator runs successfully.

Edit: the ImportExpression issue also happens in older versions of ast-types.
To force update the 2 transitive dependency versions, you may need to clean the yarn or npm cache first.