@plumeria/webpack-plugin 0.8.0 → 0.9.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.
Files changed (2) hide show
  1. package/dist/create-css.js +40 -9
  2. package/package.json +1 -1
@@ -6,28 +6,59 @@ const zss_engine_1 = require("zss-engine");
6
6
  function compileToSingleCSS(object) {
7
7
  const baseSheets = [];
8
8
  const querySheets = [];
9
- const atomicHashes = new Set();
9
+ const processedHashes = new Set();
10
10
  Object.entries(object).forEach(([key, styleObj]) => {
11
11
  const flat = {};
12
12
  const nonFlat = {};
13
13
  (0, zss_engine_1.splitAtomicAndNested)(styleObj, flat, nonFlat);
14
- if (Object.keys(flat).length > 0) {
14
+ const records = [];
15
+ Object.entries(flat).forEach(([prop, value]) => {
16
+ const hashes = new Set();
15
17
  const sheets = new Set();
16
- (0, zss_engine_1.processAtomicProps)(flat, atomicHashes, sheets);
18
+ (0, zss_engine_1.processAtomicProps)({ [prop]: value }, hashes, sheets);
19
+ const propBaseSheets = [];
20
+ const propQuerySheets = [];
17
21
  for (const sheet of sheets) {
18
22
  if (sheet.includes('@media') || sheet.includes('@container')) {
19
- querySheets.push(sheet);
23
+ propQuerySheets.push(sheet);
20
24
  }
21
25
  else {
22
- baseSheets.push(sheet);
26
+ propBaseSheets.push(sheet);
23
27
  }
24
28
  }
25
- }
29
+ const hash = [...hashes].join(' ');
30
+ const sheet = [...propBaseSheets, ...propQuerySheets].join('');
31
+ records.push({
32
+ key: prop,
33
+ hash,
34
+ sheet,
35
+ });
36
+ });
26
37
  if (Object.keys(nonFlat).length > 0) {
27
- const nonFlatHash = (0, zss_engine_1.genBase36Hash)({ [key]: nonFlat }, 1, 7);
28
- const { styleSheet } = (0, zss_engine_1.transpile)({ [key]: nonFlat }, nonFlatHash);
29
- baseSheets.push(styleSheet);
38
+ const nonFlatObj = { [key]: nonFlat };
39
+ const nonFlatHash = (0, zss_engine_1.genBase36Hash)(nonFlatObj, 1, 7);
40
+ const { styleSheet } = (0, zss_engine_1.transpile)(nonFlatObj, nonFlatHash);
41
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
42
+ Object.entries(nestedObj).forEach(([prop]) => {
43
+ records.push({
44
+ key: atRule + prop,
45
+ hash: nonFlatHash,
46
+ sheet: styleSheet,
47
+ });
48
+ });
49
+ });
30
50
  }
51
+ records.forEach(({ hash, sheet }) => {
52
+ if (!processedHashes.has(hash)) {
53
+ processedHashes.add(hash);
54
+ if (sheet.includes('@media') || sheet.includes('@container')) {
55
+ querySheets.push(sheet);
56
+ }
57
+ else {
58
+ baseSheets.push(sheet);
59
+ }
60
+ }
61
+ });
31
62
  });
32
63
  return [...baseSheets, ...querySheets].join('\n');
33
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/webpack-plugin",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Plumeria Webpack plugin",
5
5
  "repository": {
6
6
  "type": "git",