@gravity-ui/data-source 0.10.0-alpha.6 → 0.10.0-alpha.8
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/build/plugin/esbuild.cjs +1 -1
- package/build/plugin/esbuild.mjs +1 -1
- package/build/plugin/{factory-C-n_7Tjo.mjs → factory-Dwr-yuOT.mjs} +51 -37
- package/build/plugin/{factory-CIwgQy1N.cjs → factory-GDKkqVwg.cjs} +51 -37
- package/build/plugin/index.cjs +1 -1
- package/build/plugin/index.mjs +1 -1
- package/build/plugin/rollup.cjs +1 -1
- package/build/plugin/rollup.mjs +1 -1
- package/build/plugin/rspack.cjs +1 -1
- package/build/plugin/rspack.mjs +1 -1
- package/build/plugin/vite.cjs +1 -1
- package/build/plugin/vite.mjs +1 -1
- package/build/plugin/webpack.cjs +1 -1
- package/build/plugin/webpack.mjs +1 -1
- package/package.json +1 -1
package/build/plugin/esbuild.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-GDKkqVwg.cjs");
|
|
2
2
|
//#region src/plugin/esbuild.ts
|
|
3
3
|
var esbuild_default = (0, require("unplugin").createEsbuildPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/esbuild.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-Dwr-yuOT.mjs";
|
|
2
2
|
import { createEsbuildPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/esbuild.ts
|
|
4
4
|
var esbuild_default = createEsbuildPlugin(dataSourceLazyUnpluginFactory);
|
|
@@ -57,6 +57,14 @@ function parseCompanionId(id) {
|
|
|
57
57
|
function isRelativeId(id) {
|
|
58
58
|
return id[0] === ".";
|
|
59
59
|
}
|
|
60
|
+
function toRelativeImportSource(fromFile, toFile) {
|
|
61
|
+
const fromDir = path.dirname(stripQuery(fromFile));
|
|
62
|
+
let rel = path.relative(fromDir, toFile);
|
|
63
|
+
if (path.sep !== "/") rel = rel.split(path.sep).join("/");
|
|
64
|
+
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
65
|
+
const ext = path.extname(rel);
|
|
66
|
+
return ext ? rel.slice(0, -ext.length) : rel;
|
|
67
|
+
}
|
|
60
68
|
function stripQuery(id) {
|
|
61
69
|
const queryIndex = id.indexOf("?");
|
|
62
70
|
return queryIndex === -1 ? id : id.slice(0, queryIndex);
|
|
@@ -94,7 +102,7 @@ function extractHocInfo(hocsSet, filename, source) {
|
|
|
94
102
|
for (const node of program.body) {
|
|
95
103
|
if (node.type !== "ExportNamedDeclaration" || node.exportKind === "type" || node.declaration?.type !== "VariableDeclaration") continue;
|
|
96
104
|
for (const decl of node.declaration.declarations) {
|
|
97
|
-
if (decl.id.type !== "Identifier" || !decl.init || decl.init.type !== "CallExpression" || decl.init.callee.type !== "Identifier" || decl.init.arguments.length
|
|
105
|
+
if (decl.id.type !== "Identifier" || !decl.init || decl.init.type !== "CallExpression" || decl.init.callee.type !== "Identifier" || decl.init.arguments.length < 2) continue;
|
|
98
106
|
const hocEntry = trackedHocs.get(decl.init.callee.name);
|
|
99
107
|
if (!hocEntry) continue;
|
|
100
108
|
const [contentArg, loadingArg, errorArg] = decl.init.arguments;
|
|
@@ -120,12 +128,12 @@ function extractHocInfo(hocsSet, filename, source) {
|
|
|
120
128
|
argEnd: loadingArg.end,
|
|
121
129
|
imports: filterNeededImports(importDecls, collectIdentifiers(loadingArg))
|
|
122
130
|
},
|
|
123
|
-
error: {
|
|
131
|
+
error: errorArg ? {
|
|
124
132
|
argSource: source.slice(errorArg.start, errorArg.end),
|
|
125
133
|
argStart: errorArg.start,
|
|
126
134
|
argEnd: errorArg.end,
|
|
127
135
|
imports: filterNeededImports(importDecls, collectIdentifiers(errorArg))
|
|
128
|
-
}
|
|
136
|
+
} : null
|
|
129
137
|
};
|
|
130
138
|
}
|
|
131
139
|
}
|
|
@@ -310,15 +318,13 @@ function parseProgram(filename, source) {
|
|
|
310
318
|
}
|
|
311
319
|
//#endregion
|
|
312
320
|
//#region src/plugin/core/generate.ts
|
|
313
|
-
function generateAuxModule(sourceFile, info, type, options = {}) {
|
|
314
|
-
const auxInfo = info[type];
|
|
315
|
-
const name = info.exportedName;
|
|
321
|
+
function generateAuxModule(sourceFile, exportedName, info, type, options = {}) {
|
|
316
322
|
const suffix = COMPANION_TYPES[type];
|
|
317
323
|
const cleanSourceFile = stripQuery(sourceFile);
|
|
318
324
|
const code = [
|
|
319
|
-
renderImports(
|
|
325
|
+
renderImports(info.imports),
|
|
320
326
|
"",
|
|
321
|
-
`export const ${
|
|
327
|
+
`export const ${exportedName}${suffix} = ${info.argSource};`,
|
|
322
328
|
""
|
|
323
329
|
].join("\n").trimStart();
|
|
324
330
|
return transformJsx(makeCompanionId(type, cleanSourceFile), code, options);
|
|
@@ -328,21 +334,19 @@ function generateLazyModule(sourceFile, info, options = {}) {
|
|
|
328
334
|
const name = info.exportedName;
|
|
329
335
|
const cleanSourceFile = stripQuery(sourceFile);
|
|
330
336
|
const base = `./${path.basename(cleanSourceFile, path.extname(cleanSourceFile))}`;
|
|
331
|
-
const
|
|
337
|
+
const hocBinding = info.hocImportedName === "default" ? info.hocLocalName : info.hocImportedName;
|
|
338
|
+
const lines = [
|
|
332
339
|
`import {lazy} from '${importSource}';`,
|
|
333
340
|
"",
|
|
334
341
|
info.hocImportedName === "default" ? `import ${info.hocLocalName} from '${info.hocImportSource}';` : `import {${info.hocImportedName}} from '${info.hocImportSource}';`,
|
|
335
342
|
"",
|
|
336
|
-
`import {${name}Loading} from '${base}.Loading'
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
`);`,
|
|
344
|
-
``
|
|
345
|
-
].join("\n");
|
|
343
|
+
`import {${name}Loading} from '${base}.Loading';`
|
|
344
|
+
];
|
|
345
|
+
if (info.error) lines.push(`import {${name}Error} from '${base}.Error';`);
|
|
346
|
+
lines.push("", `export const ${name}Lazy = ${hocBinding}(`, ` lazy(() => import('${base}').then((m) => ({default: m.${name}Content}))),`, ` ${name}Loading,`);
|
|
347
|
+
if (info.error) lines.push(` ${name}Error,`);
|
|
348
|
+
lines.push(`);`, ``);
|
|
349
|
+
const code = lines.join("\n");
|
|
346
350
|
const filename = makeCompanionId("lazy", cleanSourceFile);
|
|
347
351
|
return {
|
|
348
352
|
code,
|
|
@@ -423,9 +427,11 @@ function transformDefinitionModule(s, filename, info) {
|
|
|
423
427
|
const name = info.exportedName;
|
|
424
428
|
const cleanFilename = stripQuery(filename);
|
|
425
429
|
const localSource = `./${path.basename(cleanFilename, path.extname(cleanFilename))}`;
|
|
426
|
-
|
|
430
|
+
const prependImports = [renderNamedImport(`${name}Loading`, `${name}Loading`, makeCompanionId("loading", localSource))];
|
|
431
|
+
if (info.error) prependImports.push(renderNamedImport(`${name}Error`, `${name}Error`, makeCompanionId("error", localSource)));
|
|
432
|
+
s.prepend(prependImports.join("\n") + "\n");
|
|
427
433
|
s.overwrite(info.loading.argStart, info.loading.argEnd, `${name}Loading`);
|
|
428
|
-
s.overwrite(info.error.argStart, info.error.argEnd, `${name}Error`);
|
|
434
|
+
if (info.error) s.overwrite(info.error.argStart, info.error.argEnd, `${name}Error`);
|
|
429
435
|
if (info.content.kind === "identifier") s.append(`\nexport {${info.content.name} as ${name}Content};\n`);
|
|
430
436
|
else {
|
|
431
437
|
s.appendLeft(info.hocExportStart, `const ${name}Content = ${info.content.argSource};\n\n`);
|
|
@@ -436,9 +442,9 @@ function transformDefinitionModule(s, filename, info) {
|
|
|
436
442
|
function transformUsages(s, usages) {
|
|
437
443
|
for (const { usage } of usages) for (const access of usage.accesses) s.overwrite(access.start, access.end, `${usage.spec.localName}${access.prop}`);
|
|
438
444
|
const newImports = [];
|
|
439
|
-
for (const { usage,
|
|
445
|
+
for (const { usage, hocImportSource, hocExportedName } of usages) {
|
|
440
446
|
const propsUsed = new Set(usage.accesses.map((access) => access.prop));
|
|
441
|
-
for (const prop of propsUsed) newImports.push(renderNamedImport(`${usage.spec.localName}${prop}`, `${hocExportedName}${prop}`, makeCompanionId(COMPANION_TYPE_BY_SUFFIX[prop],
|
|
447
|
+
for (const prop of propsUsed) newImports.push(renderNamedImport(`${usage.spec.localName}${prop}`, `${hocExportedName}${prop}`, makeCompanionId(COMPANION_TYPE_BY_SUFFIX[prop], hocImportSource)));
|
|
442
448
|
}
|
|
443
449
|
if (newImports.length > 0) s.prepend(newImports.join("\n") + "\n");
|
|
444
450
|
const localsByDecl = /* @__PURE__ */ new Map();
|
|
@@ -469,13 +475,20 @@ function renderNamedImport(local, imported, source) {
|
|
|
469
475
|
}
|
|
470
476
|
//#endregion
|
|
471
477
|
//#region src/plugin/core/factory.ts
|
|
472
|
-
const DEFAULT_HOCS = [
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
478
|
+
const DEFAULT_HOCS = [
|
|
479
|
+
{
|
|
480
|
+
from: "@gravity-ui/data-source",
|
|
481
|
+
name: "withAsync"
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
from: "@gravity-ui/data-source",
|
|
485
|
+
name: "withAsyncBoundary"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
from: "@gravity-ui/data-source",
|
|
489
|
+
name: "withQueryAsyncBoundary"
|
|
490
|
+
}
|
|
491
|
+
];
|
|
479
492
|
const DEFAULT_INCLUDE = /\.(tsx?|jsx?)$/;
|
|
480
493
|
const VIRTUAL_EXCLUDE = new RegExp(`${VIRTUAL_PREFIX}|${encodeURIComponent(VIRTUAL_PREFIX)}`);
|
|
481
494
|
const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
@@ -529,12 +542,13 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
529
542
|
this.addWatchFile(parsedId.sourceFile);
|
|
530
543
|
const info = getHocInfo(parsedId.sourceFile);
|
|
531
544
|
if (!info) return null;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
default: return assertNever(parsedId.type);
|
|
545
|
+
if (parsedId.type === "loading" || parsedId.type === "error") {
|
|
546
|
+
const auxInfo = info[parsedId.type];
|
|
547
|
+
if (!auxInfo) return null;
|
|
548
|
+
return generateAuxModule(parsedId.sourceFile, info.exportedName, auxInfo, parsedId.type, options.generateOptions);
|
|
537
549
|
}
|
|
550
|
+
if (parsedId.type === "lazy") return generateLazyModule(parsedId.sourceFile, info, options.generateOptions);
|
|
551
|
+
return assertNever(parsedId.type);
|
|
538
552
|
}
|
|
539
553
|
},
|
|
540
554
|
transform: {
|
|
@@ -580,7 +594,7 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
580
594
|
if (!target) return null;
|
|
581
595
|
return {
|
|
582
596
|
usage,
|
|
583
|
-
|
|
597
|
+
hocImportSource: toRelativeImportSource(id, target.file),
|
|
584
598
|
hocExportedName: target.info.exportedName
|
|
585
599
|
};
|
|
586
600
|
}))).filter((usage) => usage !== null);
|
|
@@ -611,7 +625,7 @@ function isInside(info, access) {
|
|
|
611
625
|
function dropAccessesInsideHocArgs(info, usages) {
|
|
612
626
|
const result = [];
|
|
613
627
|
for (const usage of usages) {
|
|
614
|
-
const accesses = usage.accesses.filter((access) => !isInside(info.loading, access) && !isInside(info.error, access) && !(info.content.kind === "inline" && isInside(info.content, access)));
|
|
628
|
+
const accesses = usage.accesses.filter((access) => !isInside(info.loading, access) && !(info.error && isInside(info.error, access)) && !(info.content.kind === "inline" && isInside(info.content, access)));
|
|
615
629
|
if (accesses.length === 0) continue;
|
|
616
630
|
if (accesses.length === usage.accesses.length) {
|
|
617
631
|
result.push(usage);
|
|
@@ -82,6 +82,14 @@ function parseCompanionId(id) {
|
|
|
82
82
|
function isRelativeId(id) {
|
|
83
83
|
return id[0] === ".";
|
|
84
84
|
}
|
|
85
|
+
function toRelativeImportSource(fromFile, toFile) {
|
|
86
|
+
const fromDir = node_path.default.dirname(stripQuery(fromFile));
|
|
87
|
+
let rel = node_path.default.relative(fromDir, toFile);
|
|
88
|
+
if (node_path.default.sep !== "/") rel = rel.split(node_path.default.sep).join("/");
|
|
89
|
+
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
90
|
+
const ext = node_path.default.extname(rel);
|
|
91
|
+
return ext ? rel.slice(0, -ext.length) : rel;
|
|
92
|
+
}
|
|
85
93
|
function stripQuery(id) {
|
|
86
94
|
const queryIndex = id.indexOf("?");
|
|
87
95
|
return queryIndex === -1 ? id : id.slice(0, queryIndex);
|
|
@@ -119,7 +127,7 @@ function extractHocInfo(hocsSet, filename, source) {
|
|
|
119
127
|
for (const node of program.body) {
|
|
120
128
|
if (node.type !== "ExportNamedDeclaration" || node.exportKind === "type" || node.declaration?.type !== "VariableDeclaration") continue;
|
|
121
129
|
for (const decl of node.declaration.declarations) {
|
|
122
|
-
if (decl.id.type !== "Identifier" || !decl.init || decl.init.type !== "CallExpression" || decl.init.callee.type !== "Identifier" || decl.init.arguments.length
|
|
130
|
+
if (decl.id.type !== "Identifier" || !decl.init || decl.init.type !== "CallExpression" || decl.init.callee.type !== "Identifier" || decl.init.arguments.length < 2) continue;
|
|
123
131
|
const hocEntry = trackedHocs.get(decl.init.callee.name);
|
|
124
132
|
if (!hocEntry) continue;
|
|
125
133
|
const [contentArg, loadingArg, errorArg] = decl.init.arguments;
|
|
@@ -145,12 +153,12 @@ function extractHocInfo(hocsSet, filename, source) {
|
|
|
145
153
|
argEnd: loadingArg.end,
|
|
146
154
|
imports: filterNeededImports(importDecls, collectIdentifiers(loadingArg))
|
|
147
155
|
},
|
|
148
|
-
error: {
|
|
156
|
+
error: errorArg ? {
|
|
149
157
|
argSource: source.slice(errorArg.start, errorArg.end),
|
|
150
158
|
argStart: errorArg.start,
|
|
151
159
|
argEnd: errorArg.end,
|
|
152
160
|
imports: filterNeededImports(importDecls, collectIdentifiers(errorArg))
|
|
153
|
-
}
|
|
161
|
+
} : null
|
|
154
162
|
};
|
|
155
163
|
}
|
|
156
164
|
}
|
|
@@ -335,15 +343,13 @@ function parseProgram(filename, source) {
|
|
|
335
343
|
}
|
|
336
344
|
//#endregion
|
|
337
345
|
//#region src/plugin/core/generate.ts
|
|
338
|
-
function generateAuxModule(sourceFile, info, type, options = {}) {
|
|
339
|
-
const auxInfo = info[type];
|
|
340
|
-
const name = info.exportedName;
|
|
346
|
+
function generateAuxModule(sourceFile, exportedName, info, type, options = {}) {
|
|
341
347
|
const suffix = COMPANION_TYPES[type];
|
|
342
348
|
const cleanSourceFile = stripQuery(sourceFile);
|
|
343
349
|
const code = [
|
|
344
|
-
renderImports(
|
|
350
|
+
renderImports(info.imports),
|
|
345
351
|
"",
|
|
346
|
-
`export const ${
|
|
352
|
+
`export const ${exportedName}${suffix} = ${info.argSource};`,
|
|
347
353
|
""
|
|
348
354
|
].join("\n").trimStart();
|
|
349
355
|
return transformJsx(makeCompanionId(type, cleanSourceFile), code, options);
|
|
@@ -353,21 +359,19 @@ function generateLazyModule(sourceFile, info, options = {}) {
|
|
|
353
359
|
const name = info.exportedName;
|
|
354
360
|
const cleanSourceFile = stripQuery(sourceFile);
|
|
355
361
|
const base = `./${node_path.default.basename(cleanSourceFile, node_path.default.extname(cleanSourceFile))}`;
|
|
356
|
-
const
|
|
362
|
+
const hocBinding = info.hocImportedName === "default" ? info.hocLocalName : info.hocImportedName;
|
|
363
|
+
const lines = [
|
|
357
364
|
`import {lazy} from '${importSource}';`,
|
|
358
365
|
"",
|
|
359
366
|
info.hocImportedName === "default" ? `import ${info.hocLocalName} from '${info.hocImportSource}';` : `import {${info.hocImportedName}} from '${info.hocImportSource}';`,
|
|
360
367
|
"",
|
|
361
|
-
`import {${name}Loading} from '${base}.Loading'
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
`);`,
|
|
369
|
-
``
|
|
370
|
-
].join("\n");
|
|
368
|
+
`import {${name}Loading} from '${base}.Loading';`
|
|
369
|
+
];
|
|
370
|
+
if (info.error) lines.push(`import {${name}Error} from '${base}.Error';`);
|
|
371
|
+
lines.push("", `export const ${name}Lazy = ${hocBinding}(`, ` lazy(() => import('${base}').then((m) => ({default: m.${name}Content}))),`, ` ${name}Loading,`);
|
|
372
|
+
if (info.error) lines.push(` ${name}Error,`);
|
|
373
|
+
lines.push(`);`, ``);
|
|
374
|
+
const code = lines.join("\n");
|
|
371
375
|
const filename = makeCompanionId("lazy", cleanSourceFile);
|
|
372
376
|
return {
|
|
373
377
|
code,
|
|
@@ -448,9 +452,11 @@ function transformDefinitionModule(s, filename, info) {
|
|
|
448
452
|
const name = info.exportedName;
|
|
449
453
|
const cleanFilename = stripQuery(filename);
|
|
450
454
|
const localSource = `./${node_path.default.basename(cleanFilename, node_path.default.extname(cleanFilename))}`;
|
|
451
|
-
|
|
455
|
+
const prependImports = [renderNamedImport(`${name}Loading`, `${name}Loading`, makeCompanionId("loading", localSource))];
|
|
456
|
+
if (info.error) prependImports.push(renderNamedImport(`${name}Error`, `${name}Error`, makeCompanionId("error", localSource)));
|
|
457
|
+
s.prepend(prependImports.join("\n") + "\n");
|
|
452
458
|
s.overwrite(info.loading.argStart, info.loading.argEnd, `${name}Loading`);
|
|
453
|
-
s.overwrite(info.error.argStart, info.error.argEnd, `${name}Error`);
|
|
459
|
+
if (info.error) s.overwrite(info.error.argStart, info.error.argEnd, `${name}Error`);
|
|
454
460
|
if (info.content.kind === "identifier") s.append(`\nexport {${info.content.name} as ${name}Content};\n`);
|
|
455
461
|
else {
|
|
456
462
|
s.appendLeft(info.hocExportStart, `const ${name}Content = ${info.content.argSource};\n\n`);
|
|
@@ -461,9 +467,9 @@ function transformDefinitionModule(s, filename, info) {
|
|
|
461
467
|
function transformUsages(s, usages) {
|
|
462
468
|
for (const { usage } of usages) for (const access of usage.accesses) s.overwrite(access.start, access.end, `${usage.spec.localName}${access.prop}`);
|
|
463
469
|
const newImports = [];
|
|
464
|
-
for (const { usage,
|
|
470
|
+
for (const { usage, hocImportSource, hocExportedName } of usages) {
|
|
465
471
|
const propsUsed = new Set(usage.accesses.map((access) => access.prop));
|
|
466
|
-
for (const prop of propsUsed) newImports.push(renderNamedImport(`${usage.spec.localName}${prop}`, `${hocExportedName}${prop}`, makeCompanionId(COMPANION_TYPE_BY_SUFFIX[prop],
|
|
472
|
+
for (const prop of propsUsed) newImports.push(renderNamedImport(`${usage.spec.localName}${prop}`, `${hocExportedName}${prop}`, makeCompanionId(COMPANION_TYPE_BY_SUFFIX[prop], hocImportSource)));
|
|
467
473
|
}
|
|
468
474
|
if (newImports.length > 0) s.prepend(newImports.join("\n") + "\n");
|
|
469
475
|
const localsByDecl = /* @__PURE__ */ new Map();
|
|
@@ -494,13 +500,20 @@ function renderNamedImport(local, imported, source) {
|
|
|
494
500
|
}
|
|
495
501
|
//#endregion
|
|
496
502
|
//#region src/plugin/core/factory.ts
|
|
497
|
-
const DEFAULT_HOCS = [
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
503
|
+
const DEFAULT_HOCS = [
|
|
504
|
+
{
|
|
505
|
+
from: "@gravity-ui/data-source",
|
|
506
|
+
name: "withAsync"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
from: "@gravity-ui/data-source",
|
|
510
|
+
name: "withAsyncBoundary"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
from: "@gravity-ui/data-source",
|
|
514
|
+
name: "withQueryAsyncBoundary"
|
|
515
|
+
}
|
|
516
|
+
];
|
|
504
517
|
const DEFAULT_INCLUDE = /\.(tsx?|jsx?)$/;
|
|
505
518
|
const VIRTUAL_EXCLUDE = new RegExp(`${VIRTUAL_PREFIX}|${encodeURIComponent(VIRTUAL_PREFIX)}`);
|
|
506
519
|
const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
@@ -554,12 +567,13 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
554
567
|
this.addWatchFile(parsedId.sourceFile);
|
|
555
568
|
const info = getHocInfo(parsedId.sourceFile);
|
|
556
569
|
if (!info) return null;
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
default: return assertNever(parsedId.type);
|
|
570
|
+
if (parsedId.type === "loading" || parsedId.type === "error") {
|
|
571
|
+
const auxInfo = info[parsedId.type];
|
|
572
|
+
if (!auxInfo) return null;
|
|
573
|
+
return generateAuxModule(parsedId.sourceFile, info.exportedName, auxInfo, parsedId.type, options.generateOptions);
|
|
562
574
|
}
|
|
575
|
+
if (parsedId.type === "lazy") return generateLazyModule(parsedId.sourceFile, info, options.generateOptions);
|
|
576
|
+
return assertNever(parsedId.type);
|
|
563
577
|
}
|
|
564
578
|
},
|
|
565
579
|
transform: {
|
|
@@ -605,7 +619,7 @@ const dataSourceLazyUnpluginFactory = (options = {}) => {
|
|
|
605
619
|
if (!target) return null;
|
|
606
620
|
return {
|
|
607
621
|
usage,
|
|
608
|
-
|
|
622
|
+
hocImportSource: toRelativeImportSource(id, target.file),
|
|
609
623
|
hocExportedName: target.info.exportedName
|
|
610
624
|
};
|
|
611
625
|
}))).filter((usage) => usage !== null);
|
|
@@ -636,7 +650,7 @@ function isInside(info, access) {
|
|
|
636
650
|
function dropAccessesInsideHocArgs(info, usages) {
|
|
637
651
|
const result = [];
|
|
638
652
|
for (const usage of usages) {
|
|
639
|
-
const accesses = usage.accesses.filter((access) => !isInside(info.loading, access) && !isInside(info.error, access) && !(info.content.kind === "inline" && isInside(info.content, access)));
|
|
653
|
+
const accesses = usage.accesses.filter((access) => !isInside(info.loading, access) && !(info.error && isInside(info.error, access)) && !(info.content.kind === "inline" && isInside(info.content, access)));
|
|
640
654
|
if (accesses.length === 0) continue;
|
|
641
655
|
if (accesses.length === usage.accesses.length) {
|
|
642
656
|
result.push(usage);
|
package/build/plugin/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_factory = require("./factory-
|
|
5
|
+
const require_factory = require("./factory-GDKkqVwg.cjs");
|
|
6
6
|
//#region src/plugin/index.ts
|
|
7
7
|
const DataSourceLazyPlugin = /* @__PURE__ */ (0, require("unplugin").createUnplugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
8
8
|
//#endregion
|
package/build/plugin/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory, t as DEFAULT_HOCS } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory, t as DEFAULT_HOCS } from "./factory-Dwr-yuOT.mjs";
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/index.ts
|
|
4
4
|
const DataSourceLazyPlugin = /* @__PURE__ */ createUnplugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/rollup.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-GDKkqVwg.cjs");
|
|
2
2
|
//#region src/plugin/rollup.ts
|
|
3
3
|
var rollup_default = (0, require("unplugin").createRollupPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/rollup.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-Dwr-yuOT.mjs";
|
|
2
2
|
import { createRollupPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/rollup.ts
|
|
4
4
|
var rollup_default = createRollupPlugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/rspack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-GDKkqVwg.cjs");
|
|
2
2
|
//#region src/plugin/rspack.ts
|
|
3
3
|
var rspack_default = (0, require("unplugin").createRspackPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/rspack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-Dwr-yuOT.mjs";
|
|
2
2
|
import { createRspackPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/rspack.ts
|
|
4
4
|
var rspack_default = createRspackPlugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-GDKkqVwg.cjs");
|
|
2
2
|
//#region src/plugin/vite.ts
|
|
3
3
|
var vite_default = (0, require("unplugin").createVitePlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-Dwr-yuOT.mjs";
|
|
2
2
|
import { createVitePlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/vite.ts
|
|
4
4
|
var vite_default = createVitePlugin(dataSourceLazyUnpluginFactory);
|
package/build/plugin/webpack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_factory = require("./factory-
|
|
1
|
+
const require_factory = require("./factory-GDKkqVwg.cjs");
|
|
2
2
|
//#region src/plugin/webpack.ts
|
|
3
3
|
var webpack_default = (0, require("unplugin").createWebpackPlugin)(require_factory.dataSourceLazyUnpluginFactory);
|
|
4
4
|
//#endregion
|
package/build/plugin/webpack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as dataSourceLazyUnpluginFactory } from "./factory-
|
|
1
|
+
import { n as dataSourceLazyUnpluginFactory } from "./factory-Dwr-yuOT.mjs";
|
|
2
2
|
import { createWebpackPlugin } from "unplugin";
|
|
3
3
|
//#region src/plugin/webpack.ts
|
|
4
4
|
var webpack_default = createWebpackPlugin(dataSourceLazyUnpluginFactory);
|