Skip to content

Commit

Permalink
Merge pull request #98 from Rezact/fix-import-array-stores-and-maps
Browse files Browse the repository at this point in the history
Fix import array stores and maps
  • Loading branch information
zachlankton committed Jan 19, 2024
2 parents 17b59ee + 898af8c commit da93bf4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rezact/rezact",
"version": "1.0.15-beta.46",
"version": "1.0.15-beta.47",
"type": "module",
"description": "Intuitive Reactivity, Simplified State. Embrace a modern UI framework that encourages direct data mutations, offers module-level reactivity, and simplifies component design. With Rezact, you get the power of reactivity without the boilerplate. Dive into a seamless development experience tailored for today's web.",
"main": "index.cjs",
Expand Down
16 changes: 11 additions & 5 deletions src/examples/Todo/Todo.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
let $todos: any = [
{ $text: "Learn Rezact", $completed: false },
{ $text: "Learn TypeScript", $completed: true },
{ $text: "Build something awesome", $completed: false },
];
// do not change importing the $todos in this file (it is crucial to our test case scenarios)
// importing this data into the Todos.tsx file would have caused a failure until
// the following fix was implemented in the vite.plugin.ts

// const hasMapDecl =
// mapDeclarationTracking[node.init?.callee?.object?.name] ||
// ["filter", "map", "reduce"].includes(
// node.init?.callee?.property?.name
// );

import { $todos } from "./todoData";

export function Page() {
let $filter = "all";
Expand Down
15 changes: 15 additions & 0 deletions src/examples/Todo/todoData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// do not move this data to another file, having it in its own file is part of a test case that is subtle
// importing this data into the Todos.tsx file would have caused a failure until
// the following fix was implemented in the vite.plugin.ts

// const hasMapDecl =
// mapDeclarationTracking[node.init?.callee?.object?.name] ||
// ["filter", "map", "reduce"].includes(
// node.init?.callee?.property?.name
// );

export let $todos: any = [
{ $text: "Learn Rezact", $completed: false },
{ $text: "Learn TypeScript", $completed: true },
{ $text: "Build something awesome", $completed: false },
];
5 changes: 4 additions & 1 deletion src/lib/rezact/vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,10 @@ function compileRezact(ast) {
!nodeWillWrapInCreateMapped(node.init)
) {
const hasMapDecl =
mapDeclarationTracking[node.init?.callee?.object?.name];
mapDeclarationTracking[node.init?.callee?.object?.name] ||
["filter", "map", "reduce"].includes(
node.init?.callee?.property?.name
);
if (hasMapDecl) {
const mapName = node.id?.name;
if (mapName) mapDeclarationTracking[mapName] = node;
Expand Down

0 comments on commit da93bf4

Please sign in to comment.