@analogjs/vite-plugin-angular 3.0.0-alpha.52 → 3.0.0-alpha.54

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/vite-plugin-angular",
3
- "version": "3.0.0-alpha.52",
3
+ "version": "3.0.0-alpha.54",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -587,6 +587,15 @@ function angular(options) {
587
587
  }
588
588
  if (isComponentStyleSheet(id)) {
589
589
  const filename = getFilenameFromPath(id);
590
+ const search = new URL(id, "http://localhost").search;
591
+ const servedSourcePath = stylesheetRegistry?.getServedSourcePath(filename);
592
+ if (servedSourcePath) {
593
+ debugStylesV("resolveId: mapped served stylesheet to source", {
594
+ filename,
595
+ resolvedPath: servedSourcePath
596
+ });
597
+ return servedSourcePath + search;
598
+ }
590
599
  if (stylesheetRegistry?.hasServed(filename)) {
591
600
  debugStylesV("resolveId: kept preprocessed ID", { filename });
592
601
  return id;
@@ -618,8 +627,8 @@ function angular(options) {
618
627
  debugHmrV("stylesheet active request registered", {
619
628
  requestId: id,
620
629
  filename,
621
- sourcePath: stylesheetRegistry?.resolveExternalSource(filename) ?? stylesheetRegistry?.resolveExternalSource(filename.replace(/^\//, "")),
622
- trackedRequestIds: stylesheetRegistry?.getRequestIdsForSource(stylesheetRegistry?.resolveExternalSource(filename) ?? stylesheetRegistry?.resolveExternalSource(filename.replace(/^\//, "")) ?? "") ?? []
630
+ sourcePath: stylesheetRegistry?.resolveExternalSource(filename) ?? stylesheetRegistry?.resolveExternalSource(filename.replace(/^\//, "")) ?? stylesheetRegistry?.getServedSourcePath(filename) ?? stylesheetRegistry?.getServedSourcePath(filename.replace(/^\//, "")),
631
+ trackedRequestIds: stylesheetRegistry?.getRequestIdsForSource(stylesheetRegistry?.resolveExternalSource(filename) ?? stylesheetRegistry?.resolveExternalSource(filename.replace(/^\//, "")) ?? stylesheetRegistry?.getServedSourcePath(filename) ?? stylesheetRegistry?.getServedSourcePath(filename.replace(/^\//, "")) ?? "") ?? []
623
632
  });
624
633
  debugStylesV("load: served inline component stylesheet", {
625
634
  filename,
@@ -731,9 +740,10 @@ function angular(options) {
731
740
  data = patched;
732
741
  }
733
742
  }
743
+ if (typescriptResult.map) data = data.replace(/\s*\/\/# sourceMappingURL=[^\r\n]*\s*$/, "");
734
744
  return {
735
745
  code: data,
736
- map: null
746
+ map: typescriptResult.map ?? null
737
747
  };
738
748
  }
739
749
  },
@@ -791,7 +801,7 @@ function angular(options) {
791
801
  classNames,
792
802
  fileEmitter
793
803
  }),
794
- ...isTest && !isStackBlitz ? angularVitestPlugins() : [],
804
+ ...isTest && !isStackBlitz ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map) : [],
795
805
  jit && jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),
796
806
  buildOptimizerPlugin({
797
807
  supportedBrowsers: pluginOptions.supportedBrowsers,
@@ -913,8 +923,18 @@ function angular(options) {
913
923
  if (!sourceFiles?.length) return;
914
924
  const filename = normalizePath(sourceFiles[0].fileName);
915
925
  if (filename.includes("ngtypecheck.ts") || filename.includes(".d.")) return;
926
+ if (/\.[cm]?js\.map$/.test(_filename)) {
927
+ const existing = outputFiles.get(filename);
928
+ outputFiles.set(filename, {
929
+ ...existing ?? { dependencies: [] },
930
+ map: content
931
+ });
932
+ return;
933
+ }
916
934
  const metadata = watchMode ? fileMetadata(filename) : {};
935
+ const existing = outputFiles.get(filename);
917
936
  outputFiles.set(filename, {
937
+ ...existing ?? {},
918
938
  content,
919
939
  dependencies: [],
920
940
  errors: metadata.errors,
@@ -935,8 +955,14 @@ function angular(options) {
935
955
  const sourceFile = builder.getSourceFile(id);
936
956
  if (!sourceFile) return;
937
957
  let content = "";
958
+ let map;
959
+ let mapFilename;
938
960
  builder.emit(sourceFile, (filename, data) => {
939
961
  if (/\.[cm]?js$/.test(filename)) content = data;
962
+ if (/\.[cm]?js\.map$/.test(filename)) {
963
+ map = data;
964
+ mapFilename = filename;
965
+ }
940
966
  if (!watchMode && !isTest && /\.d\.ts/.test(filename) && !filename.includes(".ngtypecheck.")) {
941
967
  const declarationPath = resolve(config.root, config.build.outDir, relative(config.root, filename)).replace("/src/", "/");
942
968
  const declarationFileDir = declarationPath.replace(basename(filename), "").replace("/src/", "/");
@@ -948,6 +974,7 @@ function angular(options) {
948
974
  }
949
975
  }, void 0, void 0, transformers);
950
976
  writeFileCallback(id, content, false, void 0, [sourceFile]);
977
+ if (map !== void 0 && mapFilename !== void 0) writeFileCallback(mapFilename, map, false, void 0, [sourceFile]);
951
978
  if (angularCompiler) angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
952
979
  };
953
980
  if (watchMode) {
@@ -974,14 +1001,14 @@ function isModuleForChangedResource(mod, changedFile, stylesheetRegistry) {
974
1001
  if (normalizePath((mod.file ?? "").split("?")[0]) === normalizedChangedFile) return true;
975
1002
  if (!mod.id) return false;
976
1003
  const requestPath = getFilenameFromPath(mod.id);
977
- return normalizePath((stylesheetRegistry?.resolveExternalSource(requestPath) ?? stylesheetRegistry?.resolveExternalSource(requestPath.replace(/^\//, "")) ?? "").split("?")[0]) === normalizedChangedFile;
1004
+ return normalizePath((stylesheetRegistry?.resolveExternalSource(requestPath) ?? stylesheetRegistry?.resolveExternalSource(requestPath.replace(/^\//, "")) ?? stylesheetRegistry?.getServedSourcePath(requestPath) ?? stylesheetRegistry?.getServedSourcePath(requestPath.replace(/^\//, "")) ?? "").split("?")[0]) === normalizedChangedFile;
978
1005
  }
979
1006
  function diagnoseComponentStylesheetPipeline(changedFile, directModule, stylesheetRegistry, wrapperModules, stylePreprocessor) {
980
1007
  const normalizedFile = normalizePath(changedFile.split("?")[0]);
981
1008
  const sourceExists = existsSync(normalizedFile);
982
1009
  const sourceCode = sourceExists ? readFileSync(normalizedFile, "utf-8") : void 0;
983
1010
  const directRequestPath = directModule.id ? getFilenameFromPath(directModule.id) : void 0;
984
- const sourcePath = directRequestPath ? stylesheetRegistry?.resolveExternalSource(directRequestPath) ?? stylesheetRegistry?.resolveExternalSource(directRequestPath.replace(/^\//, "")) : normalizedFile;
1011
+ const sourcePath = directRequestPath ? stylesheetRegistry?.resolveExternalSource(directRequestPath) ?? stylesheetRegistry?.resolveExternalSource(directRequestPath.replace(/^\//, "")) ?? stylesheetRegistry?.getServedSourcePath(directRequestPath) ?? stylesheetRegistry?.getServedSourcePath(directRequestPath.replace(/^\//, "")) : normalizedFile;
985
1012
  const registryCode = directRequestPath ? stylesheetRegistry?.getServedContent(directRequestPath) : void 0;
986
1013
  const trackedRequestIds = stylesheetRegistry?.getRequestIdsForSource(sourcePath ?? "") ?? [];
987
1014
  const dependencies = stylesheetRegistry?.getDependenciesForSource(sourcePath ?? "") ?? [];
@@ -1040,7 +1067,7 @@ async function findComponentStylesheetWrapperModules(server, changedFile, direct
1040
1067
  if (directModule.id) directRequestIds.add(directModule.id);
1041
1068
  if (directModule.url) directRequestIds.add(directModule.url);
1042
1069
  const requestPath = directModule.id ? getFilenameFromPath(directModule.id) : void 0;
1043
- const sourcePath = requestPath ? stylesheetRegistry?.resolveExternalSource(requestPath) ?? stylesheetRegistry?.resolveExternalSource(requestPath.replace(/^\//, "")) : void 0;
1070
+ const sourcePath = requestPath ? stylesheetRegistry?.resolveExternalSource(requestPath) ?? stylesheetRegistry?.resolveExternalSource(requestPath.replace(/^\//, "")) ?? stylesheetRegistry?.getServedSourcePath(requestPath) ?? stylesheetRegistry?.getServedSourcePath(requestPath.replace(/^\//, "")) : void 0;
1044
1071
  for (const requestId of stylesheetRegistry?.getRequestIdsForSource(sourcePath ?? "") ?? []) if (requestId.includes("?ngcomp=")) directRequestIds.add(requestId);
1045
1072
  const candidateWrapperIds = [...directRequestIds].filter((id) => id.includes("?direct&ngcomp=")).map((id) => id.replace("?direct&ngcomp=", "?ngcomp="));
1046
1073
  const lookupHits = [];