@multiplatform.one/vite-plugin-gnome 7.90.6 → 8.0.0
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/lib/index.cjs +106 -0
- package/lib/index.mjs +104 -1
- package/package.json +1 -1
- package/src/index.ts +146 -0
- package/types/index.d.ts +61 -0
- package/types/index.d.ts.map +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
let node_path = require("node:path");
|
|
2
4
|
|
|
3
5
|
//#region src/index.ts
|
|
4
6
|
/**
|
|
@@ -257,9 +259,113 @@ function tamaguiLinkedAliases(options) {
|
|
|
257
259
|
}
|
|
258
260
|
];
|
|
259
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* The export condition a package's GNOME build sits behind. A package GNOME
|
|
264
|
+
* loads puts it first on its main entry
|
|
265
|
+
* (`".": { "gnome": "./src/index.gnome.ts", … }`), so the key wins whenever
|
|
266
|
+
* the condition is on and no other target ever sees it.
|
|
267
|
+
*/
|
|
268
|
+
const gnomeCondition = "gnome";
|
|
269
|
+
/**
|
|
270
|
+
* The importer-aware redirect behind {@link gnomeResolve}, shared with tools
|
|
271
|
+
* that resolve a GNOME graph the way the bundle does. A specifier with a shim
|
|
272
|
+
* resolves to that shim, except from the shim itself or from a shim file it
|
|
273
|
+
* reaches by a relative import (`export * from "./components-core"`): those
|
|
274
|
+
* stand for the same package, so they get the real one. Any other file, shims
|
|
275
|
+
* of other packages included, gets the shim.
|
|
276
|
+
*/
|
|
277
|
+
function gnomeShimResolver(shims) {
|
|
278
|
+
const standsFor = /* @__PURE__ */ new Map();
|
|
279
|
+
const real = (id) => {
|
|
280
|
+
const file = id.split("?")[0] ?? id;
|
|
281
|
+
try {
|
|
282
|
+
return node_fs.realpathSync.native(file);
|
|
283
|
+
} catch {
|
|
284
|
+
return file;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const dir = shims ? real(shims.dir) : "";
|
|
288
|
+
const inDir = (file) => {
|
|
289
|
+
const path = (0, node_path.relative)(dir, file);
|
|
290
|
+
return Boolean(shims) && path !== "" && !path.startsWith("..") && !(0, node_path.isAbsolute)(path);
|
|
291
|
+
};
|
|
292
|
+
return {
|
|
293
|
+
shimFor(specifier, importer) {
|
|
294
|
+
const shim = shims?.packages[specifier];
|
|
295
|
+
if (!shims || !shim) return void 0;
|
|
296
|
+
if (importer && standsFor.get(real(importer))?.has(specifier)) return void 0;
|
|
297
|
+
const file = (0, node_path.isAbsolute)(shim) ? shim : (0, node_path.resolve)(shims.dir, shim);
|
|
298
|
+
const key = real(file);
|
|
299
|
+
standsFor.set(key, new Set([...standsFor.get(key) ?? [], specifier]));
|
|
300
|
+
return file;
|
|
301
|
+
},
|
|
302
|
+
reached(importer, resolved) {
|
|
303
|
+
if (standsFor.size === 0) return;
|
|
304
|
+
const family = standsFor.get(real(importer));
|
|
305
|
+
const file = real(resolved);
|
|
306
|
+
if (!family || !inDir(file)) return;
|
|
307
|
+
standsFor.set(file, new Set([...standsFor.get(file) ?? [], ...family]));
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
/** A config's `gnome.shims` with `dir` resolved against `root`, or undefined. */
|
|
312
|
+
function gnomeShimsOf(options, root) {
|
|
313
|
+
const shims = options?.shims;
|
|
314
|
+
if (!shims?.dir || !shims.packages) return void 0;
|
|
315
|
+
return {
|
|
316
|
+
dir: (0, node_path.resolve)(root, shims.dir),
|
|
317
|
+
packages: shims.packages
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Resolution for a GNOME build, in one plugin. It turns the
|
|
322
|
+
* {@link gnomeCondition} condition on, after the config's own
|
|
323
|
+
* `resolve.conditions` (which it requires), applies the config's
|
|
324
|
+
* `gnome.shims` redirect (see {@link gnomeShimResolver}), and builds with
|
|
325
|
+
* Rolldown's lazy barrels: a package's gnome entry names everything GJS can
|
|
326
|
+
* run, and a bundle that imports three of those names compiles those three
|
|
327
|
+
* modules, not the rest of the barrel (Rolldown only; Rollup builds load the
|
|
328
|
+
* whole barrel).
|
|
329
|
+
*
|
|
330
|
+
* ```ts
|
|
331
|
+
* plugins: [gnomeResolve()],
|
|
332
|
+
* gnome: { shims: { dir: "gnome/shims", packages: { "@multiplatform.one/forms": "forms-lite.ts" } } },
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
function gnomeResolve() {
|
|
336
|
+
let resolver = gnomeShimResolver(void 0);
|
|
337
|
+
return {
|
|
338
|
+
name: "mpo-gnome-resolve",
|
|
339
|
+
enforce: "pre",
|
|
340
|
+
config(user) {
|
|
341
|
+
if (!user.resolve?.conditions) throw new Error("gnomeResolve() appends the gnome condition to resolve.conditions; set them first (@react-gnome/vite-plugin's gnomeConditions)");
|
|
342
|
+
const meta = this?.meta;
|
|
343
|
+
const optionsKey = user.build?.rolldownOptions ? "rolldownOptions" : "rollupOptions";
|
|
344
|
+
return {
|
|
345
|
+
resolve: { conditions: [gnomeCondition] },
|
|
346
|
+
...meta?.rolldownVersion && { build: { [optionsKey]: { experimental: { lazyBarrel: true } } } }
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
configResolved(config) {
|
|
350
|
+
resolver = gnomeShimResolver(gnomeShimsOf(config.gnome, config.root));
|
|
351
|
+
},
|
|
352
|
+
async resolveId(source, importer) {
|
|
353
|
+
const shim = resolver.shimFor(source, importer);
|
|
354
|
+
if (shim) return shim;
|
|
355
|
+
if (!importer || !source.startsWith(".")) return null;
|
|
356
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
357
|
+
if (resolved) resolver.reached(importer, resolved.id);
|
|
358
|
+
return resolved;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
260
362
|
|
|
261
363
|
//#endregion
|
|
364
|
+
exports.gnomeCondition = gnomeCondition;
|
|
262
365
|
exports.gnomePlatformExtensions = gnomePlatformExtensions;
|
|
366
|
+
exports.gnomeResolve = gnomeResolve;
|
|
367
|
+
exports.gnomeShimResolver = gnomeShimResolver;
|
|
368
|
+
exports.gnomeShimsOf = gnomeShimsOf;
|
|
263
369
|
exports.tamaguiAliases = tamaguiAliases;
|
|
264
370
|
exports.tamaguiLinkedAliases = tamaguiLinkedAliases;
|
|
265
371
|
exports.tamaguiPatchAnchors = tamaguiPatchAnchors;
|
package/lib/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
3
|
+
|
|
1
4
|
//#region src/index.ts
|
|
2
5
|
/**
|
|
3
6
|
* Platform-suffixed extensions for the GNOME target, in resolution order.
|
|
@@ -255,6 +258,106 @@ function tamaguiLinkedAliases(options) {
|
|
|
255
258
|
}
|
|
256
259
|
];
|
|
257
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* The export condition a package's GNOME build sits behind. A package GNOME
|
|
263
|
+
* loads puts it first on its main entry
|
|
264
|
+
* (`".": { "gnome": "./src/index.gnome.ts", … }`), so the key wins whenever
|
|
265
|
+
* the condition is on and no other target ever sees it.
|
|
266
|
+
*/
|
|
267
|
+
const gnomeCondition = "gnome";
|
|
268
|
+
/**
|
|
269
|
+
* The importer-aware redirect behind {@link gnomeResolve}, shared with tools
|
|
270
|
+
* that resolve a GNOME graph the way the bundle does. A specifier with a shim
|
|
271
|
+
* resolves to that shim, except from the shim itself or from a shim file it
|
|
272
|
+
* reaches by a relative import (`export * from "./components-core"`): those
|
|
273
|
+
* stand for the same package, so they get the real one. Any other file, shims
|
|
274
|
+
* of other packages included, gets the shim.
|
|
275
|
+
*/
|
|
276
|
+
function gnomeShimResolver(shims) {
|
|
277
|
+
const standsFor = /* @__PURE__ */ new Map();
|
|
278
|
+
const real = (id) => {
|
|
279
|
+
const file = id.split("?")[0] ?? id;
|
|
280
|
+
try {
|
|
281
|
+
return realpathSync.native(file);
|
|
282
|
+
} catch {
|
|
283
|
+
return file;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
const dir = shims ? real(shims.dir) : "";
|
|
287
|
+
const inDir = (file) => {
|
|
288
|
+
const path = relative(dir, file);
|
|
289
|
+
return Boolean(shims) && path !== "" && !path.startsWith("..") && !isAbsolute(path);
|
|
290
|
+
};
|
|
291
|
+
return {
|
|
292
|
+
shimFor(specifier, importer) {
|
|
293
|
+
const shim = shims?.packages[specifier];
|
|
294
|
+
if (!shims || !shim) return void 0;
|
|
295
|
+
if (importer && standsFor.get(real(importer))?.has(specifier)) return void 0;
|
|
296
|
+
const file = isAbsolute(shim) ? shim : resolve(shims.dir, shim);
|
|
297
|
+
const key = real(file);
|
|
298
|
+
standsFor.set(key, new Set([...standsFor.get(key) ?? [], specifier]));
|
|
299
|
+
return file;
|
|
300
|
+
},
|
|
301
|
+
reached(importer, resolved) {
|
|
302
|
+
if (standsFor.size === 0) return;
|
|
303
|
+
const family = standsFor.get(real(importer));
|
|
304
|
+
const file = real(resolved);
|
|
305
|
+
if (!family || !inDir(file)) return;
|
|
306
|
+
standsFor.set(file, new Set([...standsFor.get(file) ?? [], ...family]));
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/** A config's `gnome.shims` with `dir` resolved against `root`, or undefined. */
|
|
311
|
+
function gnomeShimsOf(options, root) {
|
|
312
|
+
const shims = options?.shims;
|
|
313
|
+
if (!shims?.dir || !shims.packages) return void 0;
|
|
314
|
+
return {
|
|
315
|
+
dir: resolve(root, shims.dir),
|
|
316
|
+
packages: shims.packages
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Resolution for a GNOME build, in one plugin. It turns the
|
|
321
|
+
* {@link gnomeCondition} condition on, after the config's own
|
|
322
|
+
* `resolve.conditions` (which it requires), applies the config's
|
|
323
|
+
* `gnome.shims` redirect (see {@link gnomeShimResolver}), and builds with
|
|
324
|
+
* Rolldown's lazy barrels: a package's gnome entry names everything GJS can
|
|
325
|
+
* run, and a bundle that imports three of those names compiles those three
|
|
326
|
+
* modules, not the rest of the barrel (Rolldown only; Rollup builds load the
|
|
327
|
+
* whole barrel).
|
|
328
|
+
*
|
|
329
|
+
* ```ts
|
|
330
|
+
* plugins: [gnomeResolve()],
|
|
331
|
+
* gnome: { shims: { dir: "gnome/shims", packages: { "@multiplatform.one/forms": "forms-lite.ts" } } },
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
function gnomeResolve() {
|
|
335
|
+
let resolver = gnomeShimResolver(void 0);
|
|
336
|
+
return {
|
|
337
|
+
name: "mpo-gnome-resolve",
|
|
338
|
+
enforce: "pre",
|
|
339
|
+
config(user) {
|
|
340
|
+
if (!user.resolve?.conditions) throw new Error("gnomeResolve() appends the gnome condition to resolve.conditions; set them first (@react-gnome/vite-plugin's gnomeConditions)");
|
|
341
|
+
const meta = this?.meta;
|
|
342
|
+
const optionsKey = user.build?.rolldownOptions ? "rolldownOptions" : "rollupOptions";
|
|
343
|
+
return {
|
|
344
|
+
resolve: { conditions: [gnomeCondition] },
|
|
345
|
+
...meta?.rolldownVersion && { build: { [optionsKey]: { experimental: { lazyBarrel: true } } } }
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
configResolved(config) {
|
|
349
|
+
resolver = gnomeShimResolver(gnomeShimsOf(config.gnome, config.root));
|
|
350
|
+
},
|
|
351
|
+
async resolveId(source, importer) {
|
|
352
|
+
const shim = resolver.shimFor(source, importer);
|
|
353
|
+
if (shim) return shim;
|
|
354
|
+
if (!importer || !source.startsWith(".")) return null;
|
|
355
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
356
|
+
if (resolved) resolver.reached(importer, resolved.id);
|
|
357
|
+
return resolved;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
258
361
|
|
|
259
362
|
//#endregion
|
|
260
|
-
export { gnomePlatformExtensions, tamaguiAliases, tamaguiLinkedAliases, tamaguiPatchAnchors, tamaguiPlugin };
|
|
363
|
+
export { gnomeCondition, gnomePlatformExtensions, gnomeResolve, gnomeShimResolver, gnomeShimsOf, tamaguiAliases, tamaguiLinkedAliases, tamaguiPatchAnchors, tamaguiPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/vite-plugin-gnome",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Vite plugin that makes Tamagui render under react-gnome (GTK4/GJS) — bundle patches for @tamagui/core's native lazy-init chains, the sheet/portal native builds, the hover/animation gates, plus the Tamagui-specific resolver aliases. Pairs with @react-gnome/vite-plugin (generic GJS aliases/conditions/define).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gjs",
|
package/src/index.ts
CHANGED
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
// no longer matches no-ops silently in the build and only manifests as
|
|
31
31
|
// runtime breakage under GJS.
|
|
32
32
|
|
|
33
|
+
import { realpathSync } from "node:fs";
|
|
34
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
33
35
|
import type { Plugin } from "vite";
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -491,3 +493,147 @@ export function tamaguiLinkedAliases(options: TamaguiAliasOptions): TamaguiAlias
|
|
|
491
493
|
{ find: /^tamagui$/, replacement: options.tamaguiBarrel },
|
|
492
494
|
];
|
|
493
495
|
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* The export condition a package's GNOME build sits behind. A package GNOME
|
|
499
|
+
* loads puts it first on its main entry
|
|
500
|
+
* (`".": { "gnome": "./src/index.gnome.ts", … }`), so the key wins whenever
|
|
501
|
+
* the condition is on and no other target ever sees it.
|
|
502
|
+
*/
|
|
503
|
+
export const gnomeCondition = "gnome";
|
|
504
|
+
|
|
505
|
+
/** App-side shims that stand in for a package in one GNOME bundle. */
|
|
506
|
+
export interface GnomeShims {
|
|
507
|
+
/** Directory holding the shims. */
|
|
508
|
+
dir: string;
|
|
509
|
+
/**
|
|
510
|
+
* Bare specifier → shim file (absolute, or relative to `dir`). A falsy
|
|
511
|
+
* value drops a shim an earlier config set, so a derived config can go
|
|
512
|
+
* back to the package itself through `mergeConfig`.
|
|
513
|
+
*/
|
|
514
|
+
packages: Record<string, string | false | undefined>;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/** The `gnome` key of a GNOME Vite config, read by {@link gnomeResolve}. */
|
|
518
|
+
export interface GnomeOptions {
|
|
519
|
+
shims?: Partial<GnomeShims>;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
declare module "vite" {
|
|
523
|
+
interface UserConfig {
|
|
524
|
+
gnome?: GnomeOptions;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** One build's view of its shims; see {@link gnomeShimResolver}. */
|
|
529
|
+
export interface GnomeShimResolver {
|
|
530
|
+
/** The shim `specifier` resolves to from `importer`, or undefined for the package itself. */
|
|
531
|
+
shimFor(specifier: string, importer: string | undefined): string | undefined;
|
|
532
|
+
/** Record that `importer` reached `resolved` through a relative import. */
|
|
533
|
+
reached(importer: string, resolved: string): void;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* The importer-aware redirect behind {@link gnomeResolve}, shared with tools
|
|
538
|
+
* that resolve a GNOME graph the way the bundle does. A specifier with a shim
|
|
539
|
+
* resolves to that shim, except from the shim itself or from a shim file it
|
|
540
|
+
* reaches by a relative import (`export * from "./components-core"`): those
|
|
541
|
+
* stand for the same package, so they get the real one. Any other file, shims
|
|
542
|
+
* of other packages included, gets the shim.
|
|
543
|
+
*/
|
|
544
|
+
export function gnomeShimResolver(shims: GnomeShims | undefined): GnomeShimResolver {
|
|
545
|
+
const standsFor = new Map<string, Set<string>>();
|
|
546
|
+
const real = (id: string) => {
|
|
547
|
+
const file = id.split("?")[0] ?? id;
|
|
548
|
+
try {
|
|
549
|
+
return realpathSync.native(file);
|
|
550
|
+
} catch {
|
|
551
|
+
return file;
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const dir = shims ? real(shims.dir) : "";
|
|
555
|
+
const inDir = (file: string) => {
|
|
556
|
+
const path = relative(dir, file);
|
|
557
|
+
return Boolean(shims) && path !== "" && !path.startsWith("..") && !isAbsolute(path);
|
|
558
|
+
};
|
|
559
|
+
return {
|
|
560
|
+
shimFor(specifier, importer) {
|
|
561
|
+
const shim = shims?.packages[specifier];
|
|
562
|
+
if (!shims || !shim) return undefined;
|
|
563
|
+
if (importer && standsFor.get(real(importer))?.has(specifier)) return undefined;
|
|
564
|
+
const file = isAbsolute(shim) ? shim : resolve(shims.dir, shim);
|
|
565
|
+
const key = real(file);
|
|
566
|
+
standsFor.set(key, new Set([...(standsFor.get(key) ?? []), specifier]));
|
|
567
|
+
return file;
|
|
568
|
+
},
|
|
569
|
+
reached(importer, resolved) {
|
|
570
|
+
if (standsFor.size === 0) return;
|
|
571
|
+
const family = standsFor.get(real(importer));
|
|
572
|
+
const file = real(resolved);
|
|
573
|
+
if (!family || !inDir(file)) return;
|
|
574
|
+
standsFor.set(file, new Set([...(standsFor.get(file) ?? []), ...family]));
|
|
575
|
+
},
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/** A config's `gnome.shims` with `dir` resolved against `root`, or undefined. */
|
|
580
|
+
export function gnomeShimsOf(
|
|
581
|
+
options: GnomeOptions | undefined,
|
|
582
|
+
root: string,
|
|
583
|
+
): GnomeShims | undefined {
|
|
584
|
+
const shims = options?.shims;
|
|
585
|
+
if (!shims?.dir || !shims.packages) return undefined;
|
|
586
|
+
return { dir: resolve(root, shims.dir), packages: shims.packages };
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Resolution for a GNOME build, in one plugin. It turns the
|
|
591
|
+
* {@link gnomeCondition} condition on, after the config's own
|
|
592
|
+
* `resolve.conditions` (which it requires), applies the config's
|
|
593
|
+
* `gnome.shims` redirect (see {@link gnomeShimResolver}), and builds with
|
|
594
|
+
* Rolldown's lazy barrels: a package's gnome entry names everything GJS can
|
|
595
|
+
* run, and a bundle that imports three of those names compiles those three
|
|
596
|
+
* modules, not the rest of the barrel (Rolldown only; Rollup builds load the
|
|
597
|
+
* whole barrel).
|
|
598
|
+
*
|
|
599
|
+
* ```ts
|
|
600
|
+
* plugins: [gnomeResolve()],
|
|
601
|
+
* gnome: { shims: { dir: "gnome/shims", packages: { "@multiplatform.one/forms": "forms-lite.ts" } } },
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
export function gnomeResolve(): Plugin {
|
|
605
|
+
let resolver = gnomeShimResolver(undefined);
|
|
606
|
+
return {
|
|
607
|
+
name: "mpo-gnome-resolve",
|
|
608
|
+
enforce: "pre",
|
|
609
|
+
config(user) {
|
|
610
|
+
if (!user.resolve?.conditions) {
|
|
611
|
+
throw new Error(
|
|
612
|
+
"gnomeResolve() appends the gnome condition to resolve.conditions; set them first " +
|
|
613
|
+
"(@react-gnome/vite-plugin's gnomeConditions)",
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
const meta = (this as { meta?: { rolldownVersion?: string } } | undefined)?.meta;
|
|
617
|
+
const optionsKey = user.build?.rolldownOptions ? "rolldownOptions" : "rollupOptions";
|
|
618
|
+
return {
|
|
619
|
+
resolve: { conditions: [gnomeCondition] },
|
|
620
|
+
...(meta?.rolldownVersion && {
|
|
621
|
+
build: { [optionsKey]: { experimental: { lazyBarrel: true } } },
|
|
622
|
+
}),
|
|
623
|
+
};
|
|
624
|
+
},
|
|
625
|
+
configResolved(config) {
|
|
626
|
+
resolver = gnomeShimResolver(
|
|
627
|
+
gnomeShimsOf((config as { gnome?: GnomeOptions }).gnome, config.root),
|
|
628
|
+
);
|
|
629
|
+
},
|
|
630
|
+
async resolveId(source, importer) {
|
|
631
|
+
const shim = resolver.shimFor(source, importer);
|
|
632
|
+
if (shim) return shim;
|
|
633
|
+
if (!importer || !source.startsWith(".")) return null;
|
|
634
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
635
|
+
if (resolved) resolver.reached(importer, resolved.id);
|
|
636
|
+
return resolved;
|
|
637
|
+
},
|
|
638
|
+
};
|
|
639
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -81,4 +81,65 @@ export declare function tamaguiAliases(options: TamaguiAliasOptions): TamaguiAli
|
|
|
81
81
|
* alias could re-mangle other entries' replacements.
|
|
82
82
|
*/
|
|
83
83
|
export declare function tamaguiLinkedAliases(options: TamaguiAliasOptions): TamaguiAliasEntry[];
|
|
84
|
+
/**
|
|
85
|
+
* The export condition a package's GNOME build sits behind. A package GNOME
|
|
86
|
+
* loads puts it first on its main entry
|
|
87
|
+
* (`".": { "gnome": "./src/index.gnome.ts", … }`), so the key wins whenever
|
|
88
|
+
* the condition is on and no other target ever sees it.
|
|
89
|
+
*/
|
|
90
|
+
export declare const gnomeCondition = "gnome";
|
|
91
|
+
/** App-side shims that stand in for a package in one GNOME bundle. */
|
|
92
|
+
export interface GnomeShims {
|
|
93
|
+
/** Directory holding the shims. */
|
|
94
|
+
dir: string;
|
|
95
|
+
/**
|
|
96
|
+
* Bare specifier → shim file (absolute, or relative to `dir`). A falsy
|
|
97
|
+
* value drops a shim an earlier config set, so a derived config can go
|
|
98
|
+
* back to the package itself through `mergeConfig`.
|
|
99
|
+
*/
|
|
100
|
+
packages: Record<string, string | false | undefined>;
|
|
101
|
+
}
|
|
102
|
+
/** The `gnome` key of a GNOME Vite config, read by {@link gnomeResolve}. */
|
|
103
|
+
export interface GnomeOptions {
|
|
104
|
+
shims?: Partial<GnomeShims>;
|
|
105
|
+
}
|
|
106
|
+
declare module "vite" {
|
|
107
|
+
interface UserConfig {
|
|
108
|
+
gnome?: GnomeOptions;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** One build's view of its shims; see {@link gnomeShimResolver}. */
|
|
112
|
+
export interface GnomeShimResolver {
|
|
113
|
+
/** The shim `specifier` resolves to from `importer`, or undefined for the package itself. */
|
|
114
|
+
shimFor(specifier: string, importer: string | undefined): string | undefined;
|
|
115
|
+
/** Record that `importer` reached `resolved` through a relative import. */
|
|
116
|
+
reached(importer: string, resolved: string): void;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The importer-aware redirect behind {@link gnomeResolve}, shared with tools
|
|
120
|
+
* that resolve a GNOME graph the way the bundle does. A specifier with a shim
|
|
121
|
+
* resolves to that shim, except from the shim itself or from a shim file it
|
|
122
|
+
* reaches by a relative import (`export * from "./components-core"`): those
|
|
123
|
+
* stand for the same package, so they get the real one. Any other file, shims
|
|
124
|
+
* of other packages included, gets the shim.
|
|
125
|
+
*/
|
|
126
|
+
export declare function gnomeShimResolver(shims: GnomeShims | undefined): GnomeShimResolver;
|
|
127
|
+
/** A config's `gnome.shims` with `dir` resolved against `root`, or undefined. */
|
|
128
|
+
export declare function gnomeShimsOf(options: GnomeOptions | undefined, root: string): GnomeShims | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Resolution for a GNOME build, in one plugin. It turns the
|
|
131
|
+
* {@link gnomeCondition} condition on, after the config's own
|
|
132
|
+
* `resolve.conditions` (which it requires), applies the config's
|
|
133
|
+
* `gnome.shims` redirect (see {@link gnomeShimResolver}), and builds with
|
|
134
|
+
* Rolldown's lazy barrels: a package's gnome entry names everything GJS can
|
|
135
|
+
* run, and a bundle that imports three of those names compiles those three
|
|
136
|
+
* modules, not the rest of the barrel (Rolldown only; Rollup builds load the
|
|
137
|
+
* whole barrel).
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* plugins: [gnomeResolve()],
|
|
141
|
+
* gnome: { shims: { dir: "gnome/shims", packages: { "@multiplatform.one/forms": "forms-lite.ts" } } },
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare function gnomeResolve(): Plugin;
|
|
84
145
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAOpD,CAAC;AAEF,oEAAoE;AACpE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;IAC/D,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA+PD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,kBAAkB,EAK5D,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MA8E3B,CAAC;AAEF,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAWD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,iBAAiB,EAAE,CAShF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,iBAAiB,EAAE,CAStF;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,sEAAsE;AACtE,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;CACtD;AAED,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CAC7B;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,UAAU;QAClB,KAAK,CAAC,EAAE,YAAY,CAAC;KACtB;CACF;AAED,oEAAoE;AACpE,MAAM,WAAW,iBAAiB;IAChC,6FAA6F;IAC7F,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7E,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,iBAAiB,CAiClF;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAC1B,OAAO,EAAE,YAAY,GAAG,SAAS,EACjC,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAIxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAmCrC"}
|