unplugin-inline-css-modules 0.1.0
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/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/astro.d.mts +8 -0
- package/dist/astro.d.ts +8 -0
- package/dist/astro.js +185 -0
- package/dist/astro.js.map +1 -0
- package/dist/astro.mjs +158 -0
- package/dist/astro.mjs.map +1 -0
- package/dist/bun.d.mts +7 -0
- package/dist/bun.d.ts +7 -0
- package/dist/bun.js +167 -0
- package/dist/bun.js.map +1 -0
- package/dist/bun.mjs +142 -0
- package/dist/bun.mjs.map +1 -0
- package/dist/esbuild.d.mts +7 -0
- package/dist/esbuild.d.ts +7 -0
- package/dist/esbuild.js +167 -0
- package/dist/esbuild.js.map +1 -0
- package/dist/esbuild.mjs +142 -0
- package/dist/esbuild.mjs.map +1 -0
- package/dist/farm.d.mts +6 -0
- package/dist/farm.d.ts +6 -0
- package/dist/farm.js +167 -0
- package/dist/farm.js.map +1 -0
- package/dist/farm.mjs +142 -0
- package/dist/farm.mjs.map +1 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +139 -0
- package/dist/index.mjs.map +1 -0
- package/dist/loader.cjs +6 -0
- package/dist/next.d.mts +9 -0
- package/dist/next.d.ts +9 -0
- package/dist/next.js +193 -0
- package/dist/next.js.map +1 -0
- package/dist/next.mjs +167 -0
- package/dist/next.mjs.map +1 -0
- package/dist/nuxt.d.mts +7 -0
- package/dist/nuxt.d.ts +7 -0
- package/dist/nuxt.js +169 -0
- package/dist/nuxt.js.map +1 -0
- package/dist/nuxt.mjs +144 -0
- package/dist/nuxt.mjs.map +1 -0
- package/dist/rolldown.d.mts +8 -0
- package/dist/rolldown.d.ts +8 -0
- package/dist/rolldown.js +167 -0
- package/dist/rolldown.js.map +1 -0
- package/dist/rolldown.mjs +142 -0
- package/dist/rolldown.mjs.map +1 -0
- package/dist/rollup.d.mts +8 -0
- package/dist/rollup.d.ts +8 -0
- package/dist/rollup.js +167 -0
- package/dist/rollup.js.map +1 -0
- package/dist/rollup.mjs +142 -0
- package/dist/rollup.mjs.map +1 -0
- package/dist/rspack.d.mts +7 -0
- package/dist/rspack.d.ts +7 -0
- package/dist/rspack.js +167 -0
- package/dist/rspack.js.map +1 -0
- package/dist/rspack.mjs +142 -0
- package/dist/rspack.mjs.map +1 -0
- package/dist/vite.d.mts +8 -0
- package/dist/vite.d.ts +8 -0
- package/dist/vite.js +167 -0
- package/dist/vite.js.map +1 -0
- package/dist/vite.mjs +142 -0
- package/dist/vite.mjs.map +1 -0
- package/dist/webpack.d.mts +7 -0
- package/dist/webpack.d.ts +7 -0
- package/dist/webpack.js +167 -0
- package/dist/webpack.js.map +1 -0
- package/dist/webpack.mjs +142 -0
- package/dist/webpack.mjs.map +1 -0
- package/package.json +197 -0
package/dist/next.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/next.ts
|
|
21
|
+
var next_exports = {};
|
|
22
|
+
__export(next_exports, {
|
|
23
|
+
css: () => css,
|
|
24
|
+
default: () => next_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(next_exports);
|
|
27
|
+
var import_unplugin2 = require("unplugin");
|
|
28
|
+
var import_path2 = require("path");
|
|
29
|
+
var import_url = require("url");
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var import_unplugin = require("unplugin");
|
|
33
|
+
var import_crypto = require("crypto");
|
|
34
|
+
var import_fs = require("fs");
|
|
35
|
+
var import_path = require("path");
|
|
36
|
+
var matchInlineCssModules = /(?:const|var|let)\s*(\w+)(?:\s*:.*)?\s*=\s*(\w+)\s*`([\s\S]*?)`/gm;
|
|
37
|
+
var css = (_) => ({});
|
|
38
|
+
var virtualModuleId = "virtual:inline-css-modules";
|
|
39
|
+
var webpackModuleId = "inline-css-modules/virtual";
|
|
40
|
+
var resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
41
|
+
var resolvedWebpackModuleId = "\0inline-css-modules/virtual";
|
|
42
|
+
var cssModules = {};
|
|
43
|
+
var getCacheDir = () => (0, import_path.join)(process.cwd(), "node_modules", ".cache", "inline-css-modules");
|
|
44
|
+
var getCachePath = (hash) => (0, import_path.join)(getCacheDir(), `${hash}.css`);
|
|
45
|
+
function ensureCacheDir() {
|
|
46
|
+
const dir = getCacheDir();
|
|
47
|
+
if (!(0, import_fs.existsSync)(dir)) {
|
|
48
|
+
(0, import_fs.mkdirSync)(dir, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function hashCss(css2) {
|
|
52
|
+
return (0, import_crypto.createHash)("md5").update(css2).digest("hex");
|
|
53
|
+
}
|
|
54
|
+
function readFromCache(hash) {
|
|
55
|
+
const path = getCachePath(hash);
|
|
56
|
+
if ((0, import_fs.existsSync)(path)) {
|
|
57
|
+
return (0, import_fs.readFileSync)(path, "utf-8");
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function writeToCache(hash, css2) {
|
|
62
|
+
ensureCacheDir();
|
|
63
|
+
(0, import_fs.writeFileSync)(getCachePath(hash), css2);
|
|
64
|
+
}
|
|
65
|
+
var unpluginFactory = (config = {}, meta) => {
|
|
66
|
+
const fileMatch = config.fileMatch ?? /\.(tsx|jsx|js|vue|svelte)$/;
|
|
67
|
+
const tagName = config.tagName ?? "css";
|
|
68
|
+
const preprocessor = config.extension ?? "css";
|
|
69
|
+
const isWebpack = meta?.framework === "webpack" || meta?.framework === "rspack";
|
|
70
|
+
const moduleId = isWebpack ? webpackModuleId : virtualModuleId;
|
|
71
|
+
const resolvedId = isWebpack ? resolvedWebpackModuleId : resolvedVirtualModuleId;
|
|
72
|
+
return {
|
|
73
|
+
name: "inline-css-modules",
|
|
74
|
+
enforce: "pre",
|
|
75
|
+
resolveId(id) {
|
|
76
|
+
if (id === moduleId || id.startsWith(moduleId + "/")) {
|
|
77
|
+
return resolvedId + id.slice(moduleId.length);
|
|
78
|
+
}
|
|
79
|
+
if (id === virtualModuleId || id.startsWith(virtualModuleId + "/")) {
|
|
80
|
+
return resolvedVirtualModuleId + id.slice(virtualModuleId.length);
|
|
81
|
+
}
|
|
82
|
+
if (id === webpackModuleId || id.startsWith(webpackModuleId + "/")) {
|
|
83
|
+
return resolvedWebpackModuleId + id.slice(webpackModuleId.length);
|
|
84
|
+
}
|
|
85
|
+
return void 0;
|
|
86
|
+
},
|
|
87
|
+
loadInclude(id) {
|
|
88
|
+
return id.startsWith(resolvedVirtualModuleId) || id.startsWith(resolvedWebpackModuleId);
|
|
89
|
+
},
|
|
90
|
+
load(id) {
|
|
91
|
+
if (!id.startsWith(resolvedVirtualModuleId + "/") && !id.startsWith(resolvedWebpackModuleId + "/"))
|
|
92
|
+
return void 0;
|
|
93
|
+
const prefix = id.startsWith(resolvedVirtualModuleId + "/") ? resolvedVirtualModuleId + "/" : resolvedWebpackModuleId + "/";
|
|
94
|
+
const file = id.slice(prefix.length).replace(/\?used$/, "");
|
|
95
|
+
const css2 = cssModules[file];
|
|
96
|
+
if (!css2) {
|
|
97
|
+
if (isWebpack) {
|
|
98
|
+
const hash = file.replace(/\.module\.\w+$/, "");
|
|
99
|
+
const cached = readFromCache(hash);
|
|
100
|
+
if (cached) {
|
|
101
|
+
return {
|
|
102
|
+
code: cached,
|
|
103
|
+
map: null
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
code: css2,
|
|
111
|
+
map: null
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
transform: {
|
|
115
|
+
filter: {
|
|
116
|
+
id: fileMatch
|
|
117
|
+
},
|
|
118
|
+
handler(src, id) {
|
|
119
|
+
let imports = [];
|
|
120
|
+
src = src.replace(
|
|
121
|
+
/import\s*{\s*(?:css|inlineCss)\s*(?:as\s*\w+\s*)?}\s*from\s*('|"|`)unplugin-inline-css-modules\1;?/gm,
|
|
122
|
+
""
|
|
123
|
+
);
|
|
124
|
+
src = src.replaceAll(matchInlineCssModules, (substring, ...args) => {
|
|
125
|
+
const [variableName, tag, css2] = args;
|
|
126
|
+
if (tag !== tagName) return substring;
|
|
127
|
+
let baseFilename = id.slice(id.lastIndexOf("/") + 1);
|
|
128
|
+
baseFilename = baseFilename.slice(0, baseFilename.lastIndexOf("."));
|
|
129
|
+
let cnt = 0;
|
|
130
|
+
const ext = typeof preprocessor == "function" ? preprocessor(baseFilename) : preprocessor;
|
|
131
|
+
let filename = `${baseFilename}-${cnt}.module.${ext}`;
|
|
132
|
+
while (cssModules[filename]) {
|
|
133
|
+
cnt++;
|
|
134
|
+
filename = `${baseFilename}-${cnt}.module.${ext}`;
|
|
135
|
+
}
|
|
136
|
+
cssModules[filename] = css2;
|
|
137
|
+
let importStatement;
|
|
138
|
+
if (isWebpack) {
|
|
139
|
+
const hash = hashCss(css2);
|
|
140
|
+
writeToCache(hash, css2);
|
|
141
|
+
importStatement = `import ${variableName} from "${moduleId}/${hash}.module.${ext}"`;
|
|
142
|
+
}
|
|
143
|
+
importStatement = `import ${variableName} from "${moduleId}/${filename}"`;
|
|
144
|
+
if (config.inlineImport === false) {
|
|
145
|
+
imports.push(importStatement);
|
|
146
|
+
return "";
|
|
147
|
+
}
|
|
148
|
+
return importStatement;
|
|
149
|
+
});
|
|
150
|
+
if (imports.length) {
|
|
151
|
+
return imports.join("\n") + "\n" + src;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
code: src,
|
|
155
|
+
map: null
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
var unplugin = (0, import_unplugin.createUnplugin)(unpluginFactory);
|
|
162
|
+
|
|
163
|
+
// src/next.ts
|
|
164
|
+
var import_meta = {};
|
|
165
|
+
var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_url.fileURLToPath)(new URL(".", import_meta.url));
|
|
166
|
+
var LOADER_PATH = (0, import_path2.resolve)(_dirname, "loader.cjs");
|
|
167
|
+
var PLUGIN_NAME = "inline-css-modules";
|
|
168
|
+
function next_default(options = {}) {
|
|
169
|
+
const plugin = (0, import_unplugin2.createWebpackPlugin)(unpluginFactory)(options);
|
|
170
|
+
const originalApply = plugin.apply.bind(plugin);
|
|
171
|
+
plugin.apply = (compiler) => {
|
|
172
|
+
originalApply(compiler);
|
|
173
|
+
const wp = compiler;
|
|
174
|
+
wp.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
175
|
+
const c = compilation;
|
|
176
|
+
const NormalModule = c.compiler?.webpack?.NormalModule;
|
|
177
|
+
NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(
|
|
178
|
+
PLUGIN_NAME,
|
|
179
|
+
(loaders, module2) => {
|
|
180
|
+
loaders.push({
|
|
181
|
+
loader: LOADER_PATH
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
return plugin;
|
|
188
|
+
}
|
|
189
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
+
0 && (module.exports = {
|
|
191
|
+
css
|
|
192
|
+
});
|
|
193
|
+
//# sourceMappingURL=next.js.map
|
package/dist/next.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/next.ts","../src/index.ts"],"sourcesContent":["// WebPack / swc opportunistically caches resolutions so we have to\n// register a custom loader that gives back the source instead.\n\nimport { createWebpackPlugin } from 'unplugin'\nimport { resolve } from 'path'\nimport { fileURLToPath } from 'url'\nimport type { PluginConfig } from './index'\nimport { unpluginFactory } from './index'\n\nconst _dirname =\n typeof __dirname !== 'undefined'\n ? __dirname\n : fileURLToPath(new URL('.', import.meta.url))\nconst LOADER_PATH = resolve(_dirname, 'loader.cjs')\n\nconst PLUGIN_NAME = 'inline-css-modules'\n\n// const virtualModulePath = 'inline-css-modules/virtual'\n// const isVirtualModule = (module: { resource?: string }) =>\n// module.resource?.includes?.(virtualModulePath) ?? false\n\nexport default function (options: PluginConfig = {}) {\n const plugin = createWebpackPlugin(unpluginFactory)(options) as {\n apply: (compiler: unknown) => void\n }\n const originalApply = plugin.apply.bind(plugin)\n plugin.apply = (compiler: unknown) => {\n originalApply(compiler)\n const wp = compiler as {\n hooks: {\n compilation: {\n tap: (name: string, fn: (compilation: unknown) => void) => void\n }\n }\n }\n\n wp.hooks.compilation.tap(PLUGIN_NAME, (compilation: unknown) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const c = compilation as any\n const NormalModule = c.compiler?.webpack?.NormalModule\n\n NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(\n PLUGIN_NAME,\n (loaders: { loader: string }[], module: { resource?: string }) => {\n loaders.push({\n loader: LOADER_PATH,\n })\n }\n )\n })\n }\n return plugin\n}\n\nexport { css } from './index'\nexport type { PluginConfig } from './index'\n","import type { UnpluginFactory } from 'unplugin'\nimport { createUnplugin } from 'unplugin'\nimport { createHash } from 'crypto'\nimport { mkdirSync, readFileSync, writeFileSync, existsSync } from 'fs'\nimport { join } from 'path'\n\ntype SupportedExtension = 'css' | 'scss' | 'sass' | 'styl' | 'less'\n\nexport type PluginConfig = {\n fileMatch?: RegExp\n tagName?: string\n extension?: SupportedExtension | ((filename: string) => SupportedExtension)\n inlineImport?: boolean\n}\n\nconst matchInlineCssModules =\n /(?:const|var|let)\\s*(\\w+)(?:\\s*:.*)?\\s*=\\s*(\\w+)\\s*`([\\s\\S]*?)`/gm\n\nexport const css = (_: TemplateStringsArray): Record<string, string> => ({})\n\nconst virtualModuleId = 'virtual:inline-css-modules'\nconst webpackModuleId = 'inline-css-modules/virtual'\nconst resolvedVirtualModuleId = '\\0' + virtualModuleId\nconst resolvedWebpackModuleId = '\\0inline-css-modules/virtual'\n\nlet cssModules: Record<string, string> = {}\n\nconst getCacheDir = () =>\n join(process.cwd(), 'node_modules', '.cache', 'inline-css-modules')\nconst getCachePath = (hash: string) => join(getCacheDir(), `${hash}.css`)\n\nfunction ensureCacheDir() {\n const dir = getCacheDir()\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true })\n }\n}\n\nfunction hashCss(css: string): string {\n return createHash('md5').update(css).digest('hex')\n}\n\nfunction readFromCache(hash: string): string | null {\n const path = getCachePath(hash)\n if (existsSync(path)) {\n return readFileSync(path, 'utf-8')\n }\n return null\n}\n\nfunction writeToCache(hash: string, css: string): void {\n ensureCacheDir()\n writeFileSync(getCachePath(hash), css)\n}\n\nexport const unpluginFactory: UnpluginFactory<PluginConfig | undefined> = (\n config = {},\n meta\n) => {\n const fileMatch = config.fileMatch ?? /\\.(tsx|jsx|js|vue|svelte)$/\n const tagName = config.tagName ?? 'css'\n const preprocessor = config.extension ?? 'css'\n const isWebpack =\n meta?.framework === 'webpack' || meta?.framework === 'rspack'\n const moduleId = isWebpack ? webpackModuleId : virtualModuleId\n const resolvedId = isWebpack\n ? resolvedWebpackModuleId\n : resolvedVirtualModuleId\n\n return {\n name: 'inline-css-modules',\n enforce: 'pre',\n resolveId(id) {\n if (id === moduleId || id.startsWith(moduleId + '/')) {\n return resolvedId + id.slice(moduleId.length)\n }\n if (id === virtualModuleId || id.startsWith(virtualModuleId + '/')) {\n return resolvedVirtualModuleId + id.slice(virtualModuleId.length)\n }\n if (id === webpackModuleId || id.startsWith(webpackModuleId + '/')) {\n return resolvedWebpackModuleId + id.slice(webpackModuleId.length)\n }\n return undefined\n },\n loadInclude(id) {\n return (\n id.startsWith(resolvedVirtualModuleId) ||\n id.startsWith(resolvedWebpackModuleId)\n )\n },\n load(id) {\n if (\n !id.startsWith(resolvedVirtualModuleId + '/') &&\n !id.startsWith(resolvedWebpackModuleId + '/')\n )\n return undefined\n\n const prefix = id.startsWith(resolvedVirtualModuleId + '/')\n ? resolvedVirtualModuleId + '/'\n : resolvedWebpackModuleId + '/'\n const file = id.slice(prefix.length).replace(/\\?used$/, '')\n const css = cssModules[file]\n\n if (!css) {\n if (isWebpack) {\n const hash = file.replace(/\\.module\\.\\w+$/, '')\n const cached = readFromCache(hash)\n if (cached) {\n return {\n code: cached,\n map: null,\n }\n }\n }\n return undefined\n }\n return {\n code: css,\n map: null,\n }\n },\n transform: {\n filter: {\n id: fileMatch,\n },\n handler(src, id) {\n // Build up a list of import statements to inject to the top of the file\n let imports: string[] = []\n\n src = src.replace(\n /import\\s*{\\s*(?:css|inlineCss)\\s*(?:as\\s*\\w+\\s*)?}\\s*from\\s*('|\"|`)unplugin-inline-css-modules\\1;?/gm,\n ''\n )\n\n src = src.replaceAll(matchInlineCssModules, (substring, ...args) => {\n const [variableName, tag, css] = args\n\n if (tag !== tagName) return substring\n\n let baseFilename = id.slice(id.lastIndexOf('/') + 1)\n baseFilename = baseFilename.slice(0, baseFilename.lastIndexOf('.'))\n let cnt = 0\n const ext =\n typeof preprocessor == 'function'\n ? preprocessor(baseFilename)\n : preprocessor\n let filename = `${baseFilename}-${cnt}.module.${ext}`\n while (cssModules[filename]) {\n cnt++\n filename = `${baseFilename}-${cnt}.module.${ext}`\n }\n cssModules[filename] = css\n\n let importStatement\n\n if (isWebpack) {\n const hash = hashCss(css)\n writeToCache(hash, css)\n importStatement = `import ${variableName} from \"${moduleId}/${hash}.module.${ext}\"`\n }\n importStatement = `import ${variableName} from \"${moduleId}/${filename}\"`\n\n if (config.inlineImport === false) {\n imports.push(importStatement)\n return ''\n }\n return importStatement\n })\n if (imports.length) {\n return imports.join('\\n') + '\\n' + src\n }\n return {\n code: src,\n map: null,\n }\n },\n },\n }\n}\n\nexport const unplugin = createUnplugin(unpluginFactory)\n\nexport default unplugin\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,mBAAoC;AACpC,IAAAC,eAAwB;AACxB,iBAA8B;;;ACJ9B,sBAA+B;AAC/B,oBAA2B;AAC3B,gBAAmE;AACnE,kBAAqB;AAWrB,IAAM,wBACJ;AAEK,IAAM,MAAM,CAAC,OAAqD,CAAC;AAE1E,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,0BAA0B,OAAO;AACvC,IAAM,0BAA0B;AAEhC,IAAI,aAAqC,CAAC;AAE1C,IAAM,cAAc,UAClB,kBAAK,QAAQ,IAAI,GAAG,gBAAgB,UAAU,oBAAoB;AACpE,IAAM,eAAe,CAAC,aAAiB,kBAAK,YAAY,GAAG,GAAG,IAAI,MAAM;AAExE,SAAS,iBAAiB;AACxB,QAAM,MAAM,YAAY;AACxB,MAAI,KAAC,sBAAW,GAAG,GAAG;AACpB,6BAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,EACpC;AACF;AAEA,SAAS,QAAQC,MAAqB;AACpC,aAAO,0BAAW,KAAK,EAAE,OAAOA,IAAG,EAAE,OAAO,KAAK;AACnD;AAEA,SAAS,cAAc,MAA6B;AAClD,QAAM,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,cAAI,OAAO,iBAAiB,OAAO;AACjC,oBAAQ,KAAK,eAAe;AAC5B,mBAAO;AAAA,UACT;AACA,iBAAO;AAAA,QACT,CAAC;AACD,YAAI,QAAQ,QAAQ;AAClB,iBAAO,QAAQ,KAAK,IAAI,IAAI,OAAO;AAAA,QACrC;AACA,eAAO;AAAA,UACL,MAAM;AAAA,UACN,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,eAAW,gCAAe,eAAe;;;ADpLtD;AASA,IAAM,WACJ,OAAO,cAAc,cACjB,gBACA,0BAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC;AACjD,IAAM,kBAAc,sBAAQ,UAAU,YAAY;AAElD,IAAM,cAAc;AAML,SAAR,aAAkB,UAAwB,CAAC,GAAG;AACnD,QAAM,aAAS,sCAAoB,eAAe,EAAE,OAAO;AAG3D,QAAM,gBAAgB,OAAO,MAAM,KAAK,MAAM;AAC9C,SAAO,QAAQ,CAAC,aAAsB;AACpC,kBAAc,QAAQ;AACtB,UAAM,KAAK;AAQX,OAAG,MAAM,YAAY,IAAI,aAAa,CAAC,gBAAyB;AAE9D,YAAM,IAAI;AACV,YAAM,eAAe,EAAE,UAAU,SAAS;AAE1C,mBAAa,oBAAoB,WAAW,EAAE,cAAc;AAAA,QAC1D;AAAA,QACA,CAAC,SAA+BC,YAAkC;AAChE,kBAAQ,KAAK;AAAA,YACX,QAAQ;AAAA,UACV,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":["import_unplugin","import_path","css","module"]}
|
package/dist/next.mjs
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// src/next.ts
|
|
2
|
+
import { createWebpackPlugin } from "unplugin";
|
|
3
|
+
import { resolve } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
import { createUnplugin } from "unplugin";
|
|
8
|
+
import { createHash } from "crypto";
|
|
9
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync } from "fs";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
var matchInlineCssModules = /(?:const|var|let)\s*(\w+)(?:\s*:.*)?\s*=\s*(\w+)\s*`([\s\S]*?)`/gm;
|
|
12
|
+
var css = (_) => ({});
|
|
13
|
+
var virtualModuleId = "virtual:inline-css-modules";
|
|
14
|
+
var webpackModuleId = "inline-css-modules/virtual";
|
|
15
|
+
var resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
16
|
+
var resolvedWebpackModuleId = "\0inline-css-modules/virtual";
|
|
17
|
+
var cssModules = {};
|
|
18
|
+
var getCacheDir = () => join(process.cwd(), "node_modules", ".cache", "inline-css-modules");
|
|
19
|
+
var getCachePath = (hash) => join(getCacheDir(), `${hash}.css`);
|
|
20
|
+
function ensureCacheDir() {
|
|
21
|
+
const dir = getCacheDir();
|
|
22
|
+
if (!existsSync(dir)) {
|
|
23
|
+
mkdirSync(dir, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function hashCss(css2) {
|
|
27
|
+
return createHash("md5").update(css2).digest("hex");
|
|
28
|
+
}
|
|
29
|
+
function readFromCache(hash) {
|
|
30
|
+
const path = getCachePath(hash);
|
|
31
|
+
if (existsSync(path)) {
|
|
32
|
+
return readFileSync(path, "utf-8");
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function writeToCache(hash, css2) {
|
|
37
|
+
ensureCacheDir();
|
|
38
|
+
writeFileSync(getCachePath(hash), css2);
|
|
39
|
+
}
|
|
40
|
+
var unpluginFactory = (config = {}, meta) => {
|
|
41
|
+
const fileMatch = config.fileMatch ?? /\.(tsx|jsx|js|vue|svelte)$/;
|
|
42
|
+
const tagName = config.tagName ?? "css";
|
|
43
|
+
const preprocessor = config.extension ?? "css";
|
|
44
|
+
const isWebpack = meta?.framework === "webpack" || meta?.framework === "rspack";
|
|
45
|
+
const moduleId = isWebpack ? webpackModuleId : virtualModuleId;
|
|
46
|
+
const resolvedId = isWebpack ? resolvedWebpackModuleId : resolvedVirtualModuleId;
|
|
47
|
+
return {
|
|
48
|
+
name: "inline-css-modules",
|
|
49
|
+
enforce: "pre",
|
|
50
|
+
resolveId(id) {
|
|
51
|
+
if (id === moduleId || id.startsWith(moduleId + "/")) {
|
|
52
|
+
return resolvedId + id.slice(moduleId.length);
|
|
53
|
+
}
|
|
54
|
+
if (id === virtualModuleId || id.startsWith(virtualModuleId + "/")) {
|
|
55
|
+
return resolvedVirtualModuleId + id.slice(virtualModuleId.length);
|
|
56
|
+
}
|
|
57
|
+
if (id === webpackModuleId || id.startsWith(webpackModuleId + "/")) {
|
|
58
|
+
return resolvedWebpackModuleId + id.slice(webpackModuleId.length);
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
},
|
|
62
|
+
loadInclude(id) {
|
|
63
|
+
return id.startsWith(resolvedVirtualModuleId) || id.startsWith(resolvedWebpackModuleId);
|
|
64
|
+
},
|
|
65
|
+
load(id) {
|
|
66
|
+
if (!id.startsWith(resolvedVirtualModuleId + "/") && !id.startsWith(resolvedWebpackModuleId + "/"))
|
|
67
|
+
return void 0;
|
|
68
|
+
const prefix = id.startsWith(resolvedVirtualModuleId + "/") ? resolvedVirtualModuleId + "/" : resolvedWebpackModuleId + "/";
|
|
69
|
+
const file = id.slice(prefix.length).replace(/\?used$/, "");
|
|
70
|
+
const css2 = cssModules[file];
|
|
71
|
+
if (!css2) {
|
|
72
|
+
if (isWebpack) {
|
|
73
|
+
const hash = file.replace(/\.module\.\w+$/, "");
|
|
74
|
+
const cached = readFromCache(hash);
|
|
75
|
+
if (cached) {
|
|
76
|
+
return {
|
|
77
|
+
code: cached,
|
|
78
|
+
map: null
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
code: css2,
|
|
86
|
+
map: null
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
transform: {
|
|
90
|
+
filter: {
|
|
91
|
+
id: fileMatch
|
|
92
|
+
},
|
|
93
|
+
handler(src, id) {
|
|
94
|
+
let imports = [];
|
|
95
|
+
src = src.replace(
|
|
96
|
+
/import\s*{\s*(?:css|inlineCss)\s*(?:as\s*\w+\s*)?}\s*from\s*('|"|`)unplugin-inline-css-modules\1;?/gm,
|
|
97
|
+
""
|
|
98
|
+
);
|
|
99
|
+
src = src.replaceAll(matchInlineCssModules, (substring, ...args) => {
|
|
100
|
+
const [variableName, tag, css2] = args;
|
|
101
|
+
if (tag !== tagName) return substring;
|
|
102
|
+
let baseFilename = id.slice(id.lastIndexOf("/") + 1);
|
|
103
|
+
baseFilename = baseFilename.slice(0, baseFilename.lastIndexOf("."));
|
|
104
|
+
let cnt = 0;
|
|
105
|
+
const ext = typeof preprocessor == "function" ? preprocessor(baseFilename) : preprocessor;
|
|
106
|
+
let filename = `${baseFilename}-${cnt}.module.${ext}`;
|
|
107
|
+
while (cssModules[filename]) {
|
|
108
|
+
cnt++;
|
|
109
|
+
filename = `${baseFilename}-${cnt}.module.${ext}`;
|
|
110
|
+
}
|
|
111
|
+
cssModules[filename] = css2;
|
|
112
|
+
let importStatement;
|
|
113
|
+
if (isWebpack) {
|
|
114
|
+
const hash = hashCss(css2);
|
|
115
|
+
writeToCache(hash, css2);
|
|
116
|
+
importStatement = `import ${variableName} from "${moduleId}/${hash}.module.${ext}"`;
|
|
117
|
+
}
|
|
118
|
+
importStatement = `import ${variableName} from "${moduleId}/${filename}"`;
|
|
119
|
+
if (config.inlineImport === false) {
|
|
120
|
+
imports.push(importStatement);
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
123
|
+
return importStatement;
|
|
124
|
+
});
|
|
125
|
+
if (imports.length) {
|
|
126
|
+
return imports.join("\n") + "\n" + src;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
code: src,
|
|
130
|
+
map: null
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
var unplugin = createUnplugin(unpluginFactory);
|
|
137
|
+
|
|
138
|
+
// src/next.ts
|
|
139
|
+
var _dirname = typeof __dirname !== "undefined" ? __dirname : fileURLToPath(new URL(".", import.meta.url));
|
|
140
|
+
var LOADER_PATH = resolve(_dirname, "loader.cjs");
|
|
141
|
+
var PLUGIN_NAME = "inline-css-modules";
|
|
142
|
+
function next_default(options = {}) {
|
|
143
|
+
const plugin = createWebpackPlugin(unpluginFactory)(options);
|
|
144
|
+
const originalApply = plugin.apply.bind(plugin);
|
|
145
|
+
plugin.apply = (compiler) => {
|
|
146
|
+
originalApply(compiler);
|
|
147
|
+
const wp = compiler;
|
|
148
|
+
wp.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
149
|
+
const c = compilation;
|
|
150
|
+
const NormalModule = c.compiler?.webpack?.NormalModule;
|
|
151
|
+
NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(
|
|
152
|
+
PLUGIN_NAME,
|
|
153
|
+
(loaders, module) => {
|
|
154
|
+
loaders.push({
|
|
155
|
+
loader: LOADER_PATH
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
return plugin;
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
css,
|
|
165
|
+
next_default as default
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=next.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/next.ts","../src/index.ts"],"sourcesContent":["// WebPack / swc opportunistically caches resolutions so we have to\n// register a custom loader that gives back the source instead.\n\nimport { createWebpackPlugin } from 'unplugin'\nimport { resolve } from 'path'\nimport { fileURLToPath } from 'url'\nimport type { PluginConfig } from './index'\nimport { unpluginFactory } from './index'\n\nconst _dirname =\n typeof __dirname !== 'undefined'\n ? __dirname\n : fileURLToPath(new URL('.', import.meta.url))\nconst LOADER_PATH = resolve(_dirname, 'loader.cjs')\n\nconst PLUGIN_NAME = 'inline-css-modules'\n\n// const virtualModulePath = 'inline-css-modules/virtual'\n// const isVirtualModule = (module: { resource?: string }) =>\n// module.resource?.includes?.(virtualModulePath) ?? false\n\nexport default function (options: PluginConfig = {}) {\n const plugin = createWebpackPlugin(unpluginFactory)(options) as {\n apply: (compiler: unknown) => void\n }\n const originalApply = plugin.apply.bind(plugin)\n plugin.apply = (compiler: unknown) => {\n originalApply(compiler)\n const wp = compiler as {\n hooks: {\n compilation: {\n tap: (name: string, fn: (compilation: unknown) => void) => void\n }\n }\n }\n\n wp.hooks.compilation.tap(PLUGIN_NAME, (compilation: unknown) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const c = compilation as any\n const NormalModule = c.compiler?.webpack?.NormalModule\n\n NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(\n PLUGIN_NAME,\n (loaders: { loader: string }[], module: { resource?: string }) => {\n loaders.push({\n loader: LOADER_PATH,\n })\n }\n )\n })\n }\n return plugin\n}\n\nexport { css } from './index'\nexport type { PluginConfig } from './index'\n","import type { UnpluginFactory } from 'unplugin'\nimport { createUnplugin } from 'unplugin'\nimport { createHash } from 'crypto'\nimport { mkdirSync, readFileSync, writeFileSync, existsSync } from 'fs'\nimport { join } from 'path'\n\ntype SupportedExtension = 'css' | 'scss' | 'sass' | 'styl' | 'less'\n\nexport type PluginConfig = {\n fileMatch?: RegExp\n tagName?: string\n extension?: SupportedExtension | ((filename: string) => SupportedExtension)\n inlineImport?: boolean\n}\n\nconst matchInlineCssModules =\n /(?:const|var|let)\\s*(\\w+)(?:\\s*:.*)?\\s*=\\s*(\\w+)\\s*`([\\s\\S]*?)`/gm\n\nexport const css = (_: TemplateStringsArray): Record<string, string> => ({})\n\nconst virtualModuleId = 'virtual:inline-css-modules'\nconst webpackModuleId = 'inline-css-modules/virtual'\nconst resolvedVirtualModuleId = '\\0' + virtualModuleId\nconst resolvedWebpackModuleId = '\\0inline-css-modules/virtual'\n\nlet cssModules: Record<string, string> = {}\n\nconst getCacheDir = () =>\n join(process.cwd(), 'node_modules', '.cache', 'inline-css-modules')\nconst getCachePath = (hash: string) => join(getCacheDir(), `${hash}.css`)\n\nfunction ensureCacheDir() {\n const dir = getCacheDir()\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true })\n }\n}\n\nfunction hashCss(css: string): string {\n return createHash('md5').update(css).digest('hex')\n}\n\nfunction readFromCache(hash: string): string | null {\n const path = getCachePath(hash)\n if (existsSync(path)) {\n return readFileSync(path, 'utf-8')\n }\n return null\n}\n\nfunction writeToCache(hash: string, css: string): void {\n ensureCacheDir()\n writeFileSync(getCachePath(hash), css)\n}\n\nexport const unpluginFactory: UnpluginFactory<PluginConfig | undefined> = (\n config = {},\n meta\n) => {\n const fileMatch = config.fileMatch ?? /\\.(tsx|jsx|js|vue|svelte)$/\n const tagName = config.tagName ?? 'css'\n const preprocessor = config.extension ?? 'css'\n const isWebpack =\n meta?.framework === 'webpack' || meta?.framework === 'rspack'\n const moduleId = isWebpack ? webpackModuleId : virtualModuleId\n const resolvedId = isWebpack\n ? resolvedWebpackModuleId\n : resolvedVirtualModuleId\n\n return {\n name: 'inline-css-modules',\n enforce: 'pre',\n resolveId(id) {\n if (id === moduleId || id.startsWith(moduleId + '/')) {\n return resolvedId + id.slice(moduleId.length)\n }\n if (id === virtualModuleId || id.startsWith(virtualModuleId + '/')) {\n return resolvedVirtualModuleId + id.slice(virtualModuleId.length)\n }\n if (id === webpackModuleId || id.startsWith(webpackModuleId + '/')) {\n return resolvedWebpackModuleId + id.slice(webpackModuleId.length)\n }\n return undefined\n },\n loadInclude(id) {\n return (\n id.startsWith(resolvedVirtualModuleId) ||\n id.startsWith(resolvedWebpackModuleId)\n )\n },\n load(id) {\n if (\n !id.startsWith(resolvedVirtualModuleId + '/') &&\n !id.startsWith(resolvedWebpackModuleId + '/')\n )\n return undefined\n\n const prefix = id.startsWith(resolvedVirtualModuleId + '/')\n ? resolvedVirtualModuleId + '/'\n : resolvedWebpackModuleId + '/'\n const file = id.slice(prefix.length).replace(/\\?used$/, '')\n const css = cssModules[file]\n\n if (!css) {\n if (isWebpack) {\n const hash = file.replace(/\\.module\\.\\w+$/, '')\n const cached = readFromCache(hash)\n if (cached) {\n return {\n code: cached,\n map: null,\n }\n }\n }\n return undefined\n }\n return {\n code: css,\n map: null,\n }\n },\n transform: {\n filter: {\n id: fileMatch,\n },\n handler(src, id) {\n // Build up a list of import statements to inject to the top of the file\n let imports: string[] = []\n\n src = src.replace(\n /import\\s*{\\s*(?:css|inlineCss)\\s*(?:as\\s*\\w+\\s*)?}\\s*from\\s*('|\"|`)unplugin-inline-css-modules\\1;?/gm,\n ''\n )\n\n src = src.replaceAll(matchInlineCssModules, (substring, ...args) => {\n const [variableName, tag, css] = args\n\n if (tag !== tagName) return substring\n\n let baseFilename = id.slice(id.lastIndexOf('/') + 1)\n baseFilename = baseFilename.slice(0, baseFilename.lastIndexOf('.'))\n let cnt = 0\n const ext =\n typeof preprocessor == 'function'\n ? preprocessor(baseFilename)\n : preprocessor\n let filename = `${baseFilename}-${cnt}.module.${ext}`\n while (cssModules[filename]) {\n cnt++\n filename = `${baseFilename}-${cnt}.module.${ext}`\n }\n cssModules[filename] = css\n\n let importStatement\n\n if (isWebpack) {\n const hash = hashCss(css)\n writeToCache(hash, css)\n importStatement = `import ${variableName} from \"${moduleId}/${hash}.module.${ext}\"`\n }\n importStatement = `import ${variableName} from \"${moduleId}/${filename}\"`\n\n if (config.inlineImport === false) {\n imports.push(importStatement)\n return ''\n }\n return importStatement\n })\n if (imports.length) {\n return imports.join('\\n') + '\\n' + src\n }\n return {\n code: src,\n map: null,\n }\n },\n },\n }\n}\n\nexport const unplugin = createUnplugin(unpluginFactory)\n\nexport default unplugin\n"],"mappings":";AAGA,SAAS,2BAA2B;AACpC,SAAS,eAAe;AACxB,SAAS,qBAAqB;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QAAM,gBAAgB,OAAO,MAAM,KAAK,MAAM;AAC9C,SAAO,QAAQ,CAAC,aAAsB;AACpC,kBAAc,QAAQ;AACtB,UAAM,KAAK;AAQX,OAAG,MAAM,YAAY,IAAI,aAAa,CAAC,gBAAyB;AAE9D,YAAM,IAAI;AACV,YAAM,eAAe,EAAE,UAAU,SAAS;AAE1C,mBAAa,oBAAoB,WAAW,EAAE,cAAc;AAAA,QAC1D;AAAA,QACA,CAAC,SAA+B,WAAkC;AAChE,kBAAQ,KAAK;AAAA,YACX,QAAQ;AAAA,UACV,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":["css"]}
|
package/dist/nuxt.d.mts
ADDED
package/dist/nuxt.d.ts
ADDED
package/dist/nuxt.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/nuxt.ts
|
|
21
|
+
var nuxt_exports = {};
|
|
22
|
+
__export(nuxt_exports, {
|
|
23
|
+
css: () => css,
|
|
24
|
+
default: () => nuxt_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(nuxt_exports);
|
|
27
|
+
var import_unplugin2 = require("unplugin");
|
|
28
|
+
|
|
29
|
+
// src/index.ts
|
|
30
|
+
var import_unplugin = require("unplugin");
|
|
31
|
+
var import_crypto = require("crypto");
|
|
32
|
+
var import_fs = require("fs");
|
|
33
|
+
var import_path = require("path");
|
|
34
|
+
var matchInlineCssModules = /(?:const|var|let)\s*(\w+)(?:\s*:.*)?\s*=\s*(\w+)\s*`([\s\S]*?)`/gm;
|
|
35
|
+
var css = (_) => ({});
|
|
36
|
+
var virtualModuleId = "virtual:inline-css-modules";
|
|
37
|
+
var webpackModuleId = "inline-css-modules/virtual";
|
|
38
|
+
var resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
39
|
+
var resolvedWebpackModuleId = "\0inline-css-modules/virtual";
|
|
40
|
+
var cssModules = {};
|
|
41
|
+
var getCacheDir = () => (0, import_path.join)(process.cwd(), "node_modules", ".cache", "inline-css-modules");
|
|
42
|
+
var getCachePath = (hash) => (0, import_path.join)(getCacheDir(), `${hash}.css`);
|
|
43
|
+
function ensureCacheDir() {
|
|
44
|
+
const dir = getCacheDir();
|
|
45
|
+
if (!(0, import_fs.existsSync)(dir)) {
|
|
46
|
+
(0, import_fs.mkdirSync)(dir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function hashCss(css2) {
|
|
50
|
+
return (0, import_crypto.createHash)("md5").update(css2).digest("hex");
|
|
51
|
+
}
|
|
52
|
+
function readFromCache(hash) {
|
|
53
|
+
const path = getCachePath(hash);
|
|
54
|
+
if ((0, import_fs.existsSync)(path)) {
|
|
55
|
+
return (0, import_fs.readFileSync)(path, "utf-8");
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
function writeToCache(hash, css2) {
|
|
60
|
+
ensureCacheDir();
|
|
61
|
+
(0, import_fs.writeFileSync)(getCachePath(hash), css2);
|
|
62
|
+
}
|
|
63
|
+
var unpluginFactory = (config = {}, meta) => {
|
|
64
|
+
const fileMatch = config.fileMatch ?? /\.(tsx|jsx|js|vue|svelte)$/;
|
|
65
|
+
const tagName = config.tagName ?? "css";
|
|
66
|
+
const preprocessor = config.extension ?? "css";
|
|
67
|
+
const isWebpack = meta?.framework === "webpack" || meta?.framework === "rspack";
|
|
68
|
+
const moduleId = isWebpack ? webpackModuleId : virtualModuleId;
|
|
69
|
+
const resolvedId = isWebpack ? resolvedWebpackModuleId : resolvedVirtualModuleId;
|
|
70
|
+
return {
|
|
71
|
+
name: "inline-css-modules",
|
|
72
|
+
enforce: "pre",
|
|
73
|
+
resolveId(id) {
|
|
74
|
+
if (id === moduleId || id.startsWith(moduleId + "/")) {
|
|
75
|
+
return resolvedId + id.slice(moduleId.length);
|
|
76
|
+
}
|
|
77
|
+
if (id === virtualModuleId || id.startsWith(virtualModuleId + "/")) {
|
|
78
|
+
return resolvedVirtualModuleId + id.slice(virtualModuleId.length);
|
|
79
|
+
}
|
|
80
|
+
if (id === webpackModuleId || id.startsWith(webpackModuleId + "/")) {
|
|
81
|
+
return resolvedWebpackModuleId + id.slice(webpackModuleId.length);
|
|
82
|
+
}
|
|
83
|
+
return void 0;
|
|
84
|
+
},
|
|
85
|
+
loadInclude(id) {
|
|
86
|
+
return id.startsWith(resolvedVirtualModuleId) || id.startsWith(resolvedWebpackModuleId);
|
|
87
|
+
},
|
|
88
|
+
load(id) {
|
|
89
|
+
if (!id.startsWith(resolvedVirtualModuleId + "/") && !id.startsWith(resolvedWebpackModuleId + "/"))
|
|
90
|
+
return void 0;
|
|
91
|
+
const prefix = id.startsWith(resolvedVirtualModuleId + "/") ? resolvedVirtualModuleId + "/" : resolvedWebpackModuleId + "/";
|
|
92
|
+
const file = id.slice(prefix.length).replace(/\?used$/, "");
|
|
93
|
+
const css2 = cssModules[file];
|
|
94
|
+
if (!css2) {
|
|
95
|
+
if (isWebpack) {
|
|
96
|
+
const hash = file.replace(/\.module\.\w+$/, "");
|
|
97
|
+
const cached = readFromCache(hash);
|
|
98
|
+
if (cached) {
|
|
99
|
+
return {
|
|
100
|
+
code: cached,
|
|
101
|
+
map: null
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
code: css2,
|
|
109
|
+
map: null
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
transform: {
|
|
113
|
+
filter: {
|
|
114
|
+
id: fileMatch
|
|
115
|
+
},
|
|
116
|
+
handler(src, id) {
|
|
117
|
+
let imports = [];
|
|
118
|
+
src = src.replace(
|
|
119
|
+
/import\s*{\s*(?:css|inlineCss)\s*(?:as\s*\w+\s*)?}\s*from\s*('|"|`)unplugin-inline-css-modules\1;?/gm,
|
|
120
|
+
""
|
|
121
|
+
);
|
|
122
|
+
src = src.replaceAll(matchInlineCssModules, (substring, ...args) => {
|
|
123
|
+
const [variableName, tag, css2] = args;
|
|
124
|
+
if (tag !== tagName) return substring;
|
|
125
|
+
let baseFilename = id.slice(id.lastIndexOf("/") + 1);
|
|
126
|
+
baseFilename = baseFilename.slice(0, baseFilename.lastIndexOf("."));
|
|
127
|
+
let cnt = 0;
|
|
128
|
+
const ext = typeof preprocessor == "function" ? preprocessor(baseFilename) : preprocessor;
|
|
129
|
+
let filename = `${baseFilename}-${cnt}.module.${ext}`;
|
|
130
|
+
while (cssModules[filename]) {
|
|
131
|
+
cnt++;
|
|
132
|
+
filename = `${baseFilename}-${cnt}.module.${ext}`;
|
|
133
|
+
}
|
|
134
|
+
cssModules[filename] = css2;
|
|
135
|
+
let importStatement;
|
|
136
|
+
if (isWebpack) {
|
|
137
|
+
const hash = hashCss(css2);
|
|
138
|
+
writeToCache(hash, css2);
|
|
139
|
+
importStatement = `import ${variableName} from "${moduleId}/${hash}.module.${ext}"`;
|
|
140
|
+
}
|
|
141
|
+
importStatement = `import ${variableName} from "${moduleId}/${filename}"`;
|
|
142
|
+
if (config.inlineImport === false) {
|
|
143
|
+
imports.push(importStatement);
|
|
144
|
+
return "";
|
|
145
|
+
}
|
|
146
|
+
return importStatement;
|
|
147
|
+
});
|
|
148
|
+
if (imports.length) {
|
|
149
|
+
return imports.join("\n") + "\n" + src;
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
code: src,
|
|
153
|
+
map: null
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
var unplugin = (0, import_unplugin.createUnplugin)(unpluginFactory);
|
|
160
|
+
|
|
161
|
+
// src/nuxt.ts
|
|
162
|
+
function nuxt_default(options = {}) {
|
|
163
|
+
return (0, import_unplugin2.createWebpackPlugin)(unpluginFactory)(options);
|
|
164
|
+
}
|
|
165
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
css
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=nuxt.js.map
|
package/dist/nuxt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/nuxt.ts","../src/index.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin'\nimport type { PluginConfig } from './index'\n\nexport default function (options: PluginConfig = {}) {\n return createWebpackPlugin(unpluginFactory)(options)\n}\n\nexport { css } from './index'\nexport type { PluginConfig } from './index'\n\nimport { unpluginFactory } from './index'\n","import type { UnpluginFactory } from 'unplugin'\nimport { createUnplugin } from 'unplugin'\nimport { createHash } from 'crypto'\nimport { mkdirSync, readFileSync, writeFileSync, existsSync } from 'fs'\nimport { join } from 'path'\n\ntype SupportedExtension = 'css' | 'scss' | 'sass' | 'styl' | 'less'\n\nexport type PluginConfig = {\n fileMatch?: RegExp\n tagName?: string\n extension?: SupportedExtension | ((filename: string) => SupportedExtension)\n inlineImport?: boolean\n}\n\nconst matchInlineCssModules =\n /(?:const|var|let)\\s*(\\w+)(?:\\s*:.*)?\\s*=\\s*(\\w+)\\s*`([\\s\\S]*?)`/gm\n\nexport const css = (_: TemplateStringsArray): Record<string, string> => ({})\n\nconst virtualModuleId = 'virtual:inline-css-modules'\nconst webpackModuleId = 'inline-css-modules/virtual'\nconst resolvedVirtualModuleId = '\\0' + virtualModuleId\nconst resolvedWebpackModuleId = '\\0inline-css-modules/virtual'\n\nlet cssModules: Record<string, string> = {}\n\nconst getCacheDir = () =>\n join(process.cwd(), 'node_modules', '.cache', 'inline-css-modules')\nconst getCachePath = (hash: string) => join(getCacheDir(), `${hash}.css`)\n\nfunction ensureCacheDir() {\n const dir = getCacheDir()\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true })\n }\n}\n\nfunction hashCss(css: string): string {\n return createHash('md5').update(css).digest('hex')\n}\n\nfunction readFromCache(hash: string): string | null {\n const path = getCachePath(hash)\n if (existsSync(path)) {\n return readFileSync(path, 'utf-8')\n }\n return null\n}\n\nfunction writeToCache(hash: string, css: string): void {\n ensureCacheDir()\n writeFileSync(getCachePath(hash), css)\n}\n\nexport const unpluginFactory: UnpluginFactory<PluginConfig | undefined> = (\n config = {},\n meta\n) => {\n const fileMatch = config.fileMatch ?? /\\.(tsx|jsx|js|vue|svelte)$/\n const tagName = config.tagName ?? 'css'\n const preprocessor = config.extension ?? 'css'\n const isWebpack =\n meta?.framework === 'webpack' || meta?.framework === 'rspack'\n const moduleId = isWebpack ? webpackModuleId : virtualModuleId\n const resolvedId = isWebpack\n ? resolvedWebpackModuleId\n : resolvedVirtualModuleId\n\n return {\n name: 'inline-css-modules',\n enforce: 'pre',\n resolveId(id) {\n if (id === moduleId || id.startsWith(moduleId + '/')) {\n return resolvedId + id.slice(moduleId.length)\n }\n if (id === virtualModuleId || id.startsWith(virtualModuleId + '/')) {\n return resolvedVirtualModuleId + id.slice(virtualModuleId.length)\n }\n if (id === webpackModuleId || id.startsWith(webpackModuleId + '/')) {\n return resolvedWebpackModuleId + id.slice(webpackModuleId.length)\n }\n return undefined\n },\n loadInclude(id) {\n return (\n id.startsWith(resolvedVirtualModuleId) ||\n id.startsWith(resolvedWebpackModuleId)\n )\n },\n load(id) {\n if (\n !id.startsWith(resolvedVirtualModuleId + '/') &&\n !id.startsWith(resolvedWebpackModuleId + '/')\n )\n return undefined\n\n const prefix = id.startsWith(resolvedVirtualModuleId + '/')\n ? resolvedVirtualModuleId + '/'\n : resolvedWebpackModuleId + '/'\n const file = id.slice(prefix.length).replace(/\\?used$/, '')\n const css = cssModules[file]\n\n if (!css) {\n if (isWebpack) {\n const hash = file.replace(/\\.module\\.\\w+$/, '')\n const cached = readFromCache(hash)\n if (cached) {\n return {\n code: cached,\n map: null,\n }\n }\n }\n return undefined\n }\n return {\n code: css,\n map: null,\n }\n },\n transform: {\n filter: {\n id: fileMatch,\n },\n handler(src, id) {\n // Build up a list of import statements to inject to the top of the file\n let imports: string[] = []\n\n src = src.replace(\n /import\\s*{\\s*(?:css|inlineCss)\\s*(?:as\\s*\\w+\\s*)?}\\s*from\\s*('|\"|`)unplugin-inline-css-modules\\1;?/gm,\n ''\n )\n\n src = src.replaceAll(matchInlineCssModules, (substring, ...args) => {\n const [variableName, tag, css] = args\n\n if (tag !== tagName) return substring\n\n let baseFilename = id.slice(id.lastIndexOf('/') + 1)\n baseFilename = baseFilename.slice(0, baseFilename.lastIndexOf('.'))\n let cnt = 0\n const ext =\n typeof preprocessor == 'function'\n ? preprocessor(baseFilename)\n : preprocessor\n let filename = `${baseFilename}-${cnt}.module.${ext}`\n while (cssModules[filename]) {\n cnt++\n filename = `${baseFilename}-${cnt}.module.${ext}`\n }\n cssModules[filename] = css\n\n let importStatement\n\n if (isWebpack) {\n const hash = hashCss(css)\n writeToCache(hash, css)\n importStatement = `import ${variableName} from \"${moduleId}/${hash}.module.${ext}\"`\n }\n importStatement = `import ${variableName} from \"${moduleId}/${filename}\"`\n\n if (config.inlineImport === false) {\n imports.push(importStatement)\n return ''\n }\n return importStatement\n })\n if (imports.length) {\n return imports.join('\\n') + '\\n' + src\n }\n return {\n code: src,\n map: null,\n }\n },\n },\n }\n}\n\nexport const unplugin = createUnplugin(unpluginFactory)\n\nexport default unplugin\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAoC;;;ACCpC,sBAA+B;AAC/B,oBAA2B;AAC3B,gBAAmE;AACnE,kBAAqB;AAWrB,IAAM,wBACJ;AAEK,IAAM,MAAM,CAAC,OAAqD,CAAC;AAE1E,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,0BAA0B,OAAO;AACvC,IAAM,0BAA0B;AAEhC,IAAI,aAAqC,CAAC;AAE1C,IAAM,cAAc,UAClB,kBAAK,QAAQ,IAAI,GAAG,gBAAgB,UAAU,oBAAoB;AACpE,IAAM,eAAe,CAAC,aAAiB,kBAAK,YAAY,GAAG,GAAG,IAAI,MAAM;AAExE,SAAS,iBAAiB;AACxB,QAAM,MAAM,YAAY;AACxB,MAAI,KAAC,sBAAW,GAAG,GAAG;AACpB,6BAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,EACpC;AACF;AAEA,SAAS,QAAQC,MAAqB;AACpC,aAAO,0BAAW,KAAK,EAAE,OAAOA,IAAG,EAAE,OAAO,KAAK;AACnD;AAEA,SAAS,cAAc,MAA6B;AAClD,QAAM,OAAO,aAAa,IAAI;AAC9B,UAAI,sBAAW,IAAI,GAAG;AACpB,eAAO,wBAAa,MAAM,OAAO;AAAA,EACnC;AACA,SAAO;AACT;AAEA,SAAS,aAAa,MAAcA,MAAmB;AACrD,iBAAe;AACf,+BAAc,aAAa,IAAI,GAAGA,IAAG;AACvC;AAEO,IAAM,kBAA6D,CACxE,SAAS,CAAC,GACV,SACG;AACH,QAAM,YAAY,OAAO,aAAa;AACtC,QAAM,UAAU,OAAO,WAAW;AAClC,QAAM,eAAe,OAAO,aAAa;AACzC,QAAM,Y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