@typedcss/next-plugin 22.0.4 → 22.0.6
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/dist/css.d.ts +6 -1
- package/dist/css.js +16 -4
- package/dist/shared.d.ts +2 -1
- package/dist/shared.js +14 -8
- package/package.json +3 -3
package/dist/css.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { LoaderContext } from './shared';
|
|
2
|
-
|
|
2
|
+
interface CssLoaderContext extends LoaderContext {
|
|
3
|
+
async: () => (error: Error | null, content?: string) => void;
|
|
4
|
+
emitError?: (error: Error) => void;
|
|
5
|
+
}
|
|
6
|
+
export default function typedcssCssLoader(this: CssLoaderContext): void;
|
|
7
|
+
export {};
|
package/dist/css.js
CHANGED
|
@@ -4,9 +4,21 @@ exports.default = typedcssCssLoader;
|
|
|
4
4
|
const shared_1 = require("./shared");
|
|
5
5
|
const dev_bridge_1 = require("./dev-bridge");
|
|
6
6
|
function typedcssCssLoader() {
|
|
7
|
+
const callback = this.async();
|
|
7
8
|
const options = (0, shared_1.optionsOf)(this);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
try {
|
|
10
|
+
// Watch every source before reading any, so an edit made while the
|
|
11
|
+
// stylesheet compiles still invalidates it.
|
|
12
|
+
for (const file of (0, shared_1.sourceFilesOf)(options))
|
|
13
|
+
this.addDependency(file);
|
|
14
|
+
const { css } = (0, shared_1.compileStylesheet)(options, true);
|
|
15
|
+
callback(null, (0, dev_bridge_1.withPreviousGenerations)(options.root, css));
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (process.env.NODE_ENV !== 'development' || !this.emitError) {
|
|
19
|
+
return callback(error);
|
|
20
|
+
}
|
|
21
|
+
this.emitError(error);
|
|
22
|
+
callback(null, (0, dev_bridge_1.readGenerations)((0, dev_bridge_1.devGenerationsPath)(options.root)).join('\n'));
|
|
23
|
+
}
|
|
12
24
|
}
|
package/dist/shared.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ export interface LoaderContext {
|
|
|
25
25
|
export declare function optionsOf(context: LoaderContext): ResolvedOptions;
|
|
26
26
|
export declare function sourcePackagesOf(root: string): SourcePackage[];
|
|
27
27
|
export declare function inSourcePackage(root: string, file: string): boolean;
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function sourceFilesOf({ cwd, root, include, exclude, }: ResolvedOptions): Set<string>;
|
|
29
|
+
export declare function compileStylesheet(options: ResolvedOptions, fresh?: boolean): {
|
|
29
30
|
css: string;
|
|
30
31
|
found: Set<string>;
|
|
31
32
|
};
|
package/dist/shared.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.VIRTUAL_FILE_PATH = exports.DEFAULT_STYLE_PROP = exports.PACKAGE = void
|
|
|
37
37
|
exports.optionsOf = optionsOf;
|
|
38
38
|
exports.sourcePackagesOf = sourcePackagesOf;
|
|
39
39
|
exports.inSourcePackage = inSourcePackage;
|
|
40
|
+
exports.sourceFilesOf = sourceFilesOf;
|
|
40
41
|
exports.compileStylesheet = compileStylesheet;
|
|
41
42
|
exports.transform = transform;
|
|
42
43
|
const fs = __importStar(require("fs"));
|
|
@@ -110,27 +111,31 @@ function modified(file) {
|
|
|
110
111
|
throw error;
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
-
const files = [];
|
|
115
|
-
const found = new Set();
|
|
114
|
+
function sourceFilesOf({ cwd, root, include, exclude, }) {
|
|
116
115
|
const scanned = new Set(oxide_1.oxide
|
|
117
116
|
.globFiles(include, cwd, exclude)
|
|
118
117
|
.map((relative) => path.join(cwd, relative)));
|
|
119
118
|
for (const file of sourcePackageFiles(root, exclude))
|
|
120
119
|
scanned.add(file);
|
|
121
|
-
|
|
120
|
+
return scanned;
|
|
121
|
+
}
|
|
122
|
+
function collect(options, fresh) {
|
|
123
|
+
const files = [];
|
|
124
|
+
const found = new Set();
|
|
125
|
+
for (const file of sourceFilesOf(options)) {
|
|
122
126
|
const mtime = modified(file);
|
|
123
127
|
if (mtime === undefined)
|
|
124
128
|
continue;
|
|
125
129
|
found.add(file);
|
|
126
130
|
const previous = seen.get(file);
|
|
127
|
-
if (previous && previous.mtime === mtime) {
|
|
131
|
+
if (!fresh && previous && previous.mtime === mtime) {
|
|
128
132
|
if (previous.relevant)
|
|
129
133
|
files.push({ path: file });
|
|
130
134
|
continue;
|
|
131
135
|
}
|
|
132
136
|
const source = fs.readFileSync(file, 'utf8');
|
|
133
|
-
const relevant = REEXPORT.test(source) ||
|
|
137
|
+
const relevant = REEXPORT.test(source) ||
|
|
138
|
+
oxide_1.oxide.needsCompile(source, options.styleProp, file);
|
|
134
139
|
seen.set(file, { mtime, relevant });
|
|
135
140
|
if (relevant)
|
|
136
141
|
files.push({ path: file, source });
|
|
@@ -141,8 +146,9 @@ function collect({ cwd, root, include, exclude, styleProp }) {
|
|
|
141
146
|
}
|
|
142
147
|
return { files, found };
|
|
143
148
|
}
|
|
144
|
-
|
|
145
|
-
|
|
149
|
+
// A fresh compile reads every file again instead of trusting a cached mtime.
|
|
150
|
+
function compileStylesheet(options, fresh = false) {
|
|
151
|
+
const { files, found } = collect(options, fresh);
|
|
146
152
|
try {
|
|
147
153
|
return {
|
|
148
154
|
css: oxide_1.oxide.compileCss({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typedcss/next-plugin",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.6",
|
|
4
4
|
"description": "TypedCSS Next.js plugin",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"zss-engine": "3.1.2",
|
|
42
|
-
"@typedcss/eslint-plugin": "22.0.
|
|
43
|
-
"@typedcss/oxide": "22.0.
|
|
42
|
+
"@typedcss/eslint-plugin": "22.0.6",
|
|
43
|
+
"@typedcss/oxide": "22.0.6"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public",
|