Skip to content

Commit

Permalink
Use conditional exports to hide private API
Browse files Browse the repository at this point in the history
sodic committed Mar 26, 2024
1 parent e765e8c commit 0b19844
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion waspc/data/Generator/templates/react-app/src/index.tsx
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import router from './router'
import {
initializeQueryClient,
queryClientInitialized,
} from 'wasp/client/operations'
} from 'wasp/client/operations/queryClient'

{=# setupFn.isDefined =}
{=& setupFn.importStatement =}
1 change: 1 addition & 0 deletions waspc/data/Generator/templates/react-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ const defaultViteConfig = {
outDir: "build",
},
resolve: {
conditions: ["client-runtime"],
// These packages rely on a single instance per page. Not dedpuing them
// causes runtime errors (e.g., hook rule violation in react, QueryClient
// instance error in react-query, Invariant Error in react-router-dom).
Original file line number Diff line number Diff line change
@@ -15,8 +15,4 @@ export {
export {
// PUBLIC API
configureQueryClient,
// PRIVATE API (framework code)
initializeQueryClient,
// PRIVATE API (framework code)
queryClientInitialized
} from './queryClient'
3 changes: 3 additions & 0 deletions waspc/data/Generator/templates/sdk/wasp/package.json
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@
"types": "tsc --declaration --emitDeclarationOnly --stripInternal --declarationDir dist"
},
"exports": {
"./client/operations/queryClient": {
"client-runtime": "./dist/client/operations/queryClient.js"
},
{=! todo(filip): Check all exports when done with SDK generation =}
{=! Some of the statements in the comments might become incorrect. =}
{=! "our code" means: "web-app", "server" or "SDK", or "some combination of the three". =}

0 comments on commit 0b19844

Please sign in to comment.