@blueprintui/cli 0.5.0 → 0.7.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/CHANGELOG.md +15 -6
- package/package.json +5 -4
- package/src/plugin-minify-css.mjs +97 -20
- package/src/rollup.config.mjs +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# 0.7.0
|
|
4
|
+
- lit transformer update
|
|
5
|
+
|
|
6
|
+
# 0.6.0
|
|
7
|
+
- revert rollup 4.0 upgrade
|
|
8
|
+
|
|
9
|
+
# 0.5.0
|
|
10
|
+
- migrate to TS 5.x
|
|
11
|
+
|
|
12
|
+
## 0.4.0
|
|
13
|
+
- upgrade to TypeScript 5.2.x
|
|
14
|
+
|
|
15
|
+
## 0.3.0
|
|
16
|
+
- bump dependencies
|
|
17
|
+
|
|
3
18
|
# 0.3.0
|
|
4
19
|
- support for jsdoc tagging in custom-elements.json metadata
|
|
5
20
|
- bump dependencies
|
|
@@ -9,12 +24,6 @@
|
|
|
9
24
|
- remove legacy Safari compatibility optimizations
|
|
10
25
|
- bump dependencies
|
|
11
26
|
|
|
12
|
-
## 0.4.0
|
|
13
|
-
- upgrade to TypeScript 5.2.x
|
|
14
|
-
|
|
15
|
-
## 0.3.0
|
|
16
|
-
- bump dependencies
|
|
17
|
-
|
|
18
27
|
## 0.1.3
|
|
19
28
|
- bump dependencies
|
|
20
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueprintui/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./index.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@custom-elements-manifest/analyzer": "0.8.4",
|
|
18
|
-
"@lit/ts-transformers": "2.0.0
|
|
18
|
+
"@lit/ts-transformers": "2.0.0",
|
|
19
19
|
"@rollup/plugin-node-resolve": "15.2.2",
|
|
20
20
|
"@rollup/plugin-replace": "5.0.3",
|
|
21
21
|
"@rollup/plugin-typescript": "11.1.5",
|
|
22
22
|
"@rollup/plugin-virtual": "3.0.2",
|
|
23
23
|
"@skypack/package-check": "0.2.2",
|
|
24
|
+
"acorn-import-attributes": "1.9.2",
|
|
24
25
|
"acorn-import-assertions": "1.9.0",
|
|
25
26
|
"browserslist": "4.22.1",
|
|
26
27
|
"commander": "11.0.0",
|
|
@@ -28,10 +29,10 @@
|
|
|
28
29
|
"lightningcss": "1.22.0",
|
|
29
30
|
"minify-html-literals": "1.3.5",
|
|
30
31
|
"path": "0.12.7",
|
|
31
|
-
"rollup": "
|
|
32
|
+
"rollup": "3.29.3",
|
|
32
33
|
"rollup-plugin-copy": "3.5.0",
|
|
33
34
|
"rollup-plugin-delete": "2.0.0",
|
|
34
|
-
"rollup-plugin-import-
|
|
35
|
+
"rollup-plugin-import-css": "^3.3.4",
|
|
35
36
|
"rollup-plugin-shell": "1.0.9",
|
|
36
37
|
"terser": "5.21.0",
|
|
37
38
|
"tslib": "2.6.2",
|
|
@@ -1,29 +1,106 @@
|
|
|
1
1
|
import browserslist from 'browserslist';
|
|
2
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
2
3
|
import { transform, browserslistToTargets } from 'lightningcss';
|
|
3
4
|
import { path } from 'zx';
|
|
4
5
|
|
|
5
|
-
const targets = browserslistToTargets(browserslist('Chrome >
|
|
6
|
+
const targets = browserslistToTargets(browserslist('Chrome > 116'));
|
|
7
|
+
|
|
8
|
+
// fork of https://github.com/jleeson/rollup-plugin-import-css to enable import attributes and minificaiton
|
|
9
|
+
export const css = (options = {}) => {
|
|
10
|
+
const styles = {};
|
|
11
|
+
const filter = createFilter(
|
|
12
|
+
options.include ?? ['**/*.css'],
|
|
13
|
+
options.exclude ?? []
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/* function to sort the css imports in order - credit to rollup-plugin-postcss */
|
|
17
|
+
const getRecursiveImportOrder = (id, getModuleInfo, seen = new Set()) => {
|
|
18
|
+
if (seen.has(id)) return [];
|
|
19
|
+
|
|
20
|
+
seen.add(id);
|
|
21
|
+
|
|
22
|
+
const result = [id];
|
|
23
|
+
|
|
24
|
+
getModuleInfo(id).importedIds.forEach((importFile) => {
|
|
25
|
+
result.push(...getRecursiveImportOrder(importFile, getModuleInfo, seen));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
6
30
|
|
|
7
|
-
export function minifyCSS() {
|
|
8
31
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
name: 'import-css',
|
|
33
|
+
|
|
34
|
+
/* convert the css file to a module and save the code for a file output */
|
|
35
|
+
transform(code, id) {
|
|
36
|
+
if (!filter(id)) return;
|
|
37
|
+
|
|
38
|
+
const output = options.minify
|
|
39
|
+
? transform({
|
|
40
|
+
targets,
|
|
41
|
+
drafts: {
|
|
42
|
+
nesting: true,
|
|
43
|
+
},
|
|
44
|
+
analyzeDependencies: true,
|
|
45
|
+
code: Buffer.from(code),
|
|
46
|
+
minify: true,
|
|
47
|
+
sourceMap: false,
|
|
48
|
+
}).code.toString()
|
|
49
|
+
: code;
|
|
50
|
+
|
|
51
|
+
/* cache the result */
|
|
52
|
+
if (!styles[id] || styles[id] != output) {
|
|
53
|
+
styles[id] = output;
|
|
26
54
|
}
|
|
27
|
-
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
code: `const sheet = new CSSStyleSheet();sheet.replaceSync(${JSON.stringify(
|
|
58
|
+
output
|
|
59
|
+
)});export default sheet;`,
|
|
60
|
+
map: { mappings: '' },
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/* output a css file with all css that was imported without being assigned a variable */
|
|
65
|
+
generateBundle(opts, bundle) {
|
|
66
|
+
/* collect all the imported modules for each entry file */
|
|
67
|
+
let modules = {};
|
|
68
|
+
let entryChunk = null;
|
|
69
|
+
for (let file in bundle) {
|
|
70
|
+
modules = Object.assign(modules, bundle[file].modules);
|
|
71
|
+
if (!entryChunk) entryChunk = bundle[file].facadeModuleId;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* get the list of modules in order */
|
|
75
|
+
const moduleIds = getRecursiveImportOrder(entryChunk, this.getModuleInfo);
|
|
76
|
+
|
|
77
|
+
/* remove css that was imported as a string */
|
|
78
|
+
const css = Object.entries(styles)
|
|
79
|
+
.sort((a, b) => moduleIds.indexOf(a[0]) - moduleIds.indexOf(b[0]))
|
|
80
|
+
.map(([id, code]) => {
|
|
81
|
+
if (!modules[id]) return code;
|
|
82
|
+
})
|
|
83
|
+
.join('\n');
|
|
84
|
+
|
|
85
|
+
/* return the asset name by going through a set of possible options */
|
|
86
|
+
const getAssetName = () => {
|
|
87
|
+
const fileName = options.output ?? opts.file ?? 'bundle.js';
|
|
88
|
+
return `${path.basename(fileName, path.extname(fileName))}.css`;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/* return the asset fileName by going through a set of possible options */
|
|
92
|
+
const getAssetFileName = () => {
|
|
93
|
+
if (options.output) return options.output;
|
|
94
|
+
if (opts.assetFileNames) return undefined;
|
|
95
|
+
return `${getAssetName()}.css`;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
this.emitFile({
|
|
99
|
+
type: 'asset',
|
|
100
|
+
name: getAssetName(),
|
|
101
|
+
fileName: getAssetFileName(),
|
|
102
|
+
source: css,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
28
105
|
};
|
|
29
106
|
};
|
package/src/rollup.config.mjs
CHANGED
|
@@ -7,10 +7,10 @@ import del from 'rollup-plugin-delete';
|
|
|
7
7
|
import execute from 'rollup-plugin-shell';
|
|
8
8
|
import { fs, glob, path } from 'zx';
|
|
9
9
|
import { importAssertions } from 'acorn-import-assertions';
|
|
10
|
+
// import { importAttributes } from 'acorn-import-attributes'; // enable when TypeScript supports import attributes
|
|
10
11
|
import { idiomaticDecoratorsTransformer, constructorCleanupTransformer } from '@lit/ts-transformers';
|
|
11
12
|
import { fileURLToPath } from 'url';
|
|
12
|
-
import {
|
|
13
|
-
import { minifyCSS } from './plugin-minify-css.mjs';
|
|
13
|
+
import { css } from './plugin-minify-css.mjs';
|
|
14
14
|
import { minifyHTML } from './plugin-minify-html-literals.mjs';
|
|
15
15
|
import { minifyJavaScript } from './plugin-minify-javascript.mjs';
|
|
16
16
|
import { customElementsAnalyzer } from './plugin-custom-elements-analyzer.mjs';
|
|
@@ -48,12 +48,14 @@ export default [
|
|
|
48
48
|
sourcemap: project.sourcemap,
|
|
49
49
|
sourcemapExcludeSources: true
|
|
50
50
|
},
|
|
51
|
-
acornInjectPlugins: [
|
|
51
|
+
acornInjectPlugins: [
|
|
52
|
+
importAssertions
|
|
53
|
+
// importAttributes
|
|
54
|
+
],
|
|
52
55
|
plugins: [
|
|
53
|
-
project.prod ? cleanOutDir()
|
|
56
|
+
project.prod ? cleanOutDir() : [],
|
|
57
|
+
css({ minify: project.prod }),
|
|
54
58
|
copyAssets(),
|
|
55
|
-
project.prod ? minifyCSS() : [],
|
|
56
|
-
importAssertionsPlugin(),
|
|
57
59
|
createEntrypoints(),
|
|
58
60
|
nodeResolve({ exportConditions: [project.prod ? 'production' : 'development'] }),
|
|
59
61
|
compileTypescript(),
|