@absolutejs/absolute 0.19.0-beta.21 → 0.19.0-beta.23

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/build.js CHANGED
@@ -203730,6 +203730,144 @@ var init_rebuildTrigger = __esm(() => {
203730
203730
  init_pageHandler();
203731
203731
  });
203732
203732
 
203733
+ // src/build/buildDepVendor.ts
203734
+ var exports_buildDepVendor = {};
203735
+ __export(exports_buildDepVendor, {
203736
+ computeDepVendorPaths: () => computeDepVendorPaths,
203737
+ buildDepVendor: () => buildDepVendor
203738
+ });
203739
+ import { mkdirSync as mkdirSync7 } from "fs";
203740
+ import { join as join14 } from "path";
203741
+ import { rm as rm7 } from "fs/promises";
203742
+ var {build: bunBuild5, Glob: Glob6 } = globalThis.Bun;
203743
+ var toSafeFileName3 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g, "").replace(/-/g, "_"), isResolvable2 = (specifier) => {
203744
+ try {
203745
+ __require.resolve(specifier);
203746
+ return true;
203747
+ } catch {
203748
+ return false;
203749
+ }
203750
+ }, isBareSpecifier = (spec) => !spec.startsWith(".") && !spec.startsWith("/") && !spec.startsWith("@src/"), FRAMEWORK_SPECIFIERS, scanBareImports = async (directories) => {
203751
+ const specifiers = new Set;
203752
+ const transpiler3 = new Bun.Transpiler({ loader: "tsx" });
203753
+ for (const dir of directories) {
203754
+ const glob = new Glob6("**/*.{ts,tsx,js,jsx}");
203755
+ try {
203756
+ for await (const file3 of glob.scan({
203757
+ absolute: true,
203758
+ cwd: dir
203759
+ })) {
203760
+ if (file3.includes("node_modules"))
203761
+ continue;
203762
+ if (file3.includes("/build/"))
203763
+ continue;
203764
+ if (file3.includes("/dist/"))
203765
+ continue;
203766
+ if (file3.includes("/indexes/"))
203767
+ continue;
203768
+ try {
203769
+ const content = await Bun.file(file3).text();
203770
+ const imports = transpiler3.scanImports(content);
203771
+ for (const imp of imports) {
203772
+ if (isBareSpecifier(imp.path) && !FRAMEWORK_SPECIFIERS.has(imp.path)) {
203773
+ specifiers.add(imp.path);
203774
+ }
203775
+ }
203776
+ } catch {}
203777
+ }
203778
+ } catch {}
203779
+ }
203780
+ return Array.from(specifiers).filter(isResolvable2);
203781
+ }, generateEntrySource2 = async (specifier) => {
203782
+ try {
203783
+ const mod = await import(specifier);
203784
+ const exportNames = Object.keys(mod).filter((key) => key !== "default" && key !== "__esModule");
203785
+ const lines = [];
203786
+ if (exportNames.length > 0) {
203787
+ lines.push(`export { ${exportNames.join(", ")} } from '${specifier}';`);
203788
+ }
203789
+ if ("default" in mod && mod.default !== undefined && mod.default !== mod) {
203790
+ lines.push(`export { default } from '${specifier}';`);
203791
+ }
203792
+ if (lines.length === 0) {
203793
+ return `export * from '${specifier}';
203794
+ `;
203795
+ }
203796
+ return lines.join(`
203797
+ `) + `
203798
+ `;
203799
+ } catch {
203800
+ return `export * from '${specifier}';
203801
+ `;
203802
+ }
203803
+ }, computeDepVendorPaths = async (directories) => {
203804
+ const specifiers = await scanBareImports(directories);
203805
+ const paths = {};
203806
+ for (const specifier of specifiers) {
203807
+ paths[specifier] = `/vendor/${toSafeFileName3(specifier)}.js`;
203808
+ }
203809
+ return paths;
203810
+ }, buildDepVendor = async (buildDir, directories) => {
203811
+ const specifiers = await scanBareImports(directories);
203812
+ if (specifiers.length === 0)
203813
+ return {};
203814
+ const vendorDir = join14(buildDir, "vendor");
203815
+ mkdirSync7(vendorDir, { recursive: true });
203816
+ const tmpDir = join14(buildDir, "_dep_vendor_tmp");
203817
+ mkdirSync7(tmpDir, { recursive: true });
203818
+ const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
203819
+ const safeName = toSafeFileName3(specifier);
203820
+ const entryPath = join14(tmpDir, `${safeName}.ts`);
203821
+ const source = await generateEntrySource2(specifier);
203822
+ await Bun.write(entryPath, source);
203823
+ return entryPath;
203824
+ }));
203825
+ const result = await bunBuild5({
203826
+ entrypoints,
203827
+ format: "esm",
203828
+ minify: false,
203829
+ naming: "[name].[ext]",
203830
+ outdir: vendorDir,
203831
+ splitting: true,
203832
+ target: "browser",
203833
+ throw: false
203834
+ });
203835
+ await rm7(tmpDir, { force: true, recursive: true });
203836
+ if (!result.success) {
203837
+ console.warn("\u26A0\uFE0F Dependency vendor build had errors:", result.logs);
203838
+ }
203839
+ const paths = {};
203840
+ for (const specifier of specifiers) {
203841
+ paths[specifier] = `/vendor/${toSafeFileName3(specifier)}.js`;
203842
+ }
203843
+ return paths;
203844
+ };
203845
+ var init_buildDepVendor = __esm(() => {
203846
+ FRAMEWORK_SPECIFIERS = new Set([
203847
+ "react",
203848
+ "react-dom",
203849
+ "react-dom/client",
203850
+ "react-dom/server",
203851
+ "react/jsx-runtime",
203852
+ "react/jsx-dev-runtime",
203853
+ "react-refresh/runtime",
203854
+ "svelte",
203855
+ "svelte/internal",
203856
+ "svelte/internal/client",
203857
+ "svelte/server",
203858
+ "svelte/compiler",
203859
+ "vue",
203860
+ "vue/server-renderer",
203861
+ "@vue/compiler-sfc",
203862
+ "@angular/core",
203863
+ "@angular/common",
203864
+ "@angular/compiler",
203865
+ "@angular/platform-browser",
203866
+ "@angular/platform-server",
203867
+ "@angular/ssr"
203868
+ ]);
203869
+ });
203870
+
203733
203871
  // src/core/devBuild.ts
