onion and npm?

7 views
Skip to first unread message

Basile Starynkevitch

unread,
Jun 10, 2018, 12:43:22 PM6/10/18
to onion-dev

Hello All


I am not very well aware of npm, but how would npm and libonion mix together?

Assume that I am using libonion in a project where all Web resources (HTML templates, JavaScript, CSS) should be "inside" that project and handled by libonion. I don't want to depend on external resources, because I want my web application (FWIW, it is my bismon on github) to be used either in a closed network, or even on my laptop without any Internet connection (so both the bismon program - serving HTTP thru libonion and the browser are running on the same Linux laptop).


For example, take jquery. I could have in my build process some wget https://code.jquery.com/jquery-3.3.1.js command, but I would prefer a simpler npm install jquery.

How should that really work?


Cheers

-- 
Basile STARYNKEVITCH   == http://starynkevitch.net/Basile
opinions are mine only - les opinions sont seulement miennes
Bourg La Reine, France

Zachary Grafton

unread,
Jun 11, 2018, 7:29:11 AM6/11/18
to onion-dev
Basile,

I would imagine that npm and libonion don’t really mix from libonion's perspective. If it were me, I'd use npm in combination with webpack to generate a bundle of javascript for your application. Then, I would use opack as part of the build process to generate a header file and associated handler containing the contents of the bundle. I would think that this is the easiest route.

If you really want to insist on going the route of using just npm, you would just need to run npm install, and then use opack on the minified jquery sources that are found in the node_modules directory of your project. There are 2 issues with this 1.)you will need to run opack on all of the dependencies and 2.) you will potentially have to change your build script every time you update your dependencies, as the paths within node modules might change if you upgrade a javascript package.

If you need a detailed example, I might be able to come up with one in a day or so.

Zack Grafton

From: Basile Starynkevitch [mailto:bas...@starynkevitch.net]
Sent: Sunday, June 10, 2018 12:43 PM
To: onion-dev <onio...@coralbits.com>
Subject: [onion-dev] onion and npm?

Hello All

I am not very well aware of npm, but how would npm and libonion mix together?
Assume that I am using libonion in a project where all Web resources (HTML templates, JavaScript, CSS) should be "inside" that project and handled by libonion. I don't want to depend on external resources, because I want my web application (FWIW, it is my https://github.com/bstarynk/bismon on github) to be used either in a closed network, or even on my laptop without any Internet connection (so both the bismon program - serving HTTP thru libonion and the browser are running on the same Linux laptop).

For example, take http://jquery.com/. I could have in my build process some wget https://code.jquery.com/jquery-3.3.1.js command, but I would prefer a simpler npm install jquery.
How should that really work?

Cheers
--
Basile STARYNKEVITCH == http://starynkevitch.net/Basile
opinions are mine only - les opinions sont seulement miennes
Bourg La Reine, France
--
You received this message because you are subscribed to the Google Groups "onion-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mailto:onion-dev+...@coralbits.com.
To post to this group, send email to mailto:onio...@coralbits.com.
Visit this group at https://groups.google.com/a/coralbits.com/group/onion-dev/.
For more options, visit https://groups.google.com/a/coralbits.com/d/optout.

Reply all
Reply to author
Forward
0 new messages