Skip to content

Commit

Permalink
fix(ladle): fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Dec 17, 2023
1 parent 50ea323 commit 63621df
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
7 changes: 6 additions & 1 deletion packages/features/.ladle/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'
import topLevelAwait from 'vite-plugin-top-level-await'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import svgr from 'vite-plugin-svgr'

const env = (import.meta as any).env
Expand All @@ -8,7 +9,11 @@ export default defineConfig({
define: {
__DEV__: env?.MODE === 'development'
},
plugins: [topLevelAwait(), svgr({ exportAsDefault: true })],
plugins: [
topLevelAwait(),
nodePolyfills({ protocolImports: true, globals: { Buffer: true } }),
svgr({ exportAsDefault: true })
],
build: {
commonjsOptions: {
transformMixedEsModules: true
Expand Down
7 changes: 4 additions & 3 deletions packages/features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"build": "tsup",
"dev": "tsup --watch",
"test:unit": "echo 'not yet'",
"story:dev": "ladle serve",
"story:build": "ladle build -o ./build",
"story:preview": "ladle preview",
"story:dev": "VITE_APP_LADLE=true ladle serve",
"story:build": "VITE_APP_LADLE=true ladle build -o ./build",
"story:preview": "VITE_APP_LADLE=true ladle preview",
"cleanup": "rimraf node_modules dist .turbo build"
},
"dependencies": {
Expand Down Expand Up @@ -113,6 +113,7 @@
"mina-signer": "^2.1.1",
"swr": "^2.1.5",
"vite": "^4.5.1",
"vite-plugin-node-polyfills": "^0.17.0",
"vite-plugin-svgr": "^3.2.0",
"vite-plugin-top-level-await": "^1.3.1"
},
Expand Down
1 change: 1 addition & 0 deletions packages/vault/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@types/mocha": "^10.0.1",
"@types/secp256k1": "^4.0.3",
"mina-signer": "^2.1.1",
"vite": "^4.5.1",
"msw": "^1.2.2"
}
}
9 changes: 9 additions & 0 deletions packages/vault/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ import { StoreApi, UseBoundStore } from 'zustand'
export type StoreInstance<T> = ReturnType<
UseBoundStore<StoreApi<T>>['getState']
>

interface ImportMetaEnv {
readonly VITE_APP_LADLE: string
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface ImportMeta {
readonly env: ImportMetaEnv
}
5 changes: 4 additions & 1 deletion packages/vault/src/vault/vaultStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ export const useVault = create<
}),
{
name: 'PalladVault',
storage: getSecurePersistence() as PersistStorage<any>
storage:
import.meta.env['VITE_APP_LADLE'] === 'true'
? undefined
: (getSecurePersistence() as PersistStorage<any>)
}
)
)
7 changes: 6 additions & 1 deletion packages/vault/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"extends": "@palladxyz/common/tsconfig.json"
"extends": "@palladxyz/common/tsconfig.json",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"types": ["vite/client"]
}
}
22 changes: 21 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 63621df

Please sign in to comment.