203734
203872
  var exports_devBuild = {};
203735
203873
  __export(exports_devBuild, {
@@ -203911,7 +204049,26 @@ var FRAMEWORK_DIR_KEYS, parseDirectoryConfig = (source) => {
203911
204049
  await loadVendorFiles(state.assetStore, vendorDir, "angular");
203912
204050
  return true;
203913
204051
  }) : undefined;
203914
- await Promise.all([buildReactVendorTask, buildAngularVendorTask]);
204052
+ const { buildDepVendor: buildDepVendor2 } = await Promise.resolve().then(() => (init_buildDepVendor(), exports_buildDepVendor));
204053
+ const sourceDirs = [
204054
+ config.reactDirectory,
204055
+ config.svelteDirectory,
204056
+ config.vueDirectory,
204057
+ config.angularDirectory,
204058
+ config.htmlDirectory,
204059
+ config.htmxDirectory
204060
+ ].filter((dir) => Boolean(dir));
204061
+ const buildDepVendorTask = buildDepVendor2(state.resolvedPaths.buildDir, sourceDirs).then(async (depPaths) => {
204062
+ const vendorDir = resolve20(state.resolvedPaths.buildDir, "vendor");
204063
+ await loadVendorFiles(state.assetStore, vendorDir, "vendor");
204064
+ globalThis.__depVendorPaths = depPaths;
204065
+ return true;
204066
+ });
204067
+ await Promise.all([
204068
+ buildReactVendorTask,
204069
+ buildAngularVendorTask,
204070
+ buildDepVendorTask
204071
+ ]);
203915
204072
  state.manifest = manifest;
203916
204073
  startFileWatching(state, config, (filePath) => {
203917
204074
  queueFileChange(state, filePath, config, (newBuildResult) => {
@@ -203958,5 +204115,5 @@ export {
203958
204115
  build
203959
204116
  };
203960
204117
 
203961
- //# debugId=D87CB1075218965664756E2164756E21
204118
+ //# debugId=DDD7C25E28893A1364756E2164756E21
203962
204119
  //# sourceMappingURL=build.js.map