-
-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why package.json in each component folder? #43
Comments
it's a convenience thing. It allows you to write a without
|
Interesting. Thank you |
Its conflict with https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
|
@alexesDev thanks for heads up! Fixed. |
@jayzelenkov I'm going to use package.json for every component in my app (so far I've been using index.js but I find package.json more natural for it) and I encounter this post. Now I'm wondering why you defined in the package.json also 3 other properties besides "main". Are you using:
these for anything? |
@krzywiecki just to make it a valid // components/Toolbar/Toolbar.js
export function Toolbar(props) { ... } // components/Toolbar/index.js
export { Toolbar as default } from './Toolbar'; |
@koistya thanks for the answer. Actually my editor is not complaining so I'll stick with "main" property only up until I find a use case for some other prop. Yeah, it's true that index.js is commonly used for exporting public API of a component but I think it's better to use package.json for it as:
I want to have consistency and also force to export only one thing from a module, that's why I decide to go with |
One of the use cases where {
"name": "MyComponent",
"version": "0.0.0",
"private": true,
"main": "./MyComponent.browser.js",
"node": "./MyComponent.node.js"
} |
Yeah, that's a perfect example and I believe there might be more use cases. |
@koistya |
When I put btw I don't use any of kriasoft's kits. |
Why does each component get its own
package.json
, like this?The text was updated successfully, but these errors were encountered: