@analogjs/vite-plugin-angular 3.0.0-alpha.64 → 3.0.0-alpha.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/angular-build-optimizer-plugin.js +23 -14
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.js +5 -4
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.js +51 -6
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.js +1 -1
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.js +2 -2
- package/src/lib/compiler/compile.js +1 -1
- package/src/lib/fast-compile-plugin.js +3 -3
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/template-class-binding-guard-plugin.js +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +3 -1
- 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 +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- 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 +8 -1
- package/src/lib/utils/plugin-config.js +17 -3
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/transform-cache.js +1 -1
package/package.json
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { jt } from "./utils/devkit.js";
|
|
2
|
+
import { isProdMode } from "./utils/plugin-config.js";
|
|
2
3
|
import { getJsTransformConfigKey } from "./utils/rolldown.js";
|
|
3
4
|
//#region packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts
|
|
4
5
|
function buildOptimizerPlugin({ jit }) {
|
|
5
|
-
|
|
6
|
-
sourcemap: false,
|
|
7
|
-
thirdPartySourcemaps: false,
|
|
8
|
-
advancedOptimizations: true,
|
|
9
|
-
jit: true
|
|
10
|
-
}, 1);
|
|
6
|
+
let javascriptTransformer;
|
|
11
7
|
let isProd = false;
|
|
8
|
+
let preserveVendorMaps = false;
|
|
12
9
|
return {
|
|
13
10
|
name: "@analogjs/vite-plugin-angular-optimizer",
|
|
14
|
-
apply
|
|
11
|
+
apply(_config, env) {
|
|
12
|
+
return env.command === "build" || process.env.NODE_ENV === "production";
|
|
13
|
+
},
|
|
15
14
|
config(userConfig) {
|
|
16
|
-
isProd = userConfig.mode
|
|
15
|
+
isProd = isProdMode(userConfig.mode);
|
|
16
|
+
javascriptTransformer ??= new jt({
|
|
17
|
+
sourcemap: false,
|
|
18
|
+
thirdPartySourcemaps: false,
|
|
19
|
+
advancedOptimizations: isProd,
|
|
20
|
+
jit: true
|
|
21
|
+
}, 1);
|
|
17
22
|
const jsTransformConfigKey = getJsTransformConfigKey();
|
|
18
23
|
return {
|
|
19
24
|
define: isProd ? {
|
|
@@ -30,15 +35,19 @@ function buildOptimizerPlugin({ jit }) {
|
|
|
30
35
|
} : void 0 }
|
|
31
36
|
};
|
|
32
37
|
},
|
|
38
|
+
configResolved(config) {
|
|
39
|
+
preserveVendorMaps = !!config.build.sourcemap;
|
|
40
|
+
},
|
|
33
41
|
transform: {
|
|
34
|
-
filter: { id: /\.[cm]?js
|
|
42
|
+
filter: { id: /\.[cm]?js(?:\?|$)/ },
|
|
35
43
|
async handler(code, id) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
const cleanId = id.split("?")[0];
|
|
45
|
+
if (!/fesm20/.test(cleanId)) return {
|
|
46
|
+
code: isProd && !preserveVendorMaps ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, "") : code,
|
|
47
|
+
map: preserveVendorMaps ? null : { mappings: "" }
|
|
39
48
|
};
|
|
40
|
-
const sideEffects = jit &&
|
|
41
|
-
const result = await javascriptTransformer.transformData(
|
|
49
|
+
const sideEffects = jit && cleanId.includes("@angular/compiler") ? true : false;
|
|
50
|
+
const result = await javascriptTransformer.transformData(cleanId, code, false, sideEffects);
|
|
42
51
|
return { code: Buffer.from(result).toString() };
|
|
43
52
|
}
|
|
44
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function buildOptimizerPlugin({\n jit,\n}: {\n supportedBrowsers: string[];\n jit: boolean;\n}): Plugin {\n
|
|
1
|
+
{"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode } from './utils/plugin-config.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function buildOptimizerPlugin({\n jit,\n}: {\n supportedBrowsers: string[];\n jit: boolean;\n}): Plugin {\n let javascriptTransformer: InstanceType<typeof JavaScriptTransformer>;\n let isProd = false;\n let preserveVendorMaps = false;\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n // Normally build-only. Astro's Cloudflare integration (`@astrojs/cloudflare`)\n // transforms SSR modules through a serve-style `workerd` runner *during*\n // `astro build`; an `apply: 'build'` plugin is excluded from that pipeline,\n // so the Angular linker never runs on the worker's partially-compiled\n // packages and they fall back to the JIT compiler. Also apply under a\n // production `NODE_ENV` (which `astro build` sets) so the linker runs in\n // that runner too. Regular Analog dev servers run with a development\n // `NODE_ENV`, so their behavior is unchanged.\n apply(_config, env) {\n return (\n env.command === 'build' || process.env['NODE_ENV'] === 'production'\n );\n },\n config(userConfig) {\n isProd = isProdMode(userConfig.mode);\n // Advanced optimizations paired with dev-mode defines would strip\n // dev-only code the debug API needs, so both key off `isProd`.\n javascriptTransformer ??= new JavaScriptTransformer(\n {\n sourcemap: false,\n thirdPartySourcemaps: false,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\n const jsTransformConfigKey = getJsTransformConfigKey();\n\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n [jsTransformConfigKey]: {\n define: isProd\n ? {\n ngDevMode: 'false',\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : undefined,\n },\n } as UserConfig;\n },\n configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\n },\n transform: {\n filter: {\n // Allow an optional `?query` after the extension. Some environments\n // (e.g. Cloudflare's `workerd`, used by Astro's Cloudflare integration)\n // reference optimized deps with a `?v=<hash>` suffix, e.g.\n // `.../fesm2022/_platform_location-chunk.mjs?v=a786a9ff`. A `$`-anchored\n // extension match skips those, so the Angular linker never runs and the\n // partially-compiled package falls back to the JIT compiler at runtime.\n id: /\\.[cm]?js(?:\\?|$)/,\n },\n async handler(code, id) {\n // Strip the `?query` so the fesm check and the transformer see a real\n // filename rather than `foo.mjs?v=<hash>`.\n const cleanId = id.split('?')[0];\n const angularPackage = /fesm20/.test(cleanId);\n\n if (!angularPackage) {\n // `{ mappings: '' }` declares zero segments, dropping the module's own\n // map from the chain; `null` keeps it. Removing `sourceMappingURL` is\n // what makes that map unreachable, so it only runs when discarding.\n return {\n code:\n isProd && !preserveVendorMaps\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: preserveVendorMaps ? null : { mappings: '' },\n };\n }\n\n const sideEffects =\n jit && cleanId.includes('@angular/compiler') ? true : false;\n const result: Uint8Array = await javascriptTransformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n return {\n code: Buffer.from(result).toString(),\n };\n },\n },\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,qBAAqB,EACnC,OAIS;CACT,IAAI;CACJ,IAAI,SAAS;CACb,IAAI,qBAAqB;AAEzB,QAAO;EACL,MAAM;EASN,MAAM,SAAS,KAAK;AAClB,UACE,IAAI,YAAY,WAAA,QAAA,IAAA,aAAuC;;EAG3D,OAAO,YAAY;AACjB,YAAS,WAAW,WAAW,KAAK;AAGpC,6BAA0B,IAAI,GAC5B;IACE,WAAW;IACX,sBAAsB;IACtB,uBAAuB;IACvB,KAAK;IACN,EACD,EACD;GACD,MAAM,uBAAuB,yBAAyB;AAEtD,UAAO;IACL,QAAQ,SACJ;KACE,WAAW;KACX,mBAAmB;KACnB,WAAW;KACX,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;KACtC,GACD,EAAE;KACL,uBAAuB,EACtB,QAAQ,SACJ;KACE,WAAW;KACX,WAAW;KACX,mBAAmB;KACnB,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;KACtC,GACD,KAAA,GACL;IACF;;EAEH,eAAe,QAAQ;AACrB,wBAAqB,CAAC,CAAC,OAAO,MAAM;;EAEtC,WAAW;GACT,QAAQ,EAON,IAAI,qBACL;GACD,MAAM,QAAQ,MAAM,IAAI;IAGtB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC;AAG9B,QAAI,CAFmB,SAAS,KAAK,QAAQ,CAM3C,QAAO;KACL,MACE,UAAU,CAAC,qBACP,KAAK,QAAQ,sCAAsC,GAAG,GACtD;KACN,KAAK,qBAAqB,OAAO,EAAE,UAAU,IAAI;KAClD;IAGH,MAAM,cACJ,OAAO,QAAQ,SAAS,oBAAoB,GAAG,OAAO;IACxD,MAAM,SAAqB,MAAM,sBAAsB,cACrD,SACA,MACA,OACA,YACD;AAED,WAAO,EACL,MAAM,OAAO,KAAK,OAAO,CAAC,UAAU,EACrC;;GAEJ;EACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getJitInlineStyles } from "./utils/jit-inline-styles.js";
|
|
1
2
|
import { debugStyles } from "./utils/debug.js";
|
|
2
3
|
import { isTailwindReferenceError } from "./utils/tailwind-reference.js";
|
|
3
4
|
import { preprocessCSS } from "vite";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
5
|
//#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
|
|
6
6
|
function jitPlugin({ inlineStylesExtension }) {
|
|
7
7
|
let config;
|
|
@@ -15,9 +15,10 @@ function jitPlugin({ inlineStylesExtension }) {
|
|
|
15
15
|
},
|
|
16
16
|
async load(id) {
|
|
17
17
|
if (id.includes("virtual:angular:jit:style:inline;")) {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
18
|
+
const styleIdHash = id.split("style:inline;")[1];
|
|
19
|
+
const encodedStyles = getJitInlineStyles(styleIdHash);
|
|
20
|
+
if (encodedStyles === void 0) return;
|
|
21
|
+
const decodedStyles = Buffer.from(decodeURIComponent(encodedStyles), "base64").toString();
|
|
21
22
|
let styles = "";
|
|
22
23
|
try {
|
|
23
24
|
styles = (await preprocessCSS(decodedStyles, `${styleIdHash}.${inlineStylesExtension}?direct`, config))?.code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n} from './utils/jit-inline-styles.js';\nimport { debugStyles } from './utils/debug.js';\nimport { isTailwindReferenceError } from './utils/tailwind-reference.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes(JIT_INLINE_STYLE_PREFIX)) {\n const styleIdHash = id.split('style:inline;')[1];\n const encodedStyles = getJitInlineStyles(styleIdHash);\n\n if (encodedStyles === undefined) {\n return;\n }\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n decodedStyles,\n `${styleIdHash}.${inlineStylesExtension}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n if (isTailwindReferenceError(e)) {\n throw e;\n }\n const errorMessage = e instanceof Error ? e.message : String(e);\n debugStyles('jit css compilation error', {\n styleIdHash,\n error: errorMessage,\n });\n console.warn(\n '[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s',\n styleIdHash,\n errorMessage,\n );\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;;AAQA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAA,oCAAiC,EAAE;IACxC,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;IAC9C,MAAM,gBAAgB,mBAAmB,YAAY;AAErD,QAAI,kBAAkB,KAAA,EACpB;IAGF,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,cAAc,EACjC,SACD,CAAC,UAAU;IAEZ,IAAI,SAA6B;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,eACA,GAAG,YAAY,GAAG,sBAAsB,UACxC,OACD,GACkB;aACZ,GAAG;AACV,SAAI,yBAAyB,EAAE,CAC7B,OAAM;KAER,MAAM,eAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;AAC/D,iBAAY,6BAA6B;MACvC;MACA,OAAO;MACR,CAAC;AACF,aAAQ,KACN,6HACA,aACA,aACD;;AAGH,WAAO,oBAAoB,OAAO;;;EAKvC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { angularFullVersion, cjt, sourceFileCache } from "./utils/devkit.js";
|
|
2
|
+
import { createCompilerPlugin, createRolldownCompilerPlugin } from "./compiler-plugin.js";
|
|
3
|
+
import { TS_EXT_REGEX, createTsConfigGetter, getTsConfigPath, isProdMode } from "./utils/plugin-config.js";
|
|
2
4
|
import { getJsTransformConfigKey, isRolldown } from "./utils/rolldown.js";
|
|
3
5
|
import { buildOptimizerPlugin } from "./angular-build-optimizer-plugin.js";
|
|
6
|
+
import { toJitInlineStyleId } from "./utils/jit-inline-styles.js";
|
|
4
7
|
import { activateDeferredDebug, applyDebugOption, debugCompiler, debugCompilerV, debugEmit, debugEmitV, debugHmr, debugHmrV, debugStyles, debugStylesV } from "./utils/debug.js";
|
|
5
8
|
import { jitPlugin } from "./angular-jit-plugin.js";
|
|
6
|
-
import { createCompilerPlugin, createRolldownCompilerPlugin } from "./compiler-plugin.js";
|
|
7
9
|
import { StyleUrlsResolver, TemplateUrlsResolver, getAngularComponentMetadata } from "./component-resolvers.js";
|
|
8
10
|
import { AnalogStylesheetRegistry, preprocessStylesheet, rewriteRelativeCssImports } from "./stylesheet-registry.js";
|
|
9
11
|
import { augmentHostWithCaching, augmentHostWithResources, augmentProgramWithVersioning, mergeTransformers } from "./host.js";
|
|
10
|
-
import { TS_EXT_REGEX, createTsConfigGetter, getTsConfigPath } from "./utils/plugin-config.js";
|
|
11
12
|
import { TsconfigResolver } from "./utils/tsconfig-resolver.js";
|
|
12
13
|
import { configureStylePipelineRegistry } from "./style-pipeline.js";
|
|
13
14
|
import { describeStylesheetContent, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode } from "./utils/compilation-shared.js";
|
|
@@ -214,7 +215,7 @@ function angular(options) {
|
|
|
214
215
|
async config(config, { command }) {
|
|
215
216
|
activateDeferredDebug(command);
|
|
216
217
|
watchMode = command === "serve";
|
|
217
|
-
isProd = config.mode
|
|
218
|
+
isProd = isProdMode(config.mode);
|
|
218
219
|
tsConfigResolutionContext = {
|
|
219
220
|
root: config.root || ".",
|
|
220
221
|
isProd,
|
|
@@ -296,7 +297,8 @@ function angular(options) {
|
|
|
296
297
|
},
|
|
297
298
|
async buildStart() {
|
|
298
299
|
if (!isVitestVscode) {
|
|
299
|
-
|
|
300
|
+
pendingCompilation = performCompilation(resolvedConfig);
|
|
301
|
+
await pendingCompilation;
|
|
300
302
|
pendingCompilation = null;
|
|
301
303
|
initialCompilation = true;
|
|
302
304
|
}
|
|
@@ -355,6 +357,7 @@ function angular(options) {
|
|
|
355
357
|
if (/\.(html|htm|css|less|sass|scss)$/.test(ctx.file)) {
|
|
356
358
|
debugHmr("resource file changed", { file: ctx.file });
|
|
357
359
|
fileTransformMap.delete(ctx.file.split("?")[0]);
|
|
360
|
+
const fileModules = await getModulesForChangedFile(ctx.server, ctx.file, ctx.modules, stylesheetRegistry);
|
|
358
361
|
/**
|
|
359
362
|
* Check to see if this was a direct request
|
|
360
363
|
* for an external resource (styles, html).
|
|
@@ -722,7 +725,7 @@ function angular(options) {
|
|
|
722
725
|
warningCount: typescriptResult.warnings?.length ?? 0
|
|
723
726
|
});
|
|
724
727
|
if (jit && data.includes("angular:jit:")) {
|
|
725
|
-
data = data.replace(/angular:jit:style:inline
|
|
728
|
+
data = data.replace(/angular:jit:style:inline;([A-Za-z0-9+/=]*)/g, (_match, encodedStyles) => toJitInlineStyleId(encodedStyles));
|
|
726
729
|
templateUrls.forEach((templateUrlSet) => {
|
|
727
730
|
const [templateFile, resolvedTemplateUrl] = templateUrlSet.split("|");
|
|
728
731
|
data = data.replace(`angular:jit:template:file;${templateFile}`, toVirtualRawId(resolvedTemplateUrl));
|
|
@@ -820,7 +823,7 @@ function angular(options) {
|
|
|
820
823
|
].filter(Boolean);
|
|
821
824
|
function resolveTsConfigPath() {
|
|
822
825
|
const tsconfigValue = pluginOptions.tsconfigGetter();
|
|
823
|
-
return getTsConfigPath(tsConfigResolutionContext.root, tsconfigValue, tsConfigResolutionContext.isProd, isTest, tsConfigResolutionContext.isLib);
|
|
826
|
+
return getTsConfigPath(tsConfigResolutionContext.root, tsconfigValue, tsConfigResolutionContext.isProd, isTest, tsConfigResolutionContext.isLib, pluginOptions.workspaceRoot);
|
|
824
827
|
}
|
|
825
828
|
async function performCompilation(config, ids) {
|
|
826
829
|
let resolve;
|
|
@@ -1002,6 +1005,48 @@ function createFsWatcherCacheInvalidator(invalidateFsCaches, invalidateTsconfigC
|
|
|
1002
1005
|
await performCompilation();
|
|
1003
1006
|
};
|
|
1004
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Returns every live Vite module that can legitimately represent a changed
|
|
1010
|
+
* Angular resource file.
|
|
1011
|
+
*
|
|
1012
|
+
* For normal files, `getModulesByFile()` is enough. For Angular component
|
|
1013
|
+
* stylesheets, it is not: the browser often holds virtual hashed requests
|
|
1014
|
+
* (`/abc123.css?direct&ngcomp=...` and `/abc123.css?ngcomp=...`) that are no
|
|
1015
|
+
* longer discoverable from the original source path alone. We therefore merge:
|
|
1016
|
+
* - watcher event modules
|
|
1017
|
+
* - module-graph modules by source file
|
|
1018
|
+
* - registry-tracked live request ids resolved back through the module graph
|
|
1019
|
+
*/
|
|
1020
|
+
async function getModulesForChangedFile(server, file, eventModules = [], stylesheetRegistry) {
|
|
1021
|
+
const normalizedFile = normalizePath(file.split("?")[0]);
|
|
1022
|
+
const modules = /* @__PURE__ */ new Map();
|
|
1023
|
+
for (const mod of eventModules) if (mod.id) modules.set(mod.id, mod);
|
|
1024
|
+
server.moduleGraph.getModulesByFile(normalizedFile)?.forEach((mod) => {
|
|
1025
|
+
if (mod.id) modules.set(mod.id, mod);
|
|
1026
|
+
});
|
|
1027
|
+
const stylesheetRequestIds = stylesheetRegistry?.getRequestIdsForSource(normalizedFile) ?? [];
|
|
1028
|
+
const requestIdHits = [];
|
|
1029
|
+
for (const requestId of stylesheetRequestIds) {
|
|
1030
|
+
const candidates = [requestId, requestId.startsWith("/") ? requestId : `/${requestId}`];
|
|
1031
|
+
for (const candidate of candidates) {
|
|
1032
|
+
const mod = await server.moduleGraph.getModuleByUrl(candidate) ?? server.moduleGraph.getModuleById(candidate);
|
|
1033
|
+
requestIdHits.push({
|
|
1034
|
+
requestId,
|
|
1035
|
+
candidate,
|
|
1036
|
+
via: mod?.url === candidate ? "url" : "id",
|
|
1037
|
+
moduleId: mod?.id
|
|
1038
|
+
});
|
|
1039
|
+
if (mod?.id) modules.set(mod.id, mod);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
debugHmrV("getModulesForChangedFile registry lookup", {
|
|
1043
|
+
file: normalizedFile,
|
|
1044
|
+
stylesheetRequestIds,
|
|
1045
|
+
requestIdHits,
|
|
1046
|
+
resolvedModuleIds: [...modules.keys()]
|
|
1047
|
+
});
|
|
1048
|
+
return [...modules.values()];
|
|
1049
|
+
}
|
|
1005
1050
|
function isModuleForChangedResource(mod, changedFile, stylesheetRegistry) {
|
|
1006
1051
|
const normalizedChangedFile = normalizePath(changedFile.split("?")[0]);
|
|
1007
1052
|
if (normalizePath((mod.file ?? "").split("?")[0]) === normalizedChangedFile) return true;
|