How to use idx
Closed this issue · 1 comments
Some info is missing in the README.md.
Do I need to install idx
as devDependency
or dependency
?
After I write the idx
optional chaining syntax, do I need to import the idx
function? If, yes, why?
Does idx()
function transform the syntax when using babel or in runtime?
Do I need any config in .babelrc
?
Whether the package should be installed as a devDependency
or dependency
depends entirely on how you plan to use it in your package. Typically, you'll want idx
as a dependency
and babel-plugin-idx
as a devDependency
. However, you may want idx
as a devDependency
if — for example — it is only being used by build tools. Likewise, you may want babel-plugin-idx
to be a `dependency if — for example — you use the Babel plugin during the runtime of your package.
You need to import idx
because for all intents and purposes, it's just another module that exports a function. The Babel plugin is an optional (but highly recommended) performance optimization.
There is no real "syntax" to idx
. There are limitations, but the syntax is valid ECMAScript syntax. The babel-plugin-idx
that you're probably referring to is, as mentioned above, a performance optimization. As its name implies, it requires Babel to transform your idx
call expressions. It can occur either as a build step or at runtime, depending on how you choose to use Babel.