@plumeria/compiler 0.23.1 ā 0.24.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/bin/css.js +5 -2
- package/dist/extract.js +2 -0
- package/dist/index.js +48 -2
- package/package.json +3 -3
package/bin/css.js
CHANGED
|
@@ -14,6 +14,7 @@ register();
|
|
|
14
14
|
try {
|
|
15
15
|
const checkMark = styleText('greenBright', 'ā');
|
|
16
16
|
const typecheck = process.argv.includes('--type-check');
|
|
17
|
+
const stats = process.argv.includes('--stats');
|
|
17
18
|
|
|
18
19
|
if (typecheck) {
|
|
19
20
|
execSync('tsc --noEmit --incremental false', {
|
|
@@ -24,8 +25,10 @@ try {
|
|
|
24
25
|
|
|
25
26
|
require(path.resolve(__dirname, '../dist/index.js'));
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (!stats) {
|
|
29
|
+
const compilation = typecheck ? 'Type-check completed' : '';
|
|
30
|
+
console.log(` ${checkMark} Compiled... ${compilation}`);
|
|
31
|
+
}
|
|
29
32
|
} catch (error) {
|
|
30
33
|
console.error('Compilation failed:', error.message);
|
|
31
34
|
process.exit(1);
|
package/dist/extract.js
CHANGED
|
@@ -3,12 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generatedTsMap = void 0;
|
|
6
7
|
exports.extractTSFile = extractTSFile;
|
|
7
8
|
exports.restoreAllOriginals = restoreAllOriginals;
|
|
8
9
|
exports.extractVueAndSvelte = extractVueAndSvelte;
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const generatedTsMap = new Map();
|
|
13
|
+
exports.generatedTsMap = generatedTsMap;
|
|
12
14
|
function isInComment(code, position) {
|
|
13
15
|
const beforePosition = code.substring(0, position);
|
|
14
16
|
const lines = beforePosition.split('\n');
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,40 @@ const core_1 = require("@swc/core");
|
|
|
14
14
|
const find_up_1 = require("find-up");
|
|
15
15
|
const processors_1 = require("@plumeria/core/processors");
|
|
16
16
|
const extract_1 = require("./extract");
|
|
17
|
+
async function generateStats(buildTime) {
|
|
18
|
+
const cssCode = await (0, promises_1.readFile)(coreFilePath, 'utf8');
|
|
19
|
+
const cssSize = Buffer.byteLength(cssCode, 'utf8');
|
|
20
|
+
let rules = 0;
|
|
21
|
+
const topProperties = new Map();
|
|
22
|
+
(0, lightningcss_1.transform)({
|
|
23
|
+
filename: coreFilePath,
|
|
24
|
+
code: Buffer.from(cssCode),
|
|
25
|
+
visitor: {
|
|
26
|
+
Rule(rule) {
|
|
27
|
+
if (rule.type === 'style') {
|
|
28
|
+
rules++;
|
|
29
|
+
rule.value.declarations.declarations.forEach((decl) => {
|
|
30
|
+
if ('property' in decl) {
|
|
31
|
+
topProperties.set(decl.property, (topProperties.get(decl.property) || 0) + 1);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const sortedTopProperties = [...topProperties.entries()].sort((a, b) => b[1] - a[1]);
|
|
39
|
+
console.log('\nš¦ Plumeria CSS Stats');
|
|
40
|
+
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
41
|
+
console.log(`Total CSS size: ${(cssSize / 1024).toFixed(3)} KB`);
|
|
42
|
+
console.log(`Rules: ${rules}`);
|
|
43
|
+
console.log('Top properties:');
|
|
44
|
+
for (let i = 0; i < Math.min(5, sortedTopProperties.length); i++) {
|
|
45
|
+
const [prop, count] = sortedTopProperties[i];
|
|
46
|
+
console.log(` - ${prop}: ${count}`);
|
|
47
|
+
}
|
|
48
|
+
console.log(`Build time: ${buildTime.toFixed(2)}s`);
|
|
49
|
+
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāā\n');
|
|
50
|
+
}
|
|
17
51
|
let projectRoot;
|
|
18
52
|
const workspaceRootFile = (0, find_up_1.findUpSync)((directory) => {
|
|
19
53
|
const pnpmWsPath = path_1.default.join(directory, 'pnpm-workspace.yaml');
|
|
@@ -140,6 +174,7 @@ async function optimizeCSS() {
|
|
|
140
174
|
await (0, promises_1.writeFile)(coreFilePath, optimizedCss, 'utf-8');
|
|
141
175
|
}
|
|
142
176
|
(async () => {
|
|
177
|
+
const startTime = performance.now();
|
|
143
178
|
await cleanUp();
|
|
144
179
|
const scanRoot = process.cwd();
|
|
145
180
|
const files = (0, fs_1.globSync)('**/*.{js,jsx,ts,tsx,vue,svelte}', {
|
|
@@ -162,10 +197,16 @@ async function optimizeCSS() {
|
|
|
162
197
|
const styleFiles = filesSupportExtensions
|
|
163
198
|
.filter((file) => isCSS(file))
|
|
164
199
|
.sort();
|
|
200
|
+
const tempToOriginalMap = new Map();
|
|
201
|
+
for (const [original, temp] of extract_1.generatedTsMap.entries()) {
|
|
202
|
+
tempToOriginalMap.set(temp, original);
|
|
203
|
+
}
|
|
165
204
|
for (let i = 0; i < styleFiles.length; i++) {
|
|
166
205
|
await (0, execute_1.execute)(path_1.default.resolve(styleFiles[i]));
|
|
167
|
-
if (process.argv.includes('--paths'))
|
|
168
|
-
|
|
206
|
+
if (process.argv.includes('--paths')) {
|
|
207
|
+
const originalFile = tempToOriginalMap.get(styleFiles[i]);
|
|
208
|
+
console.log(`ā
: ${projectName}/${path_1.default.relative(projectRoot, originalFile)}`);
|
|
209
|
+
}
|
|
169
210
|
}
|
|
170
211
|
for (let i = 0; i < styleFiles.length; i++) {
|
|
171
212
|
await (0, processors_1.buildGlobal)(coreFilePath);
|
|
@@ -175,4 +216,9 @@ async function optimizeCSS() {
|
|
|
175
216
|
}
|
|
176
217
|
await optimizeCSS();
|
|
177
218
|
await (0, extract_1.restoreAllOriginals)();
|
|
219
|
+
if (process.argv.includes('--stats')) {
|
|
220
|
+
const endTime = performance.now();
|
|
221
|
+
const buildTime = (endTime - startTime) / 1000;
|
|
222
|
+
await generateStats(buildTime);
|
|
223
|
+
}
|
|
178
224
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Plumeria Rust-based compiler",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"css": "./bin/css.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@swc/core": "
|
|
19
|
+
"@swc/core": "1.13.5",
|
|
20
20
|
"find-up": "^7.0.0",
|
|
21
21
|
"lightningcss": "^1.29.3",
|
|
22
22
|
"postcss": "^8.5.3",
|
|
23
23
|
"postcss-combine-media-query": "^2.0.0",
|
|
24
|
-
"rscute": "^0.2.
|
|
24
|
+
"rscute": "^0.2.11"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|