@zackad/prettier-plugin-twig 0.9.0 → 0.9.1

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": "@zackad/prettier-plugin-twig",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Prettier Plugin for Twig",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,22 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import * as t from "@babel/types";
17
- import template from "@babel/template";
17
+ import isFunction from "lodash/isFunction.js";
18
+ import _template from "@babel/template";
19
+
20
+ /**
21
+ * For some reason there's inconsistency when importing "@babel/template" on
22
+ * vitest environment and loading this plugin directly on cli. I have no idea why
23
+ * this happens but this workaround seems to be fixed it.
24
+ *
25
+ * Without this workaround, an error will occur either on test or when loading
26
+ * plugin on cli. This error doesn't happen on `src/melody/melody-extension-core/visitors/for.js`.
27
+ * ```
28
+ * [error] template is not a function
29
+ * ```
30
+ */
31
+ const template = isFunction(_template) ? _template : _template.default;
32
+
18
33
  // use default value if var is null, undefined or an empty string
19
34
  // but use var if value is 0, false, an empty array or an empty object
20
35
  const defaultFilter = template("VAR != null && VAR !== '' ? VAR : DEFAULT");
@@ -1,5 +1,5 @@
1
1
  import { doc } from "prettier";
2
- import { isBoolean } from "lodash";
2
+ import isBoolean from "lodash/isBoolean.js";
3
3
  import { printChildBlock, quoteChar } from "../util/index.js";
4
4
 
5
5
  const { hardline } = doc.builders;