quickbundle 0.0.0-next-4ad7f8b → 0.0.0-next-5441a21

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 +43 -35
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { helpers, termost } from 'termost';
2
2
  import { readFile as readFile$1, writeFile, rm } from 'node:fs/promises';
3
- import process, { chdir } from 'node:process';
3
+ import process from 'node:process';
4
4
  import { watch as watch$1, rollup } from 'rollup';
5
- import { join, dirname, basename } from 'node:path';
5
+ import { join, basename, dirname, resolve } from 'node:path';
6
6
  import { createRequire } from 'node:module';
7
7
  import { swc } from 'rollup-plugin-swc3';
8
8
  import externals from 'rollup-plugin-node-externals';
@@ -15,7 +15,7 @@ import os from 'node:os';
15
15
  import { gzipSize } from 'gzip-size';
16
16
 
17
17
  var name = "quickbundle";
18
- var version = "0.0.0-next-4ad7f8b";
18
+ var version = "0.0.0-next-5441a21";
19
19
 
20
20
  const CWD = process.cwd();
21
21
 
@@ -356,41 +356,49 @@ const createCompileCommand = (program)=>{
356
356
  return `Compile ${binaries}`;
357
357
  },
358
358
  async handler ({ config, osType }) {
359
- // TODO: Optimize via Promise.allSettled + Update README.md
360
- for (const { bin, require: filePath } of config.metadata){
361
- if (!filePath || !bin) continue;
362
- chdir(dirname(filePath));
363
- const fileName = basename(filePath);
364
- const blobFileName = `${fileName}.blob`;
365
- const executableFileName = `${bin}${osType === "windows" ? ".exe" : ""}`;
366
- const seaConfigFileName = `${fileName}.sea-config.json`;
367
- await writeFile(seaConfigFileName, JSON.stringify({
368
- disableExperimentalSEAWarning: true,
369
- main: fileName,
370
- output: blobFileName,
371
- useCodeCache: false,
372
- useSnapshot: false
373
- }), "utf-8");
374
- await Promise.all([
375
- `node --experimental-sea-config ${seaConfigFileName}`,
376
- `node -e "require('fs').copyFileSync(process.execPath, '${executableFileName}')"`
377
- ].map(async (command)=>helpers.exec(command)));
378
- if (osType === "macos") {
379
- await helpers.exec(`codesign --remove-signature ${executableFileName}`);
380
- }
381
- await helpers.exec(`npx postject ${executableFileName} NODE_SEA_BLOB ${blobFileName} --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 ${osType === "macos" ? "--macho-segment-name NODE_SEA" : ""}`);
382
- if (osType === "macos") {
383
- await helpers.exec(`codesign --sign - ${executableFileName}`);
384
- }
385
- await Promise.all([
386
- blobFileName,
387
- seaConfigFileName
388
- ].map(async (file)=>rm(file)));
389
- chdir(CWD);
390
- }
359
+ await Promise.all(config.metadata.map(async ({ bin, require })=>{
360
+ if (!require || !bin) return;
361
+ return compile({
362
+ bin,
363
+ input: require,
364
+ osType
365
+ });
366
+ }));
391
367
  }
392
368
  });
393
369
  };
370
+ const compile = async ({ bin, input, osType })=>{
371
+ const inputFileName = basename(input);
372
+ const inputDirectory = dirname(input);
373
+ const resolveFromInputDirectory = (...paths)=>{
374
+ return resolve(inputDirectory, ...paths);
375
+ };
376
+ const blobFileName = resolveFromInputDirectory(`${inputFileName}.blob`);
377
+ const executableFileName = resolveFromInputDirectory(`${bin}${osType === "windows" ? ".exe" : ""}`);
378
+ const seaConfigFileName = resolveFromInputDirectory(`${inputFileName}.sea-config.json`);
379
+ await writeFile(seaConfigFileName, JSON.stringify({
380
+ disableExperimentalSEAWarning: true,
381
+ main: input,
382
+ output: blobFileName,
383
+ useCodeCache: false,
384
+ useSnapshot: false
385
+ }), "utf-8");
386
+ await Promise.all([
387
+ `node --experimental-sea-config ${seaConfigFileName}`,
388
+ `node -e "require('fs').copyFileSync(process.execPath, '${executableFileName}')"`
389
+ ].map(async (command)=>helpers.exec(command)));
390
+ if (osType === "macos") {
391
+ await helpers.exec(`codesign --remove-signature ${executableFileName}`);
392
+ }
393
+ await helpers.exec(`npx postject ${executableFileName} NODE_SEA_BLOB ${blobFileName} --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 ${osType === "macos" ? "--macho-segment-name NODE_SEA" : ""}`);
394
+ if (osType === "macos") {
395
+ await helpers.exec(`codesign --sign - ${executableFileName}`);
396
+ }
397
+ await Promise.all([
398
+ blobFileName,
399
+ seaConfigFileName
400
+ ].map(async (file)=>rm(file)));
401
+ };
394
402
 
395
403
  const createBuildCommand = (program)=>{
396
404
  return createCommand(program, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickbundle",
3
- "version": "0.0.0-next-4ad7f8b",
3
+ "version": "0.0.0-next-5441a21",
4
4
  "description": "The zero-configuration transpiler and bundler for the web",
5
5
  "author": {
6
6
  "name": "Ayoub Adib",