2022-08-03 23:32:54 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
2022-09-09 14:36:35 +00:00
|
|
|
stdenv,
|
|
|
|
deno2nix,
|
|
|
|
lib,
|
2022-08-03 23:32:54 +00:00
|
|
|
...
|
|
|
|
}: {
|
|
|
|
name,
|
|
|
|
version,
|
|
|
|
src,
|
|
|
|
entrypoint,
|
|
|
|
lockfile,
|
|
|
|
importMap ? null,
|
|
|
|
denoFlags ? [],
|
|
|
|
}: let
|
2022-09-09 14:36:35 +00:00
|
|
|
inherit (deno2nix.internal) mkDepsLink;
|
2022-08-03 23:32:54 +00:00
|
|
|
in
|
2022-09-09 14:36:35 +00:00
|
|
|
stdenv.mkDerivation {
|
2022-08-03 23:32:54 +00:00
|
|
|
inherit name version entrypoint;
|
|
|
|
denoFlags =
|
|
|
|
denoFlags
|
|
|
|
++ (
|
|
|
|
if importMap != null
|
|
|
|
then ["--import-map" importMap]
|
|
|
|
else []
|
|
|
|
);
|
|
|
|
|
|
|
|
src = lib.cleanSourceWith {
|
|
|
|
inherit src;
|
|
|
|
filter = path: type: (baseNameOf path != "bundled.js");
|
|
|
|
};
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
deno
|
|
|
|
jq
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
export DENO_DIR=`mktemp -d`
|
|
|
|
ln -s "${mkDepsLink lockfile}" $(deno info --json | jq -r .modulesCache)
|
|
|
|
|
|
|
|
deno bundle $denoFlags $entrypoint bundled.js
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/dist
|
|
|
|
install -t $out/dist bundled.js
|
|
|
|
'';
|
|
|
|
}
|