Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built-in PBKDF2 implementation #295

Merged
merged 9 commits into from
Jul 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions packages/status-js/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@ import { defineConfig } from 'vite'

import { dependencies } from './package.json'

import type { Alias } from 'vite'

const isTest = process.env.NODE_ENV === 'test'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do it the same, but I remember reading this from their docs:

Use process.env.VITEST or mode property on defineConfig (will be set to test if not overridden) to conditionally apply different configuration in vite.config.ts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx 👍, done.


const external = [
...Object.keys(dependencies || {}),
// ...Object.keys(peerDependencies || {}),
].map(name => new RegExp(`^${name}(/.*)?`))

export default defineConfig(({ mode }) => {
const alias: Alias[] = []

if (isTest) {
alias.push({
/**
* Note: `happy-dom` nor `jsdom` have Crypto implemented (@see https://github.com/jsdom/jsdom/issues/1612)
*/
find: /^.*\/crypto\/pbkdf2.browser$/,
replacement: 'ethereum-cryptography/pbkdf2',
})
}

return {
build: {
target: 'es2020',
Expand All @@ -24,9 +40,11 @@ export default defineConfig(({ mode }) => {
external,
},
},

resolve: {
alias,
},
test: {
// environment: 'happy-dom',
environment: 'happy-dom',
},
}
})