ERROR: The 'decorators' plugin requires a 'decoratorsBeforeExport' option
matheusrezende opened this issue · comments
Got this error with node version:
⇒ node -v
v10.9.0
⇒ npm -v
6.2.0
⇒ importjs --version
3.1.0
Error Message
⇒ ./importjs.js fix ~/www/src/Components/FavoriteITem/FavoriteItem.component.js
Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean.
Current Solution
- Installed the version 3.0.0
This seems to be a typescript issue. Let's see if @williamboman has any input here.
At first glance, this is probably due to the upgrade to babel 7? Also, decorators are a bit tricky as the initial, now deprecated, babel decorator plugin is non-spec compliant so import-js might not be able to parse projects using the deprecated decorator plugin.
yes it is related the upgrade to babel, I installed the version that does not support typescript and it is working
I tried forking and fixing it, but if I downgrade babel it throws me an error related to babel-plugin-transform-decorators-legacy
I am using babel v6.26.3, and also has this issue
It’s likely that we’ll see issues like these with the babel upgrade. I see a few ways to solve this:
A) detach the bits that parse files to some kind of plugin
B) detect issues with parsing and fall back to an earlier babel version
C) mention compatibilities in the README and direct people to use an earlier version
A is potentially the ”right” solution but requires a significant chunk of work.
B is potentially complicated, is likely to lead to other issues down the line.
C is the simplest option, perhaps we can pair that with providing an actionable error message when issues occur.
What do you folks think?
This should only be an issue with the compatibility between the new decorator babel plugin and the decorator-legacy babel plugin, right?
Yeah, so far that's the only issue I've seen reported.
While the issue is not fixed yet it would be great to have the info in the README pointing users to the previous version.
I added something to the README in 655df38. Let's keep an eye out for more of these issues and potentially implement a better fix at that time.
I have the same error. I'm using Create React App 2 (2.0.0-next.3e165448) which includes babel 7.
How can I fix this? I don't use typescript or flow. I tried with import-js 3.1.0 (global and local)
I can't use 3.0.0 because I use React fragments (short syntax) and babel 6 fails on that.
This seems related: babel/babel#8562
I'm reopening this as we're seeing quite a few reports from different import-js plugins.
I would love to help debug, but I have no clue what info would help!
I am running a meteor project (and meteor seems to have a quite interesting relationship with babel) but the most weird thing is that my colleague (in the same repo with mostly the same plugins) can upgrade to 0.15.0 but i needed to downgrade to avoid this error.
Let me know what stack traces you need and what other info and I can try to provide it...
Cheers!
Since we started using babel 7 before it was officially released, it would be interesting to know if bumping a few @babel/*
dependencies could fix the issue. The way to test that would be to git clone
the import-js project, run npm install
, then run npm link
from inside the import-js folder (which will cause the cloned version to be available as the importjs
binary). You might also have to run npm run build
before you can try things. If you are able to reproduce the bug, try editing package.json to use regular babel 7 (instead of pre-releases/beta). Then npm install
and try again.
when i clone into the atom-import-js/node-modules/import-js folder and run the above three commands, i get the following error on start up in atom:
Cannot find module '~/.atom/packages/atom-import-js/node_modules/import-js/node_modules/sqlite3/lib/binding/electron-v2.0-darwin-x64/node_sqlite3.node'
but this seems unrelated to the previous error about decorators
quick report:
merging wyuenho's changes combined with:
ln -s import-js/node_modules/sqlite3/ sqlite3/
from my .atom/packages directory has fixed the issue for me!
any ideas about how to set that decoratorsBeforeExport value in webpack.config?