@analogjs/vite-plugin-angular 3.0.0-alpha.9 → 3.0.0-alpha.91
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/README.md +121 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
- package/migrations/migration.json +7 -1
- package/migrations/migrations.json +9 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
- package/package.json +49 -8
- package/src/index.d.ts +7 -2
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.d.ts +78 -0
- package/src/lib/analog-plugin-interop.js +97 -0
- package/src/lib/analog-plugin-interop.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +8 -4
- package/src/lib/angular-build-optimizer-plugin.js +66 -31
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +3 -3
- package/src/lib/angular-jit-plugin.js +28 -6
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
- package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +79 -69
- package/src/lib/angular-vite-plugin.js +775 -352
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +26 -21
- package/src/lib/angular-vitest-plugin.js +34 -25
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +24 -0
- package/src/lib/compilation-api/compilation-api-plugin.js +548 -0
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
- package/src/lib/compilation-api/index.d.ts +1 -0
- package/src/lib/compilation-api/index.js +1 -0
- package/src/lib/compiler/angular-version.d.ts +19 -0
- package/src/lib/compiler/angular-version.js +31 -0
- package/src/lib/compiler/angular-version.js.map +1 -0
- package/src/lib/compiler/class-field-lowering.d.ts +23 -0
- package/src/lib/compiler/class-field-lowering.js +131 -0
- package/src/lib/compiler/class-field-lowering.js.map +1 -0
- package/src/lib/compiler/compile.d.ts +50 -0
- package/src/lib/compiler/compile.js +814 -0
- package/src/lib/compiler/compile.js.map +1 -0
- package/src/lib/compiler/constants.d.ts +24 -0
- package/src/lib/compiler/constants.js +59 -0
- package/src/lib/compiler/constants.js.map +1 -0
- package/src/lib/compiler/debug.d.ts +22 -0
- package/src/lib/compiler/debug.js +20 -0
- package/src/lib/compiler/debug.js.map +1 -0
- package/src/lib/compiler/defer.d.ts +57 -0
- package/src/lib/compiler/defer.js +154 -0
- package/src/lib/compiler/defer.js.map +1 -0
- package/src/lib/compiler/dts-reader.d.ts +45 -0
- package/src/lib/compiler/dts-reader.js +395 -0
- package/src/lib/compiler/dts-reader.js.map +1 -0
- package/src/lib/compiler/hmr.d.ts +16 -0
- package/src/lib/compiler/hmr.js +69 -0
- package/src/lib/compiler/hmr.js.map +1 -0
- package/src/lib/compiler/index.d.ts +8 -0
- package/src/lib/compiler/index.js +8 -0
- package/src/lib/compiler/jit-metadata.d.ts +14 -0
- package/src/lib/compiler/jit-metadata.js +168 -0
- package/src/lib/compiler/jit-metadata.js.map +1 -0
- package/src/lib/compiler/jit-transform.d.ts +24 -0
- package/src/lib/compiler/jit-transform.js +204 -0
- package/src/lib/compiler/jit-transform.js.map +1 -0
- package/src/lib/compiler/js-emitter.d.ts +10 -0
- package/src/lib/compiler/js-emitter.js +446 -0
- package/src/lib/compiler/js-emitter.js.map +1 -0
- package/src/lib/compiler/metadata.d.ts +36 -0
- package/src/lib/compiler/metadata.js +710 -0
- package/src/lib/compiler/metadata.js.map +1 -0
- package/src/lib/compiler/registry.d.ts +56 -0
- package/src/lib/compiler/registry.js +176 -0
- package/src/lib/compiler/registry.js.map +1 -0
- package/src/lib/compiler/resource-inliner.d.ts +43 -0
- package/src/lib/compiler/resource-inliner.js +230 -0
- package/src/lib/compiler/resource-inliner.js.map +1 -0
- package/src/lib/compiler/style-ast.d.ts +9 -0
- package/src/lib/compiler/style-ast.js +54 -0
- package/src/lib/compiler/style-ast.js.map +1 -0
- package/src/lib/compiler/styles.d.ts +13 -0
- package/src/lib/compiler/test-helpers.d.ts +7 -0
- package/src/lib/compiler/type-elision.d.ts +28 -0
- package/src/lib/compiler/type-elision.js +211 -0
- package/src/lib/compiler/type-elision.js.map +1 -0
- package/src/lib/compiler/utils.d.ts +40 -0
- package/src/lib/compiler/utils.js +76 -0
- package/src/lib/compiler/utils.js.map +1 -0
- package/src/lib/compiler-plugin.d.ts +13 -12
- package/src/lib/compiler-plugin.js +18 -18
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +20 -4
- package/src/lib/component-resolvers.js +34 -20
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/encapsulation-plugin.d.ts +23 -0
- package/src/lib/encapsulation-plugin.js +68 -0
- package/src/lib/encapsulation-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +23 -0
- package/src/lib/fast-compile-plugin.js +434 -0
- package/src/lib/fast-compile-plugin.js.map +1 -0
- package/src/lib/host.d.ts +10 -8
- package/src/lib/host.js +59 -17
- package/src/lib/host.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +5 -5
- package/src/lib/live-reload-plugin.js +10 -0
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/models.d.ts +9 -9
- package/src/lib/nx-folder-plugin.d.ts +5 -5
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
- package/src/lib/plugins/file-replacements.plugin.js +6 -1
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +1 -1
- package/src/lib/router-plugin.js +14 -2
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-preprocessor.d.ts +35 -0
- package/src/lib/style-preprocessor.js +35 -0
- package/src/lib/style-preprocessor.js.map +1 -0
- package/src/lib/stylesheet-registry.d.ts +74 -0
- package/src/lib/stylesheet-registry.js +174 -0
- package/src/lib/stylesheet-registry.js.map +1 -0
- package/src/lib/tools/package.json +1 -3
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +7 -5
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +16 -19
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/utils/compilation-shared.d.ts +62 -0
- package/src/lib/utils/compilation-shared.js +138 -0
- package/src/lib/utils/compilation-shared.js.map +1 -0
- package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
- package/src/lib/utils/css-extension-resolver.d.ts +32 -0
- package/src/lib/utils/css-extension-resolver.js +73 -0
- package/src/lib/utils/css-extension-resolver.js.map +1 -0
- package/src/lib/utils/css-preprocessor-workers.d.ts +6 -0
- package/src/lib/utils/css-preprocessor-workers.js +29 -0
- package/src/lib/utils/css-preprocessor-workers.js.map +1 -0
- package/src/lib/utils/debug-harness.d.ts +23 -0
- package/src/lib/utils/debug-harness.js +88 -0
- package/src/lib/utils/debug-harness.js.map +1 -0
- package/src/lib/utils/debug-log-file.d.ts +5 -0
- package/src/lib/utils/debug-log-file.js +56 -0
- package/src/lib/utils/debug-log-file.js.map +1 -0
- package/src/lib/utils/debug.d.ts +26 -0
- package/src/lib/utils/debug.js +35 -0
- package/src/lib/utils/debug.js.map +1 -0
- package/src/lib/utils/devkit.d.ts +14 -6
- package/src/lib/utils/devkit.js +40 -2
- package/src/lib/utils/devkit.js.map +1 -1
- package/src/lib/utils/hmr-candidates.d.ts +28 -28
- package/src/lib/utils/jit-inline-styles.d.ts +3 -0
- package/src/lib/utils/jit-inline-styles.js +16 -0
- package/src/lib/utils/jit-inline-styles.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +41 -0
- package/src/lib/utils/plugin-config.js +85 -0
- package/src/lib/utils/plugin-config.js.map +1 -0
- package/src/lib/utils/rolldown.d.ts +1 -1
- package/src/lib/utils/rolldown.js.map +1 -1
- package/src/lib/utils/safe-module-paths.d.ts +16 -0
- package/src/lib/utils/safe-module-paths.js +29 -0
- package/src/lib/utils/safe-module-paths.js.map +1 -0
- package/src/lib/utils/source-file-cache.d.ts +8 -15
- package/src/lib/utils/source-file-cache.js.map +1 -1
- package/src/lib/utils/transform-cache.d.ts +43 -0
- package/src/lib/utils/transform-cache.js +97 -0
- package/src/lib/utils/transform-cache.js.map +1 -0
- package/src/lib/utils/tsconfig-resolver.d.ts +34 -0
- package/src/lib/utils/tsconfig-resolver.js +205 -0
- package/src/lib/utils/tsconfig-resolver.js.map +1 -0
- package/src/lib/utils/virtual-ids.d.ts +4 -0
- package/src/lib/utils/virtual-ids.js +23 -0
- package/src/lib/utils/virtual-ids.js.map +1 -0
- package/src/lib/utils/virtual-resources.d.ts +19 -0
- package/src/lib/utils/virtual-resources.js +38 -0
- package/src/lib/utils/virtual-resources.js.map +1 -0
- package/src/lib/virtual-modules-plugin.d.ts +5 -0
- package/src/lib/virtual-modules-plugin.js +23 -0
- package/src/lib/virtual-modules-plugin.js.map +1 -0
- package/src/test-setup.d.ts +2 -0
- package/setup-vitest.d.ts +0 -4
- package/setup-vitest.js +0 -176
- package/setup-vitest.js.map +0 -1
- package/src/lib/tools/src/index.d.ts +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Debugger } from "obug";
|
|
2
|
+
export type DebugMode = "build" | "dev";
|
|
3
|
+
export interface DebugModeOptions<S extends string = string> {
|
|
4
|
+
scopes?: boolean | S[];
|
|
5
|
+
mode?: DebugMode;
|
|
6
|
+
/**
|
|
7
|
+
* Write debug output to log files under `tmp/debug/` in the workspace root.
|
|
8
|
+
* - `true` or `'single'` — all output to `tmp/debug/analog.log`
|
|
9
|
+
* - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`
|
|
10
|
+
*/
|
|
11
|
+
logFile?: boolean | "single" | "scoped";
|
|
12
|
+
}
|
|
13
|
+
export type DebugOption<S extends string = string> = boolean | S[] | DebugModeOptions<S> | DebugModeOptions<S>[];
|
|
14
|
+
export interface DebugHarness<S extends string = string> {
|
|
15
|
+
applyDebugOption(debug: DebugOption<S> | undefined, workspaceRoot?: string): void;
|
|
16
|
+
activateDeferredDebug(command: "build" | "serve"): void;
|
|
17
|
+
/** @internal test-only reset */
|
|
18
|
+
_resetDeferredDebug(): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function createDebugHarness<S extends string = string>(config: {
|
|
21
|
+
fallbackNamespace: string;
|
|
22
|
+
instanceGroups: Debugger[][];
|
|
23
|
+
}): DebugHarness<S>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog } from "./debug-log-file.js";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { enable } from "obug";
|
|
4
|
+
//#region packages/vite-plugin-angular/src/lib/utils/debug-harness.ts
|
|
5
|
+
/**
|
|
6
|
+
* Duplicates of this file (keep in sync):
|
|
7
|
+
* packages/platform/src/lib/utils/debug-harness.ts
|
|
8
|
+
* packages/vite-plugin-angular/src/lib/utils/debug-harness.ts
|
|
9
|
+
*/
|
|
10
|
+
function resolveNamespaces(scopes, fallback) {
|
|
11
|
+
if (scopes === true || scopes === void 0) return fallback;
|
|
12
|
+
if (Array.isArray(scopes) && scopes.length) return scopes.join(",");
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function extractLogFile(debug) {
|
|
16
|
+
if (typeof debug === "boolean") return false;
|
|
17
|
+
if (Array.isArray(debug)) {
|
|
18
|
+
if (debug.length === 0 || typeof debug[0] === "string") return false;
|
|
19
|
+
return debug.find((e) => !!e.logFile)?.logFile ?? false;
|
|
20
|
+
}
|
|
21
|
+
return debug.logFile ?? false;
|
|
22
|
+
}
|
|
23
|
+
function createDebugHarness(config) {
|
|
24
|
+
let pendingDebug = [];
|
|
25
|
+
function installFileWrappers(logFile, root) {
|
|
26
|
+
if (logFile === "scoped") {
|
|
27
|
+
const dirPath = join(root, DEBUG_LOG_DIR);
|
|
28
|
+
for (const group of config.instanceGroups) wrapInstancesForScopedFileLog(group, dirPath);
|
|
29
|
+
} else {
|
|
30
|
+
const filePath = join(root, DEBUG_LOG_DIR, DEBUG_LOG_FILENAME);
|
|
31
|
+
for (const group of config.instanceGroups) wrapInstancesForFileLog(group, filePath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function applyEntry(entry, fallback, logFile, root) {
|
|
35
|
+
if (!entry.mode) {
|
|
36
|
+
const ns = resolveNamespaces(entry.scopes ?? true, fallback);
|
|
37
|
+
if (ns) enable(ns);
|
|
38
|
+
if (logFile) installFileWrappers(logFile, root);
|
|
39
|
+
} else pendingDebug.push({
|
|
40
|
+
entry,
|
|
41
|
+
logFile,
|
|
42
|
+
root
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
applyDebugOption(debug, workspaceRoot) {
|
|
47
|
+
if (debug == null || debug === false) return;
|
|
48
|
+
const logFile = extractLogFile(debug);
|
|
49
|
+
const root = workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd();
|
|
50
|
+
if (typeof debug === "boolean") {
|
|
51
|
+
const ns = resolveNamespaces(debug, config.fallbackNamespace);
|
|
52
|
+
if (ns) enable(ns);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(debug)) {
|
|
56
|
+
if (debug.length === 0) return;
|
|
57
|
+
if (typeof debug[0] === "string") {
|
|
58
|
+
const ns = debug.join(",");
|
|
59
|
+
if (ns) enable(ns);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
for (const entry of debug) {
|
|
63
|
+
const entryLogFile = entry.logFile ?? false;
|
|
64
|
+
applyEntry(entry, config.fallbackNamespace, entryLogFile || logFile, root);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
applyEntry(debug, config.fallbackNamespace, logFile, root);
|
|
69
|
+
},
|
|
70
|
+
activateDeferredDebug(command) {
|
|
71
|
+
if (pendingDebug.length === 0) return;
|
|
72
|
+
const currentMode = command === "serve" ? "dev" : "build";
|
|
73
|
+
for (const { entry, logFile, root } of pendingDebug) if (entry.mode === currentMode) {
|
|
74
|
+
const ns = resolveNamespaces(entry.scopes ?? true, config.fallbackNamespace);
|
|
75
|
+
if (ns) enable(ns);
|
|
76
|
+
if (logFile) installFileWrappers(logFile, root);
|
|
77
|
+
}
|
|
78
|
+
pendingDebug = [];
|
|
79
|
+
},
|
|
80
|
+
_resetDeferredDebug() {
|
|
81
|
+
pendingDebug = [];
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { createDebugHarness };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=debug-harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-harness.js","names":[],"sources":["../../../../src/lib/utils/debug-harness.ts"],"sourcesContent":["/**\n * Duplicates of this file (keep in sync):\n * packages/platform/src/lib/utils/debug-harness.ts\n * packages/vite-plugin-angular/src/lib/utils/debug-harness.ts\n */\nimport { join } from 'node:path';\nimport { enable } from 'obug';\nimport type { Debugger } from 'obug';\n\nimport {\n DEBUG_LOG_DIR,\n DEBUG_LOG_FILENAME,\n wrapInstancesForFileLog,\n wrapInstancesForScopedFileLog,\n} from './debug-log-file.js';\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions<S extends string = string> {\n scopes?: boolean | S[];\n mode?: DebugMode;\n /**\n * Write debug output to log files under `tmp/debug/` in the workspace root.\n * - `true` or `'single'` — all output to `tmp/debug/analog.log`\n * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`\n */\n logFile?: boolean | 'single' | 'scoped';\n}\n\nexport type DebugOption<S extends string = string> =\n | boolean\n | S[]\n | DebugModeOptions<S>\n | DebugModeOptions<S>[];\n\nexport interface DebugHarness<S extends string = string> {\n applyDebugOption(\n debug: DebugOption<S> | undefined,\n workspaceRoot?: string,\n ): void;\n activateDeferredDebug(command: 'build' | 'serve'): void;\n /** @internal test-only reset */\n _resetDeferredDebug(): void;\n}\n\nfunction resolveNamespaces(\n scopes: boolean | string[] | undefined,\n fallback: string,\n): string | null {\n if (scopes === true || scopes === undefined) return fallback;\n if (Array.isArray(scopes) && scopes.length) return scopes.join(',');\n return null;\n}\n\nfunction extractLogFile(\n debug: DebugOption,\n): true | 'single' | 'scoped' | false {\n if (typeof debug === 'boolean') return false;\n if (Array.isArray(debug)) {\n if (debug.length === 0 || typeof debug[0] === 'string') return false;\n const entry = (debug as DebugModeOptions[]).find((e) => !!e.logFile);\n return entry?.logFile ?? false;\n }\n return (debug as DebugModeOptions).logFile ?? false;\n}\n\nexport function createDebugHarness<S extends string = string>(config: {\n fallbackNamespace: string;\n instanceGroups: Debugger[][];\n}): DebugHarness<S> {\n interface PendingEntry {\n entry: DebugModeOptions<S>;\n logFile: true | 'single' | 'scoped' | false;\n root: string;\n }\n\n let pendingDebug: PendingEntry[] = [];\n\n function installFileWrappers(\n logFile: true | 'single' | 'scoped',\n root: string,\n ): void {\n if (logFile === 'scoped') {\n const dirPath = join(root, DEBUG_LOG_DIR);\n for (const group of config.instanceGroups) {\n wrapInstancesForScopedFileLog(group, dirPath);\n }\n } else {\n const filePath = join(root, DEBUG_LOG_DIR, DEBUG_LOG_FILENAME);\n for (const group of config.instanceGroups) {\n wrapInstancesForFileLog(group, filePath);\n }\n }\n }\n\n function applyEntry(\n entry: DebugModeOptions<S>,\n fallback: string,\n logFile: true | 'single' | 'scoped' | false,\n root: string,\n ): void {\n if (!entry.mode) {\n const ns = resolveNamespaces(entry.scopes ?? true, fallback);\n if (ns) enable(ns);\n if (logFile) installFileWrappers(logFile, root);\n } else {\n pendingDebug.push({ entry, logFile, root });\n }\n }\n\n return {\n applyDebugOption(\n debug: DebugOption<S> | undefined,\n workspaceRoot?: string,\n ): void {\n if (debug == null || debug === false) return;\n\n const logFile = extractLogFile(debug);\n const root =\n workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd();\n\n if (typeof debug === 'boolean') {\n const ns = resolveNamespaces(debug, config.fallbackNamespace);\n if (ns) enable(ns);\n return;\n }\n\n if (Array.isArray(debug)) {\n if (debug.length === 0) return;\n\n if (typeof debug[0] === 'string') {\n const ns = (debug as string[]).join(',');\n if (ns) enable(ns);\n return;\n }\n\n for (const entry of debug as DebugModeOptions<S>[]) {\n const entryLogFile = entry.logFile ?? false;\n applyEntry(\n entry,\n config.fallbackNamespace,\n entryLogFile || logFile,\n root,\n );\n }\n return;\n }\n\n applyEntry(debug, config.fallbackNamespace, logFile, root);\n },\n\n activateDeferredDebug(command: 'build' | 'serve'): void {\n if (pendingDebug.length === 0) return;\n\n const currentMode = command === 'serve' ? 'dev' : 'build';\n\n for (const { entry, logFile, root } of pendingDebug) {\n if (entry.mode === currentMode) {\n const ns = resolveNamespaces(\n entry.scopes ?? true,\n config.fallbackNamespace,\n );\n if (ns) enable(ns);\n if (logFile) installFileWrappers(logFile, root);\n }\n }\n\n pendingDebug = [];\n },\n\n _resetDeferredDebug(): void {\n pendingDebug = [];\n },\n };\n}\n"],"mappings":";;;;;;;;;AA6CA,SAAS,kBACP,QACA,UACe;AACf,KAAI,WAAW,QAAQ,WAAW,KAAA,EAAW,QAAO;AACpD,KAAI,MAAM,QAAQ,OAAO,IAAI,OAAO,OAAQ,QAAO,OAAO,KAAK,IAAI;AACnE,QAAO;;AAGT,SAAS,eACP,OACoC;AACpC,KAAI,OAAO,UAAU,UAAW,QAAO;AACvC,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,MAAI,MAAM,WAAW,KAAK,OAAO,MAAM,OAAO,SAAU,QAAO;AAE/D,SADe,MAA6B,MAAM,MAAM,CAAC,CAAC,EAAE,QAAQ,EACtD,WAAW;;AAE3B,QAAQ,MAA2B,WAAW;;AAGhD,SAAgB,mBAA8C,QAG1C;CAOlB,IAAI,eAA+B,EAAE;CAErC,SAAS,oBACP,SACA,MACM;AACN,MAAI,YAAY,UAAU;GACxB,MAAM,UAAU,KAAK,MAAM,cAAc;AACzC,QAAK,MAAM,SAAS,OAAO,eACzB,+BAA8B,OAAO,QAAQ;SAE1C;GACL,MAAM,WAAW,KAAK,MAAM,eAAe,mBAAmB;AAC9D,QAAK,MAAM,SAAS,OAAO,eACzB,yBAAwB,OAAO,SAAS;;;CAK9C,SAAS,WACP,OACA,UACA,SACA,MACM;AACN,MAAI,CAAC,MAAM,MAAM;GACf,MAAM,KAAK,kBAAkB,MAAM,UAAU,MAAM,SAAS;AAC5D,OAAI,GAAI,QAAO,GAAG;AAClB,OAAI,QAAS,qBAAoB,SAAS,KAAK;QAE/C,cAAa,KAAK;GAAE;GAAO;GAAS;GAAM,CAAC;;AAI/C,QAAO;EACL,iBACE,OACA,eACM;AACN,OAAI,SAAS,QAAQ,UAAU,MAAO;GAEtC,MAAM,UAAU,eAAe,MAAM;GACrC,MAAM,OACJ,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK;AAEpE,OAAI,OAAO,UAAU,WAAW;IAC9B,MAAM,KAAK,kBAAkB,OAAO,OAAO,kBAAkB;AAC7D,QAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,OAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,QAAI,MAAM,WAAW,EAAG;AAExB,QAAI,OAAO,MAAM,OAAO,UAAU;KAChC,MAAM,KAAM,MAAmB,KAAK,IAAI;AACxC,SAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,SAAK,MAAM,SAAS,OAAgC;KAClD,MAAM,eAAe,MAAM,WAAW;AACtC,gBACE,OACA,OAAO,mBACP,gBAAgB,SAChB,KACD;;AAEH;;AAGF,cAAW,OAAO,OAAO,mBAAmB,SAAS,KAAK;;EAG5D,sBAAsB,SAAkC;AACtD,OAAI,aAAa,WAAW,EAAG;GAE/B,MAAM,cAAc,YAAY,UAAU,QAAQ;AAElD,QAAK,MAAM,EAAE,OAAO,SAAS,UAAU,aACrC,KAAI,MAAM,SAAS,aAAa;IAC9B,MAAM,KAAK,kBACT,MAAM,UAAU,MAChB,OAAO,kBACR;AACD,QAAI,GAAI,QAAO,GAAG;AAClB,QAAI,QAAS,qBAAoB,SAAS,KAAK;;AAInD,kBAAe,EAAE;;EAGnB,sBAA4B;AAC1B,kBAAe,EAAE;;EAEpB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Debugger } from "obug";
|
|
2
|
+
export declare const DEBUG_LOG_DIR = "tmp/debug";
|
|
3
|
+
export declare const DEBUG_LOG_FILENAME = "analog.log";
|
|
4
|
+
export declare function wrapInstancesForFileLog(instances: Debugger[], filePath: string): void;
|
|
5
|
+
export declare function wrapInstancesForScopedFileLog(instances: Debugger[], dirPath: string): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { format } from "node:util";
|
|
4
|
+
//#region packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts
|
|
5
|
+
/**
|
|
6
|
+
* Duplicates of this file (keep in sync):
|
|
7
|
+
* packages/platform/src/lib/utils/debug-log-file.ts
|
|
8
|
+
* packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts
|
|
9
|
+
*/
|
|
10
|
+
var TRUNCATED_KEY = "__analogDebugLogTruncated";
|
|
11
|
+
var WRAPPED_KEY = "__analogFileLogWrapped";
|
|
12
|
+
var ANSI_RE = /\x1B\[[0-9;]*[A-Za-z]|\x1B\].*?\x07/g;
|
|
13
|
+
var DEBUG_LOG_DIR = "tmp/debug";
|
|
14
|
+
var DEBUG_LOG_FILENAME = "analog.log";
|
|
15
|
+
function ensureTruncated(filePath) {
|
|
16
|
+
const g = globalThis;
|
|
17
|
+
const truncated = g[TRUNCATED_KEY] ?? /* @__PURE__ */ new Set();
|
|
18
|
+
g[TRUNCATED_KEY] = truncated;
|
|
19
|
+
if (truncated.has(filePath)) return;
|
|
20
|
+
try {
|
|
21
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
22
|
+
writeFileSync(filePath, "", "utf-8");
|
|
23
|
+
} catch {}
|
|
24
|
+
truncated.add(filePath);
|
|
25
|
+
}
|
|
26
|
+
function wrapLog(dbg, filePath) {
|
|
27
|
+
const rec = dbg;
|
|
28
|
+
if (rec[WRAPPED_KEY] === filePath) return;
|
|
29
|
+
const originalLog = rec[WRAPPED_KEY] && rec["__analogOriginalLog"] ? rec["__analogOriginalLog"] : dbg.log;
|
|
30
|
+
rec["__analogOriginalLog"] = originalLog;
|
|
31
|
+
dbg.log = function(...args) {
|
|
32
|
+
originalLog.apply(this, args);
|
|
33
|
+
try {
|
|
34
|
+
appendFileSync(filePath, format(...args).replace(ANSI_RE, "") + "\n", "utf-8");
|
|
35
|
+
} catch {}
|
|
36
|
+
};
|
|
37
|
+
rec[WRAPPED_KEY] = filePath;
|
|
38
|
+
}
|
|
39
|
+
function wrapInstancesForFileLog(instances, filePath) {
|
|
40
|
+
ensureTruncated(filePath);
|
|
41
|
+
for (const dbg of instances) wrapLog(dbg, filePath);
|
|
42
|
+
}
|
|
43
|
+
function scopeToFilename(namespace) {
|
|
44
|
+
return namespace.replace(/:/g, ".") + ".log";
|
|
45
|
+
}
|
|
46
|
+
function wrapInstancesForScopedFileLog(instances, dirPath) {
|
|
47
|
+
for (const dbg of instances) {
|
|
48
|
+
const scopedPath = join(dirPath, scopeToFilename(dbg.namespace));
|
|
49
|
+
ensureTruncated(scopedPath);
|
|
50
|
+
wrapLog(dbg, scopedPath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=debug-log-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-log-file.js","names":[],"sources":["../../../../src/lib/utils/debug-log-file.ts"],"sourcesContent":["/**\n * Duplicates of this file (keep in sync):\n * packages/platform/src/lib/utils/debug-log-file.ts\n * packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts\n */\nimport { mkdirSync, writeFileSync, appendFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { format } from 'node:util';\nimport type { Debugger } from 'obug';\n\nconst TRUNCATED_KEY = '__analogDebugLogTruncated';\nconst WRAPPED_KEY = '__analogFileLogWrapped';\n// eslint-disable-next-line no-control-regex\nconst ANSI_RE = /\\x1B\\[[0-9;]*[A-Za-z]|\\x1B\\].*?\\x07/g;\n\nexport const DEBUG_LOG_DIR = 'tmp/debug';\nexport const DEBUG_LOG_FILENAME = 'analog.log';\n\nfunction ensureTruncated(filePath: string): void {\n const g = globalThis as Record<string, unknown>;\n const truncated = (g[TRUNCATED_KEY] as Set<string>) ?? new Set<string>();\n g[TRUNCATED_KEY] = truncated;\n if (truncated.has(filePath)) return;\n try {\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, '', 'utf-8');\n } catch {\n // best-effort: fall through to append mode if truncation fails\n }\n truncated.add(filePath);\n}\n\nfunction wrapLog(dbg: Debugger, filePath: string): void {\n const rec = dbg as Record<string, unknown>;\n if (rec[WRAPPED_KEY] === filePath) return;\n\n const originalLog =\n rec[WRAPPED_KEY] && rec['__analogOriginalLog']\n ? (rec['__analogOriginalLog'] as Debugger['log'])\n : dbg.log;\n\n rec['__analogOriginalLog'] = originalLog;\n dbg.log = function (this: Debugger, ...args: unknown[]) {\n originalLog.apply(this, args);\n try {\n const line = format(...args).replace(ANSI_RE, '') + '\\n';\n appendFileSync(filePath, line, 'utf-8');\n } catch {\n // debug logging must never crash the build\n }\n };\n rec[WRAPPED_KEY] = filePath;\n}\n\nexport function wrapInstancesForFileLog(\n instances: Debugger[],\n filePath: string,\n): void {\n ensureTruncated(filePath);\n for (const dbg of instances) {\n wrapLog(dbg, filePath);\n }\n}\n\nfunction scopeToFilename(namespace: string): string {\n return namespace.replace(/:/g, '.') + '.log';\n}\n\nexport function wrapInstancesForScopedFileLog(\n instances: Debugger[],\n dirPath: string,\n): void {\n for (const dbg of instances) {\n const scopedPath = join(dirPath, scopeToFilename(dbg.namespace));\n ensureTruncated(scopedPath);\n wrapLog(dbg, scopedPath);\n }\n}\n"],"mappings":";;;;;;;;;AAUA,IAAM,gBAAgB;AACtB,IAAM,cAAc;AAEpB,IAAM,UAAU;AAEhB,IAAa,gBAAgB;AAC7B,IAAa,qBAAqB;AAElC,SAAS,gBAAgB,UAAwB;CAC/C,MAAM,IAAI;CACV,MAAM,YAAa,EAAE,kCAAkC,IAAI,KAAa;AACxE,GAAE,iBAAiB;AACnB,KAAI,UAAU,IAAI,SAAS,CAAE;AAC7B,KAAI;AACF,YAAU,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACjD,gBAAc,UAAU,IAAI,QAAQ;SAC9B;AAGR,WAAU,IAAI,SAAS;;AAGzB,SAAS,QAAQ,KAAe,UAAwB;CACtD,MAAM,MAAM;AACZ,KAAI,IAAI,iBAAiB,SAAU;CAEnC,MAAM,cACJ,IAAI,gBAAgB,IAAI,yBACnB,IAAI,yBACL,IAAI;AAEV,KAAI,yBAAyB;AAC7B,KAAI,MAAM,SAA0B,GAAG,MAAiB;AACtD,cAAY,MAAM,MAAM,KAAK;AAC7B,MAAI;AAEF,kBAAe,UADF,OAAO,GAAG,KAAK,CAAC,QAAQ,SAAS,GAAG,GAAG,MACrB,QAAQ;UACjC;;AAIV,KAAI,eAAe;;AAGrB,SAAgB,wBACd,WACA,UACM;AACN,iBAAgB,SAAS;AACzB,MAAK,MAAM,OAAO,UAChB,SAAQ,KAAK,SAAS;;AAI1B,SAAS,gBAAgB,WAA2B;AAClD,QAAO,UAAU,QAAQ,MAAM,IAAI,GAAG;;AAGxC,SAAgB,8BACd,WACA,SACM;AACN,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,aAAa,KAAK,SAAS,gBAAgB,IAAI,UAAU,CAAC;AAChE,kBAAgB,WAAW;AAC3B,UAAQ,KAAK,WAAW"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const debugHmr: unknown;
|
|
2
|
+
export declare const debugStyles: unknown;
|
|
3
|
+
export declare const debugCompiler: unknown;
|
|
4
|
+
export declare const debugCompilationApi: unknown;
|
|
5
|
+
export declare const debugEmit: unknown;
|
|
6
|
+
export declare const debugStylePipeline: unknown;
|
|
7
|
+
export declare const debugHmrV: unknown;
|
|
8
|
+
export declare const debugStylesV: unknown;
|
|
9
|
+
export declare const debugCompilerV: unknown;
|
|
10
|
+
export declare const debugEmitV: unknown;
|
|
11
|
+
export type DebugScope = "analog:angular:*" | "analog:angular:hmr" | "analog:angular:hmr:v" | "analog:angular:styles" | "analog:angular:styles:v" | "analog:angular:compiler" | "analog:angular:compiler:v" | "analog:angular:compilation-api" | "analog:angular:emit" | "analog:angular:emit:v" | "analog:angular:style-pipeline" | (string & {});
|
|
12
|
+
export type DebugMode = "build" | "dev";
|
|
13
|
+
export interface DebugModeOptions {
|
|
14
|
+
scopes?: boolean | DebugScope[];
|
|
15
|
+
mode?: DebugMode;
|
|
16
|
+
/**
|
|
17
|
+
* Write debug output to log files under `tmp/debug/` in the workspace root.
|
|
18
|
+
* - `true` or `'single'` — all output to `tmp/debug/analog.log`
|
|
19
|
+
* - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`
|
|
20
|
+
*/
|
|
21
|
+
logFile?: boolean | "single" | "scoped";
|
|
22
|
+
}
|
|
23
|
+
export type DebugOption = boolean | DebugScope[] | DebugModeOptions | DebugModeOptions[];
|
|
24
|
+
export declare const applyDebugOption: (debug: DebugOption | undefined, workspaceRoot?: string) => void;
|
|
25
|
+
export declare const activateDeferredDebug: (command: "build" | "serve") => void;
|
|
26
|
+
export declare const _resetDeferredDebug: () => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createDebugHarness } from "./debug-harness.js";
|
|
2
|
+
import { createDebug } from "obug";
|
|
3
|
+
//#region packages/vite-plugin-angular/src/lib/utils/debug.ts
|
|
4
|
+
var debugHmr = createDebug("analog:angular:hmr");
|
|
5
|
+
var debugStyles = createDebug("analog:angular:styles");
|
|
6
|
+
var debugCompiler = createDebug("analog:angular:compiler");
|
|
7
|
+
var debugCompilationApi = createDebug("analog:angular:compilation-api");
|
|
8
|
+
var debugEmit = createDebug("analog:angular:emit");
|
|
9
|
+
var debugStylePipeline = createDebug("analog:angular:style-pipeline");
|
|
10
|
+
var debugHmrV = createDebug("analog:angular:hmr:v");
|
|
11
|
+
var debugStylesV = createDebug("analog:angular:styles:v");
|
|
12
|
+
var debugCompilerV = createDebug("analog:angular:compiler:v");
|
|
13
|
+
var debugEmitV = createDebug("analog:angular:emit:v");
|
|
14
|
+
var harness = createDebugHarness({
|
|
15
|
+
fallbackNamespace: "analog:angular:*",
|
|
16
|
+
instanceGroups: [[
|
|
17
|
+
debugHmr,
|
|
18
|
+
debugStyles,
|
|
19
|
+
debugCompiler,
|
|
20
|
+
debugCompilationApi,
|
|
21
|
+
debugEmit,
|
|
22
|
+
debugStylePipeline,
|
|
23
|
+
debugHmrV,
|
|
24
|
+
debugStylesV,
|
|
25
|
+
debugCompilerV,
|
|
26
|
+
debugEmitV
|
|
27
|
+
]]
|
|
28
|
+
});
|
|
29
|
+
var applyDebugOption = harness.applyDebugOption;
|
|
30
|
+
var activateDeferredDebug = harness.activateDeferredDebug;
|
|
31
|
+
harness._resetDeferredDebug;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugCompilerV, debugEmit, debugEmitV, debugHmr, debugHmrV, debugStylePipeline, debugStyles, debugStylesV };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug } from 'obug';\nimport { createDebugHarness } from './debug-harness.js';\n\n// Normal — key decisions, once per startup or per component\nexport const debugHmr = createDebug('analog:angular:hmr');\nexport const debugStyles = createDebug('analog:angular:styles');\nexport const debugCompiler = createDebug('analog:angular:compiler');\nexport const debugCompilationApi = createDebug(\n 'analog:angular:compilation-api',\n);\nexport const debugEmit = createDebug('analog:angular:emit');\nexport const debugStylePipeline = createDebug('analog:angular:style-pipeline');\n\n// Verbose — per-file detail, enable with :v suffix or parent:*\nexport const debugHmrV = createDebug('analog:angular:hmr:v');\nexport const debugStylesV = createDebug('analog:angular:styles:v');\nexport const debugCompilerV = createDebug('analog:angular:compiler:v');\nexport const debugEmitV = createDebug('analog:angular:emit:v');\n\nconst angularDebugInstances = [\n debugHmr,\n debugStyles,\n debugCompiler,\n debugCompilationApi,\n debugEmit,\n debugStylePipeline,\n debugHmrV,\n debugStylesV,\n debugCompilerV,\n debugEmitV,\n];\n\nexport type DebugScope =\n | 'analog:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:hmr:v'\n | 'analog:angular:styles'\n | 'analog:angular:styles:v'\n | 'analog:angular:compiler'\n | 'analog:angular:compiler:v'\n | 'analog:angular:compilation-api'\n | 'analog:angular:emit'\n | 'analog:angular:emit:v'\n | 'analog:angular:style-pipeline'\n | (string & {});\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions {\n scopes?: boolean | DebugScope[];\n mode?: DebugMode;\n /**\n * Write debug output to log files under `tmp/debug/` in the workspace root.\n * - `true` or `'single'` — all output to `tmp/debug/analog.log`\n * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`\n */\n logFile?: boolean | 'single' | 'scoped';\n}\n\nexport type DebugOption =\n | boolean\n | DebugScope[]\n | DebugModeOptions\n | DebugModeOptions[];\n\nconst harness = createDebugHarness({\n fallbackNamespace: 'analog:angular:*',\n instanceGroups: [angularDebugInstances],\n});\n\nexport const applyDebugOption: (\n debug: DebugOption | undefined,\n workspaceRoot?: string,\n) => void = harness.applyDebugOption;\nexport const activateDeferredDebug: (command: 'build' | 'serve') => void =\n harness.activateDeferredDebug;\nexport const _resetDeferredDebug: () => void = harness._resetDeferredDebug;\n"],"mappings":";;;AAIA,IAAa,WAAW,YAAY,qBAAqB;AACzD,IAAa,cAAc,YAAY,wBAAwB;AAC/D,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,sBAAsB,YACjC,iCACD;AACD,IAAa,YAAY,YAAY,sBAAsB;AAC3D,IAAa,qBAAqB,YAAY,gCAAgC;AAG9E,IAAa,YAAY,YAAY,uBAAuB;AAC5D,IAAa,eAAe,YAAY,0BAA0B;AAClE,IAAa,iBAAiB,YAAY,4BAA4B;AACtE,IAAa,aAAa,YAAY,wBAAwB;AAgD9D,IAAM,UAAU,mBAAmB;CACjC,mBAAmB;CACnB,gBAAgB,CAhDY;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAqCwC;CACxC,CAAC;AAEF,IAAa,mBAGD,QAAQ;AACpB,IAAa,wBACX,QAAQ;AACqC,QAAQ"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
1
|
+
import type { JavaScriptTransformer as AngularJavaScriptTransformer } from "@angular/build/private";
|
|
2
|
+
import type { CompilerPluginOptions } from "./compiler-plugin-options.js";
|
|
3
|
+
import type { TransformCacheStore } from "./transform-cache.js";
|
|
4
|
+
declare const angularMajor: unknown;
|
|
5
|
+
declare const angularMinor: unknown;
|
|
6
|
+
declare const angularPatch: unknown;
|
|
7
|
+
declare const angularFullVersion: unknown;
|
|
6
8
|
declare let sourceFileCache: any;
|
|
7
9
|
declare let cjt: (...args: any[]) => any;
|
|
8
10
|
declare let jt: any;
|
|
9
11
|
declare let createAngularCompilation: (...args: any[]) => any;
|
|
10
|
-
|
|
12
|
+
declare class JavaScriptTransformer extends jt {
|
|
13
|
+
constructor(options: Partial<ConstructorParameters<typeof AngularJavaScriptTransformer>[0]>, maxThreads: number, cache?: TransformCacheStore);
|
|
14
|
+
transformFile(filename: string, skipLinker?: boolean, sideEffects?: boolean, instrumentForCoverage?: boolean): Promise<Uint8Array>;
|
|
15
|
+
transformData(filename: string, data: string, skipLinker: boolean, sideEffects?: boolean, instrumentForCoverage?: boolean): Promise<Uint8Array>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export { cjt as createJitResourceTransformer, JavaScriptTransformer, sourceFileCache as SourceFileCache, CompilerPluginOptions, angularMajor, angularMinor, angularPatch, createAngularCompilation, angularFullVersion };
|
package/src/lib/utils/devkit.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SourceFileCache } from "./source-file-cache.js";
|
|
2
|
-
import {
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { VERSION } from "@angular/compiler-cli";
|
|
4
5
|
//#region packages/vite-plugin-angular/src/lib/utils/devkit.ts
|
|
5
6
|
var require = createRequire(import.meta.url);
|
|
6
7
|
var angularMajor = Number(VERSION.major);
|
|
@@ -12,6 +13,8 @@ var sourceFileCache;
|
|
|
12
13
|
var cjt;
|
|
13
14
|
var jt;
|
|
14
15
|
var createAngularCompilation;
|
|
16
|
+
var usesTransformOptions = angularFullVersion >= 220200;
|
|
17
|
+
var initializeHash;
|
|
15
18
|
if (angularMajor < 17) throw new Error("AnalogJS is not compatible with Angular v16 and lower");
|
|
16
19
|
else if (angularMajor >= 17 && angularMajor < 18) {
|
|
17
20
|
const cp = require("@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js");
|
|
@@ -30,8 +33,43 @@ else if (angularMajor >= 17 && angularMajor < 18) {
|
|
|
30
33
|
cjt = createJitResourceTransformer;
|
|
31
34
|
jt = JavaScriptTransformer;
|
|
32
35
|
createAngularCompilation = createAngularCompilationFn;
|
|
36
|
+
if (usesTransformOptions) ({initializeHash} = require(join(dirname(require.resolve("@angular/build/package.json")), "src/utils/hash.js")));
|
|
33
37
|
}
|
|
38
|
+
var JavaScriptTransformer = class extends jt {
|
|
39
|
+
constructor(options, maxThreads, cache) {
|
|
40
|
+
if (usesTransformOptions) super({
|
|
41
|
+
...options,
|
|
42
|
+
maxConcurrency: maxThreads
|
|
43
|
+
}, cache);
|
|
44
|
+
else super(options, maxThreads, cache);
|
|
45
|
+
}
|
|
46
|
+
async transformFile(filename, skipLinker, sideEffects, instrumentForCoverage) {
|
|
47
|
+
if (usesTransformOptions) {
|
|
48
|
+
await initializeHash();
|
|
49
|
+
return super.transformFile(filename, {
|
|
50
|
+
skipLinker,
|
|
51
|
+
sideEffects: sideEffects === void 0 ? void 0 : async () => sideEffects,
|
|
52
|
+
instrumentForCoverage
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return super.transformFile(filename, skipLinker, sideEffects, instrumentForCoverage);
|
|
56
|
+
}
|
|
57
|
+
async transformData(filename, data, skipLinker, sideEffects, instrumentForCoverage) {
|
|
58
|
+
if (usesTransformOptions) {
|
|
59
|
+
await initializeHash();
|
|
60
|
+
return super.transformData(filename, data, {
|
|
61
|
+
skipLinker,
|
|
62
|
+
sideEffects: sideEffects === void 0 ? void 0 : async () => sideEffects,
|
|
63
|
+
instrumentForCoverage
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return super.transformData(filename, data, skipLinker, sideEffects, instrumentForCoverage);
|
|
67
|
+
}
|
|
68
|
+
close() {
|
|
69
|
+
return super.close();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
34
72
|
//#endregion
|
|
35
|
-
export { angularFullVersion, cjt, createAngularCompilation,
|
|
73
|
+
export { JavaScriptTransformer, angularFullVersion, cjt, createAngularCompilation, sourceFileCache };
|
|
36
74
|
|
|
37
75
|
//# sourceMappingURL=devkit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devkit.js","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"devkit.js","names":[],"sources":["../../../../src/lib/utils/devkit.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport type { JavaScriptTransformer as AngularJavaScriptTransformer } from '@angular/build/private';\nimport type { CompilerPluginOptions } from './compiler-plugin-options.js';\nimport type { TransformCacheStore } from './transform-cache.js';\nimport * as sfc from './source-file-cache.js';\n\nconst require = createRequire(import.meta.url);\n\nconst angularMajor = Number(VERSION.major);\nconst angularMinor = Number(VERSION.minor);\nconst angularPatch = Number(VERSION.patch);\nconst padVersion = (version: number) => String(version).padStart(2, '0');\nconst angularFullVersion = Number(\n `${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`,\n);\nlet sourceFileCache: any;\nlet cjt: (...args: any[]) => any;\nlet jt: any;\nlet createAngularCompilation: (...args: any[]) => any;\nconst usesTransformOptions = angularFullVersion >= 220200;\nlet initializeHash: (() => Promise<void>) | undefined;\n\nif (angularMajor < 17) {\n throw new Error('AnalogJS is not compatible with Angular v16 and lower');\n} else if (angularMajor >= 17 && angularMajor < 18) {\n const cp = require('@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js');\n const {\n createJitResourceTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js');\n const {\n JavaScriptTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js');\n\n /**\n * Workaround for compatibility with Angular 17.0+\n */\n if (typeof cp['SourceFileCache'] !== 'undefined') {\n sourceFileCache = cp.SourceFileCache;\n } else {\n sourceFileCache = sfc.SourceFileCache;\n }\n\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n} else {\n const {\n createJitResourceTransformer,\n JavaScriptTransformer,\n SourceFileCache,\n createAngularCompilation: createAngularCompilationFn,\n } = require('@angular/build/private');\n\n sourceFileCache = SourceFileCache;\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n createAngularCompilation = createAngularCompilationFn;\n\n if (usesTransformOptions) {\n ({ initializeHash } = require(\n join(\n dirname(require.resolve('@angular/build/package.json')),\n 'src/utils/hash.js',\n ),\n ));\n }\n}\n\n// Keep Angular's private transformer API differences at the compatibility boundary.\nclass JavaScriptTransformer extends jt {\n constructor(\n options: Partial<\n ConstructorParameters<typeof AngularJavaScriptTransformer>[0]\n >,\n maxThreads: number,\n cache?: TransformCacheStore,\n ) {\n if (usesTransformOptions) {\n super({ ...options, maxConcurrency: maxThreads }, cache);\n } else {\n super(options, maxThreads, cache);\n }\n }\n\n async transformFile(\n filename: string,\n skipLinker?: boolean,\n sideEffects?: boolean,\n instrumentForCoverage?: boolean,\n ): Promise<Uint8Array> {\n if (usesTransformOptions) {\n await initializeHash!();\n return super.transformFile(filename, {\n skipLinker,\n sideEffects:\n sideEffects === undefined ? undefined : async () => sideEffects,\n instrumentForCoverage,\n });\n }\n return super.transformFile(\n filename,\n skipLinker,\n sideEffects,\n instrumentForCoverage,\n );\n }\n\n async transformData(\n filename: string,\n data: string,\n skipLinker: boolean,\n sideEffects?: boolean,\n instrumentForCoverage?: boolean,\n ): Promise<Uint8Array> {\n if (usesTransformOptions) {\n await initializeHash!();\n return super.transformData(filename, data, {\n skipLinker,\n sideEffects:\n sideEffects === undefined ? undefined : async () => sideEffects,\n instrumentForCoverage,\n });\n }\n return super.transformData(\n filename,\n data,\n skipLinker,\n sideEffects,\n instrumentForCoverage,\n );\n }\n\n close(): Promise<void> {\n return super.close();\n }\n}\n\nexport {\n cjt as createJitResourceTransformer,\n JavaScriptTransformer,\n sourceFileCache as SourceFileCache,\n CompilerPluginOptions,\n angularMajor,\n angularMinor,\n angularPatch,\n createAngularCompilation,\n angularFullVersion,\n};\n"],"mappings":";;;;;AAQA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,cAAc,YAAoB,OAAO,QAAQ,CAAC,SAAS,GAAG,IAAI;AACxE,IAAM,qBAAqB,OACzB,GAAG,eAAe,WAAW,aAAa,GAAG,WAAW,aAAa,GACtE;AACD,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAM,uBAAuB,sBAAsB;AACnD,IAAI;AAEJ,IAAI,eAAe,GACjB,OAAM,IAAI,MAAM,wDAAwD;SAC/D,gBAAgB,MAAM,eAAe,IAAI;CAClD,MAAM,KAAK,QAAQ,6EAA6E;CAChG,MAAM,EACJ,iCACE,QAAQ,sFAAsF;CAClG,MAAM,EACJ,0BACE,QAAQ,4EAA4E;;;;AAKxF,KAAI,OAAO,GAAG,uBAAuB,YACnC,mBAAkB,GAAG;KAErB,mBAAkB;AAGpB,OAAM;AACN,MAAK;OACA;CACL,MAAM,EACJ,8BACA,uBACA,iBACA,0BAA0B,+BACxB,QAAQ,yBAAyB;AAErC,mBAAkB;AAClB,OAAM;AACN,MAAK;AACL,4BAA2B;AAE3B,KAAI,qBACF,EAAC,CAAE,kBAAmB,QACpB,KACE,QAAQ,QAAQ,QAAQ,8BAA8B,CAAC,EACvD,oBACD,CACF;;AAKL,IAAM,wBAAN,cAAoC,GAAG;CACrC,YACE,SAGA,YACA,OACA;AACA,MAAI,qBACF,OAAM;GAAE,GAAG;GAAS,gBAAgB;GAAY,EAAE,MAAM;MAExD,OAAM,SAAS,YAAY,MAAM;;CAIrC,MAAM,cACJ,UACA,YACA,aACA,uBACqB;AACrB,MAAI,sBAAsB;AACxB,SAAM,gBAAiB;AACvB,UAAO,MAAM,cAAc,UAAU;IACnC;IACA,aACE,gBAAgB,KAAA,IAAY,KAAA,IAAY,YAAY;IACtD;IACD,CAAC;;AAEJ,SAAO,MAAM,cACX,UACA,YACA,aACA,sBACD;;CAGH,MAAM,cACJ,UACA,MACA,YACA,aACA,uBACqB;AACrB,MAAI,sBAAsB;AACxB,SAAM,gBAAiB;AACvB,UAAO,MAAM,cAAc,UAAU,MAAM;IACzC;IACA,aACE,gBAAgB,KAAA,IAAY,KAAA,IAAY,YAAY;IACtD;IACD,CAAC;;AAEJ,SAAO,MAAM,cACX,UACA,MACA,YACA,aACA,sBACD;;CAGH,QAAuB;AACrB,SAAO,MAAM,OAAO"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { NgtscProgram } from
|
|
9
|
-
import ts from
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { NgtscProgram } from "@angular/compiler-cli";
|
|
9
|
+
import ts from "typescript";
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
* Analyzes one or more modified files for changes to determine if any
|
|
12
|
+
* class declarations for Angular components are candidates for hot
|
|
13
|
+
* module replacement (HMR). If any source files are also modified but
|
|
14
|
+
* are not candidates then all candidates become invalid. This invalidation
|
|
15
|
+
* ensures that a full rebuild occurs and the running application stays
|
|
16
|
+
* synchronized with the code.
|
|
17
|
+
* @param modifiedFiles A set of modified files to analyze.
|
|
18
|
+
* @param param1 An Angular compiler instance
|
|
19
|
+
* @param staleSourceFiles A map of paths to previous source file instances.
|
|
20
|
+
* @returns A set of HMR candidate component class declarations.
|
|
21
|
+
*/
|
|
22
22
|
export declare function collectHmrCandidates(modifiedFiles: Set<string>, { compiler }: NgtscProgram, staleSourceFiles: Map<string, ts.SourceFile> | undefined): Set<ts.ClassDeclaration>;
|
|
23
23
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export declare function analyzeFileUpdates(stale: ts.SourceFile, updated: ts.SourceFile, compiler: NgtscProgram[
|
|
24
|
+
* Analyzes the updates of a source file for potential HMR component class candidates.
|
|
25
|
+
* A source file can contain candidates if only the Angular component metadata of a class
|
|
26
|
+
* has been changed and the metadata changes are only of supported fields.
|
|
27
|
+
* @param stale The stale (previous) source file instance.
|
|
28
|
+
* @param updated The updated source file instance.
|
|
29
|
+
* @param compiler An Angular compiler instance.
|
|
30
|
+
* @returns An array of candidate class declarations; or `null` if unsupported changes are present.
|
|
31
|
+
*/
|
|
32
|
+
export declare function analyzeFileUpdates(stale: ts.SourceFile, updated: ts.SourceFile, compiler: NgtscProgram["compiler"]): ts.ClassDeclaration[] | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
//#region packages/vite-plugin-angular/src/lib/utils/jit-inline-styles.ts
|
|
3
|
+
var JIT_INLINE_STYLE_PREFIX = "virtual:angular:jit:style:inline;";
|
|
4
|
+
var inlineStyles = /* @__PURE__ */ new Map();
|
|
5
|
+
function toJitInlineStyleId(encodedStyles) {
|
|
6
|
+
const hash = createHash("sha256").update(encodedStyles).digest("hex").slice(0, 16);
|
|
7
|
+
inlineStyles.set(hash, encodedStyles);
|
|
8
|
+
return `${JIT_INLINE_STYLE_PREFIX}${hash}`;
|
|
9
|
+
}
|
|
10
|
+
function getJitInlineStyles(hash) {
|
|
11
|
+
return inlineStyles.get(hash);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JIT_INLINE_STYLE_PREFIX, getJitInlineStyles, toJitInlineStyleId };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=jit-inline-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jit-inline-styles.js","names":[],"sources":["../../../../src/lib/utils/jit-inline-styles.ts"],"sourcesContent":["// Angular's JIT resource transformer emits inline component styles as\n// `angular:jit:style:inline;<base64 of the whole stylesheet>`. Keeping that\n// payload in the module id makes the emitted chunk name grow with the\n// stylesheet, so a large inline style blows past the 255-byte filename\n// limit and the build fails with ENAMETOOLONG. Hash the payload into the\n// id and keep the base64 in a lookup table instead. (#2459)\n\nimport { createHash } from 'node:crypto';\n\nexport const JIT_INLINE_STYLE_PREFIX = 'virtual:angular:jit:style:inline;';\n\nconst inlineStyles = new Map<string, string>();\n\nexport function toJitInlineStyleId(encodedStyles: string): string {\n const hash = createHash('sha256')\n .update(encodedStyles)\n .digest('hex')\n .slice(0, 16);\n inlineStyles.set(hash, encodedStyles);\n return `${JIT_INLINE_STYLE_PREFIX}${hash}`;\n}\n\nexport function getJitInlineStyles(hash: string): string | undefined {\n return inlineStyles.get(hash);\n}\n"],"mappings":";;AASA,IAAa,0BAA0B;AAEvC,IAAM,+BAAe,IAAI,KAAqB;AAE9C,SAAgB,mBAAmB,eAA+B;CAChE,MAAM,OAAO,WAAW,SAAS,CAC9B,OAAO,cAAc,CACrB,OAAO,MAAM,CACb,MAAM,GAAG,GAAG;AACf,cAAa,IAAI,MAAM,cAAc;AACrC,QAAO,GAAG,0BAA0B;;AAGtC,SAAgB,mBAAmB,MAAkC;AACnE,QAAO,aAAa,IAAI,KAAK"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript file extension regex
|
|
3
|
+
* Match .ts / .cts / .mts extensions with an optional ?query suffix.
|
|
4
|
+
* Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via
|
|
5
|
+
* a negative-lookahead on a following ASCII letter, so only genuine TS
|
|
6
|
+
* files pass.
|
|
7
|
+
*
|
|
8
|
+
* Previous form `/\.[cm]?(ts)[^x]?\??/` was intended to exclude `.tsx`
|
|
9
|
+
* specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows
|
|
10
|
+
* zero characters, and any non-`x` letter was admitted — so `.tsrx`
|
|
11
|
+
* and similar extensions matched by accident.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TS_EXT_REGEX: unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves whether Angular should be compiled for production. An explicit
|
|
16
|
+
* `development` mode wins over an ambient production `NODE_ENV` (e.g. set by
|
|
17
|
+
* `storybook build` at CLI entry), so a build can opt into Angular's
|
|
18
|
+
* development compilation. See #2458 and #2462.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isProdMode(mode: string | undefined): boolean;
|
|
21
|
+
export interface TsConfigResolutionContext {
|
|
22
|
+
root: string;
|
|
23
|
+
isProd: boolean;
|
|
24
|
+
isLib: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function getTsConfigPath(root: string, tsconfig: string, isProd: boolean, isTest: boolean, isLib: boolean, workspaceRoot?: string);
|
|
27
|
+
export declare function createTsConfigGetter(tsconfigOrGetter?: string | (() => string));
|
|
28
|
+
export interface DepOptimizerOptions {
|
|
29
|
+
tsconfig: string;
|
|
30
|
+
isProd: boolean;
|
|
31
|
+
jit: boolean;
|
|
32
|
+
watchMode: boolean;
|
|
33
|
+
isTest: boolean;
|
|
34
|
+
isAstroIntegration: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function createDepOptimizerConfig(opts: DepOptimizerOptions): {
|
|
37
|
+
optimizeDeps: {
|
|
38
|
+
include: unknown;
|
|
39
|
+
exclude: unknown;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createCompilerPlugin, createRolldownCompilerPlugin } from "../compiler-plugin.js";
|
|
2
|
+
import { createPersistentTransformCache, resolveTransformCacheDir } from "./transform-cache.js";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
5
|
+
import * as vite from "vite";
|
|
6
|
+
//#region packages/vite-plugin-angular/src/lib/utils/plugin-config.ts
|
|
7
|
+
/**
|
|
8
|
+
* TypeScript file extension regex
|
|
9
|
+
* Match .ts / .cts / .mts extensions with an optional ?query suffix.
|
|
10
|
+
* Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via
|
|
11
|
+
* a negative-lookahead on a following ASCII letter, so only genuine TS
|
|
12
|
+
* files pass.
|
|
13
|
+
*
|
|
14
|
+
* Previous form `/\.[cm]?(ts)[^x]?\??/` was intended to exclude `.tsx`
|
|
15
|
+
* specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows
|
|
16
|
+
* zero characters, and any non-`x` letter was admitted — so `.tsrx`
|
|
17
|
+
* and similar extensions matched by accident.
|
|
18
|
+
*/
|
|
19
|
+
var TS_EXT_REGEX = /\.[cm]?ts(?![a-z])/;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves whether Angular should be compiled for production. An explicit
|
|
22
|
+
* `development` mode wins over an ambient production `NODE_ENV` (e.g. set by
|
|
23
|
+
* `storybook build` at CLI entry), so a build can opt into Angular's
|
|
24
|
+
* development compilation. See #2458 and #2462.
|
|
25
|
+
*/
|
|
26
|
+
function isProdMode(mode) {
|
|
27
|
+
if (mode === "development") return false;
|
|
28
|
+
return mode === "production" || process.env.NODE_ENV === "production";
|
|
29
|
+
}
|
|
30
|
+
function getTsConfigPath(root, tsconfig, isProd, isTest, isLib, workspaceRoot) {
|
|
31
|
+
if (tsconfig && isAbsolute(tsconfig)) {
|
|
32
|
+
if (!existsSync(tsconfig)) console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
|
|
33
|
+
return tsconfig;
|
|
34
|
+
}
|
|
35
|
+
let tsconfigFilePath = "./tsconfig.app.json";
|
|
36
|
+
if (isLib) tsconfigFilePath = isProd ? "./tsconfig.lib.prod.json" : "./tsconfig.lib.json";
|
|
37
|
+
if (isTest) tsconfigFilePath = "./tsconfig.spec.json";
|
|
38
|
+
if (tsconfig) tsconfigFilePath = tsconfig;
|
|
39
|
+
const resolvedPath = resolve(root, tsconfigFilePath);
|
|
40
|
+
if (existsSync(resolvedPath)) return resolvedPath;
|
|
41
|
+
const workspacePath = workspaceRoot ? resolve(workspaceRoot, tsconfigFilePath) : void 0;
|
|
42
|
+
if (workspacePath && existsSync(workspacePath)) return workspacePath;
|
|
43
|
+
const attemptedPaths = workspacePath && workspacePath !== resolvedPath ? `${resolvedPath} or ${workspacePath}` : resolvedPath;
|
|
44
|
+
console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
|
|
45
|
+
return resolvedPath;
|
|
46
|
+
}
|
|
47
|
+
function createTsConfigGetter(tsconfigOrGetter) {
|
|
48
|
+
if (typeof tsconfigOrGetter === "function") return tsconfigOrGetter;
|
|
49
|
+
return () => tsconfigOrGetter || "";
|
|
50
|
+
}
|
|
51
|
+
function createDepOptimizerConfig(opts) {
|
|
52
|
+
const defineOptions = {
|
|
53
|
+
ngJitMode: "false",
|
|
54
|
+
ngI18nClosureMode: "false",
|
|
55
|
+
...opts.watchMode ? {} : { ngDevMode: "false" }
|
|
56
|
+
};
|
|
57
|
+
const transformCacheDir = resolveTransformCacheDir(dirname(opts.tsconfig));
|
|
58
|
+
const transformCache = transformCacheDir ? createPersistentTransformCache(transformCacheDir) : void 0;
|
|
59
|
+
const rolldownOptions = { plugins: [createRolldownCompilerPlugin({
|
|
60
|
+
tsconfig: opts.tsconfig,
|
|
61
|
+
sourcemap: !opts.isProd,
|
|
62
|
+
advancedOptimizations: opts.isProd,
|
|
63
|
+
jit: opts.jit,
|
|
64
|
+
incremental: opts.watchMode
|
|
65
|
+
}, opts.isTest, !opts.isAstroIntegration, transformCache)] };
|
|
66
|
+
const esbuildOptions = {
|
|
67
|
+
plugins: [createCompilerPlugin({
|
|
68
|
+
tsconfig: opts.tsconfig,
|
|
69
|
+
sourcemap: !opts.isProd,
|
|
70
|
+
advancedOptimizations: opts.isProd,
|
|
71
|
+
jit: opts.jit,
|
|
72
|
+
incremental: opts.watchMode
|
|
73
|
+
}, opts.isTest, !opts.isAstroIntegration, transformCache)],
|
|
74
|
+
define: defineOptions
|
|
75
|
+
};
|
|
76
|
+
return { optimizeDeps: {
|
|
77
|
+
include: ["rxjs/operators", "rxjs"],
|
|
78
|
+
exclude: ["@angular/platform-server"],
|
|
79
|
+
...vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }
|
|
80
|
+
} };
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath, isProdMode };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=plugin-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-config.js","names":[],"sources":["../../../../src/lib/utils/plugin-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport * as vite from 'vite';\n\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n createPersistentTransformCache,\n resolveTransformCacheDir,\n} from './transform-cache.js';\n\n/**\n * TypeScript file extension regex\n * Match .ts / .cts / .mts extensions with an optional ?query suffix.\n * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via\n * a negative-lookahead on a following ASCII letter, so only genuine TS\n * files pass.\n *\n * Previous form `/\\.[cm]?(ts)[^x]?\\??/` was intended to exclude `.tsx`\n * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows\n * zero characters, and any non-`x` letter was admitted — so `.tsrx`\n * and similar extensions matched by accident.\n */\nexport const TS_EXT_REGEX = /\\.[cm]?ts(?![a-z])/;\n\n/**\n * Resolves whether Angular should be compiled for production. An explicit\n * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by\n * `storybook build` at CLI entry), so a build can opt into Angular's\n * development compilation. See #2458 and #2462.\n */\nexport function isProdMode(mode: string | undefined): boolean {\n if (mode === 'development') {\n return false;\n }\n\n return mode === 'production' || process.env['NODE_ENV'] === 'production';\n}\n\nexport interface TsConfigResolutionContext {\n root: string;\n isProd: boolean;\n isLib: boolean;\n}\n\nexport function getTsConfigPath(\n root: string,\n tsconfig: string,\n isProd: boolean,\n isTest: boolean,\n isLib: boolean,\n workspaceRoot?: string,\n) {\n if (tsconfig && isAbsolute(tsconfig)) {\n if (!existsSync(tsconfig)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return tsconfig;\n }\n\n let tsconfigFilePath = './tsconfig.app.json';\n\n if (isLib) {\n tsconfigFilePath = isProd\n ? './tsconfig.lib.prod.json'\n : './tsconfig.lib.json';\n }\n\n if (isTest) {\n tsconfigFilePath = './tsconfig.spec.json';\n }\n\n if (tsconfig) {\n tsconfigFilePath = tsconfig;\n }\n\n const resolvedPath = resolve(root, tsconfigFilePath);\n\n if (existsSync(resolvedPath)) {\n return resolvedPath;\n }\n\n // Callers such as Storybook's Angular builder document their `tsConfig` as\n // workspace-relative while setting the Vite root to the project directory,\n // so the path joins onto the project root twice. Fall back to the workspace\n // root before failing.\n const workspacePath = workspaceRoot\n ? resolve(workspaceRoot, tsconfigFilePath)\n : undefined;\n\n if (workspacePath && existsSync(workspacePath)) {\n return workspacePath;\n }\n\n const attemptedPaths =\n workspacePath && workspacePath !== resolvedPath\n ? `${resolvedPath} or ${workspacePath}`\n : resolvedPath;\n\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n\n return resolvedPath;\n}\n\nexport function createTsConfigGetter(\n tsconfigOrGetter?: string | (() => string),\n) {\n if (typeof tsconfigOrGetter === 'function') {\n return tsconfigOrGetter;\n }\n\n return () => tsconfigOrGetter || '';\n}\n\nexport interface DepOptimizerOptions {\n tsconfig: string;\n isProd: boolean;\n jit: boolean;\n watchMode: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n}\n\nexport function createDepOptimizerConfig(opts: DepOptimizerOptions) {\n const defineOptions = {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ...(opts.watchMode ? {} : { ngDevMode: 'false' }),\n };\n\n // Persist linked dependency output across dep-optimizer runs. The\n // transformer's own key covers file bytes + options, and the directory\n // is namespaced by Angular version, so entries never go stale.\n const transformCacheDir = resolveTransformCacheDir(dirname(opts.tsconfig));\n const transformCache = transformCacheDir\n ? createPersistentTransformCache(transformCacheDir)\n : undefined;\n\n const rolldownOptions: vite.DepOptimizationOptions['rolldownOptions'] = {\n plugins: [\n createRolldownCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n };\n\n const esbuildOptions: vite.DepOptimizationOptions['esbuildOptions'] = {\n plugins: [\n createCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n define: defineOptions,\n };\n\n // No top-level `resolve` block: the `style` package-export condition\n // is now scoped to `.css`-extension requests via\n // `cssExtensionStyleResolverPlugin`, so this dep optimizer config no\n // longer needs to leak it into Vite's global `resolve.conditions`.\n return {\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs'],\n exclude: ['@angular/platform-server'],\n ...(vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAa,eAAe;;;;;;;AAQ5B,SAAgB,WAAW,MAAmC;AAC5D,KAAI,SAAS,cACX,QAAO;AAGT,QAAO,SAAS,gBAAA,QAAA,IAAA,aAA4C;;AAS9D,SAAgB,gBACd,MACA,UACA,QACA,QACA,OACA,eACA;AACA,KAAI,YAAY,WAAW,SAAS,EAAE;AACpC,MAAI,CAAC,WAAW,SAAS,CACvB,SAAQ,MACN,kEAAkE,SAAS,wGAC5E;AAGH,SAAO;;CAGT,IAAI,mBAAmB;AAEvB,KAAI,MACF,oBAAmB,SACf,6BACA;AAGN,KAAI,OACF,oBAAmB;AAGrB,KAAI,SACF,oBAAmB;CAGrB,MAAM,eAAe,QAAQ,MAAM,iBAAiB;AAEpD,KAAI,WAAW,aAAa,CAC1B,QAAO;CAOT,MAAM,gBAAgB,gBAClB,QAAQ,eAAe,iBAAiB,GACxC,KAAA;AAEJ,KAAI,iBAAiB,WAAW,cAAc,CAC5C,QAAO;CAGT,MAAM,iBACJ,iBAAiB,kBAAkB,eAC/B,GAAG,aAAa,MAAM,kBACtB;AAEN,SAAQ,MACN,kEAAkE,eAAe,wGAClF;AAED,QAAO;;AAGT,SAAgB,qBACd,kBACA;AACA,KAAI,OAAO,qBAAqB,WAC9B,QAAO;AAGT,cAAa,oBAAoB;;AAYnC,SAAgB,yBAAyB,MAA2B;CAClE,MAAM,gBAAgB;EACpB,WAAW;EACX,mBAAmB;EACnB,GAAI,KAAK,YAAY,EAAE,GAAG,EAAE,WAAW,SAAS;EACjD;CAKD,MAAM,oBAAoB,yBAAyB,QAAQ,KAAK,SAAS,CAAC;CAC1E,MAAM,iBAAiB,oBACnB,+BAA+B,kBAAkB,GACjD,KAAA;CAEJ,MAAM,kBAAkE,EACtE,SAAS,CACP,6BACE;EACE,UAAU,KAAK;EACf,WAAW,CAAC,KAAK;EACjB,uBAAuB,KAAK;EAC5B,KAAK,KAAK;EACV,aAAa,KAAK;EACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF,EACF;CAED,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;GACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF;EACD,QAAQ;EACT;AAMD,QAAO,EACL,cAAc;EACZ,SAAS,CAAC,kBAAkB,OAAO;EACnC,SAAS,CAAC,2BAA2B;EACrC,GAAI,KAAK,kBAAkB,EAAE,iBAAiB,GAAG,EAAE,gBAAgB;EACpE,EACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function isRolldown(): boolean;
|
|
2
|
-
export declare function getJsTransformConfigKey():
|
|
2
|
+
export declare function getJsTransformConfigKey(): "oxc" | "esbuild";
|