From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oDDqISlMeWM0NQEAbAwnHQ (envelope-from ) for ; Sat, 19 Nov 2022 22:35:37 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 8JMAISlMeWNMfQAAG6o9tA (envelope-from ) for ; Sat, 19 Nov 2022 22:35:37 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 51CDAE65D for ; Sat, 19 Nov 2022 22:35:37 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owVUg-0004AR-Pg; Sat, 19 Nov 2022 16:35:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owVMw-0000zX-Tn for guix-devel@gnu.org; Sat, 19 Nov 2022 16:27:22 -0500 Received: from mta-12-4.privateemail.com ([198.54.127.107]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owVMu-0006FK-V1 for guix-devel@gnu.org; Sat, 19 Nov 2022 16:27:22 -0500 Received: from mta-12.privateemail.com (localhost [127.0.0.1]) by mta-12.privateemail.com (Postfix) with ESMTP id C3CC018000A3 for ; Sat, 19 Nov 2022 16:27:08 -0500 (EST) Received: from APP-07 (unknown [10.50.14.157]) by mta-12.privateemail.com (Postfix) with ESMTPA id 9E6B018000A2 for ; Sat, 19 Nov 2022 16:27:08 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=twdb.moe; s=default; t=1668893228; bh=BnRGVSwHkSPHG2OXhLJnL5rSPb/62Pxm5k3RhEMjNcY=; h=Date:From:To:Subject:From; b=NCQE3Le87b1RxjcLRoU94mB8RWZVgdHSuSjxlwXKQVsUOjkznfY3BkWyP/qXvNIpC 7vNcnoMD5b3Gj8/R+ruUpie8LCQsivl6taaqduUcVX+nSDert+sjXNSxk1vlJfyKuh wETqrT6D8mNo5z43n9wZcD59TIPl4JdOyRFsnvpExV99+pTHaV7ja2KqGedgYR+sdo amTk06KQFCZ5gKMjpo/6mqNtjp7si2yRou5fAYP2FDhgh56mcKKCqwBnhkwFXt8zWj LPMOLRjsyBUkTwIqrbVE8FZkf+XoJhEY165ccLyZCcjpdv55Q2u2YdxfiRj+xbNdHn Wv2epKsb94wKA== Date: Sat, 19 Nov 2022 18:27:08 -0300 (BRT) From: zamfofex To: "guix-devel@gnu.org" Message-ID: <450401139.631101.1668893228599@privateemail.com> Subject: bringing npm packages to Guix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev30 X-Originating-Client: open-xchange-appsuite X-Virus-Scanned: ClamAV using ClamSMTP Received-SPF: pass client-ip=198.54.127.107; envelope-from=zamfofex@twdb.moe; helo=MTA-12-4.privateemail.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 19 Nov 2022 16:35:20 -0500 X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668893737; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=BnRGVSwHkSPHG2OXhLJnL5rSPb/62Pxm5k3RhEMjNcY=; b=o00fan5SxdB7MewMeYhdR6QAHtupt7dVaBIHYMtHG4ZQmq7OrK09ZKT4vdR6uZV8RwOWG/ juBDY1ACwVysBcq8SBBLfzU07cDQZgvVbU5z38RkrqcqV/6aeZSwIGVs4BUmx1BbFaTfTa PVOWyuP0JpOzH6ohiQBBG1J57Jz9GagCkqrYRlHXff581GUBCQmQSPsg8jqZHYn2+work+ jzc3tdvGQNiGVBSttqIQmATtQ1ptLRvjw+rjrmbEZtMD/960LBcm+N5x1RlCcz4s9HPsss dKywSXbo+0MEq/F6/daXmjyx8HaeHpGw5ZtDxyAT+jPAQgybc7/oKTk2Z0T8xA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668893737; a=rsa-sha256; cv=none; b=k0fgCxxnG/4N2D+xGRN7yO0gXM6wKhidhk4frmBta9AUuU725gVbORJUWhSLSh9G8nVajG 3rxynSQQLabkV2k3gLaYQ7DlrqeP9AE8ieXhcBRmH/ZgJ15hbHn3VZn3TE+JxigGupTKqT AZUKwqDEeJ6wxDA11q3h3hCRVwSdOFP96oInbRcxr0bCfMuVI3DDGg7q15BOojGWYns8JB GC0ws9R6ApMLriSlN/W0QTINjKM0DZ3LqBwCyQvQAhSP59+USgyu+b3cjSLuViGml0Pyuj hz1N1CX/I/ReYRcX1ntdUBaEARFz0LeZvy09PxLFfiueRi5IZyh2ZfMvb076CQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=twdb.moe header.s=default header.b=NCQE3Le8; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.81 Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=twdb.moe header.s=default header.b=NCQE3Le8; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 51CDAE65D X-Spam-Score: -2.81 X-Migadu-Scanner: scn1.migadu.com X-TUID: ggHg1A2JPGhG Hello, Guix! A few months ago, I picked up the work towards importing npm packages to Gu= ix by Jelle et al. in the hopes of continuing it, and I felt disheartened w= hen I concluded that it does indeed seem like a very large part of npm is n= ecessary to build even a simple package like jQuery. But, recently, I decided to spend some more time thinking about it, and I r= ealized that not all of the =E2=80=98devDependencies=E2=80=99 of a given pa= ckage are actually necessary to build it. A lot of packages have =E2=80=98d= evDependencies=E2=80=99 for things such as tests and watching the filesyste= m for changes for ease of development. If you think about it, what the vast majority of npm packages need to build= successfully comes down to (optionally) compile TypeScript, then (optional= ly) perform some kind of bundling or transpilation. And that doesn=E2=80=99= t really require TypeScript or a build tool from npm, since esbuild (which = is already packaged) can do both of those things by itself. Now, taking away the =E2=80=98devDependencies=E2=80=99 when recursing the d= ependency tree makes the whole endeavor of importing an npm package seem *m= uch less* difficult and scary! The biggest unfortunate issue is that for pa= ckages with a build step (TypeScript and/or bundling+transpilation), it is = necessary to use esbuild ad=E2=80=90hoc (i.e. in a case-by-case basis), bec= ause each package has its own build peculiarities, and esbuild doesn=E2=80= =99t acknowledge them. (One solution could be to create an esbuild wrapper = that mimics =E2=80=98tsc=E2=80=99 and other tools.) With that approach in mind, I was able to package sucrase as a proof of con= cept! Note that sucrase doesn=E2=80=99t have a lot of transitive dependenci= es, so it was easy to just modify the phases of each package in an ad=E2=80= =90hoc way. However, also note that sucrase depends on itself, so I decided= to bootstrap it with esbuild, then use the bootstrapped version to build s= ucrase again. (The bootstrapped sucrase seems to also work as expected!) The import script I wrote, alongside the sucrase package itself can be foun= d here: - Any kinds of thoughts or feedback on this would be appreciated! A few notes of potential future work: - Keep tests on packages, after packaging the necessary test libraries. - Maybe: Write a wrapper for esbuild for mimicking =E2=80=98tsc=E2=80=99 an= d other tools. (As mentioned above.) - Figure out a way to detect vendored dependencies and other forms of bundl= es in repositories. - Polish the import script, and make it fit Guix=E2=80=99 style and formatt= ing practices. - Use the =E2=80=98version=E2=80=99 variable in the source field of package= definitions when importing. (An extension of the item above.)