@absolutejs/absolute 0.19.0-beta.980 → 0.19.0-beta.982

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
@@ -11740,6 +11740,10 @@ var init_emitAngularRouteMounts = __esm(() => {
11740
11740
  });
11741
11741
 
11742
11742
  // src/build/parseAngularConfigImports.ts
11743
+ var exports_parseAngularConfigImports = {};
11744
+ __export(exports_parseAngularConfigImports, {
11745
+ parseAngularProvidersImport: () => parseAngularProvidersImport
11746
+ });
11743
11747
  import { existsSync as existsSync19, readFileSync as readFileSync12 } from "fs";
11744
11748
  import { dirname as dirname12, isAbsolute as isAbsolute3, join as join24 } from "path";
11745
11749
  import ts6 from "typescript";
@@ -14923,7 +14927,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
14923
14927
  }
14924
14928
  }
14925
14929
  return allOutputs;
14926
- }, compileAngular = async (entryPoints, outRoot, hmr = false, stylePreprocessors) => {
14930
+ }, compileAngular = async (entryPoints, outRoot, hmr = false, stylePreprocessors, providersInjection) => {
14927
14931
  const compiledParent = getFrameworkGeneratedDir("angular");
14928
14932
  if (entryPoints.length === 0) {
14929
14933
  const emptyPaths = [];
@@ -15038,25 +15042,40 @@ export default ${componentClassName};
15038
15042
  export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
15039
15043
  `;
15040
15044
  }
15041
- const providersServerPath = join29(compiledParent, "providers", `${toPascal(fileBase)}.providers.js`);
15042
- if (existsSync22(providersServerPath)) {
15043
- const rel = relative12(dirname16(rawServerFile), providersServerPath).replace(/\\/g, "/");
15044
- const specifier = rel.startsWith(".") ? rel : `./${rel}`;
15045
+ const pageInjection = providersInjection?.pagesByFile.get(resolvedEntry);
15046
+ if (providersInjection && pageInjection) {
15047
+ const compiledAppProvidersPath = (() => {
15048
+ const angularDirAbs = resolve22(outRoot);
15049
+ const appSourceAbs = resolve22(providersInjection.appProvidersSource);
15050
+ const rel = relative12(angularDirAbs, appSourceAbs).replace(/\\/g, "/");
15051
+ return join29(compiledParent, rel).replace(/\.[cm]?[tj]sx?$/, ".js");
15052
+ })();
15053
+ const appProvidersSpec = (() => {
15054
+ const rel = relative12(dirname16(rawServerFile), compiledAppProvidersPath).replace(/\\/g, "/");
15055
+ return rel.startsWith(".") ? rel : `./${rel}`;
15056
+ })();
15057
+ const importLines = [
15058
+ `import { appProviders as __abs_globalProviders } from "${appProvidersSpec}";`
15059
+ ];
15060
+ const fragments = ["...__abs_globalProviders"];
15061
+ if (pageInjection.hasRoutes) {
15062
+ importLines.push(`import { provideRouter as __abs_provideRouter, withComponentInputBinding as __abs_withComponentInputBinding, withViewTransitions as __abs_withViewTransitions } from "@angular/router";`);
15063
+ fragments.push("__abs_provideRouter(routes, __abs_withComponentInputBinding(), __abs_withViewTransitions())");
15064
+ }
15065
+ if (pageInjection.basePath !== null) {
15066
+ importLines.push(`import { APP_BASE_HREF as __abs_APP_BASE_HREF } from "@angular/common";`);
15067
+ fragments.push(`{ provide: __abs_APP_BASE_HREF, useValue: ${JSON.stringify(pageInjection.basePath)} }`);
15068
+ }
15045
15069
  rewritten += `
15046
- export { providers } from "${specifier}";
15070
+ ${importLines.join(`
15071
+ `)}
15072
+ export const providers = [${fragments.join(", ")}];
15047
15073
  `;
15048
15074
  }
15049
15075
  await traceAngularPhase("wrapper/write-server-output", () => fs5.writeFile(rawServerFile, rewritten, "utf-8"), { entry: resolvedEntry });
15050
15076
  const relativePath = relative12(indexesDir, rawServerFile).replace(/\\/g, "/");
15051
15077
  const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
15052
- const manifestKeyForProviders = toPascal(fileBase);
15053
- const providersServerFilePath = join29(compiledParent, "providers", `${manifestKeyForProviders}.providers.js`);
15054
- const hasGeneratedProviders = existsSync22(providersServerFilePath);
15055
- const providersImportPath = hasGeneratedProviders ? (() => {
15056
- const rel = relative12(indexesDir, providersServerFilePath.replace(/\.js$/, "")).replace(/\\/g, "/");
15057
- return rel.startsWith(".") ? rel : `./${rel}`;
15058
- })() : null;
15059
- const generatedProvidersImport = providersImportPath ? `import { providers as generatedProviders } from '${providersImportPath}';` : "var generatedProviders = null;";
15078
+ const generatedProvidersImport = "var generatedProviders = null;";
15060
15079
  const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
15061
15080
  import "${hmrClientPath5}";
15062
15081
  ` : "";
@@ -20119,12 +20138,42 @@ ${content.slice(firstUseIdx)}`;
20119
20138
  const shouldCompileIslandSvelte = svelteDir && islandSvelteSources.length > 0;
20120
20139
  const shouldCompileIslandVue = vueDir && islandVueSources.length > 0;
20121
20140
  const shouldCompileIslandAngular = angularDir && islandAngularSources.length > 0;
20122
- let angularProvidersFilesToCompile = [];
20141
+ let angularProvidersInjection = undefined;
20142
+ let angularAppProvidersSource = undefined;
20123
20143
  if (shouldCompileAngular && angularDir) {
20124
20144
  await tracePhase("scan/angular-handlers", async () => {
20125
20145
  const { runAngularHandlerScan: runAngularHandlerScan2 } = await Promise.resolve().then(() => (init_runAngularHandlerScan(), exports_runAngularHandlerScan));
20146
+ const { parseAngularProvidersImport: parseAngularProvidersImport2 } = await Promise.resolve().then(() => (init_parseAngularConfigImports(), exports_parseAngularConfigImports));
20126
20147
  const scanResult = runAngularHandlerScan2(projectRoot, angularDir);
20127
- angularProvidersFilesToCompile = scanResult.providersFiles.map((file4) => file4.outputPath);
20148
+ const providersImport = parseAngularProvidersImport2(projectRoot);
20149
+ if (providersImport) {
20150
+ angularAppProvidersSource = providersImport.absolutePath;
20151
+ const pagesByFile = new Map;
20152
+ const basePathByKey = new Map;
20153
+ for (const call of scanResult.calls) {
20154
+ basePathByKey.set(call.manifestKey, call.mountPath?.endsWith("/*") ? call.mountPath.slice(0, -1) : null);
20155
+ }
20156
+ for (const route of scanResult.pageRoutes) {
20157
+ const basePath = basePathByKey.get(route.manifestKey) ?? null;
20158
+ const normalizedBase = basePath === "/" ? null : basePath;
20159
+ pagesByFile.set(route.pageFile, {
20160
+ basePath: normalizedBase,
20161
+ hasRoutes: route.hasRoutes
20162
+ });
20163
+ }
20164
+ for (const route of scanResult.pageRoutes) {
20165
+ if (pagesByFile.has(route.pageFile))
20166
+ continue;
20167
+ pagesByFile.set(route.pageFile, {
20168
+ basePath: null,
20169
+ hasRoutes: route.hasRoutes
20170
+ });
20171
+ }
20172
+ angularProvidersInjection = {
20173
+ appProvidersSource: providersImport.absolutePath,
20174
+ pagesByFile
20175
+ };
20176
+ }
20128
20177
  });
20129
20178
  }
20130
20179
  const [
@@ -20149,12 +20198,12 @@ ${content.slice(firstUseIdx)}`;
20149
20198
  },
20150
20199
  shouldCompileAngular ? tracePhase("compile/angular", async () => {
20151
20200
  const mod = await Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular));
20152
- if (angularProvidersFilesToCompile.length > 0 && angularDir) {
20201
+ if (angularAppProvidersSource && angularDir) {
20153
20202
  const { getFrameworkGeneratedDir: getFrameworkGeneratedDir2 } = await Promise.resolve().then(() => (init_generatedDir(), exports_generatedDir));
20154
20203
  const compiledRoot = getFrameworkGeneratedDir2("angular", projectRoot);
20155
- await Promise.all(angularProvidersFilesToCompile.map((entry) => mod.compileAngularFileJIT(entry, compiledRoot, angularDir, styleTransformConfig)));
20204
+ await mod.compileAngularFileJIT(angularAppProvidersSource, compiledRoot, angularDir, styleTransformConfig);
20156
20205
  }
20157
- const result = await mod.compileAngular(angularEntries, angularDir, hmr, styleTransformConfig);
20206
+ const result = await mod.compileAngular(angularEntries, angularDir, hmr, styleTransformConfig, angularProvidersInjection);
20158
20207
  if (hmr) {
20159
20208
  try {
20160
20209
  const { primeComponentFingerprint: primeComponentFingerprint2 } = await Promise.resolve().then(() => (init_fastHmrCompiler(), exports_fastHmrCompiler));
@@ -26987,5 +27036,5 @@ export {
26987
27036
  build
26988
27037
  };
26989
27038
 
26990
- //# debugId=32466C8808563DDC64756E2164756E21
27039
+ //# debugId=AEC7C75119C41EB064756E2164756E21
26991
27040
  //# sourceMappingURL=build.js.map