@octohash/vite-config 0.2.3 → 0.3.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/dist/index.d.mts CHANGED
@@ -8,934 +8,12 @@ import { Options as Options$1 } from 'unplugin-vue-components';
8
8
  import { Options as Options$2 } from 'unplugin-vue-router';
9
9
  import { PluginOptions } from 'vite-plugin-dts';
10
10
  import { VitePluginVueDevToolsOptions } from 'vite-plugin-vue-devtools';
11
+ import { GeneratorOptions } from '@jspm/generator';
11
12
 
12
13
  interface AppLoadingPluginOptions {
13
- rootContainer?: string;
14
+ container?: string;
14
15
  title?: string;
15
- filePath?: string;
16
- }
17
-
18
- type Log = (type: string, message: string) => void;
19
-
20
- interface IImportMap {
21
- imports?: Record<string, string>;
22
- scopes?: {
23
- [scope: string]: Record<string, string>;
24
- };
25
- integrity?: {
26
- [url: string]: string;
27
- };
28
- }
29
- declare class ImportMap implements IImportMap {
30
- imports: Record<string, string>;
31
- scopes: Record<string, Record<string, string>>;
32
- integrity: Record<string, string>;
33
- /**
34
- * The absolute URL of the import map, for determining relative resolutions
35
- * When using file:/// URLs this allows relative modules to be co-located
36
- */
37
- mapUrl: URL;
38
- /**
39
- * The URL to use for root-level resolutions in the import map
40
- * If null, root resolutions are not resolved and instead left as-is
41
- *
42
- * By default, rootUrl is null unless the mapUrl is an http or https URL,
43
- * in which case it is taken to be the root of the mapUrl.
44
- */
45
- rootUrl: URL | null;
46
- /**
47
- * Create a new import map instance
48
- *
49
- * @param opts import map options, can be an optional bag of { map?, mapUrl?, rootUrl? } or just a direct mapUrl
50
- */
51
- constructor(opts: {
52
- map?: IImportMap;
53
- mapUrl?: string | URL;
54
- rootUrl?: string | URL | null;
55
- } | string | URL);
56
- /**
57
- * Clones the import map
58
- * @returns Cloned import map
59
- */
60
- clone(): ImportMap;
61
- /**
62
- * Extends the import map mappings
63
- * @param map Import map to extend with
64
- * @param overrideScopes Set to true to have scopes be replacing instead of extending
65
- * @returns ImportMap for chaining
66
- */
67
- extend(map: IImportMap, overrideScopes?: boolean): this;
68
- /**
69
- * Performs an alphanumerical sort on the import map imports and scopes
70
- * @returns ImportMap for chaining
71
- */
72
- sort(): this;
73
- /**
74
- * Set a specific entry in the import map
75
- *
76
- * @param name Specifier to set
77
- * @param target Target of the map
78
- * @param parent Optional parent scope
79
- * @returns ImportMap for chaining
80
- */
81
- set(name: string, target: string, parent?: string): this;
82
- /**
83
- * @param target URL target
84
- * @param integrity Integrity
85
- */
86
- setIntegrity(target: string, integrity: string): void;
87
- /**
88
- * @param target URL target
89
- * @param integrity Integrity
90
- */
91
- getIntegrity(target: string, integrity: string): string;
92
- /**
93
- * Bulk replace URLs in the import map
94
- * Provide a URL ending in "/" to perform path replacements
95
- *
96
- * @param url {String} The URL to replace
97
- * @param newUrl {String} The URL to replace it with
98
- * @returns ImportMap for chaining
99
- */
100
- replace(url: string, newUrl: string): this;
101
- /**
102
- * Groups subpath mappings into path mappings when multiple exact subpaths
103
- * exist under the same path.
104
- *
105
- * For two mappings like { "base/a.js": "/a.js", "base/b.js": "/b.js" },
106
- * these will be replaced with a single path mapping { "base/": "/" }.
107
- * Groupings are done throughout all import scopes individually.
108
- *
109
- * @returns ImportMap for chaining
110
- */
111
- combineSubpaths(): this;
112
- /**
113
- * Groups the import map scopes to shared URLs to reduce duplicate mappings.
114
- *
115
- * For two given scopes, "https://site.com/x/" and "https://site.com/y/",
116
- * a single scope will be constructed for "https://site.com/" including
117
- * their shared mappings, only retaining the scopes if they have differences.
118
- *
119
- * In the case where the scope is on the same origin as the mapUrl, the grouped
120
- * scope is determined based on determining the common baseline over all local scopes
121
- *
122
- * @returns ImportMap for chaining
123
- */
124
- flatten(): this;
125
- /**
126
- * Rebase the entire import map to a new mapUrl and rootUrl
127
- *
128
- * If the rootUrl is not provided, it will remain null if it was
129
- * already set to null.
130
- *
131
- * Otherwise, just like the constructor options, the rootUrl
132
- * will default to the mapUrl base if it is an http: or https:
133
- * scheme URL, and null otherwise keeping absolute URLs entirely
134
- * in-tact.
135
- *
136
- * @param mapUrl The new map URL to use
137
- * @param rootUrl The new root URL to use
138
- * @returns ImportMap for chaining
139
- */
140
- rebase(mapUrl?: URL | string, rootUrl?: URL | string | null): this;
141
- /**
142
- * Perform a module resolution against the import map
143
- *
144
- * @param specifier Specifier to resolve
145
- * @param parentUrl Parent URL to resolve against
146
- * @returns Resolved URL string
147
- */
148
- resolve(specifier: string, parentUrl?: string | URL): string;
149
- /**
150
- * Get the import map JSON data
151
- *
152
- * @returns Import map data
153
- */
154
- toJSON(): IImportMap;
155
- }
156
-
157
- interface Provider {
158
- parseUrlPkg(this: ProviderContext, url: string): ExactPackage | {
159
- pkg: ExactPackage;
160
- subpath: `./${string}` | null;
161
- layer: string;
162
- } | null;
163
- pkgToUrl(this: ProviderContext, pkg: ExactPackage, layer?: string): Promise<`${string}/`>;
164
- resolveLatestTarget(this: ProviderContext, target: LatestPackageTarget, layer: string, parentUrl: string, resolver: Resolver): Promise<ExactPackage | null>;
165
- ownsUrl?(this: ProviderContext, url: string): boolean;
166
- resolveBuiltin?(this: ProviderContext, specifier: string, env: string[]): string | Install | null;
167
- getPackageConfig?(this: ProviderContext, pkgUrl: string): Promise<PackageConfig | null>;
168
- getFileList?(this: ProviderContext, pkgUrl: string): Promise<Set<string> | undefined>;
169
- download?(this: ProviderContext, pkg: ExactPackage): Promise<Record<string, ArrayBuffer>>;
170
- /**
171
- * Publish a package to the provider
172
- * This is an optional method that providers can implement to support package publishing
173
- *
174
- * @param importMap Optional import map to include with the publish
175
- */
176
- publish?(this: ProviderContext, pkg: ExactPackage, files: Record<string, string | ArrayBuffer> | undefined, importMap: ImportMap | undefined, imports: string[]): Promise<PublishOutput>;
177
- /**
178
- * Authenticate with the provider
179
- * This is an optional method that providers can implement to support authentication
180
- *
181
- * @param username Optional username for authentication
182
- * @param verify Optional callback to verify authentication with the user
183
- * @returns A promise resolving to an authentication token
184
- */
185
- auth?(this: ProviderContext, options: {
186
- username?: string;
187
- verify?: (url: string, instructions: string) => void;
188
- }): Promise<{
189
- token: string;
190
- }>;
191
- supportedLayers?: string[];
192
- configure?(this: ProviderContext, config: any): void;
193
- }
194
- /**
195
- * Context provided to all provider methods
196
- * Contains necessary services and configuration
197
- */
198
- declare class ProviderContext {
199
- #private;
200
- /**
201
- * Logger instance for provider operations
202
- */
203
- log: Log;
204
- /**
205
- * Fetch options for provider operations
206
- */
207
- fetchOpts: any;
208
- /**
209
- * Custom context object for providers
210
- */
211
- context: any;
212
- constructor(pm: ProviderManager, log: Log, fetchOpts: any);
213
- }
214
- /**
215
- * Provider manager to handle provider registration, lookup and operations
216
- */
217
- declare class ProviderManager {
218
- #private;
219
- log: Log;
220
- fetchOpts: any;
221
- providers: Record<string, Provider>;
222
- contexts: Record<string, ProviderContext>;
223
- /**
224
- * Create a new ProviderManager with the given providers
225
- *
226
- * @param customProviders Custom provider definitions to add
227
- */
228
- constructor(log: Log, fetchOpts: any, providerConfig?: Record<string, any>, customProviders?: Record<string, Provider>);
229
- /**
230
- * Add a custom provider to this provider manager
231
- *
232
- * @param name Name of the provider
233
- * @param provider Provider implementation
234
- */
235
- addProvider(name: string, provider: Provider): void;
236
- /**
237
- * Find the provider name for a given URL
238
- *
239
- * @param url URL to find the provider for
240
- * @returns The name of the provider, or null if no provider handles this URL
241
- */
242
- providerNameForUrl(url: string): string | null;
243
- /**
244
- * Parse a URL to get package information
245
- *
246
- * @param url URL to parse
247
- * @returns Package information or null if URL can't be parsed
248
- */
249
- parseUrlPkg(url: string): Promise<{
250
- pkg: ExactPackage;
251
- source: {
252
- provider: string;
253
- layer: string;
254
- };
255
- subpath: `./${string}` | null;
256
- } | null>;
257
- /**
258
- * Convert a package to a URL
259
- *
260
- * @param pkg Package to convert
261
- * @param provider Provider name
262
- * @param layer Layer to use
263
- * @returns URL for the package
264
- */
265
- pkgToUrl(pkg: ExactPackage, provider: string, layer?: string): Promise<`${string}/`>;
266
- /**
267
- * Get the package config corresponding to a package URL
268
- *
269
- * @param pkgUrl URL to the package
270
- * @returns
271
- */
272
- getPackageConfig(pkgUrl: string): Promise<PackageConfig | null | undefined>;
273
- /**
274
- * Obtain a file listing of a package boundary if available
275
- */
276
- getFileList(pkgUrl: string): Promise<Set<string> | undefined>;
277
- /**
278
- * Resolve a builtin module
279
- *
280
- * @param specifier Module specifier
281
- * @returns Resolved string, install object, or undefined if not resolvable
282
- */
283
- resolveBuiltin(specifier: string, env: string[]): string | Install | undefined;
284
- resolveLatestTarget(target: PackageTarget, { provider, layer }: PackageProvider, parentUrl: string, resolver: Resolver): Promise<ExactPackage>;
285
- /**
286
- * Get the supported provider strings for all providers
287
- *
288
- * @returns List of provider string identifiers
289
- */
290
- getProviderStrings(): string[];
291
- /**
292
- * Downloads the given package files into the local folder path outDir
293
- * Does not include the import map, which must be merged separately.
294
- */
295
- download(pkg: ExactPackage, providerName: string): Promise<Record<string, ArrayBuffer>>;
296
- /**
297
- * Publish a package using the specified provider.
298
- * A publish operation may be an import map only, files only, or both.
299
- *
300
- * @param pkg Package name, version and registry to publish
301
- * @param providerName Name of the provider to use
302
- * @param files Package files to publish
303
- * @param importMap Optional import map to include with the publish
304
- */
305
- publish(pkg: ExactPackage, providerName: string, imports: string[], files: undefined, importMap: undefined): Promise<PublishOutput>;
306
- publish(pkg: ExactPackage, providerName: string, imports: string[], files: Record<string, string | ArrayBuffer>, importMap: undefined): Promise<PublishOutput>;
307
- publish(pkg: ExactPackage, providerName: string, imports: string[], files: Record<string, string | ArrayBuffer>, importMap: ImportMap): Promise<PublishOutput>;
308
- /**
309
- * Authenticate with a provider to obtain an authentication token
310
- *
311
- * @param providerName Name of the provider to authenticate with
312
- * @param options Authentication options
313
- * @returns Promise resolving to the authentication token
314
- */
315
- auth(providerName: string, options?: {
316
- username?: string;
317
- verify?: (url: string, instructions: string) => void;
318
- }): Promise<{
319
- token: string;
320
- }>;
321
- }
322
- interface PublishOutput {
323
- packageUrl: `${string}/`;
324
- mapUrl: string;
325
- codeSnippet?: string;
326
- }
327
-
328
- interface TraceEntry {
329
- deps: string[];
330
- dynamicDeps: string[];
331
- hasStaticParent: boolean;
332
- size: number;
333
- integrity: string;
334
- wasCjs: boolean;
335
- usesCjs: boolean;
336
- cjsLazyDeps: string[];
337
- format: 'esm' | 'commonjs' | 'system' | 'json' | 'css' | 'typescript' | 'wasm';
338
- parseError: Error;
339
- }
340
- declare class Resolver {
341
- pcfgPromises: Record<string, Promise<void>>;
342
- analysisPromises: Record<string, Promise<void>>;
343
- pcfgs: Record<string, PackageConfig | null>;
344
- fetchOpts: any;
345
- preserveSymlinks: any;
346
- pm: ProviderManager;
347
- traceEntries: Record<string, TraceEntry | null>;
348
- traceEntryPromises: Record<string, Promise<void>>;
349
- env: string[];
350
- cjsEnv: string[];
351
- traceCjs: boolean;
352
- traceTs: boolean;
353
- traceSystem: boolean;
354
- installer: Installer;
355
- constructor({ env, fetchOpts, providerManager, preserveSymlinks, traceCjs, traceTs, traceSystem }: {
356
- env: string[];
357
- fetchOpts?: any;
358
- preserveSymlinks?: boolean;
359
- traceCjs?: boolean;
360
- traceTs?: boolean;
361
- traceSystem: boolean;
362
- providerManager: ProviderManager;
363
- });
364
- resolveBuiltin(specifier: string): string | Install | undefined;
365
- getPackageBase(url: string): Promise<`${string}/`>;
366
- getPackageConfig(pkgUrl: string): Promise<PackageConfig | null>;
367
- getDepList(pkgUrl: string, dev?: boolean): Promise<string[]>;
368
- checkPjson(url: string): Promise<string | false>;
369
- exists(resolvedUrl: string): Promise<boolean>;
370
- wasCommonJS(url: string): Promise<boolean>;
371
- realPath(url: string): Promise<string>;
372
- finalizeResolve(url: string, parentIsCjs: boolean, exportsResolution: boolean, pkgUrl: `${string}/`): Promise<string>;
373
- getExportResolution(pkgUrl: `${string}/`, subpath: '.' | `./${string}`, originalSpecifier: string): Promise<'.' | `./${string}` | null>;
374
- resolveEmpty(cjsEnv: boolean, originalSpecifier: string, parentUrl: string): Promise<string>;
375
- resolveExport(pkgUrl: `${string}/`, subpath: `.${string}`, cjsEnv: boolean, parentIsCjs: boolean, originalSpecifier: string, parentUrl?: string): Promise<string>;
376
- getAnalysis(resolvedUrl: string): TraceEntry | null | undefined;
377
- analyze(resolvedUrl: string): Promise<TraceEntry | null>;
378
- resolvePackageTarget(target: ExportsTarget, packageUrl: string, cjsEnv: boolean, subpath: string, isImport: boolean): string | null;
379
- }
380
-
381
- interface LockResolutions {
382
- primary: {
383
- [pkgName: string]: InstalledResolution;
384
- };
385
- secondary: {
386
- [pkgUrl: `${string}/`]: {
387
- [pkgName: string]: InstalledResolution;
388
- };
389
- };
390
- flattened: {
391
- [scopeUrl: `${string}/`]: {
392
- [pkgName: string]: FlatInstalledResolution[];
393
- };
394
- };
395
- }
396
- interface PackageToTarget {
397
- [pkgName: string]: PackageTarget | URL;
398
- }
399
- interface VersionConstraints {
400
- primary: PackageToTarget;
401
- secondary: {
402
- [pkgUrl: `${string}/`]: PackageToTarget;
403
- };
404
- }
405
- interface InstalledResolution {
406
- installUrl: `${string}/`;
407
- installSubpath: '.' | `./${string}` | null;
408
- }
409
- interface FlatInstalledResolution {
410
- export: `.${string}`;
411
- resolution: InstalledResolution;
412
- }
413
-
414
- interface PackageProvider {
415
- provider: string;
416
- layer: string;
417
- }
418
- /**
419
- * InstallOptions configure the generator's behaviour for existing mappings
420
- * in the import map. An existing mapping is considered "in-range" if either:
421
- * 1. its parent package.json has no "dependencies" range for it
422
- * 2. its semver version is within the parent's range
423
- *
424
- * The "latest-compatible version" of a package is the latest existing version
425
- * within the parent's "dependencies range", or just the latest existing
426
- * version if there is no such range.
427
- *
428
- * "default":
429
- * New installs always resolve to the latest compatible version. Existing
430
- * mappings are kept unless they are out-of-range, in which case they are
431
- * bumped to the latest compatible version.
432
- *
433
- * "latest-primaries":
434
- * Existing primary dependencies (i.e. mappings under "imports") are bumped
435
- * to latest. Existing secondary dependencies are kept unless they are
436
- * out-of-range, in which case they are bumped to the latest compatible
437
- * version. New installs behave according to "default".
438
- *
439
- * "latest-all":
440
- * All existing mappings are bumped to the latest compatible version. New
441
- * installs behave according to "default".
442
- *
443
- * "freeze":
444
- * No existing mappings are changed, and existing mappings are always used
445
- * for new installs wherever possible. Completely new installs behave
446
- * according to "default".
447
- */
448
- type InstallMode = 'default' | 'latest-primaries' | 'latest-all' | 'freeze';
449
- type InstallTarget = {
450
- pkgTarget: PackageTarget | URL;
451
- installSubpath: null | '.' | `./${string}`;
452
- };
453
- interface InstallerOptions {
454
- mapUrl: URL;
455
- baseUrl: URL;
456
- rootUrl?: URL | null;
457
- lock?: LockResolutions;
458
- reset?: boolean;
459
- prune?: boolean;
460
- save?: boolean;
461
- saveDev?: boolean;
462
- savePeer?: boolean;
463
- saveOptional?: boolean;
464
- resolutions?: Record<string, string>;
465
- defaultProvider?: string;
466
- defaultRegistry?: string;
467
- providers?: Record<string, string>;
468
- }
469
- declare class Installer {
470
- opts: InstallerOptions;
471
- installs: LockResolutions;
472
- constraints: VersionConstraints;
473
- newInstalls: boolean;
474
- installBaseUrl: `${string}/`;
475
- hasLock: boolean;
476
- defaultProvider: {
477
- provider: string;
478
- layer: string;
479
- };
480
- defaultRegistry: string;
481
- providers: Record<string, string>;
482
- resolutions: Record<string, string>;
483
- log: Log;
484
- resolver: Resolver;
485
- constructor(baseUrl: `${string}/`, opts: InstallerOptions, log: Log, resolver: Resolver);
486
- visitInstalls(visitor: (scope: Record<string, InstalledResolution>, scopeUrl: string | null) => boolean | void): void;
487
- getProvider(target: PackageTarget): {
488
- provider: string;
489
- layer: string;
490
- };
491
- /**
492
- * Locks a package against the given target.
493
- *
494
- * @param {string} pkgName Name of the package being installed.
495
- * @param {InstallTarget} target The installation target being installed.
496
- * @param {`./${string}` | '.'} traceSubpath
497
- * @param {InstallMode} mode Specifies how to interact with existing installs.
498
- * @param {`${string}/` | null} pkgScope URL of the package scope in which this install is occurring, null if it's a top-level install.
499
- * @param {string} parentUrl URL of the parent for this install.
500
- * @returns {Promise<InstalledResolution>}
501
- */
502
- installTarget(pkgName: string, { pkgTarget, installSubpath }: InstallTarget, traceSubpath: `./${string}` | '.', mode: InstallMode, pkgScope: `${string}/` | null, parentUrl: string): Promise<InstalledResolution>;
503
- /**
504
- * Installs the given package specifier.
505
- *
506
- * @param {string} pkgName The package specifier being installed.
507
- * @param {InstallMode} mode Specifies how to interact with existing installs.
508
- * @param {`${string}/` | null} pkgScope URL of the package scope in which this install is occurring, null if it's a top-level install.
509
- * @param {`./${string}` | '.'} traceSubpath
510
- * @param {string} parentUrl URL of the parent for this install.
511
- * @returns {Promise<string | InstalledResolution>}
512
- */
513
- install(pkgName: string, mode: InstallMode, pkgScope: `${string}/` | null, traceSubpath: `./${string}` | '.', parentUrl?: string): Promise<string | InstalledResolution>;
514
- private get pkgUrls();
515
- private getBestExistingMatch;
516
- private inRange;
517
- private tryUpgradeAllTo;
518
- private upgradeSupportedTo;
519
- }
520
-
521
- /**
522
- * ExportsTarget defines specifier mappings for the public entry points of a
523
- * package, with support for conditionals.
524
- * see https://nodejs.org/dist/latest-v19.x/docs/api/packages.html#exports
525
- */
526
- type ExportsTarget = '.' | `./${string}` | null | {
527
- [condition: string]: ExportsTarget;
528
- } | ExportsTarget[];
529
- /**
530
- * PackageConfig is a parsed version of a package's package.json file.
531
- * see https://nodejs.org/dist/latest-v19.x/docs/api/packages.html
532
- */
533
- interface PackageConfig {
534
- registry?: string;
535
- name?: string;
536
- version?: string;
537
- main?: string;
538
- files?: string[];
539
- module?: string;
540
- browser?: string | Record<string, string | false>;
541
- imports?: Record<string, ExportsTarget>;
542
- exports?: ExportsTarget | Record<string, ExportsTarget>;
543
- type?: string;
544
- dependencies?: Record<string, string>;
545
- peerDependencies?: Record<string, string>;
546
- optionalDependencies?: Record<string, string>;
547
- devDependencies?: Record<string, string>;
548
- }
549
- /**
550
- * ExactPackage pins down an exact version of a package on an external registry,
551
- * such as npm or deno.
552
- */
553
- interface ExactPackage {
554
- name: string;
555
- registry: string;
556
- version: string;
557
- }
558
- /**
559
- * PackageTarget pins down a particular version range of a package on an
560
- * external registry, such as npm or deno.
561
- */
562
- interface PackageTarget {
563
- registry: string;
564
- name: string;
565
- ranges: any[];
566
- unstable: boolean;
567
- }
568
- /**
569
- * LatestPackageTarget pins down the latest version of a package on an external
570
- * registry, such as npm or deno.
571
- */
572
- interface LatestPackageTarget {
573
- registry: string;
574
- name: string;
575
- range: any;
576
- unstable: boolean;
577
- }
578
-
579
- /**
580
- * @interface GeneratorOptions.
581
- */
582
- interface GeneratorOptions {
583
- /**
584
- * The URL to use for resolutions without a parent context.
585
- *
586
- * Defaults to mapUrl or the process base URL.
587
- *
588
- * Also determines the default scoping base for the import map when flattening.
589
- */
590
- baseUrl?: URL | string;
591
- /**
592
- * The URL of the import map itself, used to construct relative import map URLs.
593
- *
594
- * Defaults to the base URL.
595
- *
596
- * The `mapUrl` is used in order to output relative URLs for modules located on the same
597
- * host as the import map.
598
- *
599
- * E.g. for `mapUrl: 'file:///path/to/project/map.importmap'`, installing local file packages
600
- * will be output as relative URLs to their file locations from the map location, since all URLs in an import
601
- * map are relative to the URL of the import map.
602
- */
603
- mapUrl?: URL | string;
604
- /**
605
- * The URL to treat as the root of the serving protocol of the
606
- * import map, used to construct absolute import map URLs.
607
- *
608
- * When set, `rootUrl` takes precendence over `mapUrl` and is used to normalize all import map URLs
609
- * as absolute paths against this URL.
610
- *
611
- * E.g. for `rootUrl: 'file:///path/to/project/public'`, any local module `public/local/mod.js` within the `public` folder
612
- * will be normalized to `/local/mod.js` in the output map.
613
- */
614
- rootUrl?: URL | string | null;
615
- /**
616
- * An authoritative initial import map.
617
- *
618
- * An initial import map to start with - can be from a previous
619
- * install or to provide custom mappings.
620
- */
621
- inputMap?: IImportMap;
622
- /**
623
- * The provider to use for top-level (i.e. root package) installs if there's no context in the inputMap. This can be used to set the provider for a new import map. To use a specific provider for an install, rather than relying on context, register an override using the 'providers' option.
624
- *
625
- * Supports: 'jspm.io' | 'jspm.io#system' | 'nodemodules' | 'skypack' | 'jsdelivr' | 'unpkg' | 'esm.sh';
626
- *
627
- * Providers are responsible for resolution from abstract package names and version ranges to exact URL locations.
628
- *
629
- * Providers resolve package names and semver ranges to exact CDN package URL paths using provider hooks.
630
- *
631
- * These hooks include version resolution and converting package versions into URLs and back again.
632
- *
633
- * See `src/providers/[name].ts` for how to define a custom provider.
634
- *
635
- * New providers can be provided via the `customProviders` option. PRs to merge in providers are welcome as well.
636
- */
637
- defaultProvider?: string;
638
- /**
639
- * The default registry to use when no registry is provided to an install.
640
- * Defaults to 'npm:'.
641
- *
642
- * Registries are separated from providers because multiple providers can serve
643
- * any public registry.
644
- *
645
- * Internally, the default providers for registries are handled by the providers object
646
- */
647
- defaultRegistry?: string;
648
- /**
649
- * The conditional environment resolutions to apply.
650
- *
651
- * The conditions passed to the `env` option are environment conditions, as [supported by Node.js](https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#packages_conditions_definitions) in the package exports field.
652
- *
653
- * By default the `"default"`, `"require"` and `"import"` conditions are always supported regardless of what `env` conditions are provided.
654
- *
655
- * In addition the default conditions applied if no `env` option is set are `"browser"`, `"development"` and `"module"`.
656
- *
657
- * Webpack and RollupJS support a custom `"module"` condition as a bundler-specific solution to the [dual package hazard](https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#packages_dual_package_hazard), which is by default included in the JSPM resolution as well although
658
- * can be turned off if needed.
659
- *
660
- * Note when providing custom conditions like setting `env: ["production"]` that the `"browser"` and `"module"` conditions still need to be
661
- * applied as well via `env: ["production", "browser", "module"]`. Ordering does not matter though.
662
- *
663
- * Any other custom condition strings can also be provided.
664
- */
665
- env?: string[];
666
- /**
667
- * Whether to use a local FS cache for fetched modules. Set to 'offline' to use the offline cache.
668
- *
669
- * By default a global fetch cache is maintained between runs on the file system.
670
- *
671
- * This caching can be disabled by setting `cache: false`.
672
- *
673
- * When running offline, setting `cache: 'offline'` will only use the local cache and not touch the network at all,
674
- * making fully offline workflows possible provided the modules have been seen before.
675
- */
676
- cache?: 'offline' | boolean;
677
- /**
678
- * User-provided fetch options for fetching modules, eg check https://github.com/npm/make-fetch-happen#extra-options for Node.js fetch
679
- */
680
- fetchOptions?: Record<string, any>;
681
- /**
682
- * Custom provider definitions.
683
- *
684
- * When installing from a custom CDN it can be advisable to define a custom provider in order to be able to get version deduping against that CDN.
685
- *
686
- * Custom provider definitions define a provider name, and the provider instance consisting of three main hooks:
687
- *
688
- * * `pkgToUrl({ registry: string, name: string, version: string }, layer: string) -> String URL`: Returns the URL for a given exact package registry, name and version to use for this provider. If the provider is using layers, the `layer` string can be used to determine the URL layer (where the `defaultProvider: '[name].[layer]'` form is used to determine the layer, eg minified v unminified etc). It is important that package URLs always end in `/`, because packages must be treated as folders not files. An error will be thrown for package URLs returned not ending in `/`.
689
- * * `parsePkgUrl(url: string) -> { { registry: string, name: string, version: string }, layer: string } | undefined`: Defines the converse operation to `pkgToUrl`, converting back from a string URL
690
- * into the exact package registry, name and version, as well as the layer. Should always return `undefined` for unknown URLs as the first matching provider is treated as authoritative when dealing with
691
- * multi-provider installations.
692
- * * `resolveLatestTarget(target: { registry: string, name: string, range: SemverRange }, unstable: boolean, layer: string, parentUrl: string) -> Promise<{ registry: string, name: string, version: string } | null>`: Resolve the latest version to use for a given package target. `unstable` indicates that prerelease versions can be matched. The definition of `SemverRange` is as per the [sver package](https://www.npmjs.com/package/sver#semverrange). Returning `null` corresponds to a package not found error.
693
- *
694
- * The use of `pkgToUrl` and `parsePkgUrl` is what allows the JSPM Generator to dedupe package versions internally based on their unique internal identifier `[registry]:[name]@[version]` regardless of what CDN location is used. URLs that do not support `parsePkgUrl` can still be installed and used fine, they just do not participate in version deduping operations.
695
- *
696
- * @example
697
- * ```js
698
- * const unpkgUrl = 'https://unpkg.com/';
699
- * const exactPkgRegEx = /^((?:@[^/\\%@]+\/)?[^./\\%@][^/\\%@]*)@([^\/]+)(\/.*)?$/;
700
- *
701
- * const generator = new Generator({
702
- * defaultProvider: 'custom',
703
- * customProviders: {
704
- * custom: {
705
- * pkgToUrl ({ registry, name, version }) {
706
- * return `${unpkgUrl}${name}@${version}/`;
707
- * },
708
- * parseUrlPkg (url) {
709
- * if (url.startsWith(unpkgUrl)) {
710
- * const [, name, version] = url.slice(unpkgUrl.length).match(exactPkgRegEx) || [];
711
- * return { registry: 'npm', name, version };
712
- * }
713
- * },
714
- * resolveLatestTarget ({ registry, name, range }, unstable, layer, parentUrl) {
715
- * return { registry, name, version: '3.6.0' };
716
- * }
717
- * }
718
- * }
719
- * });
720
- *
721
- * await generator.install('custom:jquery');
722
- * ```
723
- */
724
- customProviders?: Record<string, Provider>;
725
- /**
726
- * A map of custom scoped providers.
727
- *
728
- * The provider map allows setting custom providers for specific package names, package scopes or registries.
729
- *
730
- * @example
731
- * For example, an organization with private packages with names like `npmpackage` and `@orgscope/...` can define the custom providers to reference these from a custom source:
732
- *
733
- * ```js
734
- * providers: {
735
- * 'npmpackage': 'nodemodules',
736
- * '@orgscope': 'nodemodules',
737
- * 'npm:': 'nodemodules'
738
- * }
739
- * ```
740
- *
741
- * Alternatively a custom provider can be referenced this way for eg private CDN / registry support.
742
- */
743
- providers?: Record<string, string>;
744
- /**
745
- * Custom dependency resolution overrides for all installs.
746
- *
747
- * The resolutions option allows configuring a specific dependency version to always be used overriding all version resolution
748
- * logic for that dependency for all nestings.
749
- *
750
- * It is a map from package name to package version target just like the package.json "dependencies" map, but that applies and overrides universally.
751
- *
752
- * @example
753
- * ```js
754
- * const generator = new Generator({
755
- * resolutions: {
756
- * dep: '1.2.3'
757
- * }
758
- * });
759
- * ```
760
- *
761
- * It is also useful for local monorepo patterns where all local packages should be located locally.
762
- * When referencing local paths, the baseUrl configuration option is used as the URL parent.
763
- *
764
- * ```js
765
- * const generator = new Generator({
766
- * mapUrl: new URL('./app.html', import.meta.url),
767
- * baseUrl: new URL('../', import.meta.url),
768
- * resolutions: {
769
- * '@company/pkgA': `./pkgA`,
770
- * '@company/pkgB': `./pkgB`
771
- * '@company/pkgC': `./pkgC`
772
- * }
773
- * })
774
- * ```
775
- *
776
- * All subpath and main resolution logic will follow the package.json definitions of the resolved package, unlike `inputMap`
777
- * which only maps specific specifiers.
778
- */
779
- resolutions?: Record<string, string>;
780
- /**
781
- * Allows ignoring certain module specifiers during the tracing process.
782
- * It can be useful, for example, when you provide an `inputMap`
783
- * that contains a mapping that can't be traced in current context,
784
- * but you know it will work in the context where the generated map
785
- * is going to be used.
786
- * ```js
787
- * const generator = new Generator({
788
- * inputMap: {
789
- * imports: {
790
- * "react": "./my/own/react.js",
791
- * }
792
- * },
793
- * ignore: ["react"]
794
- * });
795
- *
796
- * // Even though `@react-three/fiber@7` depends upon `react`,
797
- * // `generator` will not try to trace and resolve `react`,
798
- * // so the mapping provided in `inputMap` will end up in the resulting import map.
799
- * await generator.install("@react-three/fiber@7")
800
- * ```
801
- */
802
- ignore?: string[];
803
- /**
804
- * Lockfile data to use for resolutions
805
- */
806
- lock?: LockResolutions;
807
- /**
808
- * Support tracing CommonJS dependencies locally. This is necessary if you
809
- * are using the "nodemodules" provider and have CommonJS dependencies.
810
- * Disabled by default.
811
- */
812
- commonJS?: boolean;
813
- /**
814
- * Support tracing TypeScript dependencies when generating the import map.
815
- * Disabled by default.
816
- */
817
- typeScript?: boolean;
818
- /**
819
- * Support tracing SystemJS dependencies when generating the import map.
820
- * Disabled by default.
821
- */
822
- system?: boolean;
823
- /**
824
- * Whether to include "integrity" field in the import map
825
- */
826
- integrity?: boolean;
827
- /**
828
- * The number of fetch retries to attempt for request failures.
829
- * Defaults to 3.
830
- */
831
- fetchRetries?: number;
832
- /**
833
- * The same as the Node.js `--preserve-symlinks` flag, except it will apply
834
- * to both the main and the dependencies.
835
- * See https://nodejs.org/api/cli.html#--preserve-symlinks.
836
- * This is only supported for file: URLs.
837
- * Defaults to false, like Node.js.
838
- */
839
- preserveSymlinks?: boolean;
840
- /**
841
- * Provider configuration options
842
- *
843
- * @example
844
- * ```js
845
- * const generator = new Generator({
846
- * mapUrl: import.meta.url,
847
- * defaultProvider: "jspm.io",
848
- * providerConfig: {
849
- * "jspm.io": {
850
- * cdnUrl: `https://jspm-mirror.com/`
851
- * }
852
- * }
853
- */
854
- providerConfig?: {
855
- [providerName: string]: any;
856
- };
857
- /**
858
- * Custom async resolver function for intercepting resolution operations.
859
- *
860
- * When provided, this function will be called first for all resolution operations.
861
- * If it returns a string URL, that will be used as the resolved module and persisted
862
- * in the import map. If it returns undefined, normal resolution continues.
863
- *
864
- * @param specifier The module specifier being resolved
865
- * @param parentUrl The URL of the parent module
866
- * @param context Additional context including environment and other metadata
867
- * @returns A resolved URL string or undefined to continue with default resolution
868
- *
869
- * @example
870
- * ```js
871
- * const generator = new Generator({
872
- * customResolver: async (specifier, parentUrl, context) => {
873
- * if (specifier === 'my-custom-lib') {
874
- * return 'https://cdn.example.com/my-custom-lib@1.0.0/index.js';
875
- * }
876
- * return undefined;
877
- * }
878
- * });
879
- * ```
880
- */
881
- customResolver?: (specifier: string, parentUrl: string, context: {
882
- parentPkgUrl: string;
883
- env?: string[];
884
- installMode: any;
885
- toplevel: boolean;
886
- [key: string]: any;
887
- }) => string | undefined | Promise<string | undefined>;
888
- /**
889
- * @default true
890
- *
891
- * Whether to flatten import map scopes into domain-groupings.
892
- * This is a lossy process, removing scoped dependencies.
893
- * By default this is done to create a smaller import map output
894
- * size. Set to false to retain dependency scoping information.
895
- *
896
- */
897
- flattenScopes?: boolean;
898
- /**
899
- * @default true
900
- *
901
- * Whether to combine subpaths in the final import map.
902
- * By default, when possible, the generator will at output time
903
- * combine similar subpaths in an imports map like:
904
- *
905
- * @example
906
- * ```json
907
- * {
908
- * "imports": {
909
- * "a/b.js": "./pkg/b.js",
910
- * "a/c.js": "./pkg/c.js"
911
- * }
912
- * }
913
- * ```
914
- *
915
- * Into a single folder mapping:
916
- *
917
- * ```json
918
- * {
919
- * "imports": {
920
- * "a/": "./pkg/"
921
- * }
922
- * }
923
- * ```
924
- *
925
- * Resulting in a smaller import map size. This process is done
926
- * carefully to never break any existing mappings, but is a lossy
927
- * import map compression as well.
928
- *
929
- * Set this option to false to disable this default behaviour and
930
- * retain individual mappings.
931
- */
932
- combineSubpaths?: boolean;
933
- }
934
- interface Install {
935
- target: string | InstallTarget;
936
- alias?: string;
937
- subpath?: '.' | `./${string}`;
938
- subpaths?: ('.' | `./${string}`)[] | true;
16
+ filepath?: string;
939
17
  }
940
18
 
941
19
  interface ImportMapPluginOptions extends GeneratorOptions {
@@ -1093,6 +171,11 @@ interface OptionsConfig extends CommonPluginOptions, AppPluginOptions, LibPlugin
1093
171
  * @default auto-detect based on the dependencies
1094
172
  */
1095
173
  vue?: boolean | OptionsVue;
174
+ /**
175
+ * Vite configuration override
176
+ *
177
+ * @default {}
178
+ */
1096
179
  vite?: UserConfig;
1097
180
  }
1098
181
  interface ConditionPlugin {