@zeus-js/output-css 0.1.0-beta.2 → 0.1.0-beta.4
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/output-css.cjs.js +24 -10
- package/dist/output-css.cjs.prod.js +24 -10
- package/dist/output-css.esm-bundler.js +36 -16
- package/package.json +5 -5
package/dist/output-css.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* output-css v0.1.0-beta.
|
|
2
|
+
* output-css v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -62,16 +62,16 @@ async function processCssEntry(entry, options, root) {
|
|
|
62
62
|
const raw = await node_fs_promises.default.readFile(input, "utf-8");
|
|
63
63
|
const processor = entry.processor === "auto" ? await detectCssProcessor(input, root) : entry.processor;
|
|
64
64
|
let css = raw;
|
|
65
|
-
if (processor === "sass") css = await processSass(input);
|
|
66
|
-
else if (processor === "less") css = await processLess(input, raw);
|
|
65
|
+
if (processor === "sass") css = await processSass(input, root);
|
|
66
|
+
else if (processor === "less") css = await processLess(input, raw, root);
|
|
67
67
|
else if (processor === "postcss") css = await processPostcss(input, raw, root);
|
|
68
68
|
if (options.minify) css = await minifyCss(input, css);
|
|
69
69
|
return { css };
|
|
70
70
|
}
|
|
71
|
-
async function processSass(input) {
|
|
71
|
+
async function processSass(input, root) {
|
|
72
72
|
let sass;
|
|
73
73
|
try {
|
|
74
|
-
sass =
|
|
74
|
+
sass = await loadOptionalPackage("sass", root);
|
|
75
75
|
} catch {
|
|
76
76
|
throw new Error("[zeus-output-css] Install \"sass\" to process .scss/.sass files.");
|
|
77
77
|
}
|
|
@@ -80,10 +80,10 @@ async function processSass(input) {
|
|
|
80
80
|
loadPaths: [node_path.default.dirname(input)]
|
|
81
81
|
})).css;
|
|
82
82
|
}
|
|
83
|
-
async function processLess(input, source) {
|
|
83
|
+
async function processLess(input, source, root) {
|
|
84
84
|
let less;
|
|
85
85
|
try {
|
|
86
|
-
less =
|
|
86
|
+
less = await loadOptionalPackage("less", root);
|
|
87
87
|
} catch {
|
|
88
88
|
throw new Error("[zeus-output-css] Install \"less\" to process .less files.");
|
|
89
89
|
}
|
|
@@ -92,13 +92,13 @@ async function processLess(input, source) {
|
|
|
92
92
|
async function processPostcss(input, source, root) {
|
|
93
93
|
let postcss;
|
|
94
94
|
try {
|
|
95
|
-
postcss =
|
|
95
|
+
postcss = await loadOptionalPackage("postcss", root);
|
|
96
96
|
} catch {
|
|
97
97
|
throw new Error("[zeus-output-css] Install \"postcss\" to process CSS with PostCSS.");
|
|
98
98
|
}
|
|
99
99
|
let loadConfig;
|
|
100
100
|
try {
|
|
101
|
-
loadConfig =
|
|
101
|
+
loadConfig = await loadOptionalPackage("postcss-load-config", root);
|
|
102
102
|
} catch {
|
|
103
103
|
throw new Error("[zeus-output-css] Install \"postcss-load-config\" to load PostCSS config.");
|
|
104
104
|
}
|
|
@@ -108,10 +108,24 @@ async function processPostcss(input, source, root) {
|
|
|
108
108
|
map: false
|
|
109
109
|
})).css;
|
|
110
110
|
}
|
|
111
|
+
async function loadOptionalPackage(id, root) {
|
|
112
|
+
if (root) try {
|
|
113
|
+
return (0, node_module.createRequire)(node_path.default.resolve(root, "package.json"))(id);
|
|
114
|
+
} catch {}
|
|
115
|
+
try {
|
|
116
|
+
return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)(id);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
try {
|
|
119
|
+
return await import(id);
|
|
120
|
+
} catch {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
111
125
|
async function minifyCss(_input, source) {
|
|
112
126
|
try {
|
|
113
127
|
let lightningcss;
|
|
114
|
-
lightningcss =
|
|
128
|
+
lightningcss = await loadOptionalPackage("lightningcss");
|
|
115
129
|
return lightningcss.transform({
|
|
116
130
|
filename: _input,
|
|
117
131
|
code: Buffer.from(source),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* output-css v0.1.0-beta.
|
|
2
|
+
* output-css v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -62,16 +62,16 @@ async function processCssEntry(entry, options, root) {
|
|
|
62
62
|
const raw = await node_fs_promises.default.readFile(input, "utf-8");
|
|
63
63
|
const processor = entry.processor === "auto" ? await detectCssProcessor(input, root) : entry.processor;
|
|
64
64
|
let css = raw;
|
|
65
|
-
if (processor === "sass") css = await processSass(input);
|
|
66
|
-
else if (processor === "less") css = await processLess(input, raw);
|
|
65
|
+
if (processor === "sass") css = await processSass(input, root);
|
|
66
|
+
else if (processor === "less") css = await processLess(input, raw, root);
|
|
67
67
|
else if (processor === "postcss") css = await processPostcss(input, raw, root);
|
|
68
68
|
if (options.minify) css = await minifyCss(input, css);
|
|
69
69
|
return { css };
|
|
70
70
|
}
|
|
71
|
-
async function processSass(input) {
|
|
71
|
+
async function processSass(input, root) {
|
|
72
72
|
let sass;
|
|
73
73
|
try {
|
|
74
|
-
sass =
|
|
74
|
+
sass = await loadOptionalPackage("sass", root);
|
|
75
75
|
} catch {
|
|
76
76
|
throw new Error("[zeus-output-css] Install \"sass\" to process .scss/.sass files.");
|
|
77
77
|
}
|
|
@@ -80,10 +80,10 @@ async function processSass(input) {
|
|
|
80
80
|
loadPaths: [node_path.default.dirname(input)]
|
|
81
81
|
})).css;
|
|
82
82
|
}
|
|
83
|
-
async function processLess(input, source) {
|
|
83
|
+
async function processLess(input, source, root) {
|
|
84
84
|
let less;
|
|
85
85
|
try {
|
|
86
|
-
less =
|
|
86
|
+
less = await loadOptionalPackage("less", root);
|
|
87
87
|
} catch {
|
|
88
88
|
throw new Error("[zeus-output-css] Install \"less\" to process .less files.");
|
|
89
89
|
}
|
|
@@ -92,13 +92,13 @@ async function processLess(input, source) {
|
|
|
92
92
|
async function processPostcss(input, source, root) {
|
|
93
93
|
let postcss;
|
|
94
94
|
try {
|
|
95
|
-
postcss =
|
|
95
|
+
postcss = await loadOptionalPackage("postcss", root);
|
|
96
96
|
} catch {
|
|
97
97
|
throw new Error("[zeus-output-css] Install \"postcss\" to process CSS with PostCSS.");
|
|
98
98
|
}
|
|
99
99
|
let loadConfig;
|
|
100
100
|
try {
|
|
101
|
-
loadConfig =
|
|
101
|
+
loadConfig = await loadOptionalPackage("postcss-load-config", root);
|
|
102
102
|
} catch {
|
|
103
103
|
throw new Error("[zeus-output-css] Install \"postcss-load-config\" to load PostCSS config.");
|
|
104
104
|
}
|
|
@@ -108,10 +108,24 @@ async function processPostcss(input, source, root) {
|
|
|
108
108
|
map: false
|
|
109
109
|
})).css;
|
|
110
110
|
}
|
|
111
|
+
async function loadOptionalPackage(id, root) {
|
|
112
|
+
if (root) try {
|
|
113
|
+
return (0, node_module.createRequire)(node_path.default.resolve(root, "package.json"))(id);
|
|
114
|
+
} catch {}
|
|
115
|
+
try {
|
|
116
|
+
return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)(id);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
try {
|
|
119
|
+
return await import(id);
|
|
120
|
+
} catch {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
111
125
|
async function minifyCss(_input, source) {
|
|
112
126
|
try {
|
|
113
127
|
let lightningcss;
|
|
114
|
-
lightningcss =
|
|
128
|
+
lightningcss = await loadOptionalPackage("lightningcss");
|
|
115
129
|
return lightningcss.transform({
|
|
116
130
|
filename: _input,
|
|
117
131
|
code: Buffer.from(source),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* output-css v0.1.0-beta.
|
|
2
|
+
* output-css v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -7,7 +7,7 @@ import fs from "node:fs/promises";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/asyncToGenerator.js
|
|
11
11
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
12
12
|
try {
|
|
13
13
|
var i = n[a](c), u = i.value;
|
|
@@ -76,22 +76,22 @@ function _processCssEntry() {
|
|
|
76
76
|
const raw = yield fs.readFile(input, "utf-8");
|
|
77
77
|
const processor = entry.processor === "auto" ? yield detectCssProcessor(input, root) : entry.processor;
|
|
78
78
|
let css = raw;
|
|
79
|
-
if (processor === "sass") css = yield processSass(input);
|
|
80
|
-
else if (processor === "less") css = yield processLess(input, raw);
|
|
79
|
+
if (processor === "sass") css = yield processSass(input, root);
|
|
80
|
+
else if (processor === "less") css = yield processLess(input, raw, root);
|
|
81
81
|
else if (processor === "postcss") css = yield processPostcss(input, raw, root);
|
|
82
82
|
if (options.minify) css = yield minifyCss(input, css);
|
|
83
83
|
return { css };
|
|
84
84
|
});
|
|
85
85
|
return _processCssEntry.apply(this, arguments);
|
|
86
86
|
}
|
|
87
|
-
function processSass(_x4) {
|
|
87
|
+
function processSass(_x4, _x5) {
|
|
88
88
|
return _processSass.apply(this, arguments);
|
|
89
89
|
}
|
|
90
90
|
function _processSass() {
|
|
91
|
-
_processSass = _asyncToGenerator(function* (input) {
|
|
91
|
+
_processSass = _asyncToGenerator(function* (input, root) {
|
|
92
92
|
let sass;
|
|
93
93
|
try {
|
|
94
|
-
sass =
|
|
94
|
+
sass = yield loadOptionalPackage("sass", root);
|
|
95
95
|
} catch (_unused) {
|
|
96
96
|
throw new Error("[zeus-output-css] Install \"sass\" to process .scss/.sass files.");
|
|
97
97
|
}
|
|
@@ -102,14 +102,14 @@ function _processSass() {
|
|
|
102
102
|
});
|
|
103
103
|
return _processSass.apply(this, arguments);
|
|
104
104
|
}
|
|
105
|
-
function processLess(
|
|
105
|
+
function processLess(_x6, _x7, _x8) {
|
|
106
106
|
return _processLess.apply(this, arguments);
|
|
107
107
|
}
|
|
108
108
|
function _processLess() {
|
|
109
|
-
_processLess = _asyncToGenerator(function* (input, source) {
|
|
109
|
+
_processLess = _asyncToGenerator(function* (input, source, root) {
|
|
110
110
|
let less;
|
|
111
111
|
try {
|
|
112
|
-
less =
|
|
112
|
+
less = yield loadOptionalPackage("less", root);
|
|
113
113
|
} catch (_unused2) {
|
|
114
114
|
throw new Error("[zeus-output-css] Install \"less\" to process .less files.");
|
|
115
115
|
}
|
|
@@ -117,20 +117,20 @@ function _processLess() {
|
|
|
117
117
|
});
|
|
118
118
|
return _processLess.apply(this, arguments);
|
|
119
119
|
}
|
|
120
|
-
function processPostcss(
|
|
120
|
+
function processPostcss(_x9, _x10, _x11) {
|
|
121
121
|
return _processPostcss.apply(this, arguments);
|
|
122
122
|
}
|
|
123
123
|
function _processPostcss() {
|
|
124
124
|
_processPostcss = _asyncToGenerator(function* (input, source, root) {
|
|
125
125
|
let postcss;
|
|
126
126
|
try {
|
|
127
|
-
postcss =
|
|
127
|
+
postcss = yield loadOptionalPackage("postcss", root);
|
|
128
128
|
} catch (_unused3) {
|
|
129
129
|
throw new Error("[zeus-output-css] Install \"postcss\" to process CSS with PostCSS.");
|
|
130
130
|
}
|
|
131
131
|
let loadConfig;
|
|
132
132
|
try {
|
|
133
|
-
loadConfig =
|
|
133
|
+
loadConfig = yield loadOptionalPackage("postcss-load-config", root);
|
|
134
134
|
} catch (_unused4) {
|
|
135
135
|
throw new Error("[zeus-output-css] Install \"postcss-load-config\" to load PostCSS config.");
|
|
136
136
|
}
|
|
@@ -142,20 +142,40 @@ function _processPostcss() {
|
|
|
142
142
|
});
|
|
143
143
|
return _processPostcss.apply(this, arguments);
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function loadOptionalPackage(_x12, _x13) {
|
|
146
|
+
return _loadOptionalPackage.apply(this, arguments);
|
|
147
|
+
}
|
|
148
|
+
function _loadOptionalPackage() {
|
|
149
|
+
_loadOptionalPackage = _asyncToGenerator(function* (id, root) {
|
|
150
|
+
if (root) try {
|
|
151
|
+
return createRequire(path.resolve(root, "package.json"))(id);
|
|
152
|
+
} catch (_unused5) {}
|
|
153
|
+
try {
|
|
154
|
+
return createRequire(import.meta.url)(id);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
try {
|
|
157
|
+
return yield import(id);
|
|
158
|
+
} catch (_unused6) {
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return _loadOptionalPackage.apply(this, arguments);
|
|
164
|
+
}
|
|
165
|
+
function minifyCss(_x14, _x15) {
|
|
146
166
|
return _minifyCss.apply(this, arguments);
|
|
147
167
|
}
|
|
148
168
|
function _minifyCss() {
|
|
149
169
|
_minifyCss = _asyncToGenerator(function* (_input, source) {
|
|
150
170
|
try {
|
|
151
171
|
let lightningcss;
|
|
152
|
-
lightningcss =
|
|
172
|
+
lightningcss = yield loadOptionalPackage("lightningcss");
|
|
153
173
|
return lightningcss.transform({
|
|
154
174
|
filename: _input,
|
|
155
175
|
code: Buffer.from(source),
|
|
156
176
|
minify: true
|
|
157
177
|
}).code.toString();
|
|
158
|
-
} catch (
|
|
178
|
+
} catch (_unused7) {
|
|
159
179
|
return source;
|
|
160
180
|
}
|
|
161
181
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeus-js/output-css",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "Zeus CSS asset output plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/output-css.d.ts",
|
|
16
|
+
"module": "./dist/output-css.esm-bundler.js",
|
|
17
|
+
"import": "./dist/output-css.esm-bundler.js",
|
|
18
|
+
"require": "./index.js",
|
|
16
19
|
"node": {
|
|
17
20
|
"production": "./dist/output-css.cjs.prod.js",
|
|
18
21
|
"development": "./dist/output-css.cjs.js",
|
|
19
22
|
"default": "./index.js"
|
|
20
|
-
}
|
|
21
|
-
"module": "./dist/output-css.esm-bundler.js",
|
|
22
|
-
"import": "./dist/output-css.esm-bundler.js",
|
|
23
|
-
"require": "./index.js"
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"sideEffects": false,
|