solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

add a new server functions rename transform

Open ghalle opened this issue 2 years ago • 6 comments

Supersedes https://github.com/solidjs/solid-start/pull/147

Adds a new babel plugin to rename the server functions to make sure they can be uniquely identified after the code gets split up by the routeData transform.

This allows us to alter the plugin order without causing potential conflicts like discussed in #147.

ghalle avatar Jun 23 '22 20:06 ghalle

The CI is failing.. could you see why? You can run the tests locally by running pnpm run test in the monorepo

nksaraf avatar Jun 24 '22 05:06 nksaraf

Was missing a check to only add the import if it's actually needed, looks like that caused some issues.

ghalle avatar Jun 24 '22 12:06 ghalle

I think the serverResource transform should probably be moved above the renameServer transform so that the server calls can all be renamed but doing so causes an error with the sessions-test.

The error is

ReferenceError: server is not defined

The logic added to the server transform to add back the import should cover this so I'm not sure why it's happening.

ghalle avatar Jun 24 '22 18:06 ghalle

Should be ok to merge now.

ghalle avatar Jun 24 '22 18:06 ghalle

Ended up finding an off by one error using something like this:

export function routeData() {
  server((a: number, b: number, c: number) => {
    console.log("handler0", a, b, c)
  })(1, 2, 3)

  return createServerData(async (_, { request }) => {
    console.log("handler1")
  })
}

The first server call was getting called with the request parameter from the createServerData call.

ghalle avatar Jun 25 '22 19:06 ghalle

Rebased this, also not quite sure why github displays the diff for babel.js like that, there isn't actually that much change, the vscode built-in diff view displays it correctly.

ghalle avatar Aug 06 '22 00:08 ghalle

In setting up for SolidStarts next Beta Phase built on Nitro and Vinxi we are closing all PRs/Issues that will not be merged due to the system changing. If you feel your issue was closed in mistake. Feel free to re-open it after updating/testing against 0.4.x release. Thank you for your patience.

ryansolid avatar Dec 18 '23 19:12 ryansolid