@wix/origami-site-runtime 1.0.11 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/origami-site-runtime",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Vite development and build helpers for wix-import static sites",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -65,5 +65,5 @@
65
65
  "./default-error-404": "./src/default-error-404.jsx"
66
66
  },
67
67
  "type": "module",
68
- "falconPackageHash": "e22a7402b3249122540518d623a21731e722614ef9110bb8cce0eef7"
68
+ "falconPackageHash": "2e7b7eab8ba52e6afa27dfa363e20a634506137bd61591f8bf6015a3"
69
69
  }
@@ -4,6 +4,9 @@
4
4
  // `--preset` off the presets-wrapper classes it renders (see the origami-component-usage skill), so each declaration
5
5
  // moves there, as `--preset` in a rule of its own: `.{id}-presets-wrapper`, or `{selector} .{key}-presets-wrapper` so
6
6
  // an inner element's preset reaches that instance only. A rule that does not start at a component is left as authored.
7
+ //
8
+ // A preset on a component selector that can't be mapped is reported as a warning and left as authored rather than failing the
9
+ // build: exported sites still carry presets in the older shape, and they must keep building until they are migrated.
7
10
 
8
11
  import postcss from 'postcss'
9
12
 
@@ -24,7 +27,7 @@ const target = (selector, key) => {
24
27
  export const presetsPlugin = {
25
28
  name: 'presets',
26
29
  order: 13,
27
- transform(root) {
30
+ transform(root, context) {
28
31
  /** @type {import('postcss').Declaration[]} */
29
32
  const declarations = []
30
33
  root.walkDecls(PRESET, declaration => {
@@ -46,10 +49,13 @@ export const presetsPlugin = {
46
49
  const targets = selectors.map(selector => target(selector, PRESET.exec(declaration.prop)?.[1]))
47
50
  if (targets.every(selector => selector === undefined)) continue
48
51
  if (!targets.every(Boolean)) {
49
- throw new Error(
50
- `${declaration.prop} on "${selectors.join(', ')}": set --preset on #id or .id alone, ` +
51
- `and an inner element's as --preset-{key} on the rule of the element it sits in`
52
+ context.warn?.(
53
+ declaration,
54
+ `presets: ${context.relativePath ?? context.filePath}: ` +
55
+ `${declaration.prop} on "${selectors.join(', ')}": set --preset on #id or .id alone, ` +
56
+ `and an inner element's as --preset-{key} on the rule of the element it sits in. Left as authored.`
52
57
  )
58
+ continue
53
59
  }
54
60
  declaration.prop = '--preset'
55
61
  const presetRule = postcss.rule({ selector: targets.join(', ') })
@@ -46,8 +46,11 @@ export const createCssPostcssPlugin = ({ selectPlugins, contextFor, failures })
46
46
  declared.add(file)
47
47
  result.messages.push({ type: 'dependency', plugin: 'wix-import-css-transform', file, parent: from })
48
48
  }
49
+ // A plugin reports a problem that need not stop the build as a PostCSS warning, which Vite prints with the
50
+ // node's code frame.
51
+ const warn = (node, text) => node.warn(result, text)
49
52
  try {
50
- runCssPlugins({ plugins, root, context: { ...fileContext, addDependency } })
53
+ runCssPlugins({ plugins, root, context: { ...fileContext, addDependency, warn } })
51
54
  failures?.delete(from)
52
55
  } catch (error) {
53
56
  failures?.set(from, declared)
@@ -36,10 +36,12 @@
36
36
  * }} CssTransformPlugin
37
37
  *
38
38
  * @typedef {TransformContext & {
39
- * addDependency?: (file: string) => void
39
+ * addDependency?: (file: string) => void,
40
+ * warn?: (node: import('postcss').Node, text: string) => void
40
41
  * }} CssTransformContext
41
42
  * `addDependency` declares a file the plugin read besides the stylesheet, so the bundler re-runs the
42
- * stylesheet when it changes. Absent when no bundler drives the run.
43
+ * stylesheet when it changes. `warn` reports a problem at `node` without failing the run, as a PostCSS
44
+ * warning on the stylesheet's result. Both are absent when no bundler drives the run.
43
45
  */
44
46
 
45
47
  export {}