Skip to content
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

Main is an alias #8

Closed
wants to merge 2 commits into from
Closed

Main is an alias #8

wants to merge 2 commits into from

Conversation

josh
Copy link
Contributor

@josh josh commented Nov 12, 2013

Regardless of an extension to main being accepted #7, I want to clarify the original main intent and how build tools are already using it.

main is a way to alias the package name to a file inside the package. Its a convenience to package authors so they can organize their internal directories however they wish but still export there module as a simple symbol.

Bower already understands the index.js convention. Again taken from node, but Sprockets also supports it as well. When you install a package from a url, it writes to foo/index.js. index.js is the implicit value of main.

index is fine, but not everything wants to name their file that in the package. main is a way to rewrite that path to another.

@unscriptable
Copy link

Nice! I like the wording and it clearly states the purpose of main. However, the default is not consistent with current implementations of AMD loaders and builders which assume "main" is the default, not "index": https://github.com/amdjs/amdjs-api/wiki/Common-Config#packages-

@josh
Copy link
Contributor Author

josh commented Nov 12, 2013

Hmm, I guess I can remove that language and leave the default to be implementation specific.

For single file resources bower already generates a main property with a path to the index.js. In practice build tools don't actually need to be configured handle a fallback main property.

@@ -50,7 +50,7 @@ Used for search by keyword. Helps make your package easier to discover without p

#### main [string|array of strings]

The primary acting files necessary to use your package. While Bower does not directly use these files, they are listed with the commands `bower list --json` and `bower list --paths`, so they can be used by build tools.
The primary filename to use as an alias for the package name. Any "requires" or "imports" of the package name symbol should reference this file instead. While Bower does not directly use these files, they are listed with the commands `bower list --json` and `bower list --paths`, so they can be used by build tools.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording is a bit clumsy. This change also seems to merge 2 different ideas for main. If we change things, then I'd suggest that main should be used the same way as npm and Component(1) - the entry point for the component's JS if it uses a module format.

@briandipalma
Copy link

This spec is for bower though and for bower index.js is the default entry point of a package if no main is supplied, a build tool creator would still find some use in having that specified in the spec I think.

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

Successfully merging this pull request may close these issues.

None yet

4 participants