quickbundle 0.0.0-next-750bdbd → 0.0.0-next-180c331

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 +44 -28
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import { writeFileSync } from 'node:fs';
16
16
  import { gzipSize } from 'gzip-size';
17
17
 
18
18
  var name = "quickbundle";
19
- var version = "0.0.0-next-750bdbd";
19
+ var version = "0.0.0-next-180c331";
20
20
 
21
21
  const CWD = process.cwd();
22
22
 
@@ -42,10 +42,10 @@ const isRecord = (value)=>{
42
42
  return typeof value === "object" && value !== null && !Array.isArray(value);
43
43
  };
44
44
 
45
- const watch = (configurations)=>{
45
+ const watch = (input)=>{
46
46
  process.env.NODE_ENV ??= "development";
47
- const watcher = watch$1(configurations.map((config)=>({
48
- ...config,
47
+ const watcher = watch$1(input.data.map((configItem)=>({
48
+ ...configItem,
49
49
  onLog
50
50
  })));
51
51
  let startDuration;
@@ -90,39 +90,48 @@ const clearLog = (...input)=>{
90
90
 
91
91
  const require = createRequire(import.meta.url);
92
92
  const PKG = require(join(CWD, "./package.json"));
93
- const createConfigurations = (options = {
93
+ const createConfiguration = (options = {
94
94
  minification: false,
95
95
  sourceMaps: false,
96
96
  standalone: false
97
97
  })=>{
98
- return getBuildableExports(options).flatMap((buildableExport)=>{
99
- return [
100
- buildableExport.source && createMainConfig({
101
- ...buildableExport,
102
- source: buildableExport.source
103
- }, options),
104
- buildableExport.source && buildableExport.types && createTypesConfig({
105
- source: buildableExport.source,
106
- types: buildableExport.types
107
- }, options)
108
- ].filter(Boolean);
109
- });
98
+ const buildableExports = getBuildableExports(options);
99
+ return {
100
+ data: buildableExports.flatMap((buildableExport)=>{
101
+ return [
102
+ buildableExport.source && createMainConfig({
103
+ ...buildableExport,
104
+ source: buildableExport.source
105
+ }, options),
106
+ buildableExport.source && buildableExport.types && createTypesConfig({
107
+ source: buildableExport.source,
108
+ types: buildableExport.types
109
+ }, options)
110
+ ].filter(Boolean);
111
+ }),
112
+ metadata: buildableExports
113
+ };
110
114
  };
115
+ // eslint-disable-next-line sonarjs/cyclomatic-complexity
111
116
  const getBuildableExports = ({ standalone })=>{
112
117
  if (standalone) {
113
118
  /**
114
119
  * Entry-point resolution invariants for standalone target (mostly binaries).
115
- */ if (!PKG.source || !PKG.bin) {
116
- throw new Error("Invalid package entry points contract. Standalone compilation is enabled but required fields `source` and/or `bin` are missing. Make sure to set them.");
120
+ */ if (!PKG.source || !PKG.bin || !PKG.name) {
121
+ throw new Error("Invalid package entry points contract. Standalone compilation is enabled but required fields are missing. Make sure to set `name`, `source`, and `bin` fields.");
117
122
  }
118
123
  const bin = PKG.bin;
124
+ const name = PKG.name;
125
+ const source = PKG.source;
119
126
  return isRecord(bin) ? Object.entries(bin).map((data)=>({
127
+ bin: data[0],
120
128
  require: data[1],
121
- source: data[0]
129
+ source
122
130
  })) : [
123
131
  {
132
+ bin: name,
124
133
  require: bin,
125
- source: PKG.source
134
+ source
126
135
  }
127
136
  ];
128
137
  }
@@ -263,7 +272,7 @@ const createWatchCommand = (program)=>{
263
272
  description: "Watch and rebuild on any code change (development mode)"
264
273
  }).task({
265
274
  handler (context) {
266
- watch(createConfigurations({
275
+ watch(createConfiguration({
267
276
  minification: context.minification,
268
277
  sourceMaps: context.sourceMaps,
269
278
  standalone: false
@@ -272,8 +281,9 @@ const createWatchCommand = (program)=>{
272
281
  });
273
282
  };
274
283
 
275
- const build = async (configurations)=>{
284
+ const build = async (input)=>{
276
285
  process.env.NODE_ENV ??= "production";
286
+ const { data: configurations } = input;
277
287
  const output = [];
278
288
  for (const config of configurations){
279
289
  const initialTime = Date.now();
@@ -317,16 +327,22 @@ const createCompileCommand = (program)=>{
317
327
  const osType = os.type();
318
328
  const isWindowsOS = osType === "Windows_NT";
319
329
  const isMacOS = osType === "Darwin";
320
- const items = await build(createConfigurations({
330
+ const configuration = createConfiguration({
321
331
  minification: true,
322
332
  sourceMaps: false,
323
333
  standalone: true
324
- }));
325
- for (const { filePath } of items){
334
+ });
335
+ await build(configuration);
336
+ for (const { bin, require: filePath } of configuration.metadata){
337
+ if (!filePath || !bin) {
338
+ throw new Error("Invalid configuration output. Missing `filePath` or `bin` field definition.");
339
+ }
326
340
  chdir(dirname(filePath));
327
341
  const fileName = basename(filePath);
328
342
  const blobFileName = `${fileName}.blob`;
329
- const executableFileName = `hello${isWindowsOS ? ".exe" : ""}`;
343
+ /*
344
+ * TODO: split with several tasks
345
+ */ const executableFileName = `${bin}${isWindowsOS ? ".exe" : ""}`;
330
346
  const seaConfigFileName = `${fileName}.sea-config.json`;
331
347
  writeFileSync(seaConfigFileName, JSON.stringify({
332
348
  disableExperimentalSEAWarning: true,
@@ -357,7 +373,7 @@ const createBuildCommand = (program)=>{
357
373
  key: "buildOutput",
358
374
  label: "Bundle assets 📦",
359
375
  async handler (context) {
360
- return build(createConfigurations({
376
+ return build(createConfiguration({
361
377
  minification: context.minification,
362
378
  sourceMaps: context.sourceMaps,
363
379
  standalone: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickbundle",
3
- "version": "0.0.0-next-750bdbd",
3
+ "version": "0.0.0-next-180c331",
4
4
  "description": "The zero-configuration transpiler and bundler for the web",
5
5
  "author": {
6
6
  "name": "Ayoub Adib",
@@ -58,7 +58,7 @@
58
58
  "rollup-plugin-dts": "^6.1.1",
59
59
  "rollup-plugin-node-externals": "^7.1.3",
60
60
  "rollup-plugin-swc3": "^0.12.1",
61
- "termost": "^0.18.0"
61
+ "termost": "^1.2.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/node": "22.9.0"