@absolutejs/absolute 0.19.0-beta.1023 → 0.19.0-beta.1025
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/angular/browser.js +13 -17
- package/dist/angular/browser.js.map +3 -3
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +595 -267
- package/dist/angular/index.js.map +11 -8
- package/dist/angular/server.js +577 -249
- package/dist/angular/server.js.map +11 -8
- package/dist/build.js +827 -735
- package/dist/build.js.map +11 -10
- package/dist/cli/config/server.js +49 -42
- package/dist/cli/index.js +366 -9
- package/dist/client/index.js +34 -20
- package/dist/client/index.js.map +6 -6
- package/dist/index.js +899 -800
- package/dist/index.js.map +12 -11
- package/dist/islands/index.js +416 -95
- package/dist/islands/index.js.map +10 -7
- package/dist/react/browser.js +13 -17
- package/dist/react/browser.js.map +3 -3
- package/dist/react/index.js +484 -156
- package/dist/react/index.js.map +12 -9
- package/dist/react/server.js +69 -62
- package/dist/react/server.js.map +5 -5
- package/dist/src/cli/scripts/tunnelRelay.d.ts +9 -0
- package/dist/src/client/preserveIslandMarkup.d.ts +4 -1
- package/dist/src/core/angularServerModule.d.ts +1 -0
- package/dist/src/dev/tunnel/client.d.ts +20 -0
- package/dist/src/dev/tunnel/protocol.d.ts +85 -0
- package/dist/src/dev/tunnel/relay.d.ts +28 -0
- package/dist/src/utils/loadConfig.d.ts +4 -0
- package/dist/svelte/index.js +389 -61
- package/dist/svelte/index.js.map +11 -8
- package/dist/svelte/server.js +50 -43
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/angular.d.ts +3 -0
- package/dist/types/build.d.ts +11 -0
- package/dist/types/globals.d.ts +0 -1
- package/dist/vue/browser.js +13 -17
- package/dist/vue/browser.js.map +3 -3
- package/dist/vue/index.js +477 -153
- package/dist/vue/index.js.map +12 -9
- package/dist/vue/server.js +50 -43
- package/dist/vue/server.js.map +3 -3
- package/package.json +2 -6
package/dist/islands/index.js
CHANGED
|
@@ -342,9 +342,12 @@ var initDominoAdapter = (platformServer) => {
|
|
|
342
342
|
return {
|
|
343
343
|
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
344
344
|
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
345
|
+
Component: core.Component,
|
|
345
346
|
DomSanitizer: platformBrowser.DomSanitizer,
|
|
346
347
|
ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
|
|
347
348
|
inject: core.inject,
|
|
349
|
+
InjectionToken: core.InjectionToken,
|
|
350
|
+
NgComponentOutlet: common.NgComponentOutlet,
|
|
348
351
|
provideClientHydration: platformBrowser.provideClientHydration,
|
|
349
352
|
provideServerRendering: platformServer.provideServerRendering,
|
|
350
353
|
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
@@ -600,9 +603,8 @@ var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) =
|
|
|
600
603
|
const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
|
|
601
604
|
return `${componentName}:${JSON.stringify(props)}`;
|
|
602
605
|
}, buildAngularIslandWrapperMetadata = async (component, islandId, wrapperKey) => {
|
|
603
|
-
const { Component, InjectionToken, inject } = await import("@angular/core");
|
|
604
|
-
const { NgComponentOutlet } = await import("@angular/common");
|
|
605
606
|
const deps = await getAngularDeps();
|
|
607
|
+
const { Component, InjectionToken, NgComponentOutlet, inject } = deps;
|
|
606
608
|
const selector = getAngularIslandSelector(islandId);
|
|
607
609
|
const propsToken = new InjectionToken(`${wrapperKey}:props`);
|
|
608
610
|
|
|
@@ -708,7 +710,15 @@ var init_islands2 = __esm(() => {
|
|
|
708
710
|
var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
709
711
|
const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands2(), exports_islands));
|
|
710
712
|
return renderAngularIslandToHtml2(component, props, islandId);
|
|
711
|
-
}, renderAngularIslandToHtml2,
|
|
713
|
+
}, renderAngularIslandToHtml2, LEADING_HOISTED_RESOURCE_RE, stripLeadingHoistedResources = (html) => {
|
|
714
|
+
let result = html;
|
|
715
|
+
let match = LEADING_HOISTED_RESOURCE_RE.exec(result);
|
|
716
|
+
while (match) {
|
|
717
|
+
result = result.slice(match[0].length);
|
|
718
|
+
match = LEADING_HOISTED_RESOURCE_RE.exec(result);
|
|
719
|
+
}
|
|
720
|
+
return result.trimStart();
|
|
721
|
+
}, renderReactIslandToHtml = (component, props) => import("react").then(({ createElement }) => import("react-dom/server").then(({ renderToString }) => stripLeadingHoistedResources(renderToString(createElement(component, props))))), renderSvelteIslandToHtml = (component, props) => import("svelte/server").then(({ render }) => {
|
|
712
722
|
const { body } = render(component, { props });
|
|
713
723
|
return body;
|
|
714
724
|
}), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h: createVueVNode }) => {
|
|
@@ -719,10 +729,311 @@ var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
|
719
729
|
});
|
|
720
730
|
var init_islandSsr = __esm(() => {
|
|
721
731
|
renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
|
|
732
|
+
LEADING_HOISTED_RESOURCE_RE = /^\s*(?:<link\b[^>]*\/?>|<meta\b[^>]*\/?>|<title\b[^>]*>[\s\S]*?<\/title>|<style\b[^>]*>[\s\S]*?<\/style>|<script\b[^>]*>[\s\S]*?<\/script>)/i;
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
// src/build/nativeRewrite.ts
|
|
736
|
+
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
737
|
+
import { platform, arch } from "os";
|
|
738
|
+
import { resolve as resolve2 } from "path";
|
|
739
|
+
var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
740
|
+
if (nativeLib !== null)
|
|
741
|
+
return nativeLib;
|
|
742
|
+
const osPlatform = platform();
|
|
743
|
+
const cpu = arch();
|
|
744
|
+
const platformMap = {
|
|
745
|
+
"darwin-arm64": "darwin-arm64/fast_ops.dylib",
|
|
746
|
+
"darwin-x64": "darwin-x64/fast_ops.dylib",
|
|
747
|
+
"linux-arm64": "linux-arm64/fast_ops.so",
|
|
748
|
+
"linux-x64": "linux-x64/fast_ops.so",
|
|
749
|
+
"win32-arm64": "windows-arm64/fast_ops.dll",
|
|
750
|
+
"win32-x64": "windows-x64/fast_ops.dll"
|
|
751
|
+
};
|
|
752
|
+
const libPath = platformMap[`${osPlatform}-${cpu}`];
|
|
753
|
+
if (!libPath)
|
|
754
|
+
return null;
|
|
755
|
+
try {
|
|
756
|
+
const fullPath = resolve2(import.meta.dir, "../../native/packages", libPath);
|
|
757
|
+
const lib = dlopen(fullPath, ffiDefinition);
|
|
758
|
+
nativeLib = lib.symbols;
|
|
759
|
+
return nativeLib;
|
|
760
|
+
} catch {
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
}, nativeRewriteImports = (content, replacements) => {
|
|
764
|
+
const lib = loadNative();
|
|
765
|
+
if (!lib)
|
|
766
|
+
return null;
|
|
767
|
+
const jsonStr = JSON.stringify(replacements);
|
|
768
|
+
const contentBuf = Buffer.from(content);
|
|
769
|
+
const jsonBuf = Buffer.from(jsonStr);
|
|
770
|
+
const outBuf = Buffer.alloc(content.length * 2);
|
|
771
|
+
const outLenBuf = new BigUint64Array([BigInt(outBuf.length)]);
|
|
772
|
+
const result = lib.rewrite_imports(ptr(contentBuf), contentBuf.length, ptr(jsonBuf), jsonBuf.length, ptr(outBuf), ptr(new Uint8Array(outLenBuf.buffer)));
|
|
773
|
+
if (result < 0)
|
|
774
|
+
return null;
|
|
775
|
+
if (result === 0)
|
|
776
|
+
return content;
|
|
777
|
+
const outLen = Number(outLenBuf[0]);
|
|
778
|
+
return outBuf.subarray(0, outLen).toString("utf-8");
|
|
779
|
+
};
|
|
780
|
+
var init_nativeRewrite = __esm(() => {
|
|
781
|
+
ffiDefinition = {
|
|
782
|
+
rewrite_imports: {
|
|
783
|
+
args: [
|
|
784
|
+
FFIType.ptr,
|
|
785
|
+
FFIType.u64,
|
|
786
|
+
FFIType.ptr,
|
|
787
|
+
FFIType.u64,
|
|
788
|
+
FFIType.ptr,
|
|
789
|
+
FFIType.ptr
|
|
790
|
+
],
|
|
791
|
+
returns: FFIType.i32
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// src/build/rewriteImportsPlugin.ts
|
|
797
|
+
var exports_rewriteImportsPlugin = {};
|
|
798
|
+
__export(exports_rewriteImportsPlugin, {
|
|
799
|
+
rewriteVendorDirectories: () => rewriteVendorDirectories,
|
|
800
|
+
rewriteImportsInContent: () => rewriteImportsInContent,
|
|
801
|
+
rewriteBuildOutputsWith: () => rewriteBuildOutputsWith,
|
|
802
|
+
rewriteBuildOutputs: () => rewriteBuildOutputs,
|
|
803
|
+
jsRewriteImports: () => jsRewriteImports,
|
|
804
|
+
fixMissingReExportNamespacesInContent: () => fixMissingReExportNamespacesInContent,
|
|
805
|
+
buildWithImportRewrite: () => buildWithImportRewrite
|
|
806
|
+
});
|
|
807
|
+
import { readdir } from "fs/promises";
|
|
808
|
+
import { join as join2 } from "path";
|
|
809
|
+
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
|
|
810
|
+
let result = content;
|
|
811
|
+
for (const [specifier, webPath] of replacements) {
|
|
812
|
+
const escaped = escapeRegex(specifier);
|
|
813
|
+
const fromRegex = new RegExp(`(from\\s*["'])${escaped}(["'])`, "g");
|
|
814
|
+
const sideEffectRegex = new RegExp(`(import\\s*["'])${escaped}(["'])`, "g");
|
|
815
|
+
const dynamicRegex = new RegExp(`(import\\s*\\(\\s*["'])${escaped}(["']\\s*\\))`, "g");
|
|
816
|
+
result = result.replace(fromRegex, `$1${webPath}$2`);
|
|
817
|
+
result = result.replace(sideEffectRegex, `$1${webPath}$2`);
|
|
818
|
+
result = result.replace(dynamicRegex, `$1${webPath}$2`);
|
|
819
|
+
}
|
|
820
|
+
return result;
|
|
821
|
+
}, rewriteImportsInContent = (content, vendorPaths) => {
|
|
822
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
823
|
+
return content;
|
|
824
|
+
const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
|
|
825
|
+
const native = nativeRewriteImports(content, replacements);
|
|
826
|
+
return native ?? jsRewriteImports(content, replacements);
|
|
827
|
+
}, fixMissingReExportNamespacesInContent = (content) => {
|
|
828
|
+
const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
|
|
829
|
+
REEXPORT_PATTERN.lastIndex = 0;
|
|
830
|
+
const missing = [];
|
|
831
|
+
let match;
|
|
832
|
+
while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
|
|
833
|
+
const ident = match[1];
|
|
834
|
+
if (!ident)
|
|
835
|
+
continue;
|
|
836
|
+
const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
|
|
837
|
+
if (nsImportRe.test(content))
|
|
838
|
+
continue;
|
|
839
|
+
const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
|
|
840
|
+
if (declRe.test(content))
|
|
841
|
+
continue;
|
|
842
|
+
const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
|
|
843
|
+
if (namedImportRe.test(content))
|
|
844
|
+
continue;
|
|
845
|
+
const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
|
|
846
|
+
let pathMatch;
|
|
847
|
+
let sourcePath;
|
|
848
|
+
while ((pathMatch = importPathRe.exec(content)) !== null) {
|
|
849
|
+
const p = pathMatch[1];
|
|
850
|
+
if (!p)
|
|
851
|
+
continue;
|
|
852
|
+
const base = p.split("/").pop()?.replace(/\.[mc]?js$/, "");
|
|
853
|
+
if (!base)
|
|
854
|
+
continue;
|
|
855
|
+
const normalized = base.startsWith("_") ? base.slice(1) : base;
|
|
856
|
+
if (normalized === ident || normalized.endsWith(`_${ident}`)) {
|
|
857
|
+
sourcePath = p;
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (sourcePath)
|
|
862
|
+
missing.push({ ident, path: sourcePath });
|
|
863
|
+
}
|
|
864
|
+
if (missing.length === 0)
|
|
865
|
+
return content;
|
|
866
|
+
const seen = new Set;
|
|
867
|
+
const unique = missing.filter((entry) => {
|
|
868
|
+
if (seen.has(entry.ident))
|
|
869
|
+
return false;
|
|
870
|
+
seen.add(entry.ident);
|
|
871
|
+
return true;
|
|
872
|
+
});
|
|
873
|
+
const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
|
|
874
|
+
`);
|
|
875
|
+
return `${inserts}
|
|
876
|
+
${content}`;
|
|
877
|
+
}, isReadableArtifact = (artifact) => artifact.path.endsWith(".js"), rewriteBuildOutputs = async (outputs, vendorPaths) => {
|
|
878
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
879
|
+
return;
|
|
880
|
+
await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
|
|
881
|
+
let original;
|
|
882
|
+
try {
|
|
883
|
+
original = await artifact.text();
|
|
884
|
+
} catch (err) {
|
|
885
|
+
const code = err.code;
|
|
886
|
+
if (code === "ENOENT")
|
|
887
|
+
return;
|
|
888
|
+
throw err;
|
|
889
|
+
}
|
|
890
|
+
const rewritten = rewriteImportsInContent(original, vendorPaths);
|
|
891
|
+
if (rewritten === original)
|
|
892
|
+
return;
|
|
893
|
+
try {
|
|
894
|
+
await Bun.write(artifact.path, rewritten);
|
|
895
|
+
} catch (err) {
|
|
896
|
+
const code = err.code;
|
|
897
|
+
if (code === "ENOENT")
|
|
898
|
+
return;
|
|
899
|
+
throw err;
|
|
900
|
+
}
|
|
901
|
+
}));
|
|
902
|
+
}, rewriteBuildOutputsWith = async (outputs, resolveVendorPaths) => {
|
|
903
|
+
await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
|
|
904
|
+
const vendorPaths = resolveVendorPaths(artifact);
|
|
905
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
906
|
+
return;
|
|
907
|
+
let original;
|
|
908
|
+
try {
|
|
909
|
+
original = await artifact.text();
|
|
910
|
+
} catch (err) {
|
|
911
|
+
const code = err.code;
|
|
912
|
+
if (code === "ENOENT")
|
|
913
|
+
return;
|
|
914
|
+
throw err;
|
|
915
|
+
}
|
|
916
|
+
const rewritten = rewriteImportsInContent(original, vendorPaths);
|
|
917
|
+
if (rewritten === original)
|
|
918
|
+
return;
|
|
919
|
+
try {
|
|
920
|
+
await Bun.write(artifact.path, rewritten);
|
|
921
|
+
} catch (err) {
|
|
922
|
+
const code = err.code;
|
|
923
|
+
if (code === "ENOENT")
|
|
924
|
+
return;
|
|
925
|
+
throw err;
|
|
926
|
+
}
|
|
927
|
+
}));
|
|
928
|
+
}, rewriteVendorDirectories = async (vendorDirs, vendorPaths) => {
|
|
929
|
+
if (Object.keys(vendorPaths).length === 0)
|
|
930
|
+
return;
|
|
931
|
+
const allFiles = [];
|
|
932
|
+
for (const dir of vendorDirs) {
|
|
933
|
+
try {
|
|
934
|
+
const entries = await readdir(dir);
|
|
935
|
+
for (const entry of entries) {
|
|
936
|
+
if (entry.endsWith(".js"))
|
|
937
|
+
allFiles.push(join2(dir, entry));
|
|
938
|
+
}
|
|
939
|
+
} catch {}
|
|
940
|
+
}
|
|
941
|
+
await Promise.all(allFiles.map(async (filePath) => {
|
|
942
|
+
let original;
|
|
943
|
+
try {
|
|
944
|
+
original = await Bun.file(filePath).text();
|
|
945
|
+
} catch (err) {
|
|
946
|
+
const code = err.code;
|
|
947
|
+
if (code === "ENOENT")
|
|
948
|
+
return;
|
|
949
|
+
throw err;
|
|
950
|
+
}
|
|
951
|
+
let next = rewriteImportsInContent(original, vendorPaths);
|
|
952
|
+
next = fixMissingReExportNamespacesInContent(next);
|
|
953
|
+
if (next === original)
|
|
954
|
+
return;
|
|
955
|
+
try {
|
|
956
|
+
await Bun.write(filePath, next);
|
|
957
|
+
} catch (err) {
|
|
958
|
+
const code = err.code;
|
|
959
|
+
if (code === "ENOENT")
|
|
960
|
+
return;
|
|
961
|
+
throw err;
|
|
962
|
+
}
|
|
963
|
+
}));
|
|
964
|
+
}, buildWithImportRewrite = async (pendingBuild, vendorPaths) => {
|
|
965
|
+
const result = await pendingBuild;
|
|
966
|
+
if (result.outputs.length > 0) {
|
|
967
|
+
await rewriteBuildOutputs(result.outputs, vendorPaths);
|
|
968
|
+
}
|
|
969
|
+
return result;
|
|
970
|
+
};
|
|
971
|
+
var init_rewriteImportsPlugin = __esm(() => {
|
|
972
|
+
init_nativeRewrite();
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
// src/core/angularServerModule.ts
|
|
976
|
+
import { mkdir } from "fs/promises";
|
|
977
|
+
import { dirname, join as join3, relative } from "path";
|
|
978
|
+
var serverCacheRoot, compiledModuleCache, ANGULAR_SPECIFIER_RE, getCachedModulePath = (sourcePath) => {
|
|
979
|
+
const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
980
|
+
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
981
|
+
return join3(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
982
|
+
}, collectVendorPaths = (code) => {
|
|
983
|
+
const vendorPaths = {};
|
|
984
|
+
if (!isProductionRuntime()) {
|
|
985
|
+
return vendorPaths;
|
|
986
|
+
}
|
|
987
|
+
const specifiers = new Set([...code.matchAll(ANGULAR_SPECIFIER_RE)].map((match) => match[1]));
|
|
988
|
+
specifiers.forEach((specifier) => {
|
|
989
|
+
if (!specifier)
|
|
990
|
+
return;
|
|
991
|
+
const resolved = resolveAngularRuntimePath(specifier);
|
|
992
|
+
if (resolved === specifier)
|
|
993
|
+
return;
|
|
994
|
+
vendorPaths[specifier] = resolved;
|
|
995
|
+
});
|
|
996
|
+
return vendorPaths;
|
|
997
|
+
}, buildAngularServerModule = async (sourcePath) => {
|
|
998
|
+
const result = await Bun.build({
|
|
999
|
+
entrypoints: [sourcePath],
|
|
1000
|
+
format: "esm",
|
|
1001
|
+
packages: "external",
|
|
1002
|
+
target: "bun",
|
|
1003
|
+
throw: false
|
|
1004
|
+
});
|
|
1005
|
+
const entry = result.outputs.find((output) => output.kind === "entry-point");
|
|
1006
|
+
if (!result.success || !entry) {
|
|
1007
|
+
const message = result.logs.map((log) => String(log)).join(`
|
|
1008
|
+
`);
|
|
1009
|
+
throw new Error(`Failed to compile Angular island server module for "${sourcePath}":
|
|
1010
|
+
${message}`);
|
|
1011
|
+
}
|
|
1012
|
+
const code = await entry.text();
|
|
1013
|
+
const rewritten = rewriteImportsInContent(code, collectVendorPaths(code));
|
|
1014
|
+
const modulePath = getCachedModulePath(sourcePath);
|
|
1015
|
+
await mkdir(dirname(modulePath), { recursive: true });
|
|
1016
|
+
await Bun.write(modulePath, rewritten);
|
|
1017
|
+
return modulePath;
|
|
1018
|
+
}, compileAngularServerModule = (sourcePath) => {
|
|
1019
|
+
const cached = compiledModuleCache.get(sourcePath);
|
|
1020
|
+
if (cached) {
|
|
1021
|
+
return cached;
|
|
1022
|
+
}
|
|
1023
|
+
const compiledModulePromise = buildAngularServerModule(sourcePath);
|
|
1024
|
+
compiledModuleCache.set(sourcePath, compiledModulePromise);
|
|
1025
|
+
return compiledModulePromise;
|
|
1026
|
+
};
|
|
1027
|
+
var init_angularServerModule = __esm(() => {
|
|
1028
|
+
init_resolveAngularPackage();
|
|
1029
|
+
init_rewriteImportsPlugin();
|
|
1030
|
+
serverCacheRoot = join3(process.cwd(), ".absolutejs", "islands", "angular");
|
|
1031
|
+
compiledModuleCache = new Map;
|
|
1032
|
+
ANGULAR_SPECIFIER_RE = /["'](@angular\/[^"']+)["']/g;
|
|
722
1033
|
});
|
|
723
1034
|
|
|
724
1035
|
// src/build/resolvePackageImport.ts
|
|
725
|
-
import { resolve as
|
|
1036
|
+
import { resolve as resolve3, join as join4 } from "path";
|
|
726
1037
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
727
1038
|
var resolveExportPath = (entry, conditions) => {
|
|
728
1039
|
if (typeof entry === "string")
|
|
@@ -744,11 +1055,11 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
744
1055
|
const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
745
1056
|
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
746
1057
|
const exportKey = subpath ? `./${subpath}` : ".";
|
|
747
|
-
const currentPackageJsonPath =
|
|
1058
|
+
const currentPackageJsonPath = resolve3(process.cwd(), "package.json");
|
|
748
1059
|
const currentPackageJson = existsSync2(currentPackageJsonPath) ? JSON.parse(readFileSync2(currentPackageJsonPath, "utf-8")) : null;
|
|
749
1060
|
const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
|
|
750
|
-
const packageDir = currentPackageDir ??
|
|
751
|
-
const packageJsonPath =
|
|
1061
|
+
const packageDir = currentPackageDir ?? resolve3(process.cwd(), "node_modules", packageName ?? "");
|
|
1062
|
+
const packageJsonPath = join4(packageDir, "package.json");
|
|
752
1063
|
if (!existsSync2(packageJsonPath))
|
|
753
1064
|
return null;
|
|
754
1065
|
try {
|
|
@@ -763,12 +1074,12 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
763
1074
|
if (!importPath)
|
|
764
1075
|
return null;
|
|
765
1076
|
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
766
|
-
const sourceCandidate =
|
|
1077
|
+
const sourceCandidate = resolve3(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
767
1078
|
if (existsSync2(sourceCandidate)) {
|
|
768
1079
|
return sourceCandidate;
|
|
769
1080
|
}
|
|
770
1081
|
}
|
|
771
|
-
const resolved =
|
|
1082
|
+
const resolved = resolve3(packageDir, importPath);
|
|
772
1083
|
return existsSync2(resolved) ? resolved : null;
|
|
773
1084
|
} catch {
|
|
774
1085
|
return null;
|
|
@@ -944,12 +1255,12 @@ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
|
944
1255
|
import { readFile } from "fs/promises";
|
|
945
1256
|
import { createRequire } from "module";
|
|
946
1257
|
import {
|
|
947
|
-
dirname,
|
|
1258
|
+
dirname as dirname2,
|
|
948
1259
|
extname,
|
|
949
1260
|
isAbsolute,
|
|
950
|
-
join as
|
|
951
|
-
relative,
|
|
952
|
-
resolve as
|
|
1261
|
+
join as join5,
|
|
1262
|
+
relative as relative2,
|
|
1263
|
+
resolve as resolve4
|
|
953
1264
|
} from "path";
|
|
954
1265
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
955
1266
|
var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
|
|
@@ -985,9 +1296,9 @@ ${message}`);
|
|
|
985
1296
|
return requireOptionalPeer(specifier);
|
|
986
1297
|
}
|
|
987
1298
|
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
988
|
-
|
|
1299
|
+
dirname2(filePath),
|
|
989
1300
|
process.cwd(),
|
|
990
|
-
...paths.map((path) =>
|
|
1301
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
991
1302
|
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
992
1303
|
pattern,
|
|
993
1304
|
replacements: Array.isArray(value) ? value : [value]
|
|
@@ -995,7 +1306,7 @@ ${message}`);
|
|
|
995
1306
|
const cwd = process.cwd();
|
|
996
1307
|
if (tsconfigAliasCache?.cwd === cwd)
|
|
997
1308
|
return tsconfigAliasCache;
|
|
998
|
-
const tsconfigPath =
|
|
1309
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
999
1310
|
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
1000
1311
|
if (!existsSync3(tsconfigPath)) {
|
|
1001
1312
|
tsconfigAliasCache = empty;
|
|
@@ -1004,7 +1315,7 @@ ${message}`);
|
|
|
1004
1315
|
try {
|
|
1005
1316
|
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
1006
1317
|
const compilerOptions = parsed.compilerOptions ?? {};
|
|
1007
|
-
const baseUrl =
|
|
1318
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
1008
1319
|
tsconfigAliasCache = {
|
|
1009
1320
|
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
1010
1321
|
baseUrl,
|
|
@@ -1032,7 +1343,7 @@ ${message}`);
|
|
|
1032
1343
|
continue;
|
|
1033
1344
|
const wildcard = match[1] ?? "";
|
|
1034
1345
|
for (const replacement of alias.replacements) {
|
|
1035
|
-
targets.push(
|
|
1346
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
1036
1347
|
}
|
|
1037
1348
|
}
|
|
1038
1349
|
return targets;
|
|
@@ -1046,21 +1357,21 @@ ${message}`);
|
|
|
1046
1357
|
const ext = extname(basePath);
|
|
1047
1358
|
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
1048
1359
|
`${basePath}${extension}`,
|
|
1049
|
-
|
|
1360
|
+
join5(basePath, `index${extension}`)
|
|
1050
1361
|
]);
|
|
1051
1362
|
if (language === "scss" || language === "sass") {
|
|
1052
1363
|
return paths.flatMap((path) => {
|
|
1053
|
-
const dir =
|
|
1364
|
+
const dir = dirname2(path);
|
|
1054
1365
|
const base = path.slice(dir.length + 1);
|
|
1055
|
-
return [path,
|
|
1366
|
+
return [path, join5(dir, `_${base}`)];
|
|
1056
1367
|
});
|
|
1057
1368
|
}
|
|
1058
1369
|
return paths;
|
|
1059
1370
|
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
1060
1371
|
const rawCandidates = [
|
|
1061
1372
|
...resolveAliasTargets(specifier, config),
|
|
1062
|
-
isAbsolute(specifier) ? specifier :
|
|
1063
|
-
...loadPaths.map((path) =>
|
|
1373
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
1374
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
1064
1375
|
];
|
|
1065
1376
|
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
1066
1377
|
if (existsSync3(candidate))
|
|
@@ -1076,8 +1387,8 @@ ${message}`);
|
|
|
1076
1387
|
path: url.slice(0, markerIndex)
|
|
1077
1388
|
};
|
|
1078
1389
|
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
1079
|
-
const sourceDir =
|
|
1080
|
-
const entryDir =
|
|
1390
|
+
const sourceDir = dirname2(sourceFile);
|
|
1391
|
+
const entryDir = dirname2(entryFile);
|
|
1081
1392
|
if (sourceDir === entryDir)
|
|
1082
1393
|
return contents;
|
|
1083
1394
|
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
@@ -1085,7 +1396,7 @@ ${message}`);
|
|
|
1085
1396
|
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
1086
1397
|
return match;
|
|
1087
1398
|
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
1088
|
-
const rebased =
|
|
1399
|
+
const rebased = relative2(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
1089
1400
|
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
1090
1401
|
const nextQuote = quote || '"';
|
|
1091
1402
|
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
@@ -1093,7 +1404,7 @@ ${message}`);
|
|
|
1093
1404
|
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
1094
1405
|
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
1095
1406
|
return match;
|
|
1096
|
-
const resolved = resolveImportPath(specifier,
|
|
1407
|
+
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
1097
1408
|
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
1098
1409
|
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
1099
1410
|
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
@@ -1123,7 +1434,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1123
1434
|
}
|
|
1124
1435
|
return mod;
|
|
1125
1436
|
}, loadPostcssConfigFile = async (configPath) => {
|
|
1126
|
-
const resolved =
|
|
1437
|
+
const resolved = resolve4(process.cwd(), configPath);
|
|
1127
1438
|
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
1128
1439
|
const config = normalizePostcssModule(loaded);
|
|
1129
1440
|
const value = typeof config === "function" ? await config({
|
|
@@ -1183,9 +1494,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1183
1494
|
return result.css;
|
|
1184
1495
|
}, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
|
|
1185
1496
|
canonicalize(specifier, options) {
|
|
1186
|
-
const fromDirectory = options.containingUrl ?
|
|
1497
|
+
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
1187
1498
|
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
1188
|
-
return resolved ? new URL(pathToFileURL(
|
|
1499
|
+
return resolved ? new URL(pathToFileURL(resolve4(resolved)).href) : null;
|
|
1189
1500
|
},
|
|
1190
1501
|
load(canonicalUrl) {
|
|
1191
1502
|
const filePath = fileURLToPath(canonicalUrl);
|
|
@@ -1202,9 +1513,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1202
1513
|
install(less, pluginManager) {
|
|
1203
1514
|
const baseManager = new less.FileManager;
|
|
1204
1515
|
const manager = Object.create(baseManager);
|
|
1205
|
-
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename,
|
|
1516
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
1206
1517
|
manager.loadFile = async (filename, currentDirectory) => {
|
|
1207
|
-
const resolved = resolveImportPath(filename,
|
|
1518
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
1208
1519
|
if (!resolved) {
|
|
1209
1520
|
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1210
1521
|
}
|
|
@@ -1241,29 +1552,29 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1241
1552
|
const stylusDeps = renderer.deps?.();
|
|
1242
1553
|
if (Array.isArray(stylusDeps)) {
|
|
1243
1554
|
for (const dep of stylusDeps)
|
|
1244
|
-
deps.add(
|
|
1555
|
+
deps.add(resolve4(dep));
|
|
1245
1556
|
}
|
|
1246
1557
|
}
|
|
1247
1558
|
resolveCss(css ?? "");
|
|
1248
1559
|
});
|
|
1249
1560
|
});
|
|
1250
1561
|
}, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
|
|
1251
|
-
const key =
|
|
1562
|
+
const key = resolve4(entry);
|
|
1252
1563
|
const stripped = new Set;
|
|
1253
1564
|
for (const dep of deps) {
|
|
1254
|
-
const resolved =
|
|
1565
|
+
const resolved = resolve4(dep);
|
|
1255
1566
|
if (resolved !== key)
|
|
1256
1567
|
stripped.add(resolved);
|
|
1257
1568
|
}
|
|
1258
1569
|
styleDependencyGraph.set(key, stripped);
|
|
1259
1570
|
}, addStyleImporter = (importerPath, stylePath) => {
|
|
1260
|
-
const key =
|
|
1261
|
-
const target =
|
|
1571
|
+
const key = resolve4(importerPath);
|
|
1572
|
+
const target = resolve4(stylePath);
|
|
1262
1573
|
const deps = styleDependencyGraph.get(key) ?? new Set;
|
|
1263
1574
|
deps.add(target);
|
|
1264
1575
|
styleDependencyGraph.set(key, deps);
|
|
1265
1576
|
}, findStyleEntriesImporting = (changedPath) => {
|
|
1266
|
-
const target =
|
|
1577
|
+
const target = resolve4(changedPath);
|
|
1267
1578
|
const importers = [];
|
|
1268
1579
|
for (const [entry, deps] of styleDependencyGraph) {
|
|
1269
1580
|
if (deps.has(target))
|
|
@@ -1271,13 +1582,13 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1271
1582
|
}
|
|
1272
1583
|
return importers;
|
|
1273
1584
|
}, recordStyleOutput = (entry, css) => {
|
|
1274
|
-
const key =
|
|
1585
|
+
const key = resolve4(entry);
|
|
1275
1586
|
const hash = createHash("sha1").update(css).digest("hex");
|
|
1276
1587
|
const previous = styleOutputHashes.get(key);
|
|
1277
1588
|
styleOutputHashes.set(key, hash);
|
|
1278
1589
|
return previous !== hash;
|
|
1279
1590
|
}, forgetStyleEntry = (entry) => {
|
|
1280
|
-
const key =
|
|
1591
|
+
const key = resolve4(entry);
|
|
1281
1592
|
styleDependencyGraph.delete(key);
|
|
1282
1593
|
styleOutputHashes.delete(key);
|
|
1283
1594
|
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
@@ -1303,7 +1614,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1303
1614
|
loadPaths,
|
|
1304
1615
|
style: "expanded",
|
|
1305
1616
|
syntax: language === "sass" ? "indented" : "scss",
|
|
1306
|
-
url: new URL(pathToFileURL(
|
|
1617
|
+
url: new URL(pathToFileURL(resolve4(filePath)).href)
|
|
1307
1618
|
});
|
|
1308
1619
|
const css = await runPostcss(result.css, filePath, config);
|
|
1309
1620
|
const loadedUrls = result.loadedUrls ?? [];
|
|
@@ -1311,7 +1622,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1311
1622
|
if (url.protocol !== "file:")
|
|
1312
1623
|
continue;
|
|
1313
1624
|
const dep = fileURLToPath(url);
|
|
1314
|
-
if (
|
|
1625
|
+
if (resolve4(dep) === resolve4(filePath))
|
|
1315
1626
|
continue;
|
|
1316
1627
|
deps.add(dep);
|
|
1317
1628
|
}
|
|
@@ -1432,7 +1743,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1432
1743
|
const start = match.index ?? 0;
|
|
1433
1744
|
const end = start + match[0].length;
|
|
1434
1745
|
parts.push(content.slice(cursor, start));
|
|
1435
|
-
const fullPath = isAbsolute(importPath) ? importPath :
|
|
1746
|
+
const fullPath = isAbsolute(importPath) ? importPath : resolve4(baseDir, importPath);
|
|
1436
1747
|
if (visited.has(fullPath) || !existsSync3(fullPath)) {
|
|
1437
1748
|
parts.push(visited.has(fullPath) ? "" : match[0]);
|
|
1438
1749
|
cursor = end;
|
|
@@ -1441,7 +1752,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1441
1752
|
const nextVisited = new Set(visited);
|
|
1442
1753
|
nextVisited.add(fullPath);
|
|
1443
1754
|
const imported = await readFile(fullPath, "utf-8");
|
|
1444
|
-
parts.push(await resolveCssImportsAsync(imported,
|
|
1755
|
+
parts.push(await resolveCssImportsAsync(imported, dirname2(fullPath), nextVisited));
|
|
1445
1756
|
cursor = end;
|
|
1446
1757
|
}
|
|
1447
1758
|
parts.push(content.slice(cursor));
|
|
@@ -1450,13 +1761,13 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1450
1761
|
if (!isPreprocessableStylePath(filePath)) {
|
|
1451
1762
|
const raw = await readFile(filePath, "utf-8");
|
|
1452
1763
|
const processed = await runPostcss(raw, filePath, config);
|
|
1453
|
-
return resolveCssImportsAsync(processed,
|
|
1764
|
+
return resolveCssImportsAsync(processed, dirname2(filePath), new Set([filePath]));
|
|
1454
1765
|
}
|
|
1455
1766
|
const compiled = await compileStyleSource(filePath, undefined, undefined, config);
|
|
1456
|
-
return resolveCssImportsAsync(compiled,
|
|
1767
|
+
return resolveCssImportsAsync(compiled, dirname2(filePath), new Set([filePath]));
|
|
1457
1768
|
}, resolveCssImportsSync = (content, baseDir, visited) => {
|
|
1458
1769
|
return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
|
|
1459
|
-
const fullPath = isAbsolute(importPath) ? importPath :
|
|
1770
|
+
const fullPath = isAbsolute(importPath) ? importPath : resolve4(baseDir, importPath);
|
|
1460
1771
|
if (visited.has(fullPath))
|
|
1461
1772
|
return "";
|
|
1462
1773
|
if (!existsSync3(fullPath))
|
|
@@ -1464,7 +1775,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1464
1775
|
const nextVisited = new Set(visited);
|
|
1465
1776
|
nextVisited.add(fullPath);
|
|
1466
1777
|
const imported = readFileSync3(fullPath, "utf-8");
|
|
1467
|
-
return resolveCssImportsSync(imported,
|
|
1778
|
+
return resolveCssImportsSync(imported, dirname2(fullPath), nextVisited);
|
|
1468
1779
|
});
|
|
1469
1780
|
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
1470
1781
|
const rawContents = readFileSync3(filePath, "utf-8");
|
|
@@ -1490,18 +1801,18 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1490
1801
|
loadPaths,
|
|
1491
1802
|
style: "expanded",
|
|
1492
1803
|
syntax: language === "sass" ? "indented" : "scss",
|
|
1493
|
-
url: new URL(pathToFileURL(
|
|
1804
|
+
url: new URL(pathToFileURL(resolve4(filePath)).href)
|
|
1494
1805
|
});
|
|
1495
1806
|
const loadedUrls = result.loadedUrls ?? [];
|
|
1496
1807
|
for (const url of loadedUrls) {
|
|
1497
1808
|
if (url.protocol !== "file:")
|
|
1498
1809
|
continue;
|
|
1499
1810
|
const dep = fileURLToPath(url);
|
|
1500
|
-
if (
|
|
1811
|
+
if (resolve4(dep) === resolve4(filePath))
|
|
1501
1812
|
continue;
|
|
1502
1813
|
addStyleImporter(filePath, dep);
|
|
1503
1814
|
}
|
|
1504
|
-
return resolveCssImportsSync(result.css,
|
|
1815
|
+
return resolveCssImportsSync(result.css, dirname2(filePath), new Set([filePath]));
|
|
1505
1816
|
}
|
|
1506
1817
|
if (language === "less") {
|
|
1507
1818
|
throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
@@ -1509,7 +1820,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1509
1820
|
if (language === "stylus") {
|
|
1510
1821
|
throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
1511
1822
|
}
|
|
1512
|
-
return resolveCssImportsSync(rawContents,
|
|
1823
|
+
return resolveCssImportsSync(rawContents, dirname2(filePath), new Set([filePath]));
|
|
1513
1824
|
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
1514
1825
|
var init_stylePreprocessor = __esm(() => {
|
|
1515
1826
|
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
@@ -1518,7 +1829,7 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
1518
1829
|
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1519
1830
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
1520
1831
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
1521
|
-
requireFromCwd = createRequire(
|
|
1832
|
+
requireFromCwd = createRequire(join5(process.cwd(), "package.json"));
|
|
1522
1833
|
styleDependencyGraph = new Map;
|
|
1523
1834
|
styleOutputHashes = new Map;
|
|
1524
1835
|
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
@@ -1526,14 +1837,14 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
1526
1837
|
});
|
|
1527
1838
|
|
|
1528
1839
|
// src/core/svelteServerModule.ts
|
|
1529
|
-
import { mkdir, readdir } from "fs/promises";
|
|
1530
|
-
import { basename, dirname as
|
|
1531
|
-
var
|
|
1532
|
-
const importPath =
|
|
1840
|
+
import { mkdir as mkdir2, readdir as readdir2 } from "fs/promises";
|
|
1841
|
+
import { basename, dirname as dirname3, extname as extname2, join as join6, relative as relative3, resolve as resolve5 } from "path";
|
|
1842
|
+
var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
1843
|
+
const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
|
|
1533
1844
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1534
1845
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
1535
1846
|
for (const entry of entries) {
|
|
1536
|
-
const entryPath =
|
|
1847
|
+
const entryPath = join6(dir, entry.name);
|
|
1537
1848
|
if (entry.isDirectory())
|
|
1538
1849
|
stack.push(entryPath);
|
|
1539
1850
|
if (entry.isFile() && entry.name === targetFileName) {
|
|
@@ -1547,7 +1858,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1547
1858
|
const nextStack = [];
|
|
1548
1859
|
const dirEntries = await Promise.all(dirs.map(async (dir) => ({
|
|
1549
1860
|
dir,
|
|
1550
|
-
entries: await
|
|
1861
|
+
entries: await readdir2(dir, {
|
|
1551
1862
|
encoding: "utf-8",
|
|
1552
1863
|
withFileTypes: true
|
|
1553
1864
|
})
|
|
@@ -1563,11 +1874,11 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1563
1874
|
if (cachedPath !== undefined) {
|
|
1564
1875
|
return cachedPath;
|
|
1565
1876
|
}
|
|
1566
|
-
if (!sourcePath.includes(`${
|
|
1877
|
+
if (!sourcePath.includes(`${join6(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
|
|
1567
1878
|
originalSourcePathCache.set(sourcePath, sourcePath);
|
|
1568
1879
|
return sourcePath;
|
|
1569
1880
|
}
|
|
1570
|
-
const resolvedSourcePath = await findSourceFileByBasename(
|
|
1881
|
+
const resolvedSourcePath = await findSourceFileByBasename(join6(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
|
|
1571
1882
|
const nextPath = resolvedSourcePath ?? sourcePath;
|
|
1572
1883
|
originalSourcePathCache.set(sourcePath, nextPath);
|
|
1573
1884
|
return nextPath;
|
|
@@ -1575,7 +1886,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1575
1886
|
if (!spec.startsWith(".")) {
|
|
1576
1887
|
return null;
|
|
1577
1888
|
}
|
|
1578
|
-
const basePath =
|
|
1889
|
+
const basePath = resolve5(dirname3(from), spec);
|
|
1579
1890
|
const candidates = [
|
|
1580
1891
|
basePath,
|
|
1581
1892
|
`${basePath}.ts`,
|
|
@@ -1583,19 +1894,19 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1583
1894
|
`${basePath}.mjs`,
|
|
1584
1895
|
`${basePath}.cjs`,
|
|
1585
1896
|
`${basePath}.json`,
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1897
|
+
join6(basePath, "index.ts"),
|
|
1898
|
+
join6(basePath, "index.js"),
|
|
1899
|
+
join6(basePath, "index.mjs"),
|
|
1900
|
+
join6(basePath, "index.cjs"),
|
|
1901
|
+
join6(basePath, "index.json")
|
|
1591
1902
|
];
|
|
1592
1903
|
const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
|
|
1593
1904
|
const foundIndex = existResults.indexOf(true);
|
|
1594
1905
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
1595
|
-
},
|
|
1596
|
-
const relativeSourcePath =
|
|
1906
|
+
}, getCachedModulePath2 = (sourcePath) => {
|
|
1907
|
+
const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1597
1908
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1598
|
-
return
|
|
1909
|
+
return join6(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
|
|
1599
1910
|
}, resolveSvelteImport = async (spec, from) => {
|
|
1600
1911
|
if (!spec.startsWith(".") && !spec.startsWith("/")) {
|
|
1601
1912
|
const resolved = resolvePackageImport(spec);
|
|
@@ -1607,7 +1918,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1607
1918
|
if (!spec.startsWith(".")) {
|
|
1608
1919
|
return null;
|
|
1609
1920
|
}
|
|
1610
|
-
const explicitPath =
|
|
1921
|
+
const explicitPath = resolve5(dirname3(from), spec);
|
|
1611
1922
|
if (extname2(explicitPath) === ".svelte") {
|
|
1612
1923
|
return explicitPath;
|
|
1613
1924
|
}
|
|
@@ -1627,7 +1938,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1627
1938
|
}
|
|
1628
1939
|
await Bun.write(path, content);
|
|
1629
1940
|
}, compileSvelteServerModule = async (sourcePath) => {
|
|
1630
|
-
const cachedModulePath =
|
|
1941
|
+
const cachedModulePath = compiledModuleCache2.get(sourcePath);
|
|
1631
1942
|
if (cachedModulePath) {
|
|
1632
1943
|
return cachedModulePath;
|
|
1633
1944
|
}
|
|
@@ -1666,7 +1977,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1666
1977
|
continue;
|
|
1667
1978
|
if (resolvedChildModules[index])
|
|
1668
1979
|
continue;
|
|
1669
|
-
rewrittenModulePaths.set(spec, ensureRelativeImportPath(
|
|
1980
|
+
rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), resolvedModuleImport));
|
|
1670
1981
|
}
|
|
1671
1982
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1672
1983
|
transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
|
|
@@ -1680,15 +1991,15 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1680
1991
|
generate: "server"
|
|
1681
1992
|
}).js.code;
|
|
1682
1993
|
for (const [spec, compiledChildPath] of childModulePaths) {
|
|
1683
|
-
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(
|
|
1994
|
+
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
|
|
1684
1995
|
}
|
|
1685
1996
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1686
1997
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
1687
1998
|
}
|
|
1688
|
-
const compiledModulePath =
|
|
1689
|
-
await
|
|
1999
|
+
const compiledModulePath = getCachedModulePath2(sourcePath);
|
|
2000
|
+
await mkdir2(dirname3(compiledModulePath), { recursive: true });
|
|
1690
2001
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
1691
|
-
|
|
2002
|
+
compiledModuleCache2.set(sourcePath, compiledModulePath);
|
|
1692
2003
|
return compiledModulePath;
|
|
1693
2004
|
};
|
|
1694
2005
|
var init_svelteServerModule = __esm(() => {
|
|
@@ -1696,8 +2007,8 @@ var init_svelteServerModule = __esm(() => {
|
|
|
1696
2007
|
init_lowerIslandSyntax();
|
|
1697
2008
|
init_lowerAwaitSlotSyntax();
|
|
1698
2009
|
init_stylePreprocessor();
|
|
1699
|
-
|
|
1700
|
-
|
|
2010
|
+
serverCacheRoot2 = join6(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
2011
|
+
compiledModuleCache2 = new Map;
|
|
1701
2012
|
originalSourcePathCache = new Map;
|
|
1702
2013
|
transpiler = new Bun.Transpiler({
|
|
1703
2014
|
loader: "ts",
|
|
@@ -1707,16 +2018,16 @@ var init_svelteServerModule = __esm(() => {
|
|
|
1707
2018
|
|
|
1708
2019
|
// src/core/vueServerModule.ts
|
|
1709
2020
|
import { existsSync as existsSync4, readFileSync as readFileSync4, realpathSync } from "fs";
|
|
1710
|
-
import { mkdir as
|
|
1711
|
-
import { dirname as
|
|
2021
|
+
import { mkdir as mkdir3 } from "fs/promises";
|
|
2022
|
+
import { dirname as dirname4, join as join7, relative as relative4, resolve as resolve6 } from "path";
|
|
1712
2023
|
var {Transpiler } = globalThis.Bun;
|
|
1713
|
-
var ISLAND_COMPONENT_ID_LENGTH = 8,
|
|
1714
|
-
const importPath =
|
|
2024
|
+
var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, transpiler2, ensureRelativeImportPath2 = (from, target) => {
|
|
2025
|
+
const importPath = relative4(dirname4(from), target).replace(/\\/g, "/");
|
|
1715
2026
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1716
|
-
},
|
|
1717
|
-
const relativeSourcePath =
|
|
2027
|
+
}, getCachedModulePath3 = (sourcePath) => {
|
|
2028
|
+
const relativeSourcePath = relative4(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1718
2029
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1719
|
-
return
|
|
2030
|
+
return join7(serverCacheRoot3, `${normalizedSourcePath}.server.js`);
|
|
1720
2031
|
}, writeIfChanged2 = async (path, content) => {
|
|
1721
2032
|
const targetFile = Bun.file(path);
|
|
1722
2033
|
if (await targetFile.exists()) {
|
|
@@ -1743,7 +2054,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
1743
2054
|
`) : nonVueLines.join(`
|
|
1744
2055
|
`);
|
|
1745
2056
|
}, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
|
|
1746
|
-
const cachedModulePath =
|
|
2057
|
+
const cachedModulePath = compiledModuleCache3.get(sourcePath);
|
|
1747
2058
|
if (cachedModulePath)
|
|
1748
2059
|
return cachedModulePath;
|
|
1749
2060
|
const compiler = await import("@vue/compiler-sfc");
|
|
@@ -1776,7 +2087,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
1776
2087
|
}).code : "const ssrRender = () => {};";
|
|
1777
2088
|
const childImportPaths = extractRelativeVueImports(compiledScript.content);
|
|
1778
2089
|
const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
|
|
1779
|
-
compiledPath: await compileVueServerModule(
|
|
2090
|
+
compiledPath: await compileVueServerModule(resolve6(dirname4(sourcePath), relativeImport)),
|
|
1780
2091
|
spec: relativeImport
|
|
1781
2092
|
})));
|
|
1782
2093
|
const strippedScript = stripExports(compiledScript.content);
|
|
@@ -1788,20 +2099,20 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
|
|
|
1788
2099
|
"export default script;"
|
|
1789
2100
|
].join(`
|
|
1790
2101
|
`));
|
|
1791
|
-
const compiledModulePath =
|
|
2102
|
+
const compiledModulePath = getCachedModulePath3(sourcePath);
|
|
1792
2103
|
let rewritten = assembled;
|
|
1793
2104
|
for (const child of compiledChildren) {
|
|
1794
2105
|
rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
|
|
1795
2106
|
}
|
|
1796
|
-
await
|
|
2107
|
+
await mkdir3(dirname4(compiledModulePath), { recursive: true });
|
|
1797
2108
|
await writeIfChanged2(compiledModulePath, rewritten);
|
|
1798
|
-
|
|
2109
|
+
compiledModuleCache3.set(sourcePath, compiledModulePath);
|
|
1799
2110
|
return compiledModulePath;
|
|
1800
2111
|
};
|
|
1801
2112
|
var init_vueServerModule = __esm(() => {
|
|
1802
2113
|
init_constants();
|
|
1803
|
-
|
|
1804
|
-
|
|
2114
|
+
serverCacheRoot3 = join7(process.cwd(), ".absolutejs", "islands", "vue");
|
|
2115
|
+
compiledModuleCache3 = new Map;
|
|
1805
2116
|
transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
|
|
1806
2117
|
});
|
|
1807
2118
|
|
|
@@ -1896,8 +2207,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
1896
2207
|
throw new Error("Resolved Vue island is not a valid Vue component.");
|
|
1897
2208
|
}
|
|
1898
2209
|
return resolvedComponent;
|
|
2210
|
+
}, loadAngularServerBuildComponent = async (buildReferencePath, exportName) => {
|
|
2211
|
+
const serverModulePath = await compileAngularServerModule(buildReferencePath);
|
|
2212
|
+
const loadedModule = await import(serverModulePath);
|
|
2213
|
+
if (exportName && exportName !== "default" && exportName in loadedModule) {
|
|
2214
|
+
return loadedModule[exportName];
|
|
2215
|
+
}
|
|
2216
|
+
return "default" in loadedModule ? loadedModule.default : loadedModule;
|
|
1899
2217
|
}, resolveAngularServerIslandComponent = async (component) => {
|
|
1900
|
-
const
|
|
2218
|
+
const buildReference = getIslandBuildReference(component);
|
|
2219
|
+
const buildReferencePath = buildReference?.source ? resolveBuildReferencePath(buildReference.source, import.meta.url) : null;
|
|
2220
|
+
const resolvedComponent = buildReferencePath ? await loadAngularServerBuildComponent(buildReferencePath, buildReference?.export) : await resolveServerIslandComponent(component);
|
|
1901
2221
|
if (!isAngularServerIslandComponent(resolvedComponent)) {
|
|
1902
2222
|
throw new Error("Resolved Angular island is not a valid Angular component.");
|
|
1903
2223
|
}
|
|
@@ -1953,6 +2273,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
1953
2273
|
};
|
|
1954
2274
|
var init_renderIslandMarkup = __esm(() => {
|
|
1955
2275
|
init_islandSsr();
|
|
2276
|
+
init_angularServerModule();
|
|
1956
2277
|
init_svelteServerModule();
|
|
1957
2278
|
init_vueServerModule();
|
|
1958
2279
|
init_islandMarkupAttributes();
|
|
@@ -2083,5 +2404,5 @@ export {
|
|
|
2083
2404
|
createIslandStore
|
|
2084
2405
|
};
|
|
2085
2406
|
|
|
2086
|
-
//# debugId=
|
|
2407
|
+
//# debugId=402D3FC3BBA2047F64756E2164756E21
|
|
2087
2408
|
//# sourceMappingURL=index.js.map
|