evolit 0.4.0 → 0.4.1
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/package.json +1 -1
- package/src/compiler.js +4 -3
- package/src/litsx-pipeline.d.ts +1 -0
- package/src/litsx-pipeline.js +8 -0
package/package.json
CHANGED
package/src/compiler.js
CHANGED
|
@@ -928,8 +928,9 @@ function getTypedOutputRoot(projectRoot, mode, target = "server") {
|
|
|
928
928
|
);
|
|
929
929
|
}
|
|
930
930
|
|
|
931
|
-
function toOutputPath(projectRoot, outputRoot, sourcePath) {
|
|
932
|
-
const relativePath =
|
|
931
|
+
function toOutputPath(projectRoot, outputRoot, sourcePath, litsxPipeline = null) {
|
|
932
|
+
const relativePath = litsxPipeline?.getOutputRelativePath?.(sourcePath)
|
|
933
|
+
?? toOutputRelativePath(projectRoot, sourcePath);
|
|
933
934
|
const extension = path.extname(relativePath);
|
|
934
935
|
if (!extension) {
|
|
935
936
|
return path.join(outputRoot, `${relativePath}.mjs`);
|
|
@@ -1416,7 +1417,7 @@ async function compileModuleGraphUncached(entryPath, options = {}) {
|
|
|
1416
1417
|
return visited.get(sourcePath);
|
|
1417
1418
|
}
|
|
1418
1419
|
|
|
1419
|
-
const outputPath = toOutputPath(projectRoot, outputRoot, sourcePath);
|
|
1420
|
+
const outputPath = toOutputPath(projectRoot, outputRoot, sourcePath, litsxPipeline);
|
|
1420
1421
|
visited.set(sourcePath, outputPath);
|
|
1421
1422
|
|
|
1422
1423
|
await ensureDirectory(path.dirname(outputPath));
|
package/src/litsx-pipeline.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ export type EvolitLitsxPipeline = {
|
|
|
105
105
|
readonly identity: Readonly<{ id: string }>;
|
|
106
106
|
readonly generation: number;
|
|
107
107
|
readonly dependencies: string[];
|
|
108
|
+
getOutputRelativePath(sourcePath: string): string | null;
|
|
108
109
|
getCompilerOptions(context: { filename: string; ssr: boolean; sourceMaps: boolean }): TransformLitsxOptions;
|
|
109
110
|
resolveModule(specifier: string, context: {
|
|
110
111
|
importer: string;
|
package/src/litsx-pipeline.js
CHANGED
|
@@ -217,6 +217,7 @@ export async function createLitsxPipeline({ projectRoot, mode, config } = {}) {
|
|
|
217
217
|
const virtualRoot = virtualModuleRoot(resolvedProjectRoot, mode, identity);
|
|
218
218
|
const virtualModulesByImporter = new Map();
|
|
219
219
|
const virtualTargetsBySpecifier = new Map();
|
|
220
|
+
const virtualOutputRelativePaths = new Map();
|
|
220
221
|
|
|
221
222
|
function rebuildDependencies() {
|
|
222
223
|
dependencies.clear();
|
|
@@ -337,6 +338,9 @@ export async function createLitsxPipeline({ projectRoot, mode, config } = {}) {
|
|
|
337
338
|
get dependencies() {
|
|
338
339
|
return [...dependencies].sort();
|
|
339
340
|
},
|
|
341
|
+
getOutputRelativePath(sourcePath) {
|
|
342
|
+
return virtualOutputRelativePaths.get(path.resolve(sourcePath)) ?? null;
|
|
343
|
+
},
|
|
340
344
|
getCompilerOptions({ filename, ssr, sourceMaps }) {
|
|
341
345
|
assertActive();
|
|
342
346
|
let options = { ...compiler };
|
|
@@ -418,6 +422,10 @@ export async function createLitsxPipeline({ projectRoot, mode, config } = {}) {
|
|
|
418
422
|
.digest("hex");
|
|
419
423
|
const integrationName = resolved.integrationName.replace(/[^a-z\d._-]+/giu, "-");
|
|
420
424
|
resolved.sourcePath = path.join(virtualRoot, integrationName, `${moduleKey}.mjs`);
|
|
425
|
+
virtualOutputRelativePaths.set(
|
|
426
|
+
path.resolve(resolved.sourcePath),
|
|
427
|
+
path.join("__litsx_virtual__", integrationName, `${moduleKey}.mjs`),
|
|
428
|
+
);
|
|
421
429
|
await ensureDirectory(path.dirname(resolved.sourcePath));
|
|
422
430
|
await fs.writeFile(resolved.sourcePath, resolved.code, "utf8");
|
|
423
431
|
const targets = virtualTargetsBySpecifier.get(specifier) ?? new Set();
|