lodash npm distribution in browser - npm

I'm using lodash in my tests, Not using webpack or browserify (don't need to).
I found that the default npm build differs from what's in bower. I could of course use bower version, but I'm curious if I can use npm's instead (it's already there for Gulp).
For bower I could just add this line to karma.conf:
bower_components/lodash/lodash.js
but in default npm distro there's no lodash.js. Of course I can always build whatever version I want using lodash cli. But maybe there's even easier way, say maybe I need to add more than just one file from node_modules/lodash?

I think you are looking for node_modules/lodash/index.js

Related

If I install lodash.minby does it means it just installs this specific function?

I am getting rid of lodash, so some stuff I am redoing in es6 and other like this one I would like to keep but just this one function.
I see there is this npm https://www.npmjs.com/package/lodash.minby but im not sure if i install this it will only install this, or the whole library, can anyone please confirm?
Thanks.
From the documentation:
The lodash method _.minBy exported as a Node.js module.
So, yes, it just installs this specific function from lodash
Yes, if you install lodash.minby, at the time of this writing, you will get version 4.6.0 which contains a package.json file, a README.md file, a LICENSE file, and an index.js file. It has no other dependencies, so that is all you will get. The index.js file is over 2000 lines long, but that's what it takes apparently to implement the functionality.
In contrast, at the time of this writing, npm install lodash will give you version 4.17.21 which contains over 44000 lines of JavaScript spread out across many files. So that's about 22 times as large.

How to make each Vue build include a version accessible in Vue app?

In Vue, I'd like to be able to get the current build version. Preferably, it would be in YYYY-MM-DD-HH-MM format (the build time), rather than a random hash (which would be ok too).
Here's how someone did this
https://medium.com/#howitson/passing-generated-build-numbers-to-vue-app-f301e6b11877
Another idea:
have a bash script which updates .env file with a line VUE_APP_BUILD_VERSION=... (is there any utility for this?)
and then run npm run build
Any suggestions for simpler ways? Maybe get the .js file path and use that? /js/app.5e716dd8.js
You can use npm version patch in your build script, and get the version number from package.json.

Remove plugins with vue-cli3

Is there a way to remove plugins and its configuration with vue-cli3 in an existing project? For example I want to replace unit test plugin Mocha with Jest. I know how to add and invoke a new plugin but I cannot find how to remove one. Is it possible with vue-cli or do I need to do it manually?
I've asked about this (How does one uninstall a plugin? #2540) and it appears the current official advice is to issue an npm uninstall X.
I think you can just go to your package.json and remove the entry for the plugin/package,
delete the directory of your node_modules,
and then run.
npm install
Delete the vuetify stuff[1] from your package.json and then run:
npm prune
[1] Dependency vuetify and dev dependencies vue-cli-plugin-vuetify, vuetify-loader...
It looks like you need to do it manually, I cannot find anything in the docs or CLI help that mentions removal of plugins. It is slightly more complicated than #alexandre-canijo says though. Besides the package.json there may be some config in your project folder. Check the src/plugins folder, and main.js.
The documentation
You have to do it manually. It worked for me.
In my case, I just removed the plugin ("vue-cli-plugin-quasar": "^2.0.1",) from devDependencies in package.json and ran npm install.
With the new "vue ui" option, removing installed cli-plugins is supported now.
Under "Dependencies" (second tab on the left of vue ui) you'll find all plugins listed. And on the right of each plugin there is a little trash icon, which removes the respective plugin.
You still might get compile errors due to dead references in your sources, but those can be identified quickly with the provided log and error messages.

How to install specific version of yarn using the npm API

I want to download a specific version of yarn by using the npm api
How can I achieve this?
After looking through the NPM Registry API, it looks like it would be pretty simple to do that.
GET: https://registry.npmjs.org/<package> returns a JSON object with a versions field and for each version there is a dist field which has a URL to that package's tarball.
If you know the version ahead of time, GET: https://registry.npmjs.org/<package>/<version> would also work.
If you just want the tarball straight up, the format for the URL for getting a package's tarball is https://registry.npmjs.org/<name>/-/<name>-<version>.tgz. Although the registry documentation says that this might not always be true.

How to use Cycle.js without Browserify/Webpack?

Bower: I couldn't find a Bower package for #Cycle/Core, #Cycle/DOM, do these libraries exist? I'm confused at why there is an NPM package in the first place since Cycle.js is front-end based (and NPM is specialized for back-end only).
ES5: Is it possible to use Cycle.js with Gulp/Typescript/ES5 (and not use Browserify/webpack)?
npm is not specialized for back-end only. It is for everything.1
It is possible to use Cycle.js without browserify or webpack. The library comes with ES5 distribution files, found in the dist directory.
Yes, you can use Gulp, TypeScript and ES5 with Cycle.js.
Everything Frederik said, plus here is a standalone Cycle.js example on codepen. You can see the links to the JavaScript files being loaded by clicking on Settings, then JavaScript. Here they are for convenience:
https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.7/rx.all.js
https://rawgit.com/cyclejs/cycle-core/master/dist/cycle.js
https://rawgit.com/cyclejs/cycle-dom/master/dist/cycle-dom.js
Full example is on codepen
Or you can try stealjs.
At runtime it downloads your dependencies.
I use npm to get the packages, gulp to move the packages to wwwroot. TypeScript to downcompile, and systemjs to load the modules. No webpack or bower required.