@master/css-vite 0.0.0-site.1793659883.g69c9aebcf628
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 +348 -0
- package/dist/common.d.ts +14 -0
- package/dist/common.js +26 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.js +165 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/internal/src/emitted-globals-module.js +12 -0
- package/dist/internal/src/manifest-facade.js +68 -0
- package/dist/internal/src/manifest-loader.js +33 -0
- package/dist/internal/src/manifest-module.js +58 -0
- package/dist/internal/src/manifest-virtual-module.js +123 -0
- package/dist/internal/src/node.js +22 -0
- package/dist/internal/src/program-module.js +50 -0
- package/dist/internal/src/project.js +10 -0
- package/dist/internal/src/runtime-bootstrap.js +80 -0
- package/dist/internal/src/style-module.js +3 -0
- package/dist/modes/pre-render.d.ts +5 -0
- package/dist/modes/pre-render.js +6 -0
- package/dist/modes/progressive.d.ts +5 -0
- package/dist/modes/progressive.js +12 -0
- package/dist/modes/runtime.d.ts +5 -0
- package/dist/modes/runtime.js +17 -0
- package/dist/modes/static.d.ts +5 -0
- package/dist/modes/static.js +5 -0
- package/dist/options.d.ts +20 -0
- package/dist/options.js +23 -0
- package/dist/plugins/avoid-fouc.d.ts +5 -0
- package/dist/plugins/avoid-fouc.js +48 -0
- package/dist/plugins/build-stylesheet-recovery.d.ts +5 -0
- package/dist/plugins/build-stylesheet-recovery.js +26 -0
- package/dist/plugins/context.d.ts +5 -0
- package/dist/plugins/context.js +12 -0
- package/dist/plugins/dev-stylesheet.d.ts +4 -0
- package/dist/plugins/dev-stylesheet.js +63 -0
- package/dist/plugins/emitted-globals-virtual-module.d.ts +14 -0
- package/dist/plugins/emitted-globals-virtual-module.js +167 -0
- package/dist/plugins/inject-runtime.d.ts +5 -0
- package/dist/plugins/inject-runtime.js +51 -0
- package/dist/plugins/inline-stylesheet.d.ts +5 -0
- package/dist/plugins/inline-stylesheet.js +197 -0
- package/dist/plugins/local-styles.d.ts +5 -0
- package/dist/plugins/local-styles.js +214 -0
- package/dist/plugins/manifest-loader.d.ts +4 -0
- package/dist/plugins/manifest-loader.js +102 -0
- package/dist/plugins/manifest-virtual-module.d.ts +4 -0
- package/dist/plugins/manifest-virtual-module.js +70 -0
- package/dist/plugins/pre-render.d.ts +5 -0
- package/dist/plugins/pre-render.js +224 -0
- package/dist/plugins/program-preload.d.ts +5 -0
- package/dist/plugins/program-preload.js +37 -0
- package/dist/plugins/runtime-bootstrap.d.ts +3 -0
- package/dist/plugins/runtime-bootstrap.js +14 -0
- package/dist/plugins/runtime-preload.d.ts +4 -0
- package/dist/plugins/runtime-preload.js +38 -0
- package/dist/plugins/sass-source.d.ts +5 -0
- package/dist/plugins/sass-source.js +176 -0
- package/dist/plugins/scanner.d.ts +5 -0
- package/dist/plugins/scanner.js +24 -0
- package/dist/plugins/style-entry-build.d.ts +5 -0
- package/dist/plugins/style-entry-build.js +121 -0
- package/dist/plugins/style-entry-hmr.d.ts +6 -0
- package/dist/plugins/style-entry-hmr.js +78 -0
- package/dist/plugins/style-entry.d.ts +5 -0
- package/dist/plugins/style-entry.js +89 -0
- package/dist/plugins/stylesheet-recovery.d.ts +5 -0
- package/dist/plugins/stylesheet-recovery.js +70 -0
- package/dist/plugins/usage-graph.d.ts +5 -0
- package/dist/plugins/usage-graph.js +48 -0
- package/dist/preset/src/default-manifest.js +15913 -0
- package/dist/utils/build-import-resolver.d.ts +29 -0
- package/dist/utils/build-import-resolver.js +101 -0
- package/dist/utils/build-sass-source.d.ts +38 -0
- package/dist/utils/build-sass-source.js +225 -0
- package/dist/utils/build-stylesheet-delivery.d.ts +12 -0
- package/dist/utils/build-stylesheet-delivery.js +130 -0
- package/dist/utils/build-watch-recovery.d.ts +10 -0
- package/dist/utils/build-watch-recovery.js +119 -0
- package/dist/utils/coalesced-task.d.ts +3 -0
- package/dist/utils/coalesced-task.js +25 -0
- package/dist/utils/dev-module-refresh.d.ts +9 -0
- package/dist/utils/dev-module-refresh.js +17 -0
- package/dist/utils/dev-stylesheet-delivery.d.ts +21 -0
- package/dist/utils/dev-stylesheet-delivery.js +98 -0
- package/dist/utils/environment-closing.d.ts +3 -0
- package/dist/utils/environment-closing.js +28 -0
- package/dist/utils/extracted-css.d.ts +4 -0
- package/dist/utils/extracted-css.js +34 -0
- package/dist/utils/failed-dependency-reconciliation.d.ts +15 -0
- package/dist/utils/failed-dependency-reconciliation.js +150 -0
- package/dist/utils/failed-stylesheet-dependencies.d.ts +16 -0
- package/dist/utils/failed-stylesheet-dependencies.js +92 -0
- package/dist/utils/html.d.ts +8 -0
- package/dist/utils/html.js +36 -0
- package/dist/utils/inline-stylesheet.d.ts +37 -0
- package/dist/utils/inline-stylesheet.js +129 -0
- package/dist/utils/local-stylesheet.d.ts +10 -0
- package/dist/utils/local-stylesheet.js +25 -0
- package/dist/utils/manifest-recovery.d.ts +11 -0
- package/dist/utils/manifest-recovery.js +77 -0
- package/dist/utils/module-sources.d.ts +26 -0
- package/dist/utils/module-sources.js +131 -0
- package/dist/utils/path.d.ts +5 -0
- package/dist/utils/path.js +27 -0
- package/dist/utils/recovery-error.d.ts +3 -0
- package/dist/utils/recovery-error.js +17 -0
- package/dist/utils/register-style-source.d.ts +4 -0
- package/dist/utils/register-style-source.js +23 -0
- package/dist/utils/sass-diagnostics.d.ts +4 -0
- package/dist/utils/sass-diagnostics.js +109 -0
- package/dist/utils/sass-proxy-access.d.ts +4 -0
- package/dist/utils/sass-proxy-access.js +28 -0
- package/dist/utils/sass-source-markers.d.ts +8 -0
- package/dist/utils/sass-source-markers.js +50 -0
- package/dist/utils/scanner-context.d.ts +12 -0
- package/dist/utils/scanner-context.js +100 -0
- package/dist/utils/scoped-plugins.d.ts +4 -0
- package/dist/utils/scoped-plugins.js +81 -0
- package/dist/utils/write-file.d.ts +3 -0
- package/dist/utils/write-file.js +9 -0
- package/package.json +62 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RESOLVED_MASTER_CSS_RUNTIME_BOOTSTRAP_ID, createMasterCSSRuntimeBootstrapSource } from "../internal/src/runtime-bootstrap.js";
|
|
2
|
+
// src/plugins/runtime-bootstrap.ts
|
|
3
|
+
function RuntimeBootstrapPlugin(progressive) {
|
|
4
|
+
return {
|
|
5
|
+
name: "master-css:runtime-bootstrap",
|
|
6
|
+
resolveId(id) {
|
|
7
|
+
if (id === "virtual:master-css-runtime") return RESOLVED_MASTER_CSS_RUNTIME_BOOTSTRAP_ID;
|
|
8
|
+
},
|
|
9
|
+
load(id) {
|
|
10
|
+
if (id === "\0virtual:master-css-runtime") return createMasterCSSRuntimeBootstrapSource({ progressive });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export { RuntimeBootstrapPlugin as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "../internal/src/runtime-bootstrap.js";
|
|
2
|
+
import { DEV_RUNTIME_ENTRY_ID, RUNTIME_ENTRY_ID } from "../common.js";
|
|
3
|
+
import { hasModulePreloadLink, toAssetHref } from "../utils/html.js";
|
|
4
|
+
// src/plugins/runtime-preload.ts
|
|
5
|
+
function isRuntimeModuleId(id) {
|
|
6
|
+
const normalized = id.replace(/\\/g, "/");
|
|
7
|
+
return normalized === RUNTIME_ENTRY_ID || normalized === "\0virtual:master-css-runtime";
|
|
8
|
+
}
|
|
9
|
+
function findRuntimeChunkFileName(bundle) {
|
|
10
|
+
for (const output of Object.values(bundle)) if (output.type === "chunk" && output.fileName && output.moduleIds?.some(isRuntimeModuleId)) return output.fileName;
|
|
11
|
+
}
|
|
12
|
+
function RuntimePreloadPlugin(context) {
|
|
13
|
+
return {
|
|
14
|
+
name: "master-css:runtime-preload",
|
|
15
|
+
transformIndexHtml: {
|
|
16
|
+
order: "post",
|
|
17
|
+
handler(html, htmlContext) {
|
|
18
|
+
const bundle = htmlContext.bundle;
|
|
19
|
+
const fileName = bundle ? findRuntimeChunkFileName(bundle) : void 0;
|
|
20
|
+
const href = fileName ? toAssetHref(fileName, context.config?.base, htmlContext.path) : htmlContext.server ? toAssetHref(DEV_RUNTIME_ENTRY_ID, htmlContext.server.config?.base ?? context.config?.base, htmlContext.path) : void 0;
|
|
21
|
+
if (!href || hasModulePreloadLink(html, href)) return;
|
|
22
|
+
return {
|
|
23
|
+
html,
|
|
24
|
+
tags: [{
|
|
25
|
+
tag: "link",
|
|
26
|
+
attrs: {
|
|
27
|
+
rel: "modulepreload",
|
|
28
|
+
crossorigin: "",
|
|
29
|
+
href
|
|
30
|
+
},
|
|
31
|
+
injectTo: "head-prepend"
|
|
32
|
+
}]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export { RuntimePreloadPlugin as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { MasterCSSVitePluginContext } from "../core.js";
|
|
3
|
+
/** Sass and CSS Modules enter the CSS pipeline after host preprocessing. */
|
|
4
|
+
declare function SassSourcePlugin(context: MasterCSSVitePluginContext): Plugin;
|
|
5
|
+
export { SassSourcePlugin as default };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { normalizeFilePath } from "../utils/path.js";
|
|
2
|
+
import { onEnvironmentClosing } from "../utils/environment-closing.js";
|
|
3
|
+
import { clearBuildSassSources, getSassSourceFile, invalidatePreparedSassSources, isRawStyleRequest, isSassModuleID, prepareBuildSassSource, sassModuleID, sassSourceID } from "../utils/build-sass-source.js";
|
|
4
|
+
import { getScanner } from "../utils/scanner-context.js";
|
|
5
|
+
import { installSassProxyAccessCheck } from "../utils/sass-proxy-access.js";
|
|
6
|
+
import { isAbsolute } from "node:path";
|
|
7
|
+
// src/plugins/sass-source.ts
|
|
8
|
+
/** Sass and CSS Modules enter the CSS pipeline after host preprocessing. */
|
|
9
|
+
function SassSourcePlugin(context) {
|
|
10
|
+
let stylesheetURLs = /* @__PURE__ */ new Map();
|
|
11
|
+
let pendingStylesheetURLs = /* @__PURE__ */ new Set();
|
|
12
|
+
const lifetimes = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
return {
|
|
14
|
+
name: "master-css:sass-source",
|
|
15
|
+
enforce: "pre",
|
|
16
|
+
buildStart() {
|
|
17
|
+
if (context.config?.command !== "serve") clearBuildSassSources(context);
|
|
18
|
+
},
|
|
19
|
+
configureServer(server) {
|
|
20
|
+
installSassProxyAccessCheck(server);
|
|
21
|
+
clearBuildSassSources(context);
|
|
22
|
+
const serverStylesheetURLs = /* @__PURE__ */ new Map();
|
|
23
|
+
const serverPendingURLs = /* @__PURE__ */ new Set();
|
|
24
|
+
stylesheetURLs = serverStylesheetURLs;
|
|
25
|
+
pendingStylesheetURLs = serverPendingURLs;
|
|
26
|
+
server.middlewares.use((request, response, next) => {
|
|
27
|
+
const requestURL = request.url;
|
|
28
|
+
if (!requestURL || !request.headers.accept?.includes("text/css")) return next();
|
|
29
|
+
const url = new URL(requestURL, "http://master-css.invalid");
|
|
30
|
+
const base = server.config.base;
|
|
31
|
+
if (base !== "/" && url.pathname.startsWith(base)) url.pathname = "/" + url.pathname.slice(base.length);
|
|
32
|
+
const servedPath = url.pathname;
|
|
33
|
+
if (!/\.(?:css|scss|sass)$/.test(servedPath)) return next();
|
|
34
|
+
let complete, finished = false, aborted = false;
|
|
35
|
+
const registration = new Promise((resolve) => {
|
|
36
|
+
complete = resolve;
|
|
37
|
+
}).finally(() => {
|
|
38
|
+
serverPendingURLs.delete(registration);
|
|
39
|
+
});
|
|
40
|
+
serverPendingURLs.add(registration);
|
|
41
|
+
response.once("close", () => {
|
|
42
|
+
if (!finished) {
|
|
43
|
+
aborted = true;
|
|
44
|
+
complete();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
response.once("finish", () => {
|
|
48
|
+
finished = true;
|
|
49
|
+
if (aborted || response.statusCode !== 200) {
|
|
50
|
+
complete();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let graphURL;
|
|
54
|
+
try {
|
|
55
|
+
graphURL = decodeURI(url.pathname) + url.search + (url.searchParams.has("direct") ? "" : url.search ? "&direct" : "?direct");
|
|
56
|
+
} catch {
|
|
57
|
+
complete();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
server.moduleGraph.getModuleByUrl(graphURL).then((module) => {
|
|
61
|
+
const owner = module?.id && getSassSourceFile(module.id);
|
|
62
|
+
if (!owner) return;
|
|
63
|
+
let urls = serverStylesheetURLs.get(normalizeFilePath(owner));
|
|
64
|
+
if (!urls) {
|
|
65
|
+
urls = /* @__PURE__ */ new Set();
|
|
66
|
+
serverStylesheetURLs.set(normalizeFilePath(owner), urls);
|
|
67
|
+
}
|
|
68
|
+
urls.add(servedPath);
|
|
69
|
+
}).catch((error) => server.config.logger.warn(`[master-css] Could not track stylesheet URL ${servedPath}: ${String(error)}`)).finally(complete);
|
|
70
|
+
});
|
|
71
|
+
next();
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
async hotUpdate({ file, modules, timestamp }) {
|
|
75
|
+
const { moduleGraph, hot } = this.environment;
|
|
76
|
+
let lifetime = lifetimes.get(this.environment);
|
|
77
|
+
if (!lifetime) {
|
|
78
|
+
let close;
|
|
79
|
+
const current = {
|
|
80
|
+
closed: false,
|
|
81
|
+
promise: new Promise((resolve) => {
|
|
82
|
+
close = resolve;
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
lifetimes.set(this.environment, current);
|
|
86
|
+
onEnvironmentClosing(this.environment, () => {
|
|
87
|
+
current.closed = true;
|
|
88
|
+
close();
|
|
89
|
+
});
|
|
90
|
+
lifetime = current;
|
|
91
|
+
}
|
|
92
|
+
const urls = stylesheetURLs;
|
|
93
|
+
await Promise.race([Promise.all(pendingStylesheetURLs), lifetime.promise]);
|
|
94
|
+
if (lifetime.closed || urls !== stylesheetURLs) return;
|
|
95
|
+
const owners = new Set(invalidatePreparedSassSources(context, file));
|
|
96
|
+
const pending = new Set(modules);
|
|
97
|
+
for (const module of pending) {
|
|
98
|
+
const owner = getSassSourceFile(module.id ?? "");
|
|
99
|
+
if (owner) owners.add(normalizeFilePath(owner));
|
|
100
|
+
else for (const importer of module.importers) pending.add(importer);
|
|
101
|
+
}
|
|
102
|
+
if (!owners.size) return;
|
|
103
|
+
const affected = new Set(modules);
|
|
104
|
+
for (const module of moduleGraph.idToModuleMap.values()) {
|
|
105
|
+
const owner = getSassSourceFile(module.id ?? "");
|
|
106
|
+
if (!owner || !owners.has(normalizeFilePath(owner))) continue;
|
|
107
|
+
moduleGraph.invalidateModule(module);
|
|
108
|
+
affected.add(module);
|
|
109
|
+
}
|
|
110
|
+
const paths = new Set([...owners].flatMap((owner) => [...urls.get(owner) ?? []]));
|
|
111
|
+
if (paths.size && this.environment.config.consumer === "client") hot.send({
|
|
112
|
+
type: "update",
|
|
113
|
+
updates: [...paths].map((path) => ({
|
|
114
|
+
type: "css-update",
|
|
115
|
+
path,
|
|
116
|
+
acceptedPath: path,
|
|
117
|
+
timestamp
|
|
118
|
+
}))
|
|
119
|
+
});
|
|
120
|
+
return [...affected];
|
|
121
|
+
},
|
|
122
|
+
shouldTransformCachedModule({ id }) {
|
|
123
|
+
if (isSassModuleID(id)) return true;
|
|
124
|
+
},
|
|
125
|
+
async transform(code, id) {
|
|
126
|
+
if (!isSassModuleID(id)) return;
|
|
127
|
+
await getScanner(context).scanModule(`${getSassSourceFile(id)}.js`, code);
|
|
128
|
+
},
|
|
129
|
+
async resolveId(id, importer) {
|
|
130
|
+
const proxyOwner = getSassSourceFile(id);
|
|
131
|
+
if (proxyOwner) {
|
|
132
|
+
if (context.config?.command !== "serve" || isSassModuleID(id)) return id;
|
|
133
|
+
const query = id.slice(sassSourceID(proxyOwner).length);
|
|
134
|
+
const resolved = await this.resolve(proxyOwner + query, importer, { skipSelf: true });
|
|
135
|
+
if (!resolved || resolved.external) return resolved;
|
|
136
|
+
const file = resolved.id.replace(/[?#].*$/, "");
|
|
137
|
+
if (!isAbsolute(file)) return;
|
|
138
|
+
return {
|
|
139
|
+
...resolved,
|
|
140
|
+
id: sassSourceID(file) + resolved.id.slice(file.length)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const stylesheetURL = context.config?.command === "build" && /[?&]url(?:[=&]|$)/.test(id) && !/[?&]raw(?:[=&]|$)/.test(id) && /\.(?:scss|sass)(?:[?#].*)?$/.test(id) && !/\.module\.(?:scss|sass)(?:[?#].*)?$/.test(id);
|
|
144
|
+
if (isRawStyleRequest(id) && !stylesheetURL) return;
|
|
145
|
+
if (!(/\.module\.css(?:[?#].*)?$/.test(id) && context.config?.css.modules !== false) && !/\.(?:scss|sass)(?:[?#].*)?$/.test(id)) return;
|
|
146
|
+
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
147
|
+
if (!resolved || resolved.external) return;
|
|
148
|
+
const file = resolved.id.replace(/[?#].*$/, "");
|
|
149
|
+
if (!isAbsolute(file)) return;
|
|
150
|
+
const query = resolved.id.slice(file.length);
|
|
151
|
+
const modules = /\.module\.(?:css|scss|sass)$/.test(file) && context.config?.css.modules !== false && !/[?&]inline(?:[=&]|$)/.test(query);
|
|
152
|
+
return {
|
|
153
|
+
...resolved,
|
|
154
|
+
id: (modules ? sassModuleID(file) : sassSourceID(file)) + query
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
async load(id) {
|
|
158
|
+
if (isRawStyleRequest(id)) return;
|
|
159
|
+
const file = getSassSourceFile(id);
|
|
160
|
+
if (!file) return;
|
|
161
|
+
this.addWatchFile(file);
|
|
162
|
+
const result = await prepareBuildSassSource(context, file, (dependency) => this.addWatchFile(dependency));
|
|
163
|
+
for (const dependency of result.deps ?? []) this.addWatchFile(dependency);
|
|
164
|
+
if (isSassModuleID(id)) {
|
|
165
|
+
const modules = result.modules ?? {};
|
|
166
|
+
const exports = Object.entries(modules).filter(([key]) => key !== "default").map(([key, value], index) => `const value${index} = ${JSON.stringify(value)}; export { value${index} as ${JSON.stringify(key)} };`);
|
|
167
|
+
return `import ${JSON.stringify(sassSourceID(file))};\n${exports.join("\n")}\nexport default ${JSON.stringify(modules)};`;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
code: result.code,
|
|
171
|
+
map: result.map
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export { SassSourcePlugin as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { ResolvedMasterCSSVitePluginOptions } from "../options.js";
|
|
3
|
+
import { MasterCSSVitePluginContext } from "../core.js";
|
|
4
|
+
declare function ScannerPlugin(options: ResolvedMasterCSSVitePluginOptions, context: MasterCSSVitePluginContext): Plugin;
|
|
5
|
+
export { ScannerPlugin as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { disposeScanner, ensureScanner, releaseScannerEnvironment, trackScannerEnvironments } from "../utils/scanner-context.js";
|
|
2
|
+
// src/plugins/scanner.ts
|
|
3
|
+
function ScannerPlugin(options, context) {
|
|
4
|
+
return {
|
|
5
|
+
name: "master-css:scanner",
|
|
6
|
+
enforce: "pre",
|
|
7
|
+
async configResolved(config) {
|
|
8
|
+
context.config = config;
|
|
9
|
+
await ensureScanner(options, context);
|
|
10
|
+
},
|
|
11
|
+
async buildStart() {
|
|
12
|
+
await ensureScanner(options, context);
|
|
13
|
+
},
|
|
14
|
+
configureServer(server) {
|
|
15
|
+
const config = server.config;
|
|
16
|
+
trackScannerEnvironments(context, config, () => server.config === config ? Object.values(server.environments) : []);
|
|
17
|
+
},
|
|
18
|
+
async closeBundle() {
|
|
19
|
+
const config = this.environment?.getTopLevelConfig() ?? context.config;
|
|
20
|
+
if (releaseScannerEnvironment(context, config, this.environment)) await disposeScanner(context, config);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { ScannerPlugin as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { ResolvedMasterCSSVitePluginOptions } from "../options.js";
|
|
3
|
+
import { MasterCSSVitePluginContext } from "../core.js";
|
|
4
|
+
declare function StyleEntryBuildPlugin(_options: ResolvedMasterCSSVitePluginOptions, context: MasterCSSVitePluginContext): Plugin;
|
|
5
|
+
export { StyleEntryBuildPlugin as default };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { getScanner } from "../utils/scanner-context.js";
|
|
2
|
+
import { prepareBuildStylesheet } from "../utils/build-stylesheet-delivery.js";
|
|
3
|
+
import getExtractedCSS, { getExtractedCSSResult } from "../utils/extracted-css.js";
|
|
4
|
+
import { removeGraphOnlyStylesheetEntries } from "../utils/build-import-resolver.js";
|
|
5
|
+
import { clearLocalStylesheets, localStylesheets } from "../utils/local-stylesheet.js";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { posix } from "node:path";
|
|
9
|
+
import { createCompilerSync } from "@master/css-compiler/node";
|
|
10
|
+
// src/plugins/style-entry-build.ts
|
|
11
|
+
function replaceSlotCSSRule(source, slotCSSRule, realCSS) {
|
|
12
|
+
let replaced = false;
|
|
13
|
+
return {
|
|
14
|
+
source: source.split(slotCSSRule).map((part, index) => {
|
|
15
|
+
if (index === 0) return part;
|
|
16
|
+
if (replaced) return part;
|
|
17
|
+
replaced = true;
|
|
18
|
+
return realCSS + part;
|
|
19
|
+
}).join(""),
|
|
20
|
+
replaced
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function StyleEntryBuildPlugin(_options, context) {
|
|
24
|
+
let renderedCSS;
|
|
25
|
+
let extracted;
|
|
26
|
+
let compiler;
|
|
27
|
+
const prepared = /* @__PURE__ */ new Map();
|
|
28
|
+
const prepare = (source) => {
|
|
29
|
+
if (!compiler || !extracted) return;
|
|
30
|
+
if (!prepared.has(source)) prepared.set(source, prepareBuildStylesheet(compiler, source, getScanner(context).slotCSSRule, extracted, [...localStylesheets(context).values()]));
|
|
31
|
+
return prepared.get(source);
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
name: "master-css:style-entry:build",
|
|
35
|
+
enforce: "post",
|
|
36
|
+
apply: "build",
|
|
37
|
+
async renderStart() {
|
|
38
|
+
if (this.getModuleInfo) removeGraphOnlyStylesheetEntries(context, (id) => this.getModuleInfo(id));
|
|
39
|
+
if (context.stylesheets?.size === 0 && !context.virtualCSSImporters?.size) context.virtualCSSPlaceholderEmitted = false;
|
|
40
|
+
extracted = await getExtractedCSSResult(context);
|
|
41
|
+
renderedCSS = extracted.css;
|
|
42
|
+
compiler?.dispose();
|
|
43
|
+
compiler = extracted.stylesheets || localStylesheets(context).size ? createCompilerSync() : void 0;
|
|
44
|
+
prepared.clear();
|
|
45
|
+
},
|
|
46
|
+
outputOptions(options) {
|
|
47
|
+
const assetFileNames = options.assetFileNames;
|
|
48
|
+
return {
|
|
49
|
+
...options,
|
|
50
|
+
assetFileNames(asset) {
|
|
51
|
+
const cssAsset = (asset.names ?? [asset.name]).some((name) => name?.endsWith(".css"));
|
|
52
|
+
const graph = cssAsset && typeof asset.source === "string" ? prepare(asset.source) : void 0;
|
|
53
|
+
const result = graph ? {
|
|
54
|
+
source: graph.source,
|
|
55
|
+
replaced: true
|
|
56
|
+
} : cssAsset && renderedCSS !== void 0 && typeof asset.source === "string" && !extracted?.stylesheets ? replaceSlotCSSRule(asset.source, getScanner(context).slotCSSRule, renderedCSS) : void 0;
|
|
57
|
+
const pattern = typeof assetFileNames === "function" ? assetFileNames(result?.replaced ? {
|
|
58
|
+
...asset,
|
|
59
|
+
source: result.source
|
|
60
|
+
} : asset) : assetFileNames ?? "[name]-[hash][extname]";
|
|
61
|
+
if (!result?.replaced) return pattern;
|
|
62
|
+
const bytes = createHash("sha256").update(result.source).digest();
|
|
63
|
+
const hash = options.hashCharacters === "hex" ? bytes.toString("hex") : options.hashCharacters === "base36" ? BigInt(`0x${bytes.toString("hex")}`).toString(36) : bytes.toString("base64url");
|
|
64
|
+
return pattern.replace(/\[hash(?::(\d+))?\]/g, (_token, length) => hash.slice(0, length ? Number(length) : 8));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
async generateBundle(_options, bundle) {
|
|
69
|
+
const slotCSSRule = getScanner(context).slotCSSRule;
|
|
70
|
+
const realCSS = renderedCSS ?? await getExtractedCSS(context);
|
|
71
|
+
const cssFileNames = Object.keys(bundle).filter((eachFileName) => eachFileName.endsWith(".css"));
|
|
72
|
+
let replacedAny = false;
|
|
73
|
+
for (const eachCssFileName of cssFileNames) {
|
|
74
|
+
const chunk = bundle[eachCssFileName];
|
|
75
|
+
if (chunk.type === "asset") {
|
|
76
|
+
const oldSource = String(bundle[eachCssFileName]["source"]);
|
|
77
|
+
const graph = prepare(oldSource);
|
|
78
|
+
if (graph) {
|
|
79
|
+
chunk.source = graph.source;
|
|
80
|
+
replacedAny = true;
|
|
81
|
+
for (const asset of graph.assets) {
|
|
82
|
+
const fileName = posix.join(posix.dirname(eachCssFileName), asset.href);
|
|
83
|
+
this.emitFile({
|
|
84
|
+
type: "asset",
|
|
85
|
+
fileName,
|
|
86
|
+
name: "master-css-generated",
|
|
87
|
+
source: asset.css
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
for (const resource of graph.resources ?? []) {
|
|
91
|
+
const fileName = posix.join(posix.dirname(eachCssFileName), resource.href);
|
|
92
|
+
this.emitFile({
|
|
93
|
+
type: "asset",
|
|
94
|
+
fileName,
|
|
95
|
+
source: readFileSync(resource.file)
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (extracted?.stylesheets) continue;
|
|
101
|
+
const result = replaceSlotCSSRule(oldSource, slotCSSRule, realCSS);
|
|
102
|
+
if (result.source !== oldSource) bundle[eachCssFileName]["source"] = result.source;
|
|
103
|
+
if (result.replaced) replacedAny = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (context.virtualCSSPlaceholderEmitted && !replacedAny && realCSS.length > 0 && !(context.config?.build.ssr && cssFileNames.length === 0)) this.warn(`[master-css.vite] Could not splice managed style CSS into any bundle asset. The placeholder "${slotCSSRule}" was emitted but no CSS chunk in the final bundle still contained it — Vite's downstream CSS pipeline (a PostCSS plugin in your vite config, the bundler's CSS minifier, etc.) most likely rewrote or dropped it. The output will be missing Master CSS output.`);
|
|
107
|
+
},
|
|
108
|
+
closeBundle() {
|
|
109
|
+
compiler?.dispose();
|
|
110
|
+
compiler = void 0;
|
|
111
|
+
prepared.clear();
|
|
112
|
+
clearLocalStylesheets(context);
|
|
113
|
+
},
|
|
114
|
+
renderError() {
|
|
115
|
+
compiler?.dispose();
|
|
116
|
+
compiler = void 0;
|
|
117
|
+
prepared.clear();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export { StyleEntryBuildPlugin as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { ResolvedMasterCSSVitePluginOptions } from "../options.js";
|
|
3
|
+
import { MasterCSSVitePluginContext } from "../core.js";
|
|
4
|
+
/** HMR when the config and source files changed */
|
|
5
|
+
declare function StyleEntryHMRPlugin(_options: ResolvedMasterCSSVitePluginOptions, context: MasterCSSVitePluginContext): Plugin;
|
|
6
|
+
export { StyleEntryHMRPlugin as default };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ensureScanner, getScanner, releaseScannerEnvironment } from "../utils/scanner-context.js";
|
|
2
|
+
import { refreshGeneratedModule } from "../utils/dev-module-refresh.js";
|
|
3
|
+
import { createCoalescedTask } from "../utils/coalesced-task.js";
|
|
4
|
+
import { existsSync, readFileSync } from "fs";
|
|
5
|
+
// src/plugins/style-entry-hmr.ts
|
|
6
|
+
/** HMR when the config and source files changed */
|
|
7
|
+
function StyleEntryHMRPlugin(_options, context) {
|
|
8
|
+
let transformedIndexHTMLModule;
|
|
9
|
+
const servers = /* @__PURE__ */ new Map();
|
|
10
|
+
const attachedScanners = /* @__PURE__ */ new WeakSet();
|
|
11
|
+
const updateStylesheetImporters = async ({ server }) => {
|
|
12
|
+
if (!server) return;
|
|
13
|
+
const affectedModuleIds = new Set(context.virtualCSSImporters || []);
|
|
14
|
+
await context.refreshEmittedGlobals?.();
|
|
15
|
+
await Promise.all(Array.from(affectedModuleIds).map((eachModuleId) => refreshGeneratedModule(server, eachModuleId)));
|
|
16
|
+
};
|
|
17
|
+
const handleReset = async ({ server }) => {
|
|
18
|
+
const scanner = getScanner(context);
|
|
19
|
+
const tasks = [];
|
|
20
|
+
if (transformedIndexHTMLModule) tasks.push(scanner.scanModule(transformedIndexHTMLModule.id, transformedIndexHTMLModule.code));
|
|
21
|
+
tasks.push(...Array.from(server.moduleGraph.idToModuleMap.keys()).filter((eachModuleId) => !eachModuleId.startsWith("\0")).map(async (eachModuleId) => {
|
|
22
|
+
const eachModule = server.moduleGraph.idToModuleMap.get(eachModuleId);
|
|
23
|
+
if (eachModule) {
|
|
24
|
+
let eachModuleCode = eachModule?.transformResult?.code || eachModule?.ssrTransformResult?.code;
|
|
25
|
+
if (eachModule.file && !eachModuleCode && !eachModule.file.startsWith("virtual:") && existsSync(eachModule.file)) eachModuleCode = readFileSync(eachModule.file, "utf-8");
|
|
26
|
+
if (eachModuleCode) await scanner.scanModule(eachModuleId, eachModuleCode);
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
await Promise.all(tasks);
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
name: "master-css:style-entry:hmr",
|
|
33
|
+
enforce: "pre",
|
|
34
|
+
apply: "serve",
|
|
35
|
+
buildStart() {
|
|
36
|
+
const attach = () => {
|
|
37
|
+
const scanner = getScanner(context);
|
|
38
|
+
if (attachedScanners.has(scanner)) return;
|
|
39
|
+
attachedScanners.add(scanner);
|
|
40
|
+
let resetChain = Promise.resolve();
|
|
41
|
+
const onError = (label) => (err) => {
|
|
42
|
+
console.error(`[master-css.vite] ${label} failed:`, err);
|
|
43
|
+
};
|
|
44
|
+
const scheduleUpdate = createCoalescedTask(async () => {
|
|
45
|
+
await resetChain;
|
|
46
|
+
await Promise.all([...servers.values()].map((server) => updateStylesheetImporters({ server })));
|
|
47
|
+
}, onError("hmr update"));
|
|
48
|
+
scanner.on("reset", () => {
|
|
49
|
+
resetChain = resetChain.then(() => Promise.all([...servers.values()].map((eachServer) => handleReset({ server: eachServer })))).catch(onError("reset")).then(() => {
|
|
50
|
+
scheduleUpdate();
|
|
51
|
+
});
|
|
52
|
+
}).on("change", () => {
|
|
53
|
+
scheduleUpdate();
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
if (context.scanner) return attach();
|
|
57
|
+
return ensureScanner(_options, context).then(attach);
|
|
58
|
+
},
|
|
59
|
+
transformIndexHtml: {
|
|
60
|
+
order: "pre",
|
|
61
|
+
handler: async (html, { filename }) => {
|
|
62
|
+
transformedIndexHTMLModule = {
|
|
63
|
+
id: filename,
|
|
64
|
+
code: html
|
|
65
|
+
};
|
|
66
|
+
await getScanner(context).scanModule(filename, html);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
closeBundle() {
|
|
70
|
+
const config = this.environment?.getTopLevelConfig() ?? context.config;
|
|
71
|
+
if (config && releaseScannerEnvironment(context, config, this.environment)) servers.delete(config);
|
|
72
|
+
},
|
|
73
|
+
configureServer(server) {
|
|
74
|
+
servers.set(server.config, server);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export { StyleEntryHMRPlugin as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { ResolvedMasterCSSVitePluginOptions } from "../options.js";
|
|
3
|
+
import { MasterCSSVitePluginContext } from "../core.js";
|
|
4
|
+
declare function StyleEntryPlugin(_options: ResolvedMasterCSSVitePluginOptions, context: MasterCSSVitePluginContext): Plugin;
|
|
5
|
+
export { StyleEntryPlugin as default };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { withStylesheetDependencies } from "../utils/failed-stylesheet-dependencies.js";
|
|
2
|
+
import { getSassSourceFile, isRawStyleRequest } from "../utils/build-sass-source.js";
|
|
3
|
+
import { withSassDiagnostics } from "../utils/sass-diagnostics.js";
|
|
4
|
+
import { getScanner } from "../utils/scanner-context.js";
|
|
5
|
+
import getExtractedCSS from "../utils/extracted-css.js";
|
|
6
|
+
import { registerStylesheetSource } from "../utils/register-style-source.js";
|
|
7
|
+
import { getBuildImportResolver } from "../utils/build-import-resolver.js";
|
|
8
|
+
import { isInlineStylesheet, registerInlineStylesheet } from "../utils/inline-stylesheet.js";
|
|
9
|
+
import { VIRTUAL_CSS_ID } from "../internal/src/style-module.js";
|
|
10
|
+
import { collectStylesheetDependenciesSync } from "@master/css-compiler/node";
|
|
11
|
+
import { resolveStylesheet } from "@master/css-compiler/stylesheet";
|
|
12
|
+
// src/plugins/style-entry.ts
|
|
13
|
+
const RESOLVED_VIRTUAL_CSS_ID = "\0" + VIRTUAL_CSS_ID;
|
|
14
|
+
function StyleEntryPlugin(_options, context) {
|
|
15
|
+
return {
|
|
16
|
+
name: "master-css:style-entry",
|
|
17
|
+
enforce: "pre",
|
|
18
|
+
resolveId(id) {
|
|
19
|
+
if (id === "virtual:master-utilities.css" || id === RESOLVED_VIRTUAL_CSS_ID) return RESOLVED_VIRTUAL_CSS_ID;
|
|
20
|
+
},
|
|
21
|
+
async load(id) {
|
|
22
|
+
if (id !== RESOLVED_VIRTUAL_CSS_ID) return;
|
|
23
|
+
context.virtualCSSImporters ??= /* @__PURE__ */ new Set();
|
|
24
|
+
context.virtualCSSImporters.add(RESOLVED_VIRTUAL_CSS_ID);
|
|
25
|
+
if (context.config?.command === "serve") return await getExtractedCSS(context);
|
|
26
|
+
context.virtualCSSPlaceholderEmitted = true;
|
|
27
|
+
return getScanner(context).slotCSSRule;
|
|
28
|
+
},
|
|
29
|
+
async transform(code, id) {
|
|
30
|
+
return withStylesheetDependencies(context, this, id, (onDependency) => withSassDiagnostics(context, async () => {
|
|
31
|
+
if (isRawStyleRequest(id)) return;
|
|
32
|
+
if (id.startsWith("\0") && context.config?.command !== "build") return;
|
|
33
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
34
|
+
const resolveImport = getBuildImportResolver(context, {
|
|
35
|
+
addWatchFile: onDependency,
|
|
36
|
+
resolve: this.resolve?.bind(this),
|
|
37
|
+
load: this.load?.bind(this)
|
|
38
|
+
});
|
|
39
|
+
let resolution;
|
|
40
|
+
try {
|
|
41
|
+
resolution = await resolveStylesheet(id, code, {
|
|
42
|
+
projectDir: context.config?.root,
|
|
43
|
+
baseFile: getSassSourceFile(id),
|
|
44
|
+
preserveImports: true,
|
|
45
|
+
resolveImport,
|
|
46
|
+
onDependency
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
for (const dependency of collectStylesheetDependenciesSync(id, code, { projectDir: context.config?.root })) {
|
|
50
|
+
dependencies.add(dependency);
|
|
51
|
+
onDependency(dependency);
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
if (!resolution || resolution.kind !== "entry" && resolution.kind !== "master-package-entry") return;
|
|
56
|
+
for (const dependency of resolution.dependencies) {
|
|
57
|
+
dependencies.add(dependency);
|
|
58
|
+
onDependency(dependency);
|
|
59
|
+
}
|
|
60
|
+
if (resolution.kind === "master-package-entry") return {
|
|
61
|
+
code: resolution.outputSource,
|
|
62
|
+
map: null
|
|
63
|
+
};
|
|
64
|
+
const inline = context.config?.command === "build" && isInlineStylesheet(id);
|
|
65
|
+
const result = inline ? await registerInlineStylesheet(context, id, code, {
|
|
66
|
+
resolveImport,
|
|
67
|
+
onDependency
|
|
68
|
+
}) : await registerStylesheetSource(context, context.config?.command === "serve" ? resolution.id : id, code, {
|
|
69
|
+
resolveImport,
|
|
70
|
+
onDependency
|
|
71
|
+
});
|
|
72
|
+
for (const dependency of result.dependencies) {
|
|
73
|
+
if (dependencies.has(dependency)) continue;
|
|
74
|
+
onDependency(dependency);
|
|
75
|
+
}
|
|
76
|
+
const masterSource = context.config?.command === "serve" ? await getExtractedCSS(context) : getScanner(context).slotCSSRule;
|
|
77
|
+
if (context.config?.command === "serve") {
|
|
78
|
+
context.virtualCSSImporters ??= /* @__PURE__ */ new Set();
|
|
79
|
+
context.virtualCSSImporters.add(id);
|
|
80
|
+
} else if (!inline) context.virtualCSSPlaceholderEmitted = true;
|
|
81
|
+
return {
|
|
82
|
+
code: masterSource,
|
|
83
|
+
map: null
|
|
84
|
+
};
|
|
85
|
+
}), "entry");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export { StyleEntryPlugin as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { MasterCSSVitePluginContext } from "../core.js";
|
|
3
|
+
/** Restore failed dependency edges before Sass invalidation and normal HMR propagation. */
|
|
4
|
+
declare function StylesheetRecoveryPlugin(context: MasterCSSVitePluginContext): Plugin;
|
|
5
|
+
export { StylesheetRecoveryPlugin as default };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { configureFailedDependencyReconciliation } from "../utils/failed-dependency-reconciliation.js";
|
|
2
|
+
import { clearFailedStylesheets, configureStylesheetRecovery, stylesheetDependencyOwners } from "../utils/failed-stylesheet-dependencies.js";
|
|
3
|
+
import { sendRecoveryError } from "../utils/recovery-error.js";
|
|
4
|
+
import { invalidatePreparedSassSources } from "../utils/build-sass-source.js";
|
|
5
|
+
// src/plugins/stylesheet-recovery.ts
|
|
6
|
+
/** Restore failed dependency edges before Sass invalidation and normal HMR propagation. */
|
|
7
|
+
function StylesheetRecoveryPlugin(context) {
|
|
8
|
+
const closed = /* @__PURE__ */ new WeakSet();
|
|
9
|
+
const recovering = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
const recover = (environment, id, files, active = () => true, reportError = false) => {
|
|
11
|
+
if (closed.has(environment) || !active()) return Promise.resolve();
|
|
12
|
+
let pending = recovering.get(environment);
|
|
13
|
+
if (!pending) {
|
|
14
|
+
pending = /* @__PURE__ */ new Map();
|
|
15
|
+
recovering.set(environment, pending);
|
|
16
|
+
}
|
|
17
|
+
const prior = pending.get(id);
|
|
18
|
+
if (prior) return prior;
|
|
19
|
+
const operation = (async () => {
|
|
20
|
+
const module = environment.moduleGraph.getModuleById(id);
|
|
21
|
+
if (!module) return;
|
|
22
|
+
for (const file of files) invalidatePreparedSassSources(context, file);
|
|
23
|
+
const initialFailure = module.isSelfAccepting === void 0;
|
|
24
|
+
environment.moduleGraph.invalidateModule(module);
|
|
25
|
+
try {
|
|
26
|
+
await environment.transformRequest(module.url);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (reportError && active() && !closed.has(environment)) sendRecoveryError(environment, error, id);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
if (closed.has(environment) || !active()) return;
|
|
32
|
+
if (initialFailure && environment.config.consumer === "client") environment.hot.send({
|
|
33
|
+
type: "full-reload",
|
|
34
|
+
path: "*"
|
|
35
|
+
});
|
|
36
|
+
else await environment.reloadModule(module);
|
|
37
|
+
})().finally(() => pending.delete(id));
|
|
38
|
+
pending.set(id, operation);
|
|
39
|
+
return operation;
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
name: "master-css:stylesheet-recovery",
|
|
43
|
+
apply: "serve",
|
|
44
|
+
enforce: "pre",
|
|
45
|
+
configureServer(server) {
|
|
46
|
+
configureStylesheetRecovery(context, server.watcher);
|
|
47
|
+
configureFailedDependencyReconciliation(context, server, (environment, id, files, active) => recover(environment, id, files, active, true));
|
|
48
|
+
},
|
|
49
|
+
async hotUpdate({ file, modules }) {
|
|
50
|
+
const owners = stylesheetDependencyOwners(context, this.environment, file);
|
|
51
|
+
if (!owners.length) return;
|
|
52
|
+
invalidatePreparedSassSources(context, file);
|
|
53
|
+
const affected = new Set(modules);
|
|
54
|
+
for (const { id, failed } of owners) {
|
|
55
|
+
const module = this.environment.moduleGraph.getModuleById(id);
|
|
56
|
+
if (!module) continue;
|
|
57
|
+
this.environment.moduleGraph.invalidateModule(module);
|
|
58
|
+
if (failed && module.isSelfAccepting === void 0) await recover(this.environment, id, [file]);
|
|
59
|
+
affected.add(module);
|
|
60
|
+
}
|
|
61
|
+
return [...affected];
|
|
62
|
+
},
|
|
63
|
+
closeBundle() {
|
|
64
|
+
closed.add(this.environment);
|
|
65
|
+
recovering.delete(this.environment);
|
|
66
|
+
clearFailedStylesheets(context, this.environment);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export { StylesheetRecoveryPlugin as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { ResolvedMasterCSSVitePluginOptions } from "../options.js";
|
|
3
|
+
import { MasterCSSVitePluginContext } from "../core.js";
|
|
4
|
+
declare function UsageGraphPlugin(_options: ResolvedMasterCSSVitePluginOptions, context: MasterCSSVitePluginContext): Plugin;
|
|
5
|
+
export { UsageGraphPlugin as default };
|