[Proposal] mix use for npm deps.

158 views
Skip to first unread message

Aleksandr Pavliutin

unread,
Jun 7, 2017, 6:41:00 PM6/7/17
to elixir-lang-core
It would be great, if I can manage node deps with mix.

As I understand, logic same as for hex repo:
- fetch need files from repo(github) using package.json config instead mix.exs, package.exs or rebar.config;
- fetch dependencies for package using MIX_ENV;
- save package, write metadata, lock and other;
- run npm build and install scripts if need with NODE_ENV=production(if MIX_ENV == prod) or NODE_ENV = develompert if (MIX_ENV == dev or MIX_ENV == test);
- make symlinks to executable files if need;

I think problem only in semvers, they use caret ^ for versions, oftem this behaviour brakes build.
Bower, npm don't have override or lock mechanism for fix this behaviour.
Yarn try solve this problems, but many packages can't build(some issues open more than year), now they have 783 open issues.

I think need simple functionality:
npm.info - print info
npm.outdated - print outdated packages
npm.search - search package

May be good have many repos, and tools for manage npm repos.
And I think don't need functionality for publishes packages in npm repo with mix.

Justin Wood

unread,
Jun 7, 2017, 6:43:17 PM6/7/17
to elixir-l...@googlegroups.com
I think this functionality would be good for a third party library. Not all Elixir applications would have use for something like this. 

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/f6fac075-949a-45d5-9781-4f8077fb364b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

José Valim

unread,
Jun 7, 2017, 6:57:46 PM6/7/17
to elixir-l...@googlegroups.com
What Justin Wood said: this definitely does not belong in Elixir *core*. This is a mailing list about the Elixir language and standard library.



José Valim
Skype: jv.ptec
Founder and Director of R&D

Aleksandr Pavliutin

unread,
Jun 8, 2017, 4:21:48 AM6/8/17
to elixir-lang-core, jose....@plataformatec.com.br
As I undestand, mix part of Elixir *core*. Without mix you can't build application more difficult than "hello world".

I don't agree with Justin, this functionality not for third party libraries, because mix have 90% for work with npm.
I can undestand this position if I propose make rust projects with mix using cargo or something like this.

Most of all phoenix projects have package.json and default build instrustion "mix deps.get && npm install".
It would be great if all npm deps and builds store in main tree (deps and _build/[MIX_ENV] folders). All brunch scripts would be more simple,
because they work with one dir in all projects.

Mix have buildin functionality in core for make c/c++ projects and erlang with rebar. And some erlang developers use mix for build they projects instead rebar.

четверг, 8 июня 2017 г., 1:57:46 UTC+3 пользователь José Valim написал:
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

Norbert Melzer

unread,
Jun 8, 2017, 4:29:06 AM6/8/17
to elixir-l...@googlegroups.com
Not every phoenix-project uses javascript, not every elixir project is phoenix. So this does not belong into mix or elixir core. Perhaps your proposal is better to be done to the phoenix team, but absolutely not in the elixir language core team. 

Even for phoenix I think it is a bad choice, since the phoenix team once said they won't force anyone to a certain javascript buildtool, which would essentially happen once they support a single one through mix tasks, while supporting all is essentially impossible.

So please do roll your own third party plugin which does build the javascript for you and everyone else who chooses to use the same javascript buildsystem as you did.

Michał Muskała

unread,
Jun 8, 2017, 4:53:13 AM6/8/17
to elixir-lang-core, jose....@plataformatec.com.br
Even hex itself is not part of elixir core or mix, why would we have npm?

Michał.

Aleksandr Pavliutin

unread,
Jun 8, 2017, 6:31:40 AM6/8/17
to elixir-lang-core
IMHO, if mix in elixir source tree, mix part of elixir core.

Third party plugin will allow me to do like this
{:babel-core, '~> 6.24.1', manager: :npm, ovveride: true} or
{:babel-core, '~> 6.24.1', manager: :npm, only: [:dev, :test]}  or
{:test_dep, '~> 0.1.1', git: "http://..../test_dep.git", manager: :npm} or
{:test_dep, path: '.../test_dep", manager: :npm} or
other case available for mix, make or rebar manager?
No, I don't think.

May be good solution, split mix to core and managers with unified api.
The same situation, if elixir core team or phoenix team or other teem won't support this manager, but they can apply pull request for this manager.

четверг, 8 июня 2017 г., 11:29:06 UTC+3 пользователь Norbert Melzer написал:

Aleksandr Pavliutin

unread,
Jun 8, 2017, 6:46:25 AM6/8/17
to elixir-lang-core, jose....@plataformatec.com.br
hex, rebar and make part of mix. You can find do_mix, do_make, do_rebar, do_rebar3 in lib/mix/lib/mix/tasks/deps.compile.ex. 
And I can answer for you question "why would we have npm?"... Why not?

npm have problem with deps, deps in deps, locks and cache deps tree.
bower sovle this problems using flat deps tree, and have simple ovveride mechanism(use newerest version).
npm try solve problems with shrinkwrap and caching modules(all this solution ugly).
bower depricated.

mix have all mechanism for work with deps: versioning, local deps, lock, and other.
mix don't have good api to extended managers, thats all.

четверг, 8 июня 2017 г., 11:53:13 UTC+3 пользователь Michał Muskała написал:

Norbert Melzer

unread,
Jun 8, 2017, 6:57:20 AM6/8/17
to elixir-lang-core
Yes, mix is part of elixir core. But JavaScript or NPM aren't. Both aren't related to elixir even in the slightliest. There is no need to pull in a dependency on nodejs or similar into the languages core, to make a feature available that only a small fraction of users need, if there is at all.

So far, I am happy with running npm_install once after the first clone of my project and on CI. The remainder of my buildstuff is heavily customized, and relies on various JS buildtools, since there is JavaScript generated from PureScript, Elm and ElixirScript. (Wan't to move to have only ElixirScript though).

All of this is pretty well handled by a simple shell script. Also changes in the scriptfiles are very seldom such that it is only rarely needed to run.

Even then, I do not consider all the JS stuff a dependency of my application. In fact, its a JavaScript implementation of a client to my application. My server side stuff does not depend on the existence of a client. The server is fine without. So I do not see any necessity to make my server software aware of all that JavaScript, except for delivering it to the clients browser. On the other hand side, that client has a hard dependency on the server, but only that it has to exist **somewhere**.

Also it would be very nice if you could a little bit more effort into wording. I had a hard time to actually understand what you wanted in your last mail and I am still not sure if I got you right.



José Valim

unread,
Jun 8, 2017, 8:08:45 AM6/8/17
to elixir-l...@googlegroups.com
hex, rebar and make part of mix. You can find do_mix, do_make, do_rebar, do_rebar3 in lib/mix/lib/mix/tasks/deps.compile.ex. 

Hex is not part of Mix. You can implement your SCM that downloads packages from NPM if you want to, the same way Hex integrates into the language.

mix don't have good api to extended managers, thats all.

It has, it is the :compile option, which you can set to whatever command you want. For example, if you want to support NPM, you could have a NPM SCM that sets :compile to a command that will compile it in the same way NPM would.

As said previously, we do not have any interest in marking this part of Elixir core. If you are interested in working on such feature, you should go ahead. If you find limitations in Mix that are blocking your work, please send a pull request. But keep in mind the features added to Mix should be generic and not refer to NPM in any way - for example, SCMs are a great example of a generic feature that allows Hex to plug-in.

I recommend those interested in continuing this discussion to move it elsewhere.

Thank you.



José Valim
Skype: jv.ptec
Founder and Director of R&D

To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CA%2BbCVsucbFtoV%2BSRaUeiLfrM719u1adR2VEP7x8pk%3DLfEVsFfQ%40mail.gmail.com.

Aleksandr Pavliutin

unread,
Jun 8, 2017, 8:24:35 AM6/8/17
to elixir-lang-core
You talk about js build tools, I talk about deps manager.

For example, in mix.exs I have {:bootstrap, '~> x.y.z', manager: :npm}.
I want mix fetch this package and deps from package.json to deps/ folder, make package using "npm run build && npm install" if need in _build folder.

After that I can build my assets using grunt, gulp, brunch, webpack from deps/bootstrap or _build/dev/lib/bootstrap.
mix with npm module can make all my deps(and js too) and subdeps idempotent, because mix have lock and cache mechanism.

четверг, 8 июня 2017 г., 13:57:20 UTC+3 пользователь Norbert Melzer написал:

Eric Meadows-Jönsson

unread,
Jun 8, 2017, 11:37:37 AM6/8/17
to elixir-l...@googlegroups.com
The :manager option for dependencies is for the tool that manages BUILDING the dependency, not how to fetch it. SCMs is how you fetch dependencies in Mix https://hexdocs.pm/mix/Mix.SCM.html#content. This is how Hex works: https://github.com/hexpm/hex/blob/master/lib/hex/scm.ex

Hex is a package manager for BEAM languages that run on the same virtual machine that Elixir runs. Hex is not part of Elixir. Why should we make a package manager for code that runs on a completely different virtual machine part of Elixir core when the package manager for Elixir code is not part of Elixir core?

To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/60dd9df8-2eb7-46fa-ad29-0fd3f99db88b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Eric Meadows-Jönsson

Aleksandr Pavliutin

unread,
Jun 8, 2017, 1:32:14 PM6/8/17
to elixir-lang-core
Thanks Jose and Eric and other people who spend time for answer. All understand, disqussion closed.

четверг, 8 июня 2017 г., 18:37:37 UTC+3 пользователь Eric Meadows-Jönsson написал:



--
Eric Meadows-Jönsson
Reply all
Reply to author
Forward
0 new messages