I feel comfortable using Gulp for compiling scss, minifying it, minifying and concatenating scripts etc. For installing vendor libraries bower seems really nice to me due to its flat dependency tree. But when I install Gulp locally with
npm install gulp
it creates a node_modules folder with lots of different libs except Gulp itself. So I it comes to that I don't actually need bower and I may use these libs. But I really don't like npm's complicated dependency tree. Perhaps, I could somehow install only Gulp itself and use just bower for dependencies?
And what about package.json and bower.json? Do I really need both of them in the project or maybe they duplicate one another's functions? In general, I'm feeling a bit of confused with how to use bower and gulp together. Maybe someone could clarify those moments to me?
Gulp is an automated build tool you get with nodejs's package manager npm, it's used to run tasks such as concatenating, compiling sass, etc.
Bower is a dependency management tool whereby it fetches libraries, and their dependencies for your project. It does nothing but dependency management.
An example of how the two are used together would be fetching bootstrap and jquery with bower, then using gulp to copy the relevant scripts (jquery.js &bootstrap.js) to your websites assets folder.
Basically you'd use bower to fetch a library, such as jquery, then you'd use gulp to minify your jquery code.
A final example would, you use bower to fetch jquery, bootstrap, and say angularjs, you then use gulp to concatenate them into one file 'vendor.js', to save http requests in your app.
Hope those examples shine some light on how the two are used together.
Related
The current project is an older monorepo project, which uses yarn to manage dependency packages, and many subprojects use phantom dependencies. At present, the project is gradually migrating to pnpm, but there is a problem that each subproject uses many npm packages that are not in its own package.json. However, there are dozens of such sub-projects, and manual statistics are a very heavy workload. Is there any good tool that can help me find out all the npm packages that each sub-project depends on through text analysis? In this way, I can find all missing dependencies by comparing the subproject's package.json and add them to the subproject's package.json.
There is currently no good idea to solve this problem. In the search tool, if there is no such tool, consider using python to write a new one.
When webpack bundles the node_modules my project needs, do I still need dependencies or could I list everything to devDependencies?
I have created a react component library and have published it to npm. The only peerDependencies I've listed are react and react-dom, because, well, you'll need them when using my library. At first I set up my project like I normally would, stuff like babel, eslint, css-loader listed in the devDependencies, and stuff I actually use in my code, like prop-types, classnames, react-slick, listed as dependencies.
I then use webpack with babel to create one main.js with the module imports included
When someone on my team tries to use my library npm will give some errors 'Peer dependencies unmet' with stuff like webpack, eslint & #babel/core. So I'm guessing these are some peer dependencies from my dependencies? (that's a little side question)
That got me thinking, do I even need dependencies at all? Since webpack bundles everything and I only use my main.js, shouldn't everything be a devDependency?
Dependencies are those that your project needs to run, like a library that provides functions that you call from your code.
Dev dependencies are dependencies you only need during development or releasing, like compilers that take your code and compile it into javascript, test frameworks or documentation generators.
Working on a larger typescript project we decided to move the code to a monorepo with yarn workspaces.
We use webpack to build and bundle and everything works well (especially the linking between local modules/packages).
Since yarn workspaces will store most of the node_modules in the mono repo's root folder, the IDE (IntelliJ as well as VSCode) have problems resolving the imports to any node_modules when coding inside a "inner" project (so called "package" of a monorepo).
The strange thing is that imports are not known but on the other hand most of the time you can navigate to the correct source / definition within the IDEs for the same import if you write it down manually.
We have tried to tell IntelliJ to look into another folder for node_modules, but still not satisfying.
Please share your experience with yarn workspaces / monorepo (e.g. lerna) and how you develop the code living in these monorepos.
Which IDE do you use?
Did you add any special configurations to the IDE and/or package.json, tsconfig.json?
https://github.com/Izhaki/mono.ts
It uses yarn workspaces and marry well with VSCode. I hope the README is clear enough.
Basically, use two (parallel) typescript configuration trees:
Pre-build - uses aliases (for VSCode, tests, webpack, etc).
Build - uses typescript 3 project references for publishing essentially.
IDEA doesn't provide any support for Yarn workspaces; if you miss it, please follow WEB-29250 and linked tickets for updates.
You can try adding path mappings to your tsconfig.json - see https://intellij-support.jetbrains.com/hc/en-us/community/posts/207656825/comments/115000529564
Upodate as of 2018.1.1 IntelliJ now supports yarn workspaces so if you use this there should not be a problem.
https://blog.jetbrains.com/webstorm/2018/04/webstorm-2018-1-1/
Please share your experience with yarn workspaces / monorepo (e.g. lerna) and how you develop the code living in these monorepos.
Which IDE do you use?
Since you are asking. I basically ran into the same issues as you did. One solution I was looking into was disable hoisting node modules as described here. Unfortunately it seems it is not yet in the stable release.
What I ended up was ditiching workspaces for now until they fix either the IDE or release the nohoist option. Instead I am using lerna for now. It is less convenient but it does not hoist so that both the build tools and the IDE are satisfied.
Oh, I am also using IntelliJ (ultimate)
So I'm creating my own ivy repository. I have went through the tutorial for building the repository and the basic task of installing one module works flawlessly. Of course, there we have examples of installing one module. Actually the ant task install can do only one module at the time. Since I'd like to store everything that's in the cache in the repository, it would be quite tedious to do that by running one module at the time...
Other then writing some kind of a build.xml generator that would have install task for each of the module I need/have, is there an easier way to do this? If there is some trick to use some kind of meta ivy.xml that has all the dependencies I need installed, that would also be ok.
In addition if I run install on one module with transitive=true, for example module M, in my repo I have M's jar,sources,javadoc and everything, but for M's dependencies - only the jars. How would I install sources,javadocs,etc of transitively dependent modules?
I have a nuget package that provides frontend as well as backend code.
Usually I'd use the content folder in my nuget structure to distribute javascript and css files to the clients.
Now, with aspnet5, the recommended way to install frontend dependencies is to use bower or npm.
My nuget package makes no sense as a standalone .net package nor as a js+css package. It'd be great if I could just add a dependency to my package and have it working.
What's the recommended way to achieve this?
Edit:
As #VictorHurdugaci said, Nuget is not a great delivery mechanism for frontend dependencies. But I need a way to build a cohesive package that my clients install it and "just works (tm)".
I could use bower, but then I'd have to remember to add the dependency to my bower.json and keep them in sync with my nupkg.
Using bower, or npm, is there a way to pack it all in a single "artifact" for clients to use?
Nuget is not a great delivery mechanism for client side assets. Use Bower or something similar instead.