@builder.io/mitosis 0.0.144 → 0.0.145

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.
@@ -312,7 +312,29 @@ var componentToSvelte = function (userProvidedOptions) {
312
312
  return "afterUpdate(() => { ".concat(code, " });");
313
313
  }
314
314
  var fnName = "onUpdateFn_".concat(index);
315
- return "\n function ".concat(fnName, "(..._args").concat(options.typescript ? ': any[]' : '', ") {\n ").concat(code, "\n }\n $: ").concat(fnName, "(...").concat(deps, ")\n ");
315
+ var depsArray = deps
316
+ .slice(1, deps.length - 1)
317
+ .split(',')
318
+ .map(function (x) { return x.trim(); });
319
+ var getReactiveDepName = function (dep) {
320
+ return "".concat(fnName, "_").concat(dep.slice(1).replace(/(\.|\?)/g, '_'));
321
+ };
322
+ var isStoreAccessDep = function (dep) { return dep.startsWith('$'); };
323
+ var reactiveDepsWorkaround = depsArray
324
+ .filter(isStoreAccessDep)
325
+ .map(function (dep) { return "$: ".concat(getReactiveDepName(dep), " = ").concat(dep, ";"); })
326
+ .join('\n');
327
+ var depsArrayStr = depsArray
328
+ .map(function (x) { return (isStoreAccessDep(x) ? getReactiveDepName(x) : x); })
329
+ .join(', ');
330
+ /**
331
+ * We create a reactive value for each `onUpdate`'s dependency that
332
+ * accesses a store so that Svelte has accurate dependency tracking.
333
+ *
334
+ * Otherwise, if the dependency is a value within a store, Svelte will
335
+ * rerun the effect every time the parent store is changed in any way.
336
+ */
337
+ return "\n function ".concat(fnName, "(..._args").concat(options.typescript ? ': any[]' : '', ") {\n ").concat(code, "\n }\n ").concat(reactiveDepsWorkaround, "\n $: ").concat(fnName, "(...[").concat(depsArrayStr, "]);\n ");
316
338
  }).join(';')) || '',
317
339
  // make sure this is after all other state/code is initialized
318
340
  setContextCode({ json: json, options: options }), !((_k = json.hooks.onUnMount) === null || _k === void 0 ? void 0 : _k.code) ? '' : "onDestroy(() => { ".concat(json.hooks.onUnMount.code, " });"), json.children
@@ -53,7 +53,7 @@ var getProject = function (tsConfigFilePath) {
53
53
  return new ts_morph_1.Project({ tsConfigFilePath: tsConfigFilePath });
54
54
  }
55
55
  catch (err) {
56
- throw new Error('Error creating Typescript Project. Make sure `tsConfigFilePath` points to a valid tsconfig.json file');
56
+ throw new Error("Error creating Typescript Project. Make sure `tsConfigFilePath` points to a valid tsconfig.json file.\n Path received: \"".concat(tsConfigFilePath, "\"\n "));
57
57
  }
58
58
  };
59
59
  var createTypescriptProject = function (tsConfigFilePath) {
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "name": "Builder.io",
23
23
  "url": "https://www.builder.io"
24
24
  },
25
- "version": "0.0.144",
25
+ "version": "0.0.145",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {