Programmatic SEA blob generation API
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 122k
- Forks
- 37.3k
- Merge moyen
- 4 j 2 h
- PR mergées (30 j)
- 283
Description
Currently, CLI commands and many files are involved in generating a SEA using Javascript.
For example:
import { execSync } from 'node:child_process';
import { copyFileSync, readFileSync, writeFileSync } from 'node:fs';
import { inject } from 'postject';
const blobPath = 'path/to/sea.blob',
configPath = 'path/to/sea.json',
outputPath = 'path/to/executable';
writeFileSync(
configPath,
JSON.stringify({
main: 'path/to/main.js',
output: blobPath,
disableExperimentalSEAWarning: true,
})
);
execSync('node --experimental-sea-config ' + configPath, { stdio: 'inherit' });
copyFileSync(process.execPath, outputPath);
await inject(outputPath, 'NODE_SEA_BLOB', readFileSync(blobPath), {
machoSegmentName: 'NODE_SEA',
sentinelFuse: 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2',
});
It would be nice if Node.js provided a Javascript API for generating SEA blobs. This would eliminate extra file creation and streamline the SEA creation process. I propose adding a function to the node:sea module/API (Typescript used for clarity):
/**
* Configuration options for generating a SEA blob
* @see https://nodejs.org/api/single-executable-applications.html#generating-single-executable-preparation-blobs
*/
interface BlobConfiguration {
main: string;
disableExperimentalSEAWarning?: boolean;
useSnapshot?: boolean;
useCodeCache?: boolean;
assets?: Record<string, string>;
}
/**
* Generates a SEA blob to be injected into an executable
* @param config configuration options for the blob
* @returns The blob contents in a buffer
*/
function generateBlob(config: BlobConfiguration): Buffer;
This new function in the SEA API would allow for more streamlined and readable code:
import { copyFileSync } from 'node:fs';
import { generateBlob } from 'node:sea';
import { inject } from 'postject';
const outputPath = 'path/to/executable';
const blob = generateBlob({
main: 'path/to/main.js',
disableExperimentalSEAWarning: true,
});
copyFileSync(process.execPath, outputPath);
await inject(outputPath, 'NODE_SEA_BLOB', blob, {
machoSegmentName: 'NODE_SEA',
sentinelFuse: 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2',
});
Which could even be inlined:
import { copyFileSync } from 'node:fs';
import { generateBlob } from 'node:sea';
import { inject } from 'postject';
const outputPath = 'path/to/executable';
copyFileSync(process.execPath, outputPath);
await inject(
outputPath,
'NODE_SEA_BLOB',
generateBlob({
main: 'path/to/main.js',
disableExperimentalSEAWarning: true,
}),
{
machoSegmentName: 'NODE_SEA',
sentinelFuse: 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2',
}
);
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’API node:sea existante et le flux de génération de --experimental-sea-config décrit dans l’issue, puis retracez la manière dont la CLI produit les blobs SEA. Le travail est terminé lorsqu’une API JavaScript peut générer des contenus de blob équivalents à partir de la configuration proposée sans créer de fichiers temporaires de configuration et de blob.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, node.js
- Domaine
- api, tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 48/100