@gjsify/esbuild-plugin-gjsify 0.0.2 → 0.0.3
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.
- package/dist/cjs/index.cjs +125 -126
- package/dist/esm/index.mjs +125 -126
- package/dist/types/lib/index.d.ts +1 -2
- package/dist/types/lib/{cjs.d.ts → lib.d.ts} +1 -1
- package/dist/types/types/plugin-options.d.ts +1 -1
- package/dist/types/utils/extension.d.ts +1 -1
- package/esbuild.mjs +1 -1
- package/package.json +8 -20
- package/src/app/browser.ts +1 -1
- package/src/app/deno.ts +5 -2
- package/src/app/gjs.ts +7 -6
- package/src/app/node.ts +3 -5
- package/src/lib/index.ts +1 -2
- package/src/lib/{esm.ts → lib.ts} +9 -6
- package/src/lodash.d.ts +46 -0
- package/src/plugin.ts +2 -3
- package/src/types/plugin-options.ts +1 -1
- package/src/utils/extension.ts +2 -2
- package/tsconfig.json +4 -0
- package/dist/types/debug-plugin.d.ts +0 -2
- package/dist/types/lib/esm.d.ts +0 -3
- package/src/alias-plugin.ts +0 -68
- package/src/lib/cjs.ts +0 -46
package/dist/esm/index.mjs
CHANGED
|
@@ -3371,7 +3371,7 @@ var require_stream = __commonJS({
|
|
|
3371
3371
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3372
3372
|
exports.merge = void 0;
|
|
3373
3373
|
var merge22 = require_merge2();
|
|
3374
|
-
function
|
|
3374
|
+
function merge6(streams) {
|
|
3375
3375
|
const mergedStream = merge22(streams);
|
|
3376
3376
|
streams.forEach((stream) => {
|
|
3377
3377
|
stream.once("error", (error) => mergedStream.emit("error", error));
|
|
@@ -3380,7 +3380,7 @@ var require_stream = __commonJS({
|
|
|
3380
3380
|
mergedStream.once("end", () => propagateCloseEventToSources(streams));
|
|
3381
3381
|
return mergedStream;
|
|
3382
3382
|
}
|
|
3383
|
-
exports.merge =
|
|
3383
|
+
exports.merge = merge6;
|
|
3384
3384
|
function propagateCloseEventToSources(streams) {
|
|
3385
3385
|
streams.forEach((stream) => stream.emit("close"));
|
|
3386
3386
|
}
|
|
@@ -5455,6 +5455,84 @@ var require_out4 = __commonJS({
|
|
|
5455
5455
|
}
|
|
5456
5456
|
});
|
|
5457
5457
|
|
|
5458
|
+
// ../esbuild-plugin-alias/dist/cjs/index.cjs
|
|
5459
|
+
var require_cjs = __commonJS({
|
|
5460
|
+
"../esbuild-plugin-alias/dist/cjs/index.cjs"(exports, module) {
|
|
5461
|
+
var __defProp2 = Object.defineProperty;
|
|
5462
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
5463
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
5464
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
5465
|
+
var __export = (target, all) => {
|
|
5466
|
+
for (var name in all)
|
|
5467
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
5468
|
+
};
|
|
5469
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
5470
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
5471
|
+
for (let key of __getOwnPropNames2(from))
|
|
5472
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
5473
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
5474
|
+
}
|
|
5475
|
+
return to;
|
|
5476
|
+
};
|
|
5477
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
5478
|
+
var src_exports = {};
|
|
5479
|
+
__export(src_exports, {
|
|
5480
|
+
aliasPlugin: () => aliasPlugin6
|
|
5481
|
+
});
|
|
5482
|
+
module.exports = __toCommonJS(src_exports);
|
|
5483
|
+
var import_fs = __require("fs");
|
|
5484
|
+
var import_promises = __require("fs/promises");
|
|
5485
|
+
function escapeRegExp(str) {
|
|
5486
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5487
|
+
}
|
|
5488
|
+
var aliasPlugin6 = (aliasObj) => {
|
|
5489
|
+
const aliases = Object.keys(aliasObj);
|
|
5490
|
+
const re = new RegExp(`^(${aliases.map((x) => escapeRegExp(x)).join("|")})$`);
|
|
5491
|
+
const plugin = {
|
|
5492
|
+
name: "alias",
|
|
5493
|
+
setup(build) {
|
|
5494
|
+
build.onResolve({ filter: re }, async (args) => {
|
|
5495
|
+
let resolvedAliasPath = aliasObj[args.path];
|
|
5496
|
+
let namespace = args.namespace;
|
|
5497
|
+
if (resolvedAliasPath) {
|
|
5498
|
+
if (resolvedAliasPath.startsWith("http://")) {
|
|
5499
|
+
namespace = "http";
|
|
5500
|
+
resolvedAliasPath = resolvedAliasPath.slice(5);
|
|
5501
|
+
} else if (resolvedAliasPath.startsWith("https://")) {
|
|
5502
|
+
namespace = "https";
|
|
5503
|
+
resolvedAliasPath = resolvedAliasPath.slice(6);
|
|
5504
|
+
} else {
|
|
5505
|
+
const resolvedAlias = await build.resolve(resolvedAliasPath, {
|
|
5506
|
+
importer: args.importer,
|
|
5507
|
+
kind: args.kind,
|
|
5508
|
+
namespace,
|
|
5509
|
+
resolveDir: args.resolveDir,
|
|
5510
|
+
pluginData: args.pluginData
|
|
5511
|
+
});
|
|
5512
|
+
if (resolvedAlias.errors) {
|
|
5513
|
+
return resolvedAlias;
|
|
5514
|
+
} else {
|
|
5515
|
+
resolvedAliasPath = resolvedAlias.path;
|
|
5516
|
+
namespace = resolvedAlias.namespace;
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
5519
|
+
if ((0, import_fs.existsSync)(resolvedAliasPath)) {
|
|
5520
|
+
resolvedAliasPath = await (0, import_promises.realpath)(resolvedAliasPath);
|
|
5521
|
+
}
|
|
5522
|
+
return {
|
|
5523
|
+
path: resolvedAliasPath,
|
|
5524
|
+
namespace
|
|
5525
|
+
};
|
|
5526
|
+
}
|
|
5527
|
+
return null;
|
|
5528
|
+
});
|
|
5529
|
+
}
|
|
5530
|
+
};
|
|
5531
|
+
return plugin;
|
|
5532
|
+
};
|
|
5533
|
+
}
|
|
5534
|
+
});
|
|
5535
|
+
|
|
5458
5536
|
// ../../../node_modules/lodash/lodash.js
|
|
5459
5537
|
var require_lodash = __commonJS({
|
|
5460
5538
|
"../../../node_modules/lodash/lodash.js"(exports, module) {
|
|
@@ -9821,7 +9899,7 @@ var require_lodash = __commonJS({
|
|
|
9821
9899
|
});
|
|
9822
9900
|
return result2;
|
|
9823
9901
|
}
|
|
9824
|
-
var
|
|
9902
|
+
var merge6 = createAssigner(function(object, source, srcIndex) {
|
|
9825
9903
|
baseMerge(object, source, srcIndex);
|
|
9826
9904
|
});
|
|
9827
9905
|
var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
|
|
@@ -10012,7 +10090,7 @@ var require_lodash = __commonJS({
|
|
|
10012
10090
|
string = toString(string);
|
|
10013
10091
|
return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string;
|
|
10014
10092
|
}
|
|
10015
|
-
function
|
|
10093
|
+
function escapeRegExp(string) {
|
|
10016
10094
|
string = toString(string);
|
|
10017
10095
|
return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, "\\$&") : string;
|
|
10018
10096
|
}
|
|
@@ -10511,7 +10589,7 @@ var require_lodash = __commonJS({
|
|
|
10511
10589
|
lodash.matches = matches;
|
|
10512
10590
|
lodash.matchesProperty = matchesProperty;
|
|
10513
10591
|
lodash.memoize = memoize;
|
|
10514
|
-
lodash.merge =
|
|
10592
|
+
lodash.merge = merge6;
|
|
10515
10593
|
lodash.mergeWith = mergeWith;
|
|
10516
10594
|
lodash.method = method;
|
|
10517
10595
|
lodash.methodOf = methodOf;
|
|
@@ -10615,7 +10693,7 @@ var require_lodash = __commonJS({
|
|
|
10615
10693
|
lodash.endsWith = endsWith;
|
|
10616
10694
|
lodash.eq = eq;
|
|
10617
10695
|
lodash.escape = escape;
|
|
10618
|
-
lodash.escapeRegExp =
|
|
10696
|
+
lodash.escapeRegExp = escapeRegExp;
|
|
10619
10697
|
lodash.every = every;
|
|
10620
10698
|
lodash.find = find;
|
|
10621
10699
|
lodash.findIndex = findIndex;
|
|
@@ -11278,76 +11356,27 @@ var globToEntryPoints = async (_entryPoints, ignore = []) => {
|
|
|
11278
11356
|
// src/utils/extension.ts
|
|
11279
11357
|
var getJsExtensions = (allowExt) => {
|
|
11280
11358
|
const extensions = { ".js": ".js", ".ts": ".js", ".mts": ".js", ".cts": ".js", ".cjs": ".js", ".mjs": ".js" };
|
|
11281
|
-
if (extensions[allowExt]) {
|
|
11359
|
+
if (allowExt && extensions[allowExt]) {
|
|
11282
11360
|
delete extensions[allowExt];
|
|
11283
11361
|
}
|
|
11284
11362
|
return extensions;
|
|
11285
11363
|
};
|
|
11286
11364
|
|
|
11287
|
-
// src/
|
|
11288
|
-
|
|
11289
|
-
import { realpath } from "fs/promises";
|
|
11290
|
-
var aliasPlugin = (aliasObj) => {
|
|
11291
|
-
const aliases = Object.keys(aliasObj);
|
|
11292
|
-
const re = new RegExp(`^(${aliases.map((x) => escapeRegExp(x)).join("|")})$`);
|
|
11293
|
-
const plugin = {
|
|
11294
|
-
name: "alias",
|
|
11295
|
-
setup(build) {
|
|
11296
|
-
build.onResolve({ filter: re }, async (args) => {
|
|
11297
|
-
let resolvedAliasPath = aliasObj[args.path];
|
|
11298
|
-
let namespace = args.namespace;
|
|
11299
|
-
if (resolvedAliasPath) {
|
|
11300
|
-
if (resolvedAliasPath.startsWith("http://")) {
|
|
11301
|
-
namespace = "http";
|
|
11302
|
-
resolvedAliasPath = resolvedAliasPath.slice(5);
|
|
11303
|
-
} else if (resolvedAliasPath.startsWith("https://")) {
|
|
11304
|
-
namespace = "https";
|
|
11305
|
-
resolvedAliasPath = resolvedAliasPath.slice(6);
|
|
11306
|
-
} else {
|
|
11307
|
-
const resolvedAlias = await build.resolve(resolvedAliasPath, {
|
|
11308
|
-
importer: args.importer,
|
|
11309
|
-
kind: args.kind,
|
|
11310
|
-
namespace,
|
|
11311
|
-
resolveDir: args.resolveDir,
|
|
11312
|
-
pluginData: args.pluginData
|
|
11313
|
-
});
|
|
11314
|
-
if (resolvedAlias.errors) {
|
|
11315
|
-
return resolvedAlias;
|
|
11316
|
-
} else {
|
|
11317
|
-
resolvedAliasPath = resolvedAlias.path;
|
|
11318
|
-
namespace = resolvedAlias.namespace;
|
|
11319
|
-
}
|
|
11320
|
-
}
|
|
11321
|
-
if (existsSync(resolvedAliasPath)) {
|
|
11322
|
-
resolvedAliasPath = await realpath(resolvedAliasPath);
|
|
11323
|
-
}
|
|
11324
|
-
return {
|
|
11325
|
-
path: resolvedAliasPath,
|
|
11326
|
-
namespace
|
|
11327
|
-
};
|
|
11328
|
-
}
|
|
11329
|
-
return null;
|
|
11330
|
-
});
|
|
11331
|
-
}
|
|
11332
|
-
};
|
|
11333
|
-
return plugin;
|
|
11334
|
-
};
|
|
11335
|
-
function escapeRegExp(str) {
|
|
11336
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11337
|
-
}
|
|
11338
|
-
|
|
11339
|
-
// src/lib/cjs.ts
|
|
11365
|
+
// src/lib/lib.ts
|
|
11366
|
+
var import_esbuild_plugin_alias = __toESM(require_cjs(), 1);
|
|
11340
11367
|
var import_lodash = __toESM(require_lodash(), 1);
|
|
11341
11368
|
import { transformExtPlugin } from "@gjsify/esbuild-plugin-transform-ext";
|
|
11342
|
-
var
|
|
11369
|
+
var setupLib = async (build, pluginOptions) => {
|
|
11370
|
+
const format = pluginOptions.format || "esm";
|
|
11343
11371
|
pluginOptions.aliases ||= {};
|
|
11344
11372
|
pluginOptions.exclude ||= [];
|
|
11345
11373
|
const esbuildOptions = {
|
|
11374
|
+
format,
|
|
11346
11375
|
bundle: false,
|
|
11347
|
-
splitting: false,
|
|
11348
|
-
// only works with esm, see https://esbuild.github.io/api/#splitting
|
|
11349
11376
|
minify: false,
|
|
11350
11377
|
sourcemap: false,
|
|
11378
|
+
splitting: format === "esm" ? true : false,
|
|
11379
|
+
// Works only on esm
|
|
11351
11380
|
loader: {
|
|
11352
11381
|
".ts": "ts",
|
|
11353
11382
|
".mts": "ts",
|
|
@@ -11360,56 +11389,20 @@ var setupCjsLib = async (build, pluginOptions) => {
|
|
|
11360
11389
|
".js": "ts"
|
|
11361
11390
|
},
|
|
11362
11391
|
target: ["esnext"],
|
|
11363
|
-
platform: "
|
|
11392
|
+
platform: "neutral",
|
|
11393
|
+
mainFields: format === "esm" ? ["module", "main"] : ["main"],
|
|
11364
11394
|
// https://esbuild.github.io/api/#conditions
|
|
11365
|
-
conditions: ["require"]
|
|
11366
|
-
format: "cjs"
|
|
11395
|
+
conditions: format === "esm" ? ["module", "import"] : ["require"]
|
|
11367
11396
|
};
|
|
11368
11397
|
(0, import_lodash.merge)(build.initialOptions, esbuildOptions);
|
|
11369
11398
|
build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
|
|
11370
|
-
|
|
11371
|
-
console.debug("initialOptions", build.initialOptions);
|
|
11372
|
-
await aliasPlugin(pluginOptions.aliases).setup(build);
|
|
11399
|
+
await (0, import_esbuild_plugin_alias.aliasPlugin)(pluginOptions.aliases).setup(build);
|
|
11373
11400
|
await transformExtPlugin({ outExtension: getJsExtensions(pluginOptions.jsExtension) }).setup(build);
|
|
11374
11401
|
};
|
|
11375
11402
|
|
|
11376
|
-
// src/lib/esm.ts
|
|
11377
|
-
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
11378
|
-
import { transformExtPlugin as transformExtPlugin2 } from "@gjsify/esbuild-plugin-transform-ext";
|
|
11379
|
-
var setupEsmLib = async (build, pluginOptions) => {
|
|
11380
|
-
pluginOptions.aliases ||= {};
|
|
11381
|
-
pluginOptions.exclude ||= [];
|
|
11382
|
-
const esbuildOptions = {
|
|
11383
|
-
bundle: false,
|
|
11384
|
-
minify: false,
|
|
11385
|
-
sourcemap: false,
|
|
11386
|
-
splitting: true,
|
|
11387
|
-
// Works only on esm
|
|
11388
|
-
loader: {
|
|
11389
|
-
".ts": "ts",
|
|
11390
|
-
".mts": "ts",
|
|
11391
|
-
".cts": "ts",
|
|
11392
|
-
".tsx": "ts",
|
|
11393
|
-
".mtsx": "ts",
|
|
11394
|
-
".ctsx": "ts",
|
|
11395
|
-
".mjs": "ts",
|
|
11396
|
-
".cjs": "ts",
|
|
11397
|
-
".js": "ts"
|
|
11398
|
-
},
|
|
11399
|
-
target: ["esnext"],
|
|
11400
|
-
platform: "browser",
|
|
11401
|
-
// https://esbuild.github.io/api/#conditions
|
|
11402
|
-
conditions: ["module", "import"],
|
|
11403
|
-
format: "esm"
|
|
11404
|
-
};
|
|
11405
|
-
(0, import_lodash2.merge)(build.initialOptions, esbuildOptions);
|
|
11406
|
-
build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
|
|
11407
|
-
await aliasPlugin(pluginOptions.aliases).setup(build);
|
|
11408
|
-
await transformExtPlugin2({ outExtension: getJsExtensions(pluginOptions.jsExtension) }).setup(build);
|
|
11409
|
-
};
|
|
11410
|
-
|
|
11411
11403
|
// src/app/browser.ts
|
|
11412
|
-
var
|
|
11404
|
+
var import_esbuild_plugin_alias2 = __toESM(require_cjs(), 1);
|
|
11405
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
11413
11406
|
import { denoPlugin } from "@gjsify/esbuild-plugin-deno-loader";
|
|
11414
11407
|
import * as deepkitPlugin from "@gjsify/esbuild-plugin-deepkit";
|
|
11415
11408
|
var setupForBrowser = async (build, pluginOptions) => {
|
|
@@ -11446,26 +11439,31 @@ var setupForBrowser = async (build, pluginOptions) => {
|
|
|
11446
11439
|
window: "globalThis"
|
|
11447
11440
|
}
|
|
11448
11441
|
};
|
|
11449
|
-
(0,
|
|
11442
|
+
(0, import_lodash2.merge)(build.initialOptions, esbuildOptions);
|
|
11450
11443
|
build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
|
|
11451
11444
|
const aliases = { ...pluginOptions.aliases };
|
|
11452
11445
|
if (pluginOptions.debug)
|
|
11453
11446
|
console.debug("initialOptions", build.initialOptions);
|
|
11454
|
-
await aliasPlugin(aliases).setup(build);
|
|
11447
|
+
await (0, import_esbuild_plugin_alias2.aliasPlugin)(aliases).setup(build);
|
|
11455
11448
|
await denoPlugin({ reflection: pluginOptions.reflection }).setup(build);
|
|
11456
11449
|
await deepkitPlugin.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
|
|
11457
11450
|
};
|
|
11458
11451
|
|
|
11459
11452
|
// src/app/deno.ts
|
|
11460
|
-
var
|
|
11453
|
+
var import_esbuild_plugin_alias3 = __toESM(require_cjs(), 1);
|
|
11454
|
+
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
11461
11455
|
import { denoPlugin as denoPlugin2 } from "@gjsify/esbuild-plugin-deno-loader";
|
|
11462
11456
|
import * as deepkitPlugin3 from "@gjsify/esbuild-plugin-deepkit";
|
|
11463
11457
|
var setupForDeno = async (build, pluginOptions) => {
|
|
11464
11458
|
const external = [];
|
|
11459
|
+
const format = pluginOptions.format || "esm";
|
|
11460
|
+
if (format !== "esm")
|
|
11461
|
+
throw new TypeError("Only ESM format is supported for Deno");
|
|
11465
11462
|
pluginOptions.aliases ||= {};
|
|
11466
11463
|
pluginOptions.exclude ||= [];
|
|
11467
11464
|
const esbuildOptions = {
|
|
11468
|
-
format
|
|
11465
|
+
format,
|
|
11466
|
+
// Only 'esm' is supported for Deno
|
|
11469
11467
|
bundle: true,
|
|
11470
11468
|
minify: false,
|
|
11471
11469
|
sourcemap: false,
|
|
@@ -11494,29 +11492,30 @@ var setupForDeno = async (build, pluginOptions) => {
|
|
|
11494
11492
|
window: "globalThis"
|
|
11495
11493
|
}
|
|
11496
11494
|
};
|
|
11497
|
-
(0,
|
|
11495
|
+
(0, import_lodash3.merge)(build.initialOptions, esbuildOptions);
|
|
11498
11496
|
build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
|
|
11499
11497
|
const aliases = { ...getAliasesForDeno({ external }), ...pluginOptions.aliases };
|
|
11500
11498
|
if (pluginOptions.debug)
|
|
11501
11499
|
console.debug("initialOptions", build.initialOptions);
|
|
11502
|
-
await aliasPlugin(aliases).setup(build);
|
|
11500
|
+
await (0, import_esbuild_plugin_alias3.aliasPlugin)(aliases).setup(build);
|
|
11503
11501
|
await denoPlugin2({ reflection: pluginOptions.reflection }).setup(build);
|
|
11504
11502
|
await deepkitPlugin3.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
|
|
11505
11503
|
};
|
|
11506
11504
|
|
|
11507
11505
|
// src/app/gjs.ts
|
|
11508
|
-
var
|
|
11506
|
+
var import_esbuild_plugin_alias4 = __toESM(require_cjs(), 1);
|
|
11507
|
+
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
11509
11508
|
import { denoPlugin as denoPlugin3 } from "@gjsify/esbuild-plugin-deno-loader";
|
|
11510
11509
|
import * as deepkitPlugin5 from "@gjsify/esbuild-plugin-deepkit";
|
|
11511
11510
|
var setupForGjs = async (build, pluginOptions) => {
|
|
11512
11511
|
const external = ["gi://*", "cairo", "gettext", "system"];
|
|
11512
|
+
const format = pluginOptions.format || "esm";
|
|
11513
11513
|
pluginOptions.aliases ||= {};
|
|
11514
11514
|
pluginOptions.exclude ||= [];
|
|
11515
11515
|
const esbuildOptions = {
|
|
11516
|
-
format
|
|
11517
|
-
// On Gjs we only support esm
|
|
11516
|
+
format,
|
|
11518
11517
|
bundle: true,
|
|
11519
|
-
metafile:
|
|
11518
|
+
metafile: false,
|
|
11520
11519
|
minify: false,
|
|
11521
11520
|
sourcemap: false,
|
|
11522
11521
|
treeShaking: true,
|
|
@@ -11529,9 +11528,9 @@ var setupForGjs = async (build, pluginOptions) => {
|
|
|
11529
11528
|
// firefox102 // Since GJS 1.73.2
|
|
11530
11529
|
target: ["firefox102"],
|
|
11531
11530
|
platform: "neutral",
|
|
11532
|
-
mainFields: ["module", "main"],
|
|
11531
|
+
mainFields: format === "esm" ? ["module", "main"] : ["main", "module"],
|
|
11533
11532
|
// https://esbuild.github.io/api/#conditions
|
|
11534
|
-
conditions: ["
|
|
11533
|
+
conditions: format === "esm" ? ["import", "require"] : ["require", "import"],
|
|
11535
11534
|
external,
|
|
11536
11535
|
loader: {
|
|
11537
11536
|
".ts": "ts",
|
|
@@ -11549,25 +11548,26 @@ var setupForGjs = async (build, pluginOptions) => {
|
|
|
11549
11548
|
window: "globalThis"
|
|
11550
11549
|
}
|
|
11551
11550
|
};
|
|
11552
|
-
(0,
|
|
11551
|
+
(0, import_lodash4.merge)(build.initialOptions, esbuildOptions);
|
|
11553
11552
|
build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
|
|
11554
11553
|
const aliases = { ...getAliasesForGjs({ external }), ...pluginOptions.aliases };
|
|
11555
11554
|
if (pluginOptions.debug)
|
|
11556
11555
|
console.debug("initialOptions", build.initialOptions);
|
|
11557
|
-
await aliasPlugin(aliases).setup(build);
|
|
11556
|
+
await (0, import_esbuild_plugin_alias4.aliasPlugin)(aliases).setup(build);
|
|
11558
11557
|
await denoPlugin3({ reflection: pluginOptions.reflection }).setup(build);
|
|
11559
11558
|
await deepkitPlugin5.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
|
|
11560
11559
|
};
|
|
11561
11560
|
|
|
11562
11561
|
// src/app/node.ts
|
|
11563
|
-
var
|
|
11562
|
+
var import_esbuild_plugin_alias5 = __toESM(require_cjs(), 1);
|
|
11563
|
+
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
11564
11564
|
import { denoPlugin as denoPlugin4 } from "@gjsify/esbuild-plugin-deno-loader";
|
|
11565
11565
|
import * as deepkitPlugin7 from "@gjsify/esbuild-plugin-deepkit";
|
|
11566
11566
|
var setupForNode = async (build, pluginOptions) => {
|
|
11567
11567
|
const external = [...EXTERNALS_NODE, "gi://*"];
|
|
11568
|
+
const format = pluginOptions.format || "esm";
|
|
11568
11569
|
pluginOptions.aliases ||= {};
|
|
11569
11570
|
pluginOptions.exclude ||= [];
|
|
11570
|
-
const format = pluginOptions.format || "esm";
|
|
11571
11571
|
const esbuildOptions = {
|
|
11572
11572
|
format,
|
|
11573
11573
|
bundle: true,
|
|
@@ -11578,7 +11578,7 @@ var setupForNode = async (build, pluginOptions) => {
|
|
|
11578
11578
|
// false means follow symlinks
|
|
11579
11579
|
target: ["node18"],
|
|
11580
11580
|
platform: "node",
|
|
11581
|
-
mainFields: format === "esm" ? ["module", "main"] : ["main", "module", "browser"],
|
|
11581
|
+
mainFields: format === "esm" ? ["module", "main", "browser"] : ["main", "module", "browser"],
|
|
11582
11582
|
conditions: format === "esm" ? ["module", "import"] : ["require"],
|
|
11583
11583
|
external,
|
|
11584
11584
|
loader: {
|
|
@@ -11597,12 +11597,12 @@ var setupForNode = async (build, pluginOptions) => {
|
|
|
11597
11597
|
window: "globalThis"
|
|
11598
11598
|
}
|
|
11599
11599
|
};
|
|
11600
|
-
(0,
|
|
11600
|
+
(0, import_lodash5.merge)(build.initialOptions, esbuildOptions);
|
|
11601
11601
|
build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
|
|
11602
11602
|
const aliases = { ...getAliasesForNode({ external }), ...pluginOptions.aliases };
|
|
11603
11603
|
if (pluginOptions.debug)
|
|
11604
11604
|
console.debug("initialOptions", build.initialOptions);
|
|
11605
|
-
await aliasPlugin(aliases).setup(build);
|
|
11605
|
+
await (0, import_esbuild_plugin_alias5.aliasPlugin)(aliases).setup(build);
|
|
11606
11606
|
await denoPlugin4({ reflection: pluginOptions.reflection }).setup(build);
|
|
11607
11607
|
await deepkitPlugin7.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
|
|
11608
11608
|
};
|
|
@@ -11615,9 +11615,8 @@ var gjsifyPlugin = (pluginOptions = {}) => {
|
|
|
11615
11615
|
if (pluginOptions.library) {
|
|
11616
11616
|
switch (pluginOptions.library) {
|
|
11617
11617
|
case "esm":
|
|
11618
|
-
return setupEsmLib(build, pluginOptions);
|
|
11619
11618
|
case "cjs":
|
|
11620
|
-
return
|
|
11619
|
+
return setupLib(build, pluginOptions);
|
|
11621
11620
|
default:
|
|
11622
11621
|
throw new TypeError("Unknown library type: " + pluginOptions.library);
|
|
11623
11622
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './esm.js';
|
|
1
|
+
export * from './lib.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PluginBuild } from "esbuild";
|
|
2
2
|
import type { PluginOptions } from '../types/plugin-options.js';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const setupLib: (build: PluginBuild, pluginOptions: PluginOptions) => Promise<void>;
|
|
@@ -7,7 +7,7 @@ export interface PluginOptions extends DeepkitPluginOptions {
|
|
|
7
7
|
/** An array of glob patterns to exclude matches and aliases */
|
|
8
8
|
exclude?: string[];
|
|
9
9
|
jsExtension?: string;
|
|
10
|
-
/** Override the format
|
|
10
|
+
/** Override the format */
|
|
11
11
|
format?: 'esm' | 'cjs';
|
|
12
12
|
/**
|
|
13
13
|
* Library Mode
|
package/esbuild.mjs
CHANGED
|
@@ -17,6 +17,7 @@ const baseConfig = {
|
|
|
17
17
|
entryPoints: ['src/index.ts'],
|
|
18
18
|
bundle: true,
|
|
19
19
|
minify: false,
|
|
20
|
+
platform: "node",
|
|
20
21
|
external: [
|
|
21
22
|
...EXTERNALS_NODE,
|
|
22
23
|
'typescript',
|
|
@@ -35,7 +36,6 @@ if (pkg.main) {
|
|
|
35
36
|
outdir: dirname(pkg.main),
|
|
36
37
|
format: 'cjs',
|
|
37
38
|
outExtension: {'.js': extname(pkg.main)},
|
|
38
|
-
platform: "node",
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/esbuild-plugin-gjsify",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Deepkit type compiler plugin for esbuild",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.cjs",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test": "yarn print:name && echo 'nothing to do'",
|
|
13
13
|
"build": "yarn print:name && yarn build:js && yarn build:types",
|
|
14
14
|
"build:js": "node esbuild.mjs",
|
|
15
|
-
"build:types": "tsc --
|
|
15
|
+
"build:types": "tsc --project ./tsconfig.json"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"gjs",
|
|
@@ -20,27 +20,15 @@
|
|
|
20
20
|
"esbuild"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@gjsify/esbuild-plugin-
|
|
24
|
-
"@gjsify/esbuild-plugin-
|
|
25
|
-
"@gjsify/esbuild-plugin-
|
|
26
|
-
"
|
|
27
|
-
"constants-browserify": "^1.0.0",
|
|
28
|
-
"core-js": "^3.31.0",
|
|
29
|
-
"crypto-browserify": "^3.12.0",
|
|
30
|
-
"esm": "^3.2.25",
|
|
23
|
+
"@gjsify/esbuild-plugin-alias": "^0.0.3",
|
|
24
|
+
"@gjsify/esbuild-plugin-deepkit": "^0.0.3",
|
|
25
|
+
"@gjsify/esbuild-plugin-deno-loader": "^0.0.3",
|
|
26
|
+
"@gjsify/esbuild-plugin-transform-ext": "^0.0.3",
|
|
31
27
|
"fast-glob": "^3.2.12",
|
|
32
|
-
"lodash": "^4.17.21"
|
|
33
|
-
"micromatch": "^4.0.5",
|
|
34
|
-
"path-browserify": "^1.0.1",
|
|
35
|
-
"punycode": "^2.3.0",
|
|
36
|
-
"stream-browserify": "^3.0.0",
|
|
37
|
-
"string_decoder": "^1.3.0",
|
|
38
|
-
"test": "^3.3.0"
|
|
28
|
+
"lodash": "^4.17.21"
|
|
39
29
|
},
|
|
40
30
|
"devDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"@types/micromatch": "^4.0.2",
|
|
43
|
-
"esbuild": "^0.18.2",
|
|
31
|
+
"esbuild": "^0.18.3",
|
|
44
32
|
"typescript": "^5.1.3"
|
|
45
33
|
}
|
|
46
34
|
}
|
package/src/app/browser.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aliasPlugin } from '
|
|
1
|
+
import { aliasPlugin } from '@gjsify/esbuild-plugin-alias';
|
|
2
2
|
import { denoPlugin } from '@gjsify/esbuild-plugin-deno-loader';
|
|
3
3
|
import * as deepkitPlugin from '@gjsify/esbuild-plugin-deepkit';
|
|
4
4
|
import { merge } from "lodash";
|
package/src/app/deno.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aliasPlugin } from '
|
|
1
|
+
import { aliasPlugin } from '@gjsify/esbuild-plugin-alias';
|
|
2
2
|
import { denoPlugin } from '@gjsify/esbuild-plugin-deno-loader';
|
|
3
3
|
import * as deepkitPlugin from '@gjsify/esbuild-plugin-deepkit';
|
|
4
4
|
import { merge } from "lodash";
|
|
@@ -11,13 +11,16 @@ import { getAliasesForDeno, globToEntryPoints } from "../utils/index.js";
|
|
|
11
11
|
export const setupForDeno = async (build: PluginBuild, pluginOptions: PluginOptions) => {
|
|
12
12
|
|
|
13
13
|
const external = [];
|
|
14
|
+
const format = pluginOptions.format || 'esm';
|
|
15
|
+
|
|
16
|
+
if(format !== 'esm') throw new TypeError('Only ESM format is supported for Deno');
|
|
14
17
|
|
|
15
18
|
pluginOptions.aliases ||= {};
|
|
16
19
|
pluginOptions.exclude ||= [];
|
|
17
20
|
|
|
18
21
|
// Set default options
|
|
19
22
|
const esbuildOptions: BuildOptions = {
|
|
20
|
-
format
|
|
23
|
+
format, // Only 'esm' is supported for Deno
|
|
21
24
|
bundle: true,
|
|
22
25
|
minify: false,
|
|
23
26
|
sourcemap: false,
|
package/src/app/gjs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aliasPlugin } from '
|
|
1
|
+
import { aliasPlugin } from '@gjsify/esbuild-plugin-alias';
|
|
2
2
|
import { denoPlugin } from '@gjsify/esbuild-plugin-deno-loader';
|
|
3
3
|
import * as deepkitPlugin from '@gjsify/esbuild-plugin-deepkit';
|
|
4
4
|
import { merge } from "lodash";
|
|
@@ -11,15 +11,16 @@ import type { PluginOptions } from '../types/plugin-options.js';
|
|
|
11
11
|
export const setupForGjs = async (build: PluginBuild, pluginOptions: PluginOptions) => {
|
|
12
12
|
|
|
13
13
|
const external = ['gi://*', 'cairo', 'gettext', 'system'];
|
|
14
|
+
const format = pluginOptions.format || 'esm';
|
|
14
15
|
|
|
15
16
|
pluginOptions.aliases ||= {};
|
|
16
17
|
pluginOptions.exclude ||= [];
|
|
17
18
|
|
|
18
19
|
// Set default options
|
|
19
20
|
const esbuildOptions: BuildOptions = {
|
|
20
|
-
format
|
|
21
|
+
format,
|
|
21
22
|
bundle: true,
|
|
22
|
-
metafile:
|
|
23
|
+
metafile: false,
|
|
23
24
|
minify: false,
|
|
24
25
|
sourcemap: false,
|
|
25
26
|
treeShaking: true,
|
|
@@ -30,10 +31,10 @@ export const setupForGjs = async (build: PluginBuild, pluginOptions: PluginOptio
|
|
|
30
31
|
// firefox91 // Since GJS 1.71.1
|
|
31
32
|
// firefox102 // Since GJS 1.73.2
|
|
32
33
|
target: [ "firefox102" ],
|
|
33
|
-
platform:
|
|
34
|
-
mainFields: ['module', 'main'],
|
|
34
|
+
platform: 'neutral',
|
|
35
|
+
mainFields: format === 'esm' ? ['module', 'main'] : ['main', 'module'],
|
|
35
36
|
// https://esbuild.github.io/api/#conditions
|
|
36
|
-
conditions: ['
|
|
37
|
+
conditions: format === 'esm' ? ['import', 'require'] : ['require', 'import'],
|
|
37
38
|
external,
|
|
38
39
|
loader: {
|
|
39
40
|
'.ts': 'ts',
|
package/src/app/node.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { aliasPlugin } from '../alias-plugin.js';
|
|
1
|
+
import { aliasPlugin } from '@gjsify/esbuild-plugin-alias';
|
|
3
2
|
import { denoPlugin } from '@gjsify/esbuild-plugin-deno-loader';
|
|
4
3
|
import * as deepkitPlugin from '@gjsify/esbuild-plugin-deepkit';
|
|
5
4
|
import { merge } from "lodash";
|
|
@@ -13,12 +12,11 @@ import type { PluginOptions } from '../types/plugin-options.js';
|
|
|
13
12
|
export const setupForNode = async (build: PluginBuild, pluginOptions: PluginOptions) => {
|
|
14
13
|
|
|
15
14
|
const external = [...EXTERNALS_NODE, 'gi://*'];
|
|
15
|
+
const format = pluginOptions.format || 'esm';
|
|
16
16
|
|
|
17
17
|
pluginOptions.aliases ||= {};
|
|
18
18
|
pluginOptions.exclude ||= [];
|
|
19
19
|
|
|
20
|
-
const format = pluginOptions.format || 'esm';
|
|
21
|
-
|
|
22
20
|
// Set default options
|
|
23
21
|
const esbuildOptions: BuildOptions = {
|
|
24
22
|
format,
|
|
@@ -29,7 +27,7 @@ export const setupForNode = async (build: PluginBuild, pluginOptions: PluginOpti
|
|
|
29
27
|
preserveSymlinks: false, // false means follow symlinks
|
|
30
28
|
target: [ "node18" ],
|
|
31
29
|
platform: "node",
|
|
32
|
-
mainFields: format === 'esm' ? ['module', 'main'] : ['main', 'module', 'browser'],
|
|
30
|
+
mainFields: format === 'esm' ? ['module', 'main', 'browser'] : ['main', 'module', 'browser'],
|
|
33
31
|
conditions: format === 'esm' ? ['module', 'import'] : ['require'],
|
|
34
32
|
external,
|
|
35
33
|
loader: {
|
package/src/lib/index.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './esm.js';
|
|
1
|
+
export * from './lib.js';
|