formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.22k stars 405 forks source link

Stop using publish-latest #589

Closed kentcdodds closed 6 years ago

kentcdodds commented 8 years ago

Use npmcdn instead. This will require some documentation updates and a major version change. You can now install angular-formly via npmcdn like so:

bower install --save https://npmcdn.com/angular-formly@^7.3.9/bower.zip

We'll have to also tell people who want to just download the script to use npmcdn (rather than going to the tag or latest branch because we'll no longer be committing the built stuff and pointing tags at that.

This will make the whole process easier to manage and I'm not so concerned about making it a little more tricky for bower users. It will encourage them to stop using a dead technology.

dmitriz commented 8 years ago

Is bower a dead technology?

kentcdodds commented 8 years ago

Dying is probably the more appropriate term: https://gofore.com/ohjelmistokehitys/stop-using-bower/

dmitriz commented 8 years ago

Thanks, I see it is recommended to use npm instead.

The only advantage of bower I would have been that you don't need to use browserify (or another module packager) to access your modules, but maybe you actually should use it. ;)

I'm somewhat worried though the location where npm modules install is unpredictable, which becomes a problem when I want to copy files up to the user directory. Right now I'm copying naively to ../../, which is sadly the only way I could find for now.

kentcdodds commented 8 years ago

Actually, you don't need to use browserify, webpack or any other module packager even if you use npm. You can just reference the built files just as you would without those tools. Most packages distribute a stand-alone distributable that works in the browser (like angular-formly).

As for the location of the installed files, as long as they're listed in your package.json dependencies then they'll be in the root of node_modules (regardless of npm version). And if someone moves where the distributable file goes then that's a breaking change (and would happen with bower as well).

So, for example, for angular-formly, you could use npm by installing it like so:

$ npm i angular-formly --save

Then in an html file you could reference that like so:

<script src="node_modules/angular-formly/dist/formly.js"></script>

And that'd work just perfectly :-)

dmitriz commented 8 years ago

It is possible that I misunderstand how npm works, but I don't see any easy way to guarantee that the package lands in your project root directory, from where you run

$ npm i angular-formly --save

When you say "as long as they're listed in your package.json dependencies", do you mean -- before the installation? Usually they are not.

I have a Sandbox directory with many modules that I frequently need, in the hope not to download them again. Unfortunately, it is resulting in all sort of weird and unexpected behaviour. One of which is -- I can never successfully run a yeoman generator in any of the subdirectories, which always result in errors and leaving empty directory even after 10 minutes of intensive downloads :( The same generator would run quickly and successfully in another remote directory.

I might be missing something but that behaviour makes me somewhat uneasy. bower has indeed this annoying version conflict menus, but other than that it is more predictable.

kentcdodds commented 8 years ago

@dmitriz, I'm not sure I understand what you're describing, but if I had to guess, you're using npm in the wrong way.

When you say "as long as they're listed in your package.json dependencies", do you mean -- before the installation?

No, they don't need to be there before installation. When you install the module explicitly (either from an npm install angular-formly or from having it in your package.json), it'll go in the root of your node_modules directory.

Not sure what to tell you, but I'm pretty sure that you're not using npm correctly if you're experiencing that.

dmitriz commented 8 years ago

Hm... I wonder what could be my mistake...

I find the behaviour unpredictable if you don't have package.json files.

For instance, if you have node_modules inside your root, and empty subdirectory root/subdir, then running npm install package inside root/subdir leads to the package appearing in root/node_modules.

The same happens if root has package.json but root/subdir is empty.

However, if root has neither node_modules nor package.json, then the new package will appear in root/subdir/node_modules.

So when you are inside root/subdir, the behaviour depends the contents of root, which can be a problem, if you forget to do npm init and run the installation. Then the package will end up higher in the tree and your link will be broken.

However, you can still resolve it with browserify as far as I understand, so I guess this is a better way to stay out of troubles.

kentcdodds commented 8 years ago

Yeah, generally every project that depends on npm or bower will have a package.json or bower.json (respectively) to list dependencies. Then all the dependencies for the project will be added to as a sibling directory to the package.json (in the case of npm) called node_modules. If you're wanting to spread node_modules directories all over your project, that's a pretty unconventional way to use npm.