zyzz 0.0.26 → 0.0.28
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/compiler/Source.d.ts.map +1 -1
- package/dist/compiler/Source.js +165 -11
- package/dist/compiler/Source.js.map +1 -1
- package/dist/compiler/Transform.d.ts.map +1 -1
- package/dist/compiler/Transform.js +3 -0
- package/dist/compiler/Transform.js.map +1 -1
- package/dist/compiler/internal/Applications.d.ts.map +1 -1
- package/dist/compiler/internal/Applications.js +42 -1
- package/dist/compiler/internal/Applications.js.map +1 -1
- package/dist/compiler/internal/Selectors.d.ts +3 -2
- package/dist/compiler/internal/Selectors.d.ts.map +1 -1
- package/dist/compiler/internal/Selectors.js +23 -11
- package/dist/compiler/internal/Selectors.js.map +1 -1
- package/dist/internal/Authoring.d.ts.map +1 -1
- package/dist/internal/Authoring.js +37 -7
- package/dist/internal/Authoring.js.map +1 -1
- package/dist/internal/Configuration.d.ts +6 -1
- package/dist/internal/Configuration.d.ts.map +1 -1
- package/dist/internal/Configuration.js.map +1 -1
- package/dist/internal/Literal.d.ts +1 -1
- package/dist/internal/Literal.d.ts.map +1 -1
- package/dist/internal/Literal.js +3 -0
- package/dist/internal/Literal.js.map +1 -1
- package/dist/internal/Theme.d.ts +4 -0
- package/dist/internal/Theme.d.ts.map +1 -1
- package/dist/internal/Theme.js.map +1 -1
- package/dist/styleFunction.d.ts +11 -2
- package/dist/styleFunction.d.ts.map +1 -1
- package/dist/styleFunction.js +3 -1
- package/dist/styleFunction.js.map +1 -1
- package/dist/vite/index.d.ts +7 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +173 -22
- package/dist/vite/index.js.map +1 -1
- package/dist/web/internal/Themes.d.ts.map +1 -1
- package/dist/web/internal/Themes.js +38 -2
- package/dist/web/internal/Themes.js.map +1 -1
- package/package.json +13 -1
- package/src/compiler/Source.ts +237 -13
- package/src/compiler/Transform.ts +4 -1
- package/src/compiler/internal/Applications.ts +57 -1
- package/src/compiler/internal/Selectors.ts +25 -11
- package/src/internal/Authoring.ts +53 -18
- package/src/internal/Configuration.ts +38 -1
- package/src/internal/Literal.ts +3 -0
- package/src/internal/Theme.ts +15 -0
- package/src/styleFunction.ts +31 -2
- package/src/vite/index.ts +242 -27
- package/src/web/internal/Themes.ts +47 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleFunction.d.ts","sourceRoot":"","sources":["../src/styleFunction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,OAAO,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,KAAK,UAAU,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,KAAK,OAAO,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AAExC,KAAK,IAAI,CAAC,KAAK,IAAI,KAAK,SAAS,OAAO,GAAG,MAAM,KAAK,GAAG,KAAK,CAAA;AAG9D,KAAK,gBAAgB,CAAC,UAAU,SAAS,MAAM,IAAI;IACjD,QAAQ,EAAE,QAAQ,IAAI,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAChE,CAAA;AAED,KAAK,eAAe,CAAC,KAAK,IAAI,KAAK,SAAS;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,SAAS,CAAA;CAC/B,GACG;IACE,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,EAAE,GAAG,IAAI,MAAM,SAAS,GAAG,MAAM,SAAS,GAAG,GACjD,SAAS,CAAC,GAAG,CAAC,GACd,GAAG,SAAS,KAAK,MAAM,EAAE,GACvB,SAAS,CAAC,GAAG,CAAC,GACd,KAAK;KACZ,CAAA;CACF,GACD,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"styleFunction.d.ts","sourceRoot":"","sources":["../src/styleFunction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,OAAO,MAAM,uBAAuB,CAA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G,OAAO,CAAC,MAAM,CAAC,EACvD,OAAO,CAAC,EAAE,OAAO,GACf,eAAe,CAAC,OAAO,CAAC,GACxB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,EAAE,KAAK,CAAC,KACnD,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;CACtB;AAED,wDAAwD;AACxD,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,qEAAqE;IACrE,cAIC;IACD,yCAAyC;IAChC,IAAI,SAAgC;CAC9C"}
|
package/dist/styleFunction.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import * as Authoring from './internal/Authoring.js';
|
|
6
|
-
export function style(styles, options = {}
|
|
6
|
+
export function style(styles, options = {},
|
|
7
|
+
// Matches the arity-gated overloads, whose invalid branches add parameters.
|
|
8
|
+
..._) {
|
|
7
9
|
return Authoring.create(styles, options);
|
|
8
10
|
}
|
|
9
11
|
/** Executed authoring source has not been rewritten. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleFunction.js","sourceRoot":"","sources":["../src/styleFunction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"styleFunction.js","sourceRoot":"","sources":["../src/styleFunction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAA;AAiFpD,MAAM,UAAU,KAAK,CACnB,MAAgB,EAChB,OAAO,GAA4B,EAAE;AACrC,4EAA4E;AAC5E,GAAG,CAAmB;IAEtB,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC1C,CAAC;AAiED,wDAAwD;AACxD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,qEAAqE;IACrE;QACE,KAAK,CACH,yIAAyI,CAC1I,CAAA;IACH,CAAC;IACD,yCAAyC;IAChC,IAAI,GAAG,6BAA6B,CAAA;CAC9C"}
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ export declare namespace zyzz {
|
|
|
12
12
|
type Options = {
|
|
13
13
|
/** False retains authored calls and requires explicit identities where needed. */
|
|
14
14
|
readonly compiler?: boolean | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Source modules left out of discovery and transforms. Globs resolve against the
|
|
17
|
+
* Vite root unless they start with `**`, and regular expressions test absolute paths.
|
|
18
|
+
* Imports of excluded modules stay runtime imports. Vite and Vitest configuration
|
|
19
|
+
* modules are always excluded.
|
|
20
|
+
*/
|
|
21
|
+
readonly exclude?: readonly (RegExp | string)[] | undefined;
|
|
15
22
|
/** Additional source directories, absolute or relative to the Vite root. */
|
|
16
23
|
readonly include?: readonly string[] | undefined;
|
|
17
24
|
/** Native context captured at creation. Disables CSS delivery and initialization scripts. */
|
package/dist/vite/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAGV,MAAM,EAIP,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAA;AAI7C;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,IAAI,CAAC,OAAY,GAAG,MAAM,CA6sDvD;AAwGD,sCAAsC;AACtC,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,kFAAkF;IAClF,KAAK,OAAO,GAAG;QACb,kFAAkF;QAClF,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QACvC;;;;;WAKG;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAAA;QAC3D,4EAA4E;QAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;QAChD,6FAA6F;QAC7F,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACjD,gDAAgD;QAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QACpC;;;WAGG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;KACtC,CAAA;CACF"}
|
package/dist/vite/index.js
CHANGED
|
@@ -9,10 +9,11 @@ import * as Contracts from '../node/internal/Contracts.js';
|
|
|
9
9
|
import * as Mapping from '@jridgewell/gen-mapping';
|
|
10
10
|
import * as Lightning from 'lightningcss';
|
|
11
11
|
import * as Crypto from 'node:crypto';
|
|
12
|
+
import { existsSync } from 'node:fs';
|
|
12
13
|
import * as Fs from 'node:fs/promises';
|
|
13
14
|
import * as Path from 'node:path';
|
|
14
15
|
import * as Reset from '../node/Reset.js';
|
|
15
|
-
import { isBuiltin } from 'node:module';
|
|
16
|
+
import { createRequire, isBuiltin } from 'node:module';
|
|
16
17
|
import * as Parser from 'oxc-parser';
|
|
17
18
|
import * as Walker from 'oxc-walker';
|
|
18
19
|
import * as Snapshot from '../node/internal/Snapshot.js';
|
|
@@ -43,6 +44,7 @@ export function zyzz(options = {}) {
|
|
|
43
44
|
const states = new WeakMap();
|
|
44
45
|
const removed = new WeakMap();
|
|
45
46
|
const reads = new WeakMap();
|
|
47
|
+
const lookups = new WeakMap();
|
|
46
48
|
const compilers = new WeakMap();
|
|
47
49
|
const packages = Contracts.create();
|
|
48
50
|
function compiler(environment) {
|
|
@@ -62,8 +64,11 @@ export function zyzz(options = {}) {
|
|
|
62
64
|
const initializers = new WeakMap();
|
|
63
65
|
const sourceEntrypoints = new Set();
|
|
64
66
|
const identities = new Map();
|
|
67
|
+
const exclusions = new Map();
|
|
65
68
|
const lazyImports = new WeakMap();
|
|
66
69
|
let directories;
|
|
70
|
+
let filter;
|
|
71
|
+
let optimizeRuntime = false;
|
|
67
72
|
let root;
|
|
68
73
|
function snapshot(environment) {
|
|
69
74
|
let value = snapshots.get(environment);
|
|
@@ -125,7 +130,20 @@ export function zyzz(options = {}) {
|
|
|
125
130
|
return (Path.isAbsolute(id) &&
|
|
126
131
|
sourceRoot(id) !== undefined &&
|
|
127
132
|
/\.[cm]?[jt]sx?$/.test(id) &&
|
|
128
|
-
!/\.(?:d|test|test-d|bench|bench-d)\.[cm]?[jt]sx?$/.test(id)
|
|
133
|
+
!/\.(?:d|test|test-d|bench|bench-d)\.[cm]?[jt]sx?$/.test(id) &&
|
|
134
|
+
!excluded(id));
|
|
135
|
+
}
|
|
136
|
+
/** Matches excluded files inside source directories. Package files never match, so packed contracts stay readable. */
|
|
137
|
+
function excluded(id) {
|
|
138
|
+
const file = id.split(/[?#]/)[0];
|
|
139
|
+
let value = exclusions.get(file);
|
|
140
|
+
// Vite's filter recompiles each glob per call, and every compile checks each import.
|
|
141
|
+
if (value === undefined) {
|
|
142
|
+
value =
|
|
143
|
+
Path.isAbsolute(file) && sourceRoot(file) !== undefined && !filter(file);
|
|
144
|
+
exclusions.set(file, value);
|
|
145
|
+
}
|
|
146
|
+
return value;
|
|
129
147
|
}
|
|
130
148
|
function sourceRoot(file) {
|
|
131
149
|
return directories.find((directory) => {
|
|
@@ -275,6 +293,7 @@ export function zyzz(options = {}) {
|
|
|
275
293
|
}
|
|
276
294
|
async function updateDiscovery(environment, file, event) {
|
|
277
295
|
reads.delete(environment);
|
|
296
|
+
lookups.delete(environment);
|
|
278
297
|
if (event === 'delete') {
|
|
279
298
|
if (entries(environment).has(file)) {
|
|
280
299
|
let files = removed.get(environment);
|
|
@@ -304,10 +323,30 @@ export function zyzz(options = {}) {
|
|
|
304
323
|
}
|
|
305
324
|
}
|
|
306
325
|
async function compile(entry, host, code, allSources = false, everything = false) {
|
|
326
|
+
// Every compile visits the discovered project, so modules share lookups
|
|
327
|
+
// until the watcher reports a change. Full-project compiles look up afresh.
|
|
328
|
+
const cache = (() => {
|
|
329
|
+
const fresh = { contracts: new Map(), resolutions: new Map() };
|
|
330
|
+
if (everything)
|
|
331
|
+
return fresh;
|
|
332
|
+
let value = lookups.get(entry.environment);
|
|
333
|
+
if (!value) {
|
|
334
|
+
value = fresh;
|
|
335
|
+
lookups.set(entry.environment, value);
|
|
336
|
+
}
|
|
337
|
+
return value;
|
|
338
|
+
})();
|
|
307
339
|
async function resolve(source, importer) {
|
|
308
340
|
if (isBuiltin(source))
|
|
309
341
|
return { id: source, external: true };
|
|
310
|
-
const
|
|
342
|
+
const key = `${importer}\0${source}`;
|
|
343
|
+
let pending = cache.resolutions.get(key);
|
|
344
|
+
if (!pending) {
|
|
345
|
+
pending = host.resolve(source, importer);
|
|
346
|
+
cache.resolutions.set(key, pending);
|
|
347
|
+
pending.catch(() => cache.resolutions.delete(key));
|
|
348
|
+
}
|
|
349
|
+
const resolved = await pending;
|
|
311
350
|
if (!resolved)
|
|
312
351
|
return resolved;
|
|
313
352
|
if (entry.environment.mode === 'dev') {
|
|
@@ -325,15 +364,36 @@ export function zyzz(options = {}) {
|
|
|
325
364
|
const lazy = Object.create(null);
|
|
326
365
|
const modules = Object.create(null);
|
|
327
366
|
const files = new Set();
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
367
|
+
// A package contract derives from the files it reads and the resolutions
|
|
368
|
+
// above. A cached contract still makes this compile watch those files.
|
|
369
|
+
async function readContract(file, required = false) {
|
|
370
|
+
const key = `${required}\0${file}`;
|
|
371
|
+
let pending = cache.contracts.get(key);
|
|
372
|
+
if (!pending) {
|
|
373
|
+
const read = new Set();
|
|
374
|
+
pending = packages
|
|
375
|
+
.read(file, {
|
|
376
|
+
read: async (path) => {
|
|
377
|
+
const source = await snapshot(entry.environment).read(path);
|
|
378
|
+
read.add(path);
|
|
379
|
+
return source;
|
|
380
|
+
},
|
|
381
|
+
required,
|
|
382
|
+
resolve: async (specifier, importer) => (await resolve(specifier, importer))?.id.split(/[?#]/)[0],
|
|
383
|
+
})
|
|
384
|
+
.then((contract) => ({ contract, files: read }));
|
|
385
|
+
cache.contracts.set(key, pending);
|
|
386
|
+
pending.catch(() => cache.contracts.delete(key));
|
|
387
|
+
}
|
|
388
|
+
const derived = await pending;
|
|
389
|
+
for (const path of derived.files) {
|
|
390
|
+
if (files.has(path))
|
|
391
|
+
continue;
|
|
392
|
+
files.add(path);
|
|
393
|
+
host.watch(path);
|
|
394
|
+
}
|
|
395
|
+
return derived.contract;
|
|
396
|
+
}
|
|
337
397
|
async function visit(file, source) {
|
|
338
398
|
if (files.has(file))
|
|
339
399
|
return;
|
|
@@ -404,10 +464,15 @@ export function zyzz(options = {}) {
|
|
|
404
464
|
await visit(resolved.id);
|
|
405
465
|
continue;
|
|
406
466
|
}
|
|
467
|
+
// An excluded source stays a runtime import instead of deriving a package contract.
|
|
468
|
+
if (excluded(resolved.id)) {
|
|
469
|
+
resolutions[specifier] = null;
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
407
472
|
if (resolved.external || !eligible(resolved.id)) {
|
|
408
473
|
const physical = resolved.id.split('?')[0].split('#')[0];
|
|
409
474
|
const contract = Path.isAbsolute(physical) && /\.[cm]?[jt]sx?$/.test(physical)
|
|
410
|
-
? await
|
|
475
|
+
? await readContract(physical)
|
|
411
476
|
: undefined;
|
|
412
477
|
if (contract !== undefined) {
|
|
413
478
|
contracts[resolved.id] = contract;
|
|
@@ -495,14 +560,16 @@ export function zyzz(options = {}) {
|
|
|
495
560
|
(specifier.startsWith('zyzz/') && specifier !== 'zyzz/default'))
|
|
496
561
|
continue;
|
|
497
562
|
const resolved = await resolve(specifier, file);
|
|
498
|
-
if (!resolved ||
|
|
563
|
+
if (!resolved ||
|
|
564
|
+
(!resolved.external && eligible(resolved.id)) ||
|
|
565
|
+
excluded(resolved.id))
|
|
499
566
|
continue;
|
|
500
567
|
if (resource(specifier) || resource(resolved.id))
|
|
501
568
|
continue;
|
|
502
569
|
const physical = resolved.id.split(/[?#]/)[0];
|
|
503
570
|
if (!Path.isAbsolute(physical) || !/\.[cm]?[jt]sx?$/.test(physical))
|
|
504
571
|
continue;
|
|
505
|
-
const contract = await
|
|
572
|
+
const contract = await readContract(physical);
|
|
506
573
|
if (contract === undefined)
|
|
507
574
|
continue;
|
|
508
575
|
contracts[resolved.id] = contract;
|
|
@@ -551,7 +618,7 @@ export function zyzz(options = {}) {
|
|
|
551
618
|
throw new Error('Unable to resolve packed stylesheet dependency.');
|
|
552
619
|
imports[owner] ??= Object.create(null);
|
|
553
620
|
imports[owner][specifier] = target.id;
|
|
554
|
-
contracts[target.id] ??= (await
|
|
621
|
+
contracts[target.id] ??= (await readContract(target.id.split(/[?#]/)[0], true));
|
|
555
622
|
await dependencies(target.id);
|
|
556
623
|
owner = target.id;
|
|
557
624
|
}
|
|
@@ -771,9 +838,10 @@ export function zyzz(options = {}) {
|
|
|
771
838
|
async function initializations(server) {
|
|
772
839
|
const environment = server.environments.client;
|
|
773
840
|
reads.delete(environment);
|
|
841
|
+
lookups.delete(environment);
|
|
774
842
|
const host = {
|
|
775
843
|
asset: async (file) => file,
|
|
776
|
-
resolve: (
|
|
844
|
+
resolve: resolver(environment),
|
|
777
845
|
watch: (file) => server.watcher.add(file),
|
|
778
846
|
};
|
|
779
847
|
const sources = await discover(environment, host);
|
|
@@ -911,10 +979,16 @@ export function zyzz(options = {}) {
|
|
|
911
979
|
return {
|
|
912
980
|
buildStart() {
|
|
913
981
|
reads.delete(this.environment);
|
|
982
|
+
lookups.delete(this.environment);
|
|
914
983
|
},
|
|
915
984
|
config: {
|
|
916
985
|
order: 'post',
|
|
917
|
-
handler(config) {
|
|
986
|
+
handler(config, env) {
|
|
987
|
+
// Ordered after other config hooks, so plugin-provided aliases are visible.
|
|
988
|
+
optimizeRuntime =
|
|
989
|
+
env.command === 'serve' &&
|
|
990
|
+
options.compiler !== false &&
|
|
991
|
+
installed(config);
|
|
918
992
|
if (native)
|
|
919
993
|
return;
|
|
920
994
|
// Inline color-scheme changes cannot initialize Lightning's lowered helpers.
|
|
@@ -943,6 +1017,28 @@ export function zyzz(options = {}) {
|
|
|
943
1017
|
};
|
|
944
1018
|
},
|
|
945
1019
|
},
|
|
1020
|
+
configEnvironment: {
|
|
1021
|
+
// Plugins without enforce settle their environment options first.
|
|
1022
|
+
order: 'post',
|
|
1023
|
+
handler(name, config) {
|
|
1024
|
+
if (!optimizeRuntime)
|
|
1025
|
+
return;
|
|
1026
|
+
const optimizeDeps = config.optimizeDeps ?? {};
|
|
1027
|
+
const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');
|
|
1028
|
+
// Vite defaults server environments to noDiscovery. An include list there
|
|
1029
|
+
// would create an explicit optimizer that otherwise never exists.
|
|
1030
|
+
if (optimizeDeps.noDiscovery ?? consumer === 'server')
|
|
1031
|
+
return;
|
|
1032
|
+
if (optimizeDeps.include?.includes(runtime) ||
|
|
1033
|
+
optimizeDeps.exclude?.some((id) => id === 'zyzz' || id === runtime))
|
|
1034
|
+
return;
|
|
1035
|
+
// Vite scans authored source, so the runtime import that compilation
|
|
1036
|
+
// adds first appears while a request transforms a module. Discovering
|
|
1037
|
+
// it then re-runs the optimizer, and modules loaded before the re-run
|
|
1038
|
+
// can keep a separate copy of a shared dependency such as React.
|
|
1039
|
+
return { optimizeDeps: { include: [runtime] } };
|
|
1040
|
+
},
|
|
1041
|
+
},
|
|
946
1042
|
configureServer(server) {
|
|
947
1043
|
// Directory watches belong to the server, not module import dependencies.
|
|
948
1044
|
server.watcher.add(directories.slice(1));
|
|
@@ -971,6 +1067,11 @@ export function zyzz(options = {}) {
|
|
|
971
1067
|
return file;
|
|
972
1068
|
}))),
|
|
973
1069
|
];
|
|
1070
|
+
// Portable build adapters share this module and do not require Vite.
|
|
1071
|
+
const { createFilter } = await import('vite');
|
|
1072
|
+
const patterns = [...configFiles, ...(options.exclude ?? [])];
|
|
1073
|
+
filter = createFilter(null, patterns, { resolve: root });
|
|
1074
|
+
exclusions.clear();
|
|
974
1075
|
if (native)
|
|
975
1076
|
return;
|
|
976
1077
|
const lightning = (config.css.lightningcss ??= {});
|
|
@@ -1049,7 +1150,7 @@ export function zyzz(options = {}) {
|
|
|
1049
1150
|
// Failed edits retain normal invalidation so Vite reports errors on reload.
|
|
1050
1151
|
const output = first && type === 'update' && eligible(file)
|
|
1051
1152
|
? await compile(first, {
|
|
1052
|
-
resolve: (
|
|
1153
|
+
resolve: resolver(this.environment),
|
|
1053
1154
|
watch: (file) => {
|
|
1054
1155
|
server.watcher.add(file);
|
|
1055
1156
|
},
|
|
@@ -1122,7 +1223,9 @@ export function zyzz(options = {}) {
|
|
|
1122
1223
|
if (!entry)
|
|
1123
1224
|
throw new Error(`Unknown Zyzz stylesheet: ${file}`);
|
|
1124
1225
|
const output = await compile(entry, {
|
|
1125
|
-
resolve:
|
|
1226
|
+
resolve: this.environment.mode === 'dev'
|
|
1227
|
+
? resolver(this.environment)
|
|
1228
|
+
: (source, importer) => this.resolve(source, importer),
|
|
1126
1229
|
watch: (file) => this.addWatchFile(file),
|
|
1127
1230
|
asset: async (file) => {
|
|
1128
1231
|
const reference = this.emitFile({
|
|
@@ -1166,7 +1269,9 @@ export function zyzz(options = {}) {
|
|
|
1166
1269
|
removed.get(this.environment)?.delete(id);
|
|
1167
1270
|
}
|
|
1168
1271
|
const output = await compile(entry, {
|
|
1169
|
-
resolve:
|
|
1272
|
+
resolve: this.environment.mode === 'dev'
|
|
1273
|
+
? resolver(this.environment)
|
|
1274
|
+
: (source, importer) => this.resolve(source, importer),
|
|
1170
1275
|
watch: (file) => this.addWatchFile(file),
|
|
1171
1276
|
asset: async (file) => {
|
|
1172
1277
|
const reference = this.emitFile({
|
|
@@ -1246,7 +1351,7 @@ export function zyzz(options = {}) {
|
|
|
1246
1351
|
return entryCatalogs(context.bundle, context.chunk);
|
|
1247
1352
|
const state = await initializations(context.server);
|
|
1248
1353
|
const environment = context.server.environments.client;
|
|
1249
|
-
return await documentCatalogs(html, context.filename, (
|
|
1354
|
+
return await documentCatalogs(html, context.filename, resolver(environment), state);
|
|
1250
1355
|
})();
|
|
1251
1356
|
// Saved preferences apply before any other script or visible content.
|
|
1252
1357
|
return Catalogs.scripts(configurations).map((children) => ({
|
|
@@ -1258,7 +1363,53 @@ export function zyzz(options = {}) {
|
|
|
1258
1363
|
},
|
|
1259
1364
|
};
|
|
1260
1365
|
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Whether `zyzz/runtime` resolves inside node_modules from the Vite root. Vite
|
|
1368
|
+
* optimizes a discovered import only there, so linked and aliased copies stay
|
|
1369
|
+
* source modules beside the other entrypoints.
|
|
1370
|
+
*/
|
|
1371
|
+
function installed(config) {
|
|
1372
|
+
const aliases = config.resolve?.alias ?? {};
|
|
1373
|
+
const entries = Array.isArray(aliases)
|
|
1374
|
+
? aliases
|
|
1375
|
+
: Object.entries(aliases).map(([find, replacement]) => ({
|
|
1376
|
+
find,
|
|
1377
|
+
replacement,
|
|
1378
|
+
}));
|
|
1379
|
+
// Matches Vite's alias semantics: a string entry covers its subpaths.
|
|
1380
|
+
if (entries.some((entry) => typeof entry.find === 'string'
|
|
1381
|
+
? runtime === entry.find || runtime.startsWith(`${entry.find}/`)
|
|
1382
|
+
: entry.find.test(runtime)))
|
|
1383
|
+
return false;
|
|
1384
|
+
try {
|
|
1385
|
+
const require = createRequire(Path.join(Path.resolve(config.root ?? ''), 'package.json'));
|
|
1386
|
+
// Vite keeps a symlinked package at its node_modules path, which Node dereferences.
|
|
1387
|
+
if (config.resolve?.preserveSymlinks)
|
|
1388
|
+
return (require.resolve.paths('zyzz') ?? []).some((directory) => existsSync(Path.join(directory, 'zyzz/package.json')));
|
|
1389
|
+
return require.resolve(runtime).split(Path.sep).includes('node_modules');
|
|
1390
|
+
}
|
|
1391
|
+
catch {
|
|
1392
|
+
return false;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
const scan = { scan: true };
|
|
1396
|
+
/**
|
|
1397
|
+
* Resolves imports read from source before other plugins transform their
|
|
1398
|
+
* importers. Marking them as scans, as Vite's dependency scanner does, keeps the
|
|
1399
|
+
* optimizer from discovering their dependencies and lets plugins tell them apart
|
|
1400
|
+
* from imports that reach the module graph.
|
|
1401
|
+
*/
|
|
1402
|
+
function resolver(environment) {
|
|
1403
|
+
return (source, importer) => environment.pluginContainer.resolveId(source, importer, scan);
|
|
1404
|
+
}
|
|
1405
|
+
// Vite and Vitest load their own configuration modules, which application code never imports.
|
|
1406
|
+
const configFiles = [
|
|
1407
|
+
'**/vite.config.*',
|
|
1408
|
+
'**/vitest.config.*',
|
|
1409
|
+
'**/vitest.workspace.*',
|
|
1410
|
+
];
|
|
1261
1411
|
const prefix = '\0zyzz:';
|
|
1412
|
+
const runtime = 'zyzz/runtime';
|
|
1262
1413
|
const sharedId = `${prefix}shared.css`;
|
|
1263
1414
|
function cssId(file) {
|
|
1264
1415
|
return `${prefix}${encodeURIComponent(file)}.css`;
|