Resolve `npm:`/`jsr:` versions from the installed tree for Deno-based presets

オープン
#4,618 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
deno, typescript

調査の方向性

既存の TracedPackage.versions ロギングがある src/build/plugins/externals.ts と、nitro.options.node のチェックがある src/build/plugins.ts から始め、deno_deploy と bunny のプリセットがこれらのパスをどのように設定しているかを比較してください。オプトイン設定と推移的依存関係の動作を明確にし、その後、関連する Deno プリセットでインストール済みの直接依存関係のバージョンが出力されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

externals preset:deno
Describe the feature

While fixing something on the Bunny preset (#4025) I've made the Deno-based presets keep npm: and jsr: specifiers external, so import { escape } from "npm:[email protected]" survives the bundle and gets resolved by the runtime instead of failing to resolve at build time.

That part works, but pinning the version is currently entirely on the user. What I would actually like is to mark a package as external and have Nitro emit the version that is installed, so a plain import { decodeJwt } from "unjwt" comes out as npm:[email protected] even when package.json says ^0.7.0.

The clearest win is on Bunny, where the script is a single file with a 10MB cap, so keeping deps out of the bundle actually matters. Tho it would apply to deno_server and deno_deploy just as well, for custom implementations and runtimes.

Most of the machinery seems to already be there: nf3 hands us the exact resolved versions per package (TracedPackage.versions), and we already consume that hook in
externals.ts only to log them.

Two things I got stuck on though:

  1. the trace only runs when nitro.options.node is true, and the presets that would want this (deno_deploy, bunny) set node: false. So the version resolution would need to be independent from the file-copying path
  2. it only pins the direct dependency. Deno then resolves the transitive ones from the registry on its side, so it is a partial pin and not really a lockfile equivalent. I am not sure whether that is acceptable or if it defeats the point

I also have no strong opinion on the config surface, an opt-in list of packages feels right but that is about as far as I got.

Additional information
  • Would you be willing to help implement this feature?
主要言語
TypeScript
スター
11.5k
フォーク
968
平均マージ
4日 9時間
マージ済み PR(30日)
64

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nitrojs/nitro のほかの issue

nitrojs/nitro の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。