UNPKG

@builder.io/mitosis

Version:

Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io

34 lines (32 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getContextWithSymbolKey = void 0; const standalone_1 = require("prettier/standalone"); const get_state_object_string_1 = require("../../../helpers/get-state-object-string"); const getContextWithSymbolKey = (options) => ({ context }) => { let str = ` const key = Symbol(); export default { ${context.name}: ${(0, get_state_object_string_1.stringifyContextValue)(context.value)}, key } `; if (options.prettier !== false) { try { str = (0, standalone_1.format)(str, { parser: 'typescript', plugins: [ require('prettier/parser-typescript'), // To support running in browsers ], }); } catch (err) { if (process.env.NODE_ENV !== 'test') { console.error('Format error for file:', str); } throw err; } } return str; }; exports.getContextWithSymbolKey = getContextWithSymbolKey;