26 ms·
Asking out loud, but is anyone aware of a way to build Ruby on Rails assets with Deno in place of yarn and node? The use case is to be able to leverage ES6/Typ
by rajangdavis 6y ago
Asking out loud, but is anyone aware of a way to build Ruby on Rails assets with Deno in place of yarn and node?
The use case is to be able to leverage ES6/Typescript but have security built into the assets management. I'm not unhappy with the sprockets pipeline, but I would like to move forward with a modern assets pipeline without having to think too hard about the security implications of using yarn and node.
- qbasic_forever 6y agoMaybe esbuild can help? It's a go-based bundler that does typescript, es6, etc. and a lot more. https://github.com/evanw/esbuild https://github.com/evanw/esbuild It's still pretty well integrated into the npm world and distributed as a node package though, so there might be some issues.
- rajangdavis 6y agoThanks, I'll take a look, there might be something to look at to get something going.
- e1g 6y agoesbuild is a "bundler" and can replace webpack/rollup, but you still need to use yarn/npm to install all dependencies exactly the same as you do now. If your concern is primarily security-driven, esbuild is not to the topic. This applies to all other bundlers like Snowpack and Vite etc. As for migrating to Deno: you probably will not be able to do this because most NPM packages will not run in Deno out of the box. Your build pipeline almost certainly relies on libraries like gulp/sass/globby, and those projects will need to be ported first (or made compatible by their authors).
- searchableguy 6y agoAny modules on npm for web may work with minimal to no changes. You will need to convert them to esm. There are cdns which provide automatic conversion. 1. https://esm.sh https://esm.sh 2. https://skypack.dev https://skypack.dev Deno provides built in bundler. It is low level but there are third party packages built on top of it. All the three packages mentioned have equivalent in the deno ecosystem. Try searching on https://deno.land/std https://deno.land/std and https://deno.land/x https://deno.land/x Manual for built-in stuff in deno: https://deno.land/manual https://deno.land/manual
- e1g 6y agoThe overwhelming majority of NPM packages are still in CJS, and will not work under Deno today. Yes, you can do hack-arounds like jspm.io/skypack, but if the person is concerned with stability and/or security, adding a 3rd party middleman into the pipeline will not go down well. Now that Node supports ESM, I hope this year will start seeing more migrations, but it will be at a glacial place because the ESM<->CJS compatibility remains extremely brittle (among all bundlers, and for Node+Browser usage). If you are writing a greenfield small library you can make it work. But it will be a long time - if ever - before we see things like @babel work.
- pupdogg 6y agoI don’t know about Rails specifically but I was able to create my own custom asset pipeline for Roda framework using the latest version of Snowpack. I’m assuming it would be no different for Deno.
- rajangdavis 6y agoDo you happen to have source you can share? I've rolled my own assets pipeline with a Sinatra app, but did not tap into Node. I think with Rails, there's probably some way to hook into the framework, just not sure how one would approach this.
- pupdogg 6y agoMy project is closed-source but I used this project as a starting point: https://github.com/choonggg/fusrodah https://github.com/choonggg/fusrodah It's a really good/barebones Roda project that uses webpack for assets/js pipeline and Tailwind CSS for UI. My methodology was: 1) clone the project 2) then swap out webpack for Snowpack I was able to do that within 1 day and honestly, it was well worth the effort due to the amount of knowledge that come with it. Snowpack is much much faster and efficient in terms of resources vs webpack. The newest version, Snowpack3, uses esbuild internally which basically puts it on steroids. Good luck! Reference: https://www.snowpack.dev/posts/2021-01-13-snowpack-3-0 https://www.snowpack.dev/posts/2021-01-13-snowpack-3-0 FYI, in my dev stack, I'm running Puma server, Sidekiq worker, Snowpack dev server and Guard for live reload capabilities. I'm using Foreman to startup all 4 things using a Procfile and my startup time clocks in at 2.85s from issuing "foreman start". I hope this helps!
- rajangdavis 6y agoThanks!
- seer 6y agoIf your concern is mainly security, you can try yarn 2 (berry)’s “zero install” feature. That vendors yours dependencies, so the whole project can then be started without yarn itself, but avoids the gigabytes and millions of files problem of node_modules. Just an alternative.