@gjsify/esbuild-plugin-gjsify 0.0.2 → 0.0.4

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.
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  }) : x)(function(x) {
10
10
  if (typeof require !== "undefined")
11
11
  return require.apply(this, arguments);
12
- throw new Error('Dynamic require of "' + x + '" is not supported');
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
13
  });
14
14
  var __commonJS = (cb, mod) => function __require2() {
15
15
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -101,10 +101,15 @@ var require_path = __commonJS({
101
101
  "../../../node_modules/fast-glob/out/utils/path.js"(exports) {
102
102
  "use strict";
103
103
  Object.defineProperty(exports, "__esModule", { value: true });
104
- exports.removeLeadingDotSegment = exports.escape = exports.makeAbsolute = exports.unixify = void 0;
104
+ exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = void 0;
105
+ var os = __require("os");
105
106
  var path = __require("path");
107
+ var IS_WINDOWS_PLATFORM = os.platform() === "win32";
106
108
  var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
107
- var UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
109
+ var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
110
+ var WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
111
+ var DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
112
+ var WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
108
113
  function unixify(filepath) {
109
114
  return filepath.replace(/\\/g, "/");
110
115
  }
@@ -113,10 +118,6 @@ var require_path = __commonJS({
113
118
  return path.resolve(cwd, filepath);
114
119
  }
115
120
  exports.makeAbsolute = makeAbsolute;
116
- function escape(pattern) {
117
- return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, "\\$2");
118
- }
119
- exports.escape = escape;
120
121
  function removeLeadingDotSegment(entry) {
121
122
  if (entry.charAt(0) === ".") {
122
123
  const secondCharactery = entry.charAt(1);
@@ -127,6 +128,24 @@ var require_path = __commonJS({
127
128
  return entry;
128
129
  }
129
130
  exports.removeLeadingDotSegment = removeLeadingDotSegment;
131
+ exports.escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath;
132
+ function escapeWindowsPath(pattern) {
133
+ return pattern.replace(WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, "\\$2");
134
+ }
135
+ exports.escapeWindowsPath = escapeWindowsPath;
136
+ function escapePosixPath(pattern) {
137
+ return pattern.replace(POSIX_UNESCAPED_GLOB_SYMBOLS_RE, "\\$2");
138
+ }
139
+ exports.escapePosixPath = escapePosixPath;
140
+ exports.convertPathToPattern = IS_WINDOWS_PLATFORM ? convertWindowsPathToPattern : convertPosixPathToPattern;
141
+ function convertWindowsPathToPattern(filepath) {
142
+ return escapeWindowsPath(filepath).replace(DOS_DEVICE_PATH_RE, "//$1").replace(WINDOWS_BACKSLASHES_RE, "/");
143
+ }
144
+ exports.convertWindowsPathToPattern = convertWindowsPathToPattern;
145
+ function convertPosixPathToPattern(filepath) {
146
+ return escapePosixPath(filepath);
147
+ }
148
+ exports.convertPosixPathToPattern = convertPosixPathToPattern;
130
149
  }
131
150
  });
132
151
 
@@ -3106,7 +3125,7 @@ var require_pattern = __commonJS({
3106
3125
  "../../../node_modules/fast-glob/out/utils/pattern.js"(exports) {
3107
3126
  "use strict";
3108
3127
  Object.defineProperty(exports, "__esModule", { value: true });
3109
- exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
3128
+ exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
3110
3129
  var path = __require("path");
3111
3130
  var globParent = require_glob_parent();
3112
3131
  var micromatch = require_micromatch();
@@ -3117,6 +3136,7 @@ var require_pattern = __commonJS({
3117
3136
  var REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
3118
3137
  var GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
3119
3138
  var BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
3139
+ var DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
3120
3140
  function isStaticPattern(pattern, options = {}) {
3121
3141
  return !isDynamicPattern(pattern, options);
3122
3142
  }
@@ -3212,10 +3232,9 @@ var require_pattern = __commonJS({
3212
3232
  }
3213
3233
  exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
3214
3234
  function expandBraceExpansion(pattern) {
3215
- return micromatch.braces(pattern, {
3216
- expand: true,
3217
- nodupes: true
3218
- });
3235
+ const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true });
3236
+ patterns.sort((a, b) => a.length - b.length);
3237
+ return patterns.filter((pattern2) => pattern2 !== "");
3219
3238
  }
3220
3239
  exports.expandBraceExpansion = expandBraceExpansion;
3221
3240
  function getPatternParts(pattern, options) {
@@ -3242,6 +3261,10 @@ var require_pattern = __commonJS({
3242
3261
  return patternsRe.some((patternRe) => patternRe.test(entry));
3243
3262
  }
3244
3263
  exports.matchAny = matchAny;
3264
+ function removeDuplicateSlashes(pattern) {
3265
+ return pattern.replace(DOUBLE_SLASH_RE, "/");
3266
+ }
3267
+ exports.removeDuplicateSlashes = removeDuplicateSlashes;
3245
3268
  }
3246
3269
  });
3247
3270
 
@@ -3371,7 +3394,7 @@ var require_stream = __commonJS({
3371
3394
  Object.defineProperty(exports, "__esModule", { value: true });
3372
3395
  exports.merge = void 0;
3373
3396
  var merge22 = require_merge2();
3374
- function merge7(streams) {
3397
+ function merge6(streams) {
3375
3398
  const mergedStream = merge22(streams);
3376
3399
  streams.forEach((stream) => {
3377
3400
  stream.once("error", (error) => mergedStream.emit("error", error));
@@ -3380,7 +3403,7 @@ var require_stream = __commonJS({
3380
3403
  mergedStream.once("end", () => propagateCloseEventToSources(streams));
3381
3404
  return mergedStream;
3382
3405
  }
3383
- exports.merge = merge7;
3406
+ exports.merge = merge6;
3384
3407
  function propagateCloseEventToSources(streams) {
3385
3408
  streams.forEach((stream) => stream.emit("close"));
3386
3409
  }
@@ -3434,9 +3457,11 @@ var require_tasks = __commonJS({
3434
3457
  Object.defineProperty(exports, "__esModule", { value: true });
3435
3458
  exports.convertPatternGroupToTask = exports.convertPatternGroupsToTasks = exports.groupPatternsByBaseDirectory = exports.getNegativePatternsAsPositive = exports.getPositivePatterns = exports.convertPatternsToTasks = exports.generate = void 0;
3436
3459
  var utils = require_utils3();
3437
- function generate(patterns, settings) {
3460
+ function generate(input, settings) {
3461
+ const patterns = processPatterns(input, settings);
3462
+ const ignore = processPatterns(settings.ignore, settings);
3438
3463
  const positivePatterns = getPositivePatterns(patterns);
3439
- const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
3464
+ const negativePatterns = getNegativePatternsAsPositive(patterns, ignore);
3440
3465
  const staticPatterns = positivePatterns.filter((pattern) => utils.pattern.isStaticPattern(pattern, settings));
3441
3466
  const dynamicPatterns = positivePatterns.filter((pattern) => utils.pattern.isDynamicPattern(pattern, settings));
3442
3467
  const staticTasks = convertPatternsToTasks(
@@ -3454,6 +3479,16 @@ var require_tasks = __commonJS({
3454
3479
  return staticTasks.concat(dynamicTasks);
3455
3480
  }
3456
3481
  exports.generate = generate;
3482
+ function processPatterns(input, settings) {
3483
+ let patterns = input;
3484
+ if (settings.braceExpansion) {
3485
+ patterns = utils.pattern.expandPatternsWithBraceExpansion(patterns);
3486
+ }
3487
+ if (settings.baseNameMatch) {
3488
+ patterns = patterns.map((pattern) => pattern.includes("/") ? pattern : `**/${pattern}`);
3489
+ }
3490
+ return patterns.map((pattern) => utils.pattern.removeDuplicateSlashes(pattern));
3491
+ }
3457
3492
  function convertPatternsToTasks(positive, negative, dynamic) {
3458
3493
  const tasks = [];
3459
3494
  const patternsOutsideCurrentDirectory = utils.pattern.getPatternsOutsideCurrentDirectory(positive);
@@ -3511,24 +3546,6 @@ var require_tasks = __commonJS({
3511
3546
  }
3512
3547
  });
3513
3548
 
3514
- // ../../../node_modules/fast-glob/out/managers/patterns.js
3515
- var require_patterns = __commonJS({
3516
- "../../../node_modules/fast-glob/out/managers/patterns.js"(exports) {
3517
- "use strict";
3518
- Object.defineProperty(exports, "__esModule", { value: true });
3519
- exports.removeDuplicateSlashes = exports.transform = void 0;
3520
- var DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
3521
- function transform(patterns) {
3522
- return patterns.map((pattern) => removeDuplicateSlashes(pattern));
3523
- }
3524
- exports.transform = transform;
3525
- function removeDuplicateSlashes(pattern) {
3526
- return pattern.replace(DOUBLE_SLASH_RE, "/");
3527
- }
3528
- exports.removeDuplicateSlashes = removeDuplicateSlashes;
3529
- }
3530
- });
3531
-
3532
3549
  // ../../../node_modules/@nodelib/fs.stat/out/providers/async.js
3533
3550
  var require_async = __commonJS({
3534
3551
  "../../../node_modules/@nodelib/fs.stat/out/providers/async.js"(exports) {
@@ -4876,8 +4893,7 @@ var require_matcher = __commonJS({
4876
4893
  this._fillStorage();
4877
4894
  }
4878
4895
  _fillStorage() {
4879
- const patterns = utils.pattern.expandPatternsWithBraceExpansion(this._patterns);
4880
- for (const pattern of patterns) {
4896
+ for (const pattern of this._patterns) {
4881
4897
  const segments = this._getPatternSegments(pattern);
4882
4898
  const sections = this._splitSegmentsIntoSections(segments);
4883
4899
  this._storage.push({
@@ -5029,32 +5045,32 @@ var require_entry = __commonJS({
5029
5045
  }
5030
5046
  getFilter(positive, negative) {
5031
5047
  const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions);
5032
- const negativeRe = utils.pattern.convertPatternsToRe(negative, this._micromatchOptions);
5048
+ const negativeRe = utils.pattern.convertPatternsToRe(negative, Object.assign(Object.assign({}, this._micromatchOptions), { dot: true }));
5033
5049
  return (entry) => this._filter(entry, positiveRe, negativeRe);
5034
5050
  }
5035
5051
  _filter(entry, positiveRe, negativeRe) {
5036
- if (this._settings.unique && this._isDuplicateEntry(entry)) {
5052
+ const filepath = utils.path.removeLeadingDotSegment(entry.path);
5053
+ if (this._settings.unique && this._isDuplicateEntry(filepath)) {
5037
5054
  return false;
5038
5055
  }
5039
5056
  if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
5040
5057
  return false;
5041
5058
  }
5042
- if (this._isSkippedByAbsoluteNegativePatterns(entry.path, negativeRe)) {
5059
+ if (this._isSkippedByAbsoluteNegativePatterns(filepath, negativeRe)) {
5043
5060
  return false;
5044
5061
  }
5045
- const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
5046
5062
  const isDirectory = entry.dirent.isDirectory();
5047
- const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(entry.path, negativeRe, isDirectory);
5063
+ const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(filepath, negativeRe, isDirectory);
5048
5064
  if (this._settings.unique && isMatched) {
5049
- this._createIndexRecord(entry);
5065
+ this._createIndexRecord(filepath);
5050
5066
  }
5051
5067
  return isMatched;
5052
5068
  }
5053
- _isDuplicateEntry(entry) {
5054
- return this.index.has(entry.path);
5069
+ _isDuplicateEntry(filepath) {
5070
+ return this.index.has(filepath);
5055
5071
  }
5056
- _createIndexRecord(entry) {
5057
- this.index.set(entry.path, void 0);
5072
+ _createIndexRecord(filepath) {
5073
+ this.index.set(filepath, void 0);
5058
5074
  }
5059
5075
  _onlyFileFilter(entry) {
5060
5076
  return this._settings.onlyFiles && !entry.dirent.isFile();
@@ -5069,8 +5085,7 @@ var require_entry = __commonJS({
5069
5085
  const fullpath = utils.path.makeAbsolute(this._settings.cwd, entryPath);
5070
5086
  return utils.pattern.matchAny(fullpath, patternsRe);
5071
5087
  }
5072
- _isMatchToPatterns(entryPath, patternsRe, isDirectory) {
5073
- const filepath = utils.path.removeLeadingDotSegment(entryPath);
5088
+ _isMatchToPatterns(filepath, patternsRe, isDirectory) {
5074
5089
  const isMatched = utils.pattern.matchAny(filepath, patternsRe);
5075
5090
  if (!isMatched && isDirectory) {
5076
5091
  return utils.pattern.matchAny(filepath + "/", patternsRe);
@@ -5376,6 +5391,7 @@ var require_settings4 = __commonJS({
5376
5391
  if (this.stats) {
5377
5392
  this.objectMode = true;
5378
5393
  }
5394
+ this.ignore = [].concat(this.ignore);
5379
5395
  }
5380
5396
  _getValue(option, value) {
5381
5397
  return option === void 0 ? value : option;
@@ -5393,7 +5409,6 @@ var require_out4 = __commonJS({
5393
5409
  "../../../node_modules/fast-glob/out/index.js"(exports, module) {
5394
5410
  "use strict";
5395
5411
  var taskManager = require_tasks();
5396
- var patternManager = require_patterns();
5397
5412
  var async_1 = require_async6();
5398
5413
  var stream_1 = require_stream4();
5399
5414
  var sync_1 = require_sync6();
@@ -5406,6 +5421,10 @@ var require_out4 = __commonJS({
5406
5421
  return utils.array.flatten(result);
5407
5422
  }
5408
5423
  (function(FastGlob2) {
5424
+ FastGlob2.glob = FastGlob2;
5425
+ FastGlob2.globSync = sync;
5426
+ FastGlob2.globStream = stream;
5427
+ FastGlob2.async = FastGlob2;
5409
5428
  function sync(source, options) {
5410
5429
  assertPatternsInput(source);
5411
5430
  const works = getWorks(source, sync_1.default, options);
@@ -5420,7 +5439,7 @@ var require_out4 = __commonJS({
5420
5439
  FastGlob2.stream = stream;
5421
5440
  function generateTasks(source, options) {
5422
5441
  assertPatternsInput(source);
5423
- const patterns = patternManager.transform([].concat(source));
5442
+ const patterns = [].concat(source);
5424
5443
  const settings = new settings_1.default(options);
5425
5444
  return taskManager.generate(patterns, settings);
5426
5445
  }
@@ -5436,9 +5455,40 @@ var require_out4 = __commonJS({
5436
5455
  return utils.path.escape(source);
5437
5456
  }
5438
5457
  FastGlob2.escapePath = escapePath;
5458
+ function convertPathToPattern(source) {
5459
+ assertPatternsInput(source);
5460
+ return utils.path.convertPathToPattern(source);
5461
+ }
5462
+ FastGlob2.convertPathToPattern = convertPathToPattern;
5463
+ let posix;
5464
+ (function(posix2) {
5465
+ function escapePath2(source) {
5466
+ assertPatternsInput(source);
5467
+ return utils.path.escapePosixPath(source);
5468
+ }
5469
+ posix2.escapePath = escapePath2;
5470
+ function convertPathToPattern2(source) {
5471
+ assertPatternsInput(source);
5472
+ return utils.path.convertPosixPathToPattern(source);
5473
+ }
5474
+ posix2.convertPathToPattern = convertPathToPattern2;
5475
+ })(posix = FastGlob2.posix || (FastGlob2.posix = {}));
5476
+ let win32;
5477
+ (function(win322) {
5478
+ function escapePath2(source) {
5479
+ assertPatternsInput(source);
5480
+ return utils.path.escapeWindowsPath(source);
5481
+ }
5482
+ win322.escapePath = escapePath2;
5483
+ function convertPathToPattern2(source) {
5484
+ assertPatternsInput(source);
5485
+ return utils.path.convertWindowsPathToPattern(source);
5486
+ }
5487
+ win322.convertPathToPattern = convertPathToPattern2;
5488
+ })(win32 = FastGlob2.win32 || (FastGlob2.win32 = {}));
5439
5489
  })(FastGlob || (FastGlob = {}));
5440
5490
  function getWorks(source, _Provider, options) {
5441
- const patterns = patternManager.transform([].concat(source));
5491
+ const patterns = [].concat(source);
5442
5492
  const settings = new settings_1.default(options);
5443
5493
  const tasks = taskManager.generate(patterns, settings);
5444
5494
  const provider = new _Provider(settings);
@@ -5455,6 +5505,85 @@ var require_out4 = __commonJS({
5455
5505
  }
5456
5506
  });
5457
5507
 
5508
+ // ../esbuild-plugin-alias/dist/cjs/index.cjs
5509
+ var require_cjs = __commonJS({
5510
+ "../esbuild-plugin-alias/dist/cjs/index.cjs"(exports, module) {
5511
+ var __defProp2 = Object.defineProperty;
5512
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
5513
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
5514
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
5515
+ var __export = (target, all) => {
5516
+ for (var name in all)
5517
+ __defProp2(target, name, { get: all[name], enumerable: true });
5518
+ };
5519
+ var __copyProps2 = (to, from, except, desc) => {
5520
+ if (from && typeof from === "object" || typeof from === "function") {
5521
+ for (let key of __getOwnPropNames2(from))
5522
+ if (!__hasOwnProp2.call(to, key) && key !== except)
5523
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
5524
+ }
5525
+ return to;
5526
+ };
5527
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
5528
+ var src_exports = {};
5529
+ __export(src_exports, {
5530
+ aliasPlugin: () => aliasPlugin6
5531
+ });
5532
+ module.exports = __toCommonJS(src_exports);
5533
+ var import_fs = __require("fs");
5534
+ var import_promises = __require("fs/promises");
5535
+ function escapeRegExp(str) {
5536
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5537
+ }
5538
+ var aliasPlugin6 = (aliasObj) => {
5539
+ const aliases = Object.keys(aliasObj);
5540
+ const re = new RegExp(`^(${aliases.map((x) => escapeRegExp(x)).join("|")})$`);
5541
+ const plugin = {
5542
+ name: "alias",
5543
+ setup(build) {
5544
+ build.onResolve({ filter: re }, async (args) => {
5545
+ let resolvedAliasPath = aliasObj[args.path];
5546
+ let namespace = args.namespace;
5547
+ if (!resolvedAliasPath) {
5548
+ return null;
5549
+ }
5550
+ if (resolvedAliasPath.startsWith("http://")) {
5551
+ namespace = "http";
5552
+ resolvedAliasPath = resolvedAliasPath.slice(5);
5553
+ } else if (resolvedAliasPath.startsWith("https://")) {
5554
+ namespace = "https";
5555
+ resolvedAliasPath = resolvedAliasPath.slice(6);
5556
+ } else {
5557
+ const resolvedAlias = await build.resolve(resolvedAliasPath, {
5558
+ importer: args.importer,
5559
+ kind: args.kind,
5560
+ namespace,
5561
+ resolveDir: args.resolveDir,
5562
+ pluginData: args.pluginData
5563
+ });
5564
+ if (resolvedAlias.errors.length > 0) {
5565
+ console.error(resolvedAlias.errors);
5566
+ return resolvedAlias;
5567
+ } else {
5568
+ resolvedAliasPath = resolvedAlias.path;
5569
+ namespace = resolvedAlias.namespace;
5570
+ }
5571
+ }
5572
+ if ((0, import_fs.existsSync)(resolvedAliasPath)) {
5573
+ resolvedAliasPath = await (0, import_promises.realpath)(resolvedAliasPath);
5574
+ }
5575
+ return {
5576
+ path: resolvedAliasPath,
5577
+ namespace
5578
+ };
5579
+ });
5580
+ }
5581
+ };
5582
+ return plugin;
5583
+ };
5584
+ }
5585
+ });
5586
+
5458
5587
  // ../../../node_modules/lodash/lodash.js
5459
5588
  var require_lodash = __commonJS({
5460
5589
  "../../../node_modules/lodash/lodash.js"(exports, module) {
@@ -6189,7 +6318,7 @@ var require_lodash = __commonJS({
6189
6318
  }
6190
6319
  return new LodashWrapper(value);
6191
6320
  }
6192
- var baseCreate = function() {
6321
+ var baseCreate = /* @__PURE__ */ function() {
6193
6322
  function object() {
6194
6323
  }
6195
6324
  return function(proto) {
@@ -9496,7 +9625,7 @@ var require_lodash = __commonJS({
9496
9625
  var gte = createRelationalOperation(function(value, other) {
9497
9626
  return value >= other;
9498
9627
  });
9499
- var isArguments = baseIsArguments(function() {
9628
+ var isArguments = baseIsArguments(/* @__PURE__ */ function() {
9500
9629
  return arguments;
9501
9630
  }()) ? baseIsArguments : function(value) {
9502
9631
  return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
@@ -9821,7 +9950,7 @@ var require_lodash = __commonJS({
9821
9950
  });
9822
9951
  return result2;
9823
9952
  }
9824
- var merge7 = createAssigner(function(object, source, srcIndex) {
9953
+ var merge6 = createAssigner(function(object, source, srcIndex) {
9825
9954
  baseMerge(object, source, srcIndex);
9826
9955
  });
9827
9956
  var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
@@ -10012,7 +10141,7 @@ var require_lodash = __commonJS({
10012
10141
  string = toString(string);
10013
10142
  return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string;
10014
10143
  }
10015
- function escapeRegExp2(string) {
10144
+ function escapeRegExp(string) {
10016
10145
  string = toString(string);
10017
10146
  return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, "\\$&") : string;
10018
10147
  }
@@ -10511,7 +10640,7 @@ var require_lodash = __commonJS({
10511
10640
  lodash.matches = matches;
10512
10641
  lodash.matchesProperty = matchesProperty;
10513
10642
  lodash.memoize = memoize;
10514
- lodash.merge = merge7;
10643
+ lodash.merge = merge6;
10515
10644
  lodash.mergeWith = mergeWith;
10516
10645
  lodash.method = method;
10517
10646
  lodash.methodOf = methodOf;
@@ -10615,7 +10744,7 @@ var require_lodash = __commonJS({
10615
10744
  lodash.endsWith = endsWith;
10616
10745
  lodash.eq = eq;
10617
10746
  lodash.escape = escape;
10618
- lodash.escapeRegExp = escapeRegExp2;
10747
+ lodash.escapeRegExp = escapeRegExp;
10619
10748
  lodash.every = every;
10620
10749
  lodash.find = find;
10621
10750
  lodash.findIndex = findIndex;
@@ -11278,76 +11407,27 @@ var globToEntryPoints = async (_entryPoints, ignore = []) => {
11278
11407
  // src/utils/extension.ts
11279
11408
  var getJsExtensions = (allowExt) => {
11280
11409
  const extensions = { ".js": ".js", ".ts": ".js", ".mts": ".js", ".cts": ".js", ".cjs": ".js", ".mjs": ".js" };
11281
- if (extensions[allowExt]) {
11410
+ if (allowExt && extensions[allowExt]) {
11282
11411
  delete extensions[allowExt];
11283
11412
  }
11284
11413
  return extensions;
11285
11414
  };
11286
11415
 
11287
- // src/alias-plugin.ts
11288
- import { existsSync } from "fs";
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
11416
+ // src/lib/lib.ts
11417
+ var import_esbuild_plugin_alias = __toESM(require_cjs(), 1);
11340
11418
  var import_lodash = __toESM(require_lodash(), 1);
11341
11419
  import { transformExtPlugin } from "@gjsify/esbuild-plugin-transform-ext";
11342
- var setupCjsLib = async (build, pluginOptions) => {
11420
+ var setupLib = async (build, pluginOptions) => {
11421
+ const format = pluginOptions.format || "esm";
11343
11422
  pluginOptions.aliases ||= {};
11344
11423
  pluginOptions.exclude ||= [];
11345
11424
  const esbuildOptions = {
11425
+ format,
11346
11426
  bundle: false,
11347
- splitting: false,
11348
- // only works with esm, see https://esbuild.github.io/api/#splitting
11349
11427
  minify: false,
11350
11428
  sourcemap: false,
11429
+ splitting: format === "esm" ? true : false,
11430
+ // Works only on esm
11351
11431
  loader: {
11352
11432
  ".ts": "ts",
11353
11433
  ".mts": "ts",
@@ -11360,56 +11440,20 @@ var setupCjsLib = async (build, pluginOptions) => {
11360
11440
  ".js": "ts"
11361
11441
  },
11362
11442
  target: ["esnext"],
11363
- platform: "browser",
11443
+ platform: "neutral",
11444
+ mainFields: format === "esm" ? ["module", "main"] : ["main"],
11364
11445
  // https://esbuild.github.io/api/#conditions
11365
- conditions: ["require"],
11366
- format: "cjs"
11446
+ conditions: format === "esm" ? ["module", "import"] : ["require"]
11367
11447
  };
11368
11448
  (0, import_lodash.merge)(build.initialOptions, esbuildOptions);
11369
11449
  build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
11370
- if (pluginOptions.debug)
11371
- console.debug("initialOptions", build.initialOptions);
11372
- await aliasPlugin(pluginOptions.aliases).setup(build);
11450
+ await (0, import_esbuild_plugin_alias.aliasPlugin)(pluginOptions.aliases).setup(build);
11373
11451
  await transformExtPlugin({ outExtension: getJsExtensions(pluginOptions.jsExtension) }).setup(build);
11374
11452
  };
11375
11453
 
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
11454
  // src/app/browser.ts
11412
- var import_lodash3 = __toESM(require_lodash(), 1);
11455
+ var import_esbuild_plugin_alias2 = __toESM(require_cjs(), 1);
11456
+ var import_lodash2 = __toESM(require_lodash(), 1);
11413
11457
  import { denoPlugin } from "@gjsify/esbuild-plugin-deno-loader";
11414
11458
  import * as deepkitPlugin from "@gjsify/esbuild-plugin-deepkit";
11415
11459
  var setupForBrowser = async (build, pluginOptions) => {
@@ -11446,26 +11490,31 @@ var setupForBrowser = async (build, pluginOptions) => {
11446
11490
  window: "globalThis"
11447
11491
  }
11448
11492
  };
11449
- (0, import_lodash3.merge)(build.initialOptions, esbuildOptions);
11493
+ (0, import_lodash2.merge)(build.initialOptions, esbuildOptions);
11450
11494
  build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
11451
11495
  const aliases = { ...pluginOptions.aliases };
11452
11496
  if (pluginOptions.debug)
11453
11497
  console.debug("initialOptions", build.initialOptions);
11454
- await aliasPlugin(aliases).setup(build);
11498
+ await (0, import_esbuild_plugin_alias2.aliasPlugin)(aliases).setup(build);
11455
11499
  await denoPlugin({ reflection: pluginOptions.reflection }).setup(build);
11456
11500
  await deepkitPlugin.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
11457
11501
  };
11458
11502
 
11459
11503
  // src/app/deno.ts
11460
- var import_lodash4 = __toESM(require_lodash(), 1);
11504
+ var import_esbuild_plugin_alias3 = __toESM(require_cjs(), 1);
11505
+ var import_lodash3 = __toESM(require_lodash(), 1);
11461
11506
  import { denoPlugin as denoPlugin2 } from "@gjsify/esbuild-plugin-deno-loader";
11462
11507
  import * as deepkitPlugin3 from "@gjsify/esbuild-plugin-deepkit";
11463
11508
  var setupForDeno = async (build, pluginOptions) => {
11464
11509
  const external = [];
11510
+ const format = pluginOptions.format || "esm";
11511
+ if (format !== "esm")
11512
+ throw new TypeError("Only ESM format is supported for Deno");
11465
11513
  pluginOptions.aliases ||= {};
11466
11514
  pluginOptions.exclude ||= [];
11467
11515
  const esbuildOptions = {
11468
- format: "esm",
11516
+ format,
11517
+ // Only 'esm' is supported for Deno
11469
11518
  bundle: true,
11470
11519
  minify: false,
11471
11520
  sourcemap: false,
@@ -11494,29 +11543,30 @@ var setupForDeno = async (build, pluginOptions) => {
11494
11543
  window: "globalThis"
11495
11544
  }
11496
11545
  };
11497
- (0, import_lodash4.merge)(build.initialOptions, esbuildOptions);
11546
+ (0, import_lodash3.merge)(build.initialOptions, esbuildOptions);
11498
11547
  build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
11499
11548
  const aliases = { ...getAliasesForDeno({ external }), ...pluginOptions.aliases };
11500
11549
  if (pluginOptions.debug)
11501
11550
  console.debug("initialOptions", build.initialOptions);
11502
- await aliasPlugin(aliases).setup(build);
11551
+ await (0, import_esbuild_plugin_alias3.aliasPlugin)(aliases).setup(build);
11503
11552
  await denoPlugin2({ reflection: pluginOptions.reflection }).setup(build);
11504
11553
  await deepkitPlugin3.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
11505
11554
  };
11506
11555
 
11507
11556
  // src/app/gjs.ts
11508
- var import_lodash5 = __toESM(require_lodash(), 1);
11557
+ var import_esbuild_plugin_alias4 = __toESM(require_cjs(), 1);
11558
+ var import_lodash4 = __toESM(require_lodash(), 1);
11509
11559
  import { denoPlugin as denoPlugin3 } from "@gjsify/esbuild-plugin-deno-loader";
11510
11560
  import * as deepkitPlugin5 from "@gjsify/esbuild-plugin-deepkit";
11511
11561
  var setupForGjs = async (build, pluginOptions) => {
11512
11562
  const external = ["gi://*", "cairo", "gettext", "system"];
11563
+ const format = pluginOptions.format || "esm";
11513
11564
  pluginOptions.aliases ||= {};
11514
11565
  pluginOptions.exclude ||= [];
11515
11566
  const esbuildOptions = {
11516
- format: "esm",
11517
- // On Gjs we only support esm
11567
+ format,
11518
11568
  bundle: true,
11519
- metafile: true,
11569
+ metafile: false,
11520
11570
  minify: false,
11521
11571
  sourcemap: false,
11522
11572
  treeShaking: true,
@@ -11529,9 +11579,9 @@ var setupForGjs = async (build, pluginOptions) => {
11529
11579
  // firefox102 // Since GJS 1.73.2
11530
11580
  target: ["firefox102"],
11531
11581
  platform: "neutral",
11532
- mainFields: ["module", "main"],
11582
+ mainFields: format === "esm" ? ["module", "main"] : ["main", "module"],
11533
11583
  // https://esbuild.github.io/api/#conditions
11534
- conditions: ["module", "import"],
11584
+ conditions: format === "esm" ? ["import", "require"] : ["require", "import"],
11535
11585
  external,
11536
11586
  loader: {
11537
11587
  ".ts": "ts",
@@ -11549,25 +11599,26 @@ var setupForGjs = async (build, pluginOptions) => {
11549
11599
  window: "globalThis"
11550
11600
  }
11551
11601
  };
11552
- (0, import_lodash5.merge)(build.initialOptions, esbuildOptions);
11602
+ (0, import_lodash4.merge)(build.initialOptions, esbuildOptions);
11553
11603
  build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
11554
11604
  const aliases = { ...getAliasesForGjs({ external }), ...pluginOptions.aliases };
11555
11605
  if (pluginOptions.debug)
11556
11606
  console.debug("initialOptions", build.initialOptions);
11557
- await aliasPlugin(aliases).setup(build);
11607
+ await (0, import_esbuild_plugin_alias4.aliasPlugin)(aliases).setup(build);
11558
11608
  await denoPlugin3({ reflection: pluginOptions.reflection }).setup(build);
11559
11609
  await deepkitPlugin5.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
11560
11610
  };
11561
11611
 
11562
11612
  // src/app/node.ts
11563
- var import_lodash6 = __toESM(require_lodash(), 1);
11613
+ var import_esbuild_plugin_alias5 = __toESM(require_cjs(), 1);
11614
+ var import_lodash5 = __toESM(require_lodash(), 1);
11564
11615
  import { denoPlugin as denoPlugin4 } from "@gjsify/esbuild-plugin-deno-loader";
11565
11616
  import * as deepkitPlugin7 from "@gjsify/esbuild-plugin-deepkit";
11566
11617
  var setupForNode = async (build, pluginOptions) => {
11567
11618
  const external = [...EXTERNALS_NODE, "gi://*"];
11619
+ const format = pluginOptions.format || "esm";
11568
11620
  pluginOptions.aliases ||= {};
11569
11621
  pluginOptions.exclude ||= [];
11570
- const format = pluginOptions.format || "esm";
11571
11622
  const esbuildOptions = {
11572
11623
  format,
11573
11624
  bundle: true,
@@ -11578,7 +11629,7 @@ var setupForNode = async (build, pluginOptions) => {
11578
11629
  // false means follow symlinks
11579
11630
  target: ["node18"],
11580
11631
  platform: "node",
11581
- mainFields: format === "esm" ? ["module", "main"] : ["main", "module", "browser"],
11632
+ mainFields: format === "esm" ? ["module", "main", "browser"] : ["main", "module", "browser"],
11582
11633
  conditions: format === "esm" ? ["module", "import"] : ["require"],
11583
11634
  external,
11584
11635
  loader: {
@@ -11597,12 +11648,12 @@ var setupForNode = async (build, pluginOptions) => {
11597
11648
  window: "globalThis"
11598
11649
  }
11599
11650
  };
11600
- (0, import_lodash6.merge)(build.initialOptions, esbuildOptions);
11651
+ (0, import_lodash5.merge)(build.initialOptions, esbuildOptions);
11601
11652
  build.initialOptions.entryPoints = await globToEntryPoints(build.initialOptions.entryPoints, pluginOptions.exclude);
11602
11653
  const aliases = { ...getAliasesForNode({ external }), ...pluginOptions.aliases };
11603
11654
  if (pluginOptions.debug)
11604
11655
  console.debug("initialOptions", build.initialOptions);
11605
- await aliasPlugin(aliases).setup(build);
11656
+ await (0, import_esbuild_plugin_alias5.aliasPlugin)(aliases).setup(build);
11606
11657
  await denoPlugin4({ reflection: pluginOptions.reflection }).setup(build);
11607
11658
  await deepkitPlugin7.deepkitPlugin({ reflection: pluginOptions.reflection }).setup(build);
11608
11659
  };
@@ -11615,9 +11666,8 @@ var gjsifyPlugin = (pluginOptions = {}) => {
11615
11666
  if (pluginOptions.library) {
11616
11667
  switch (pluginOptions.library) {
11617
11668
  case "esm":
11618
- return setupEsmLib(build, pluginOptions);
11619
11669
  case "cjs":
11620
- return setupCjsLib(build, pluginOptions);
11670
+ return setupLib(build, pluginOptions);
11621
11671
  default:
11622
11672
  throw new TypeError("Unknown library type: " + pluginOptions.library);
11623
11673
  }