@plumeria/webpack-plugin 0.24.0 → 0.24.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.
Files changed (2) hide show
  1. package/dist/create.js +30 -25
  2. package/package.json +1 -1
package/dist/create.js CHANGED
@@ -13,37 +13,42 @@ function compileToSingleCSS(object) {
13
13
  (0, zss_engine_1.splitAtomicAndNested)(styleObj, flat, nonFlat);
14
14
  const overrideLonghand = (style) => {
15
15
  const props = Object.keys(style);
16
- if (props.some((p) => p.startsWith('@'))) {
17
- const finalStyle = { ...style };
18
- for (const key of props) {
19
- if (key.startsWith('@')) {
20
- finalStyle[key] = overrideLonghand(style[key]);
21
- }
16
+ const propsToRemove = new Set();
17
+ const plainProps = [];
18
+ for (let i = 0; i < props.length; i++) {
19
+ if (!props[i].startsWith('@')) {
20
+ plainProps.push({ key: props[i], index: i });
22
21
  }
23
- return finalStyle;
24
22
  }
25
- const finalStyle = {};
26
- for (let i = 0; i < props.length; i++) {
27
- const prop = props[i];
28
- const kebab = (0, zss_engine_1.camelToKebabCase)(prop);
29
- const isShorthand = !!zss_engine_1.SHORTHAND_PROPERTIES[kebab];
30
- if (isShorthand) {
31
- finalStyle[prop] = style[prop];
23
+ const shorthandsInStyle = {};
24
+ for (const { key, index } of plainProps) {
25
+ const kebab = (0, zss_engine_1.camelToKebabCase)(key);
26
+ if (zss_engine_1.SHORTHAND_PROPERTIES[kebab]) {
27
+ shorthandsInStyle[kebab] = index;
32
28
  }
33
- else {
34
- let isOverridden = false;
35
- const shorthands = zss_engine_1.LONG_TO_SHORT[kebab] || [];
36
- for (let j = i + 1; j < props.length; j++) {
37
- const futureProp = props[j];
38
- const futureKebab = (0, zss_engine_1.camelToKebabCase)(futureProp);
39
- if (shorthands.includes(futureKebab)) {
40
- isOverridden = true;
29
+ }
30
+ for (const { key, index } of plainProps) {
31
+ const kebab = (0, zss_engine_1.camelToKebabCase)(key);
32
+ if (!zss_engine_1.SHORTHAND_PROPERTIES[kebab]) {
33
+ const longhands = zss_engine_1.LONG_TO_SHORT[kebab] || [];
34
+ for (const shorthand of longhands) {
35
+ if (shorthandsInStyle[shorthand] > index) {
36
+ propsToRemove.add(key);
41
37
  break;
42
38
  }
43
39
  }
44
- if (!isOverridden) {
45
- finalStyle[prop] = style[prop];
46
- }
40
+ }
41
+ }
42
+ const finalStyle = {};
43
+ for (const prop of props) {
44
+ if (propsToRemove.has(prop)) {
45
+ continue;
46
+ }
47
+ if (prop.startsWith('@')) {
48
+ finalStyle[prop] = overrideLonghand(style[prop]);
49
+ }
50
+ else {
51
+ finalStyle[prop] = style[prop];
47
52
  }
48
53
  }
49
54
  return finalStyle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/webpack-plugin",
3
- "version": "0.24.0",
3
+ "version": "0.24.2",
4
4
  "description": "Plumeria Webpack plugin",
5
5
  "repository": {
6
6
  "type": "git",