@analogjs/vite-plugin-angular 3.0.0-beta.4 → 3.0.0-beta.40
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/ngp/LICENSE +21 -0
- package/ngp/api.mjs +46048 -0
- package/ngp/build.json +4 -0
- package/ngp/ng_analyze.cjs +504 -0
- package/ngp/ng_analyze_bg.wasm +0 -0
- package/package.json +1 -1
- package/src/lib/analog-plugin-interop.js +1 -1
- package/src/lib/angular-build-context.d.ts +215 -0
- package/src/lib/angular-build-context.js +361 -0
- package/src/lib/angular-build-context.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +6 -4
- package/src/lib/angular-build-optimizer-plugin.js +10 -5
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +5 -3
- package/src/lib/angular-jit-plugin.js +14 -6
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +6 -109
- package/src/lib/angular-vite-plugin.js +8 -1246
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +3 -2
- package/src/lib/angular-vitest-plugin.js +6 -3
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/companion-plugins.d.ts +7 -0
- package/src/lib/companion-plugins.js +38 -0
- package/src/lib/companion-plugins.js.map +1 -0
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +11 -2
- package/src/lib/compilation-api/compilation-api-plugin.js +154 -282
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compiler/compile.d.ts +1 -1
- package/src/lib/compiler/compile.js +158 -143
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/defer.d.ts +2 -3
- package/src/lib/compiler/defer.js +11 -13
- package/src/lib/compiler/defer.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +6 -1
- package/src/lib/compiler/dts-reader.js +19 -10
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +7 -2
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +4 -4
- package/src/lib/compiler/jit-metadata.d.ts +3 -1
- package/src/lib/compiler/jit-metadata.js +10 -8
- package/src/lib/compiler/jit-metadata.js.map +1 -1
- package/src/lib/compiler/jit-transform.js +2 -2
- package/src/lib/compiler/jit-transform.js.map +1 -1
- package/src/lib/compiler/js-emitter.d.ts +0 -3
- package/src/lib/compiler/js-emitter.js +3 -21
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/compiler/registry.d.ts +7 -1
- package/src/lib/compiler/registry.js +23 -3
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/compiler/resource-inliner.d.ts +8 -9
- package/src/lib/compiler/resource-inliner.js +10 -18
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.d.ts +9 -1
- package/src/lib/compiler/style-ast.js +26 -5
- package/src/lib/compiler/style-ast.js.map +1 -1
- package/src/lib/compiler/type-elision.d.ts +4 -3
- package/src/lib/compiler/type-elision.js +10 -11
- package/src/lib/compiler/type-elision.js.map +1 -1
- package/src/lib/compiler/utils.d.ts +14 -7
- package/src/lib/compiler/utils.js +38 -9
- package/src/lib/compiler/utils.js.map +1 -1
- package/src/lib/component-styles-plugin.d.ts +52 -0
- package/src/lib/component-styles-plugin.js +353 -0
- package/src/lib/component-styles-plugin.js.map +1 -0
- package/src/lib/compose-angular-plugins.d.ts +12 -0
- package/src/lib/compose-angular-plugins.js +31 -0
- package/src/lib/compose-angular-plugins.js.map +1 -0
- package/src/lib/dev-server-mode-plugin.d.ts +7 -0
- package/src/lib/dev-server-mode-plugin.js +23 -0
- package/src/lib/dev-server-mode-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +6 -1
- package/src/lib/fast-compile-plugin.js +209 -79
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.d.ts +3 -0
- package/src/lib/host.js +4 -2
- package/src/lib/host.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +6 -3
- package/src/lib/live-reload-plugin.js +13 -6
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-plugin.d.ts +4 -0
- package/src/lib/ngp-compile-plugin.js +410 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
- package/src/lib/ngtsc-compile-plugin.js +763 -0
- package/src/lib/ngtsc-compile-plugin.js.map +1 -0
- package/src/lib/nx-folder-plugin.d.ts +6 -5
- package/src/lib/nx-folder-plugin.js +12 -7
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +6 -0
- package/src/lib/plugins/file-replacements.plugin.js +1 -0
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +5 -1
- package/src/lib/router-plugin.js +13 -4
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +1 -1
- package/src/lib/utils/devkit.js +1 -1
- package/src/lib/utils/hmr-component-updates.d.ts +7 -0
- package/src/lib/utils/hmr-component-updates.js +87 -0
- package/src/lib/utils/hmr-component-updates.js.map +1 -0
- package/src/lib/utils/lsp-type-checker.d.ts +55 -0
- package/src/lib/utils/lsp-type-checker.js +502 -0
- package/src/lib/utils/lsp-type-checker.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +15 -8
- package/src/lib/utils/plugin-config.js +18 -5
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/stylesheet-warning.d.ts +2 -0
- package/src/lib/utils/stylesheet-warning.js +11 -0
- package/src/lib/utils/stylesheet-warning.js.map +1 -0
- package/src/lib/utils/tsconfig-resolver.js +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +11 -3
- package/src/lib/virtual-modules-plugin.js +43 -12
- package/src/lib/virtual-modules-plugin.js.map +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createCompilerPlugin, createRolldownCompilerPlugin } from "../compiler-plugin.js";
|
|
2
|
+
import { isRolldown } from "./rolldown.js";
|
|
2
3
|
import { createPersistentTransformCache, resolveTransformCacheDir } from "./transform-cache.js";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
5
|
-
import * as vite from "vite";
|
|
6
6
|
//#region packages/vite-plugin-angular/src/lib/utils/plugin-config.ts
|
|
7
7
|
/**
|
|
8
8
|
* TypeScript file extension regex
|
|
@@ -28,6 +28,15 @@ function isProdMode(mode) {
|
|
|
28
28
|
if (mode === "development") return false;
|
|
29
29
|
return mode === "production" || process.env.NODE_ENV === "production";
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether a Vite environment runs on the server. `configEnvironment` sees the
|
|
33
|
+
* environment's options before Vite resolves them, so an unset `consumer`
|
|
34
|
+
* falls back to Vite's own default: every environment except `client` is a
|
|
35
|
+
* server environment.
|
|
36
|
+
*/
|
|
37
|
+
function isServerEnvironment(name, config) {
|
|
38
|
+
return (config.consumer ?? (name === "client" ? "client" : "server")) === "server";
|
|
39
|
+
}
|
|
31
40
|
function getTsConfigPath(root, tsconfig, isProd, isTest, isLib, workspaceRoot) {
|
|
32
41
|
if (tsconfig && isAbsolute(tsconfig)) {
|
|
33
42
|
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.`);
|
|
@@ -51,7 +60,7 @@ function createTsConfigGetter(tsconfigOrGetter) {
|
|
|
51
60
|
}
|
|
52
61
|
function createDepOptimizerConfig(opts) {
|
|
53
62
|
const defineOptions = {
|
|
54
|
-
ngJitMode: "false",
|
|
63
|
+
...opts.jit ? {} : { ngJitMode: "false" },
|
|
55
64
|
ngI18nClosureMode: "false",
|
|
56
65
|
...opts.watchMode ? {} : { ngDevMode: "false" }
|
|
57
66
|
};
|
|
@@ -75,12 +84,16 @@ function createDepOptimizerConfig(opts) {
|
|
|
75
84
|
define: defineOptions
|
|
76
85
|
};
|
|
77
86
|
return { optimizeDeps: {
|
|
78
|
-
include: [
|
|
87
|
+
include: [
|
|
88
|
+
"rxjs/operators",
|
|
89
|
+
"rxjs",
|
|
90
|
+
"tslib"
|
|
91
|
+
],
|
|
79
92
|
exclude: ["@angular/platform-server"],
|
|
80
|
-
...
|
|
93
|
+
...isRolldown() ? { rolldownOptions } : { esbuildOptions }
|
|
81
94
|
} };
|
|
82
95
|
}
|
|
83
96
|
//#endregion
|
|
84
|
-
export { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath, isProdMode };
|
|
97
|
+
export { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath, isProdMode, isServerEnvironment };
|
|
85
98
|
|
|
86
99
|
//# sourceMappingURL=plugin-config.js.map
|
|
@@ -1 +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// Spec files stay included — a newly added spec must join the program's\n// root names in Vitest watch mode.\nexport const EXCLUDED_TS_EXT_REGEX = /\\.d\\.[cm]?ts$/;\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 ...(
|
|
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 { isRolldown } from './rolldown.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: RegExp = /\\.[cm]?ts(?![a-z])/;\n\n// Spec files stay included — a newly added spec must join the program's\n// root names in Vitest watch mode.\nexport const EXCLUDED_TS_EXT_REGEX: RegExp = /\\.d\\.[cm]?ts$/;\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\n/**\n * Whether a Vite environment runs on the server. `configEnvironment` sees the\n * environment's options before Vite resolves them, so an unset `consumer`\n * falls back to Vite's own default: every environment except `client` is a\n * server environment.\n */\nexport function isServerEnvironment(\n name: string,\n config: { consumer?: string },\n): boolean {\n return (\n (config.consumer ?? (name === 'client' ? 'client' : 'server')) === 'server'\n );\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): string {\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): () => string {\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 optimizeDeps: vite.DepOptimizationOptions;\n} {\n const defineOptions = {\n ...(opts.jit ? {} : { 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', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(isRolldown() ? { rolldownOptions } : { esbuildOptions }),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;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AEJ,MAAM,kBAAkE,EACtE,SAAS,CACP,6BACE;EACE,UAAU,KAAK;EACf,WAAW,CAAC,KAAK;EACjB,uBAAuB,KAAK;EAC5B,KAAK,KAAK;EACV,aAAa,KAAK;CACpB,GACA,KAAK,QACL,CAAC,KAAK,oBACN,cACF,CACF,EACF;CAEA,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;EACpB,GACA,KAAK,QACL,CAAC,KAAK,oBACN,cACF,CACF;EACA,QAAQ;CACV;CAMA,OAAO,EACL,cAAc;EACZ,SAAS;GAAC;GAAkB;GAAQ;EAAO;EAC3C,SAAS,CAAC,0BAA0B;EACpC,GAAI,WAAW,IAAI,EAAE,gBAAgB,IAAI,EAAE,eAAe;CAC5D,EACF;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region packages/vite-plugin-angular/src/lib/utils/stylesheet-warning.ts
|
|
2
|
+
function reportStylesheetError(logger, filename, error, isBuild) {
|
|
3
|
+
const message = `[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}`;
|
|
4
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
5
|
+
if (isBuild) throw new Error(`${message}. ${detail}`, { cause: error });
|
|
6
|
+
logger?.warn(`${message}; it was left unprocessed. ${detail}`, { timestamp: true });
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { reportStylesheetError };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=stylesheet-warning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesheet-warning.js","names":[],"sources":["../../../../src/lib/utils/stylesheet-warning.ts"],"sourcesContent":["import type { Logger } from 'vite';\n\nexport function reportStylesheetError(\n logger: Logger | undefined,\n filename: string,\n error: unknown,\n isBuild: boolean,\n): void {\n const message = `[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}`;\n const detail = error instanceof Error ? error.message : String(error);\n if (isBuild) {\n throw new Error(`${message}. ${detail}`, { cause: error });\n }\n logger?.warn(`${message}; it was left unprocessed. ${detail}`, {\n timestamp: true,\n });\n}\n"],"mappings":";AAEA,SAAgB,sBACd,QACA,UACA,OACA,SACM;CACN,MAAM,UAAU,gEAAgE;CAChF,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACpE,IAAI,SACF,MAAM,IAAI,MAAM,GAAG,QAAQ,IAAI,UAAU,EAAE,OAAO,MAAM,CAAC;CAE3D,QAAQ,KAAK,GAAG,QAAQ,6BAA6B,UAAU,EAC7D,WAAW,KACb,CAAC;AACH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { debugEmit, debugEmitV } from "./debug.js";
|
|
2
2
|
import { existsSync, statSync } from "node:fs";
|
|
3
|
-
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
6
|
import * as compilerCli from "@angular/compiler-cli";
|
|
7
7
|
import { globSync } from "tinyglobby";
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { Plugin } from "vite";
|
|
1
|
+
import { type Plugin, type ResolvedConfig } from "vite";
|
|
2
|
+
import { type AngularBuildContext } from "./angular-build-context.js";
|
|
2
3
|
export interface VirtualModulesPluginOptions {
|
|
3
|
-
jit
|
|
4
|
+
jit?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function resolveAngularVirtualId(id: string, importer: string | undefined, options: {
|
|
7
|
+
jit: boolean;
|
|
8
|
+
resolvedConfig?: ResolvedConfig;
|
|
9
|
+
}): string | undefined;
|
|
10
|
+
export declare function loadAngularVirtualModule(pluginCtx: {
|
|
11
|
+
addWatchFile(path: string): void;
|
|
12
|
+
}, id: string, resolvedConfig?: ResolvedConfig): Promise<string | undefined>;
|
|
13
|
+
export declare function virtualModulesPlugin(ctxOrOptions?: AngularBuildContext | VirtualModulesPluginOptions): Plugin;
|
|
@@ -1,26 +1,57 @@
|
|
|
1
|
+
import { isAngularBuildContext } from "./angular-build-context.js";
|
|
2
|
+
import { markStylePathSafe } from "./utils/safe-module-paths.js";
|
|
1
3
|
import { toVirtualRawId } from "./utils/virtual-ids.js";
|
|
4
|
+
import { loadVirtualRawModule, rewriteHtmlRawImport } from "./utils/virtual-resources.js";
|
|
2
5
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
6
|
import { normalizePath } from "vite";
|
|
4
7
|
//#region packages/vite-plugin-angular/src/lib/virtual-modules-plugin.ts
|
|
5
|
-
function
|
|
8
|
+
function resolveAngularVirtualId(id, importer, options) {
|
|
9
|
+
if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
|
|
10
|
+
if (options.jit && id.startsWith("angular:jit:")) {
|
|
11
|
+
const filePath = normalizePath(resolve(dirname(importer), id.split(";")[1]));
|
|
12
|
+
if (id.includes(":style")) {
|
|
13
|
+
markStylePathSafe(options.resolvedConfig, filePath);
|
|
14
|
+
return filePath + "?inline";
|
|
15
|
+
}
|
|
16
|
+
return toVirtualRawId(filePath);
|
|
17
|
+
}
|
|
18
|
+
const rawRewrite = rewriteHtmlRawImport(id, importer);
|
|
19
|
+
if (rawRewrite) return rawRewrite;
|
|
20
|
+
if (/\.(css|scss|sass|less)\?inline$/.test(id) && importer) {
|
|
21
|
+
const filePath = id.split("?")[0];
|
|
22
|
+
const resolved = isAbsolute(filePath) ? normalizePath(filePath) : normalizePath(resolve(dirname(importer), filePath));
|
|
23
|
+
markStylePathSafe(options.resolvedConfig, resolved);
|
|
24
|
+
return resolved + "?inline";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function loadAngularVirtualModule(pluginCtx, id, resolvedConfig) {
|
|
28
|
+
const rawModule = await loadVirtualRawModule(pluginCtx, id);
|
|
29
|
+
if (rawModule !== void 0) return rawModule;
|
|
30
|
+
if (/\.(css|scss|sass|less)\?inline$/.test(id)) markStylePathSafe(resolvedConfig, id.split("?")[0]);
|
|
31
|
+
}
|
|
32
|
+
function virtualModulesPlugin(ctxOrOptions) {
|
|
33
|
+
const sharedCtx = isAngularBuildContext(ctxOrOptions) ? ctxOrOptions : void 0;
|
|
34
|
+
const standaloneJit = isAngularBuildContext(ctxOrOptions) ? ctxOrOptions.options.jit : ctxOrOptions?.jit ?? false;
|
|
35
|
+
let localConfig;
|
|
6
36
|
return {
|
|
7
37
|
name: "@analogjs/vite-plugin-angular:virtual-modules",
|
|
8
38
|
enforce: "pre",
|
|
39
|
+
configResolved(config) {
|
|
40
|
+
localConfig = config;
|
|
41
|
+
sharedCtx?.setResolvedConfig(config);
|
|
42
|
+
},
|
|
9
43
|
resolveId(id, importer) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const resolved = isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
|
|
18
|
-
if (resolved) return toVirtualRawId(resolved);
|
|
19
|
-
}
|
|
44
|
+
return resolveAngularVirtualId(id, importer, {
|
|
45
|
+
jit: sharedCtx ? sharedCtx.options.jit : standaloneJit,
|
|
46
|
+
resolvedConfig: sharedCtx?.resolvedConfig ?? localConfig
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
async load(id) {
|
|
50
|
+
return loadAngularVirtualModule(this, id, sharedCtx?.resolvedConfig ?? localConfig);
|
|
20
51
|
}
|
|
21
52
|
};
|
|
22
53
|
}
|
|
23
54
|
//#endregion
|
|
24
|
-
export { virtualModulesPlugin };
|
|
55
|
+
export { loadAngularVirtualModule, resolveAngularVirtualId, virtualModulesPlugin };
|
|
25
56
|
|
|
26
57
|
//# sourceMappingURL=virtual-modules-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit
|
|
1
|
+
{"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, type Plugin, type ResolvedConfig } from 'vite';\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { markStylePathSafe } from './utils/safe-module-paths.js';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\nimport {\n loadVirtualRawModule,\n rewriteHtmlRawImport,\n} from './utils/virtual-resources.js';\n\nexport interface VirtualModulesPluginOptions {\n jit?: boolean;\n}\n\nexport function resolveAngularVirtualId(\n id: string,\n importer: string | undefined,\n options: {\n jit: boolean;\n resolvedConfig?: ResolvedConfig;\n },\n): string | undefined {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (options.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n if (id.includes(':style')) {\n markStylePathSafe(options.resolvedConfig, filePath);\n return filePath + '?inline';\n }\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n const rawRewrite = rewriteHtmlRawImport(id, importer);\n if (rawRewrite) {\n return rawRewrite;\n }\n\n // User `.scss?inline` / `.css?inline` imports: resolve and mark\n // safe so Vite's native CSS pipeline handles them.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id) && importer) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : normalizePath(resolve(dirname(importer), filePath));\n markStylePathSafe(options.resolvedConfig, resolved);\n return resolved + '?inline';\n }\n\n return undefined;\n}\n\nexport async function loadAngularVirtualModule(\n pluginCtx: { addWatchFile(path: string): void },\n id: string,\n resolvedConfig?: ResolvedConfig,\n): Promise<string | undefined> {\n const rawModule = await loadVirtualRawModule(pluginCtx, id);\n if (rawModule !== undefined) {\n return rawModule;\n }\n\n // Vitest fallback: the module-runner can skip resolveId, so the bare\n // ?inline query reaches load. Mark safe and let Vite handle it.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id)) {\n markStylePathSafe(resolvedConfig, id.split('?')[0]);\n }\n\n return undefined;\n}\n\nexport function virtualModulesPlugin(\n ctxOrOptions?: AngularBuildContext | VirtualModulesPluginOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions\n : undefined;\n const standaloneJit = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.jit\n : (ctxOrOptions?.jit ?? false);\n let localConfig: ResolvedConfig | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n configResolved(config) {\n localConfig = config;\n sharedCtx?.setResolvedConfig(config);\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: sharedCtx ? sharedCtx.options.jit : standaloneJit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? localConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? localConfig,\n );\n },\n };\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,wBACd,IACA,UACA,SAIoB;CACpB,IAAI,GAAG,WAAA,4CAA6B,GAClC,OAAO,KAAK;CAGd,IAAI,QAAQ,OAAO,GAAG,WAAW,cAAc,GAAG;EAChD,MAAM,WAAW,cACf,QAAQ,QAAQ,QAAkB,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CACvD;EACA,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