Profiscience / knockout-contrib

:metal: KnockoutJS Goodies Monorepo
Do What The F*ck You Want To Public License
42 stars 6 forks source link

How to build?? #943

Open nkosi23 opened 3 years ago

nkosi23 commented 3 years ago

First of all, thank you for this project, it is really impressive. After spending a day studying the router and appreciating its elegance, I wanted to get started with prototyping but couldn't find release builds (the traditional .js and .min.js files often distributed as a convenience for such projects). Now my problem is that as a non-javascript developer, I do not have a javascript development environment set up and know close to nothing about setting up one with node, npm & cie. I am therefore struggling to get the ball rolling.

Package(s)

What I'm trying to do

I am trying to get started using the routing library. I need a single-file output that can be easily referenced from web pages (.js and .min.js files).

What I've tried

I have read up and installed node, npm and the typescript package, but apparently the tsc command isn't shipping with this package. So I navigated to the folder of the routing package (the source code from github, not the files coming with the npm package), and tried running npm install -D ts-node but I get an error saying:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @profiscience/knockout-contrib-router@2.1.5
npm ERR! Found: webpack@4.44.2
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^4.33.0" from @profiscience/knockout-contrib-router@2.1.5
npm ERR!   packages/router
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^5.0.0" from karma-webpack@5.0.0
npm ERR! node_modules/karma-webpack
npm ERR!   dev karma-webpack@"^5.0.0" from @profiscience/knockout-contrib-router@2.1.5
npm ERR!   packages/router
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 

My thinking is that I need to run node tsc build.ts in order to build everything, which is the reason I went that way. My goal is to have the output in a single file that I can easily include in my web page using a script tag.

Alternatively (and to be honest), I am really not interested in setting up a JS environment :smile: so if someone could send me .js and .min.js build files for the router that I can rapidly use, I would be very grateful. I am mainly a .NET guy, using typescript in an msbuild context (ie. in my applications, I launch tsc using an msbuild task). We never need to use nodejs-based webdev tooling in this ecosystem. So I am quite lost at the minute, all I hope to do is get started using this inspiring library :+1:

nkosi23 commented 3 years ago

I have been able to fix the build issue by changing the karma-webpack package version from "5.0.0" down to "4.0.2" in /router/packages.json. This has allowed me to install ts-node using the command npm install ts-node. I was then able to build the project by running npm run build in the project root.

That being said, this didn't merge the output of the various files into a single file, neither did it produce a typescript definition file. So for time being, I will simply include the source code of the router in my projects I guess.