quickbundle 0.0.0-next-d9c46be → 0.0.0-next-ed1776f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +41 -21
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { helpers, termost } from 'termost';
2
- import { readFile as readFile$1 } from 'node:fs/promises';
2
+ import { readFile as readFile$1, writeFile, rm } from 'node:fs/promises';
3
3
  import process, { chdir } from 'node:process';
4
4
  import { watch as watch$1, rollup } from 'rollup';
5
5
  import { join, dirname, basename } from 'node:path';
@@ -12,11 +12,10 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
12
12
  import json from '@rollup/plugin-json';
13
13
  import commonjs from '@rollup/plugin-commonjs';
14
14
  import os from 'node:os';
15
- import { writeFileSync } from 'node:fs';
16
15
  import { gzipSize } from 'gzip-size';
17
16
 
18
17
  var name = "quickbundle";
19
- var version = "0.0.0-next-d9c46be";
18
+ var version = "0.0.0-next-ed1776f";
20
19
 
21
20
  const CWD = process.cwd();
22
21
 
@@ -144,7 +143,7 @@ const getBuildableExports = ({ standalone })=>{
144
143
  * Following the [package entry-point specification](https://nodejs.org/api/packages.html#package-entry-points),
145
144
  * whenever an export object is defined, it take precedence over other classical entry-point fields
146
145
  * (such as main, module, and types defined at the root package.json level).
147
- */ if ((PKG.main || PKG.module) ?? PKG.types ?? !PKG.exports) {
146
+ */ if (PKG.main || PKG.module || PKG.types || !PKG.exports) {
148
147
  throw new Error("Invalid package entry points contract. Use the recommended [`exports` field](https://nodejs.org/api/packages.html#package-entry-points) instead and, for TypeScript-based projects, update the `tsconfig.json` file to resolve it properly (`moduleResolution` must be set to `Bundler` (or `NodeNext`)).");
149
148
  }
150
149
  const buildableExportFields = [
@@ -327,28 +326,44 @@ const createCompileCommand = (program)=>{
327
326
  name: "compile",
328
327
  description: "Compiles the source code into a self-contained executable"
329
328
  }).task({
330
- async handler () {
331
- const osType = os.type();
332
- const isWindowsOS = osType === "Windows_NT";
333
- const isMacOS = osType === "Darwin";
334
- const configuration = createConfiguration({
329
+ key: "osType",
330
+ label: "Get context",
331
+ handler () {
332
+ const type = os.type();
333
+ return type === "Windows_NT" ? "windows" : type === "Darwin" ? "macos" : "linux";
334
+ }
335
+ }).task({
336
+ key: "config",
337
+ label: "Create configuration",
338
+ handler () {
339
+ return createConfiguration({
335
340
  minification: true,
336
341
  sourceMaps: false,
337
342
  standalone: true
338
343
  });
339
- await build(configuration);
340
- for (const { bin, require: filePath } of configuration.metadata){
341
- if (!filePath || !bin) {
342
- throw new Error("Invalid configuration output. Missing `filePath` or `bin` field definition.");
343
- }
344
+ }
345
+ }).task({
346
+ label: "Build",
347
+ async handler ({ config }) {
348
+ await build(config);
349
+ }
350
+ }).task({
351
+ label ({ config }) {
352
+ const binaries = config.metadata.map(({ bin })=>{
353
+ if (!bin) return undefined;
354
+ return `\`${bin}\``;
355
+ }).filter(Boolean).join(", ");
356
+ return `Compile ${binaries}`;
357
+ },
358
+ async handler ({ config, osType }) {
359
+ for (const { bin, require: filePath } of config.metadata){
360
+ if (!filePath || !bin) continue;
344
361
  chdir(dirname(filePath));
345
362
  const fileName = basename(filePath);
346
363
  const blobFileName = `${fileName}.blob`;
347
- /*
348
- * TODO: split with several tasks
349
- */ const executableFileName = `${bin}${isWindowsOS ? ".exe" : ""}`;
364
+ const executableFileName = `${bin}${osType === "windows" ? ".exe" : ""}`;
350
365
  const seaConfigFileName = `${fileName}.sea-config.json`;
351
- writeFileSync(seaConfigFileName, JSON.stringify({
366
+ await writeFile(seaConfigFileName, JSON.stringify({
352
367
  disableExperimentalSEAWarning: true,
353
368
  main: fileName,
354
369
  output: blobFileName,
@@ -357,13 +372,18 @@ const createCompileCommand = (program)=>{
357
372
  }), "utf-8");
358
373
  await helpers.exec(`node --experimental-sea-config ${seaConfigFileName}`);
359
374
  await helpers.exec(`node -e "require('fs').copyFileSync(process.execPath, '${executableFileName}')"`);
360
- if (isMacOS) {
375
+ if (osType === "macos") {
361
376
  await helpers.exec(`codesign --remove-signature ${executableFileName}`);
362
377
  }
363
- await helpers.exec(`npx postject ${executableFileName} NODE_SEA_BLOB ${blobFileName} --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 ${isMacOS ? "--macho-segment-name NODE_SEA" : ""}`);
364
- if (isMacOS) {
378
+ await helpers.exec(`npx postject ${executableFileName} NODE_SEA_BLOB ${blobFileName} --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 ${osType === "macos" ? "--macho-segment-name NODE_SEA" : ""}`);
379
+ if (osType === "macos") {
365
380
  await helpers.exec(`codesign --sign - ${executableFileName}`);
366
381
  }
382
+ await Promise.all([
383
+ blobFileName,
384
+ seaConfigFileName
385
+ ].map(async (file)=>rm(file)));
386
+ chdir(CWD);
367
387
  }
368
388
  }
369
389
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickbundle",
3
- "version": "0.0.0-next-d9c46be",
3
+ "version": "0.0.0-next-ed1776f",
4
4
  "description": "The zero-configuration transpiler and bundler for the web",
5
5
  "author": {
6
6
  "name": "Ayoub Adib",