Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

How to use idx #13

Closed
xareelee opened this issue Apr 9, 2017 · 1 comment
Closed

How to use idx #13

xareelee opened this issue Apr 9, 2017 · 1 comment

Comments

@xareelee
Copy link

xareelee commented Apr 9, 2017

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?

@yungsters
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants