@bamboocss/plugin-lightningcss 1.11.1 → 1.11.2
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/index.cjs +65 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +34 -36
- package/package.json +10 -10
- package/dist/index.js +0 -80
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let _bamboocss_logger = require("@bamboocss/logger");
|
|
25
|
+
let lightningcss = require("lightningcss");
|
|
26
|
+
let browserslist = require("browserslist");
|
|
27
|
+
browserslist = __toESM(browserslist);
|
|
28
|
+
//#region src/optimize-lightningcss.ts
|
|
29
|
+
const decoder = new TextDecoder();
|
|
30
|
+
function optimizeLightCss(code, options = {}) {
|
|
31
|
+
const { minify = false, browserslist: targets } = options;
|
|
32
|
+
const result = (0, lightningcss.transform)({
|
|
33
|
+
code: Buffer.from(code),
|
|
34
|
+
minify,
|
|
35
|
+
sourceMap: false,
|
|
36
|
+
filename: "styles.css",
|
|
37
|
+
include: lightningcss.Features.Nesting | lightningcss.Features.MediaRangeSyntax,
|
|
38
|
+
targets: (0, lightningcss.browserslistToTargets)((0, browserslist.default)(targets)),
|
|
39
|
+
errorRecovery: true
|
|
40
|
+
});
|
|
41
|
+
if (result.warnings.length) {
|
|
42
|
+
const split = code.split("\n");
|
|
43
|
+
_bamboocss_logger.logger.warn("css", result.warnings.map((w) => ({
|
|
44
|
+
...w,
|
|
45
|
+
line: split[w.loc.line - 1]
|
|
46
|
+
})));
|
|
47
|
+
}
|
|
48
|
+
return decoder.decode(result.code);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/index.ts
|
|
52
|
+
function pluginLightningcss() {
|
|
53
|
+
return {
|
|
54
|
+
name: "@bamboocss/plugin-lightningcss",
|
|
55
|
+
hooks: { "css:optimize": ({ css, minify, browserslist }) => {
|
|
56
|
+
return optimizeLightCss(css, {
|
|
57
|
+
minify,
|
|
58
|
+
browserslist
|
|
59
|
+
});
|
|
60
|
+
} }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
exports.optimizeLightCss = optimizeLightCss;
|
|
65
|
+
exports.pluginLightningcss = pluginLightningcss;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BambooPlugin } from "@bamboocss/types";
|
|
2
|
+
|
|
3
|
+
//#region src/optimize-lightningcss.d.ts
|
|
4
|
+
interface OptimizeOptions {
|
|
5
|
+
minify?: boolean;
|
|
6
|
+
browserslist?: string[];
|
|
7
|
+
}
|
|
8
|
+
declare function optimizeLightCss(code: string, options?: OptimizeOptions): string;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/index.d.ts
|
|
11
|
+
declare function pluginLightningcss(): BambooPlugin;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { optimizeLightCss, pluginLightningcss };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BambooPlugin } from "@bamboocss/types";
|
|
2
|
+
|
|
3
|
+
//#region src/optimize-lightningcss.d.ts
|
|
4
|
+
interface OptimizeOptions {
|
|
5
|
+
minify?: boolean;
|
|
6
|
+
browserslist?: string[];
|
|
7
|
+
}
|
|
8
|
+
declare function optimizeLightCss(code: string, options?: OptimizeOptions): string;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/index.d.ts
|
|
11
|
+
declare function pluginLightningcss(): BambooPlugin;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { optimizeLightCss, pluginLightningcss };
|
package/dist/index.mjs
CHANGED
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
// src/optimize-lightningcss.ts
|
|
2
1
|
import { logger } from "@bamboocss/logger";
|
|
3
|
-
import { Features,
|
|
2
|
+
import { Features, browserslistToTargets, transform } from "lightningcss";
|
|
4
3
|
import browserslist from "browserslist";
|
|
5
|
-
|
|
4
|
+
//#region src/optimize-lightningcss.ts
|
|
5
|
+
const decoder = new TextDecoder();
|
|
6
6
|
function optimizeLightCss(code, options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return decoder.decode(result.code);
|
|
7
|
+
const { minify = false, browserslist: targets } = options;
|
|
8
|
+
const result = transform({
|
|
9
|
+
code: Buffer.from(code),
|
|
10
|
+
minify,
|
|
11
|
+
sourceMap: false,
|
|
12
|
+
filename: "styles.css",
|
|
13
|
+
include: Features.Nesting | Features.MediaRangeSyntax,
|
|
14
|
+
targets: browserslistToTargets(browserslist(targets)),
|
|
15
|
+
errorRecovery: true
|
|
16
|
+
});
|
|
17
|
+
if (result.warnings.length) {
|
|
18
|
+
const split = code.split("\n");
|
|
19
|
+
logger.warn("css", result.warnings.map((w) => ({
|
|
20
|
+
...w,
|
|
21
|
+
line: split[w.loc.line - 1]
|
|
22
|
+
})));
|
|
23
|
+
}
|
|
24
|
+
return decoder.decode(result.code);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/index.ts
|
|
29
28
|
function pluginLightningcss() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
return {
|
|
30
|
+
name: "@bamboocss/plugin-lightningcss",
|
|
31
|
+
hooks: { "css:optimize": ({ css, minify, browserslist }) => {
|
|
32
|
+
return optimizeLightCss(css, {
|
|
33
|
+
minify,
|
|
34
|
+
browserslist
|
|
35
|
+
});
|
|
36
|
+
} }
|
|
37
|
+
};
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
pluginLightningcss
|
|
42
|
-
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { optimizeLightCss, pluginLightningcss };
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/plugin-lightningcss",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Bamboo CSS plugin for LightningCSS optimization",
|
|
5
5
|
"homepage": "https://bamboo-css.com",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Segun Adebayo <joseshegs@gmail.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/bamboocss/bamboo.git",
|
|
11
11
|
"directory": "packages/plugin-lightningcss"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
|
-
"main": "dist/index.
|
|
17
|
+
"main": "dist/index.cjs",
|
|
18
18
|
"module": "dist/index.mjs",
|
|
19
|
-
"types": "dist/index.d.
|
|
19
|
+
"types": "dist/index.d.cts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"source": "./src/index.ts",
|
|
23
|
-
"types": "./dist/index.d.
|
|
24
|
-
"require": "./dist/index.
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
25
|
"import": {
|
|
26
26
|
"types": "./dist/index.d.mts",
|
|
27
27
|
"default": "./dist/index.mjs"
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"browserslist": "4.28.1",
|
|
37
37
|
"lightningcss": "1.31.1",
|
|
38
|
-
"@bamboocss/logger": "1.11.
|
|
39
|
-
"@bamboocss/types": "1.11.
|
|
38
|
+
"@bamboocss/logger": "1.11.2",
|
|
39
|
+
"@bamboocss/types": "1.11.2"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "
|
|
43
|
-
"build-fast": "
|
|
42
|
+
"build": "tsdown src/index.ts --format=esm,cjs --dts",
|
|
43
|
+
"build-fast": "tsdown --dts=false src/index.ts --format=esm,cjs",
|
|
44
44
|
"dev": "pnpm build-fast --watch"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/dist/index.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
optimizeLightCss: () => optimizeLightCss,
|
|
34
|
-
pluginLightningcss: () => pluginLightningcss
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
|
|
38
|
-
// src/optimize-lightningcss.ts
|
|
39
|
-
var import_logger = require("@bamboocss/logger");
|
|
40
|
-
var import_lightningcss = require("lightningcss");
|
|
41
|
-
var import_browserslist = __toESM(require("browserslist"));
|
|
42
|
-
var decoder = new TextDecoder();
|
|
43
|
-
function optimizeLightCss(code, options = {}) {
|
|
44
|
-
const { minify = false, browserslist: targets } = options;
|
|
45
|
-
const result = (0, import_lightningcss.transform)({
|
|
46
|
-
// https://stackoverflow.com/questions/78790943/in-typescript-5-6-buffer-is-not-assignable-to-arraybufferview-or-uint8arr
|
|
47
|
-
code: Buffer.from(code),
|
|
48
|
-
minify,
|
|
49
|
-
sourceMap: false,
|
|
50
|
-
filename: "styles.css",
|
|
51
|
-
include: import_lightningcss.Features.Nesting | import_lightningcss.Features.MediaRangeSyntax,
|
|
52
|
-
targets: (0, import_lightningcss.browserslistToTargets)((0, import_browserslist.default)(targets)),
|
|
53
|
-
errorRecovery: true
|
|
54
|
-
});
|
|
55
|
-
if (result.warnings.length) {
|
|
56
|
-
const split = code.split("\n");
|
|
57
|
-
import_logger.logger.warn(
|
|
58
|
-
"css",
|
|
59
|
-
result.warnings.map((w) => ({ ...w, line: split[w.loc.line - 1] }))
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
return decoder.decode(result.code);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/index.ts
|
|
66
|
-
function pluginLightningcss() {
|
|
67
|
-
return {
|
|
68
|
-
name: "@bamboocss/plugin-lightningcss",
|
|
69
|
-
hooks: {
|
|
70
|
-
"css:optimize": ({ css, minify, browserslist: browserslist2 }) => {
|
|
71
|
-
return optimizeLightCss(css, { minify, browserslist: browserslist2 });
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
-
0 && (module.exports = {
|
|
78
|
-
optimizeLightCss,
|
|
79
|
-
pluginLightningcss
|
|
80
|
-
});
|