File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,12 @@ export default defineBuildConfig({
8
8
opts . plugins . push ( {
9
9
name : "selective-minify" ,
10
10
async transform ( code , id ) {
11
- if ( id . includes ( "crypto/js " ) || id . includes ( "serialize" ) ) {
11
+ if ( id . includes ( "crypto" ) || id . includes ( "serialize" ) ) {
12
12
const res = await transform ( code , { minify : true } ) ;
13
- return res . code . replace ( "=function(){" , "=/*@__PURE__*/function(){" ) ;
13
+ return res . code . replace (
14
+ "=function(){" ,
15
+ "=/*@__PURE__*/function(){" ,
16
+ ) ;
14
17
}
15
18
} ,
16
19
} ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ import { createHash } from "node:crypto";
5
5
const fastHash = /*@__PURE__ */ ( ( ) =>
6
6
globalThis . process ?. getBuiltinModule ?.( "crypto" ) ?. hash ) ( ) ;
7
7
8
+ const algorithm = "sha256" ;
9
+ const encoding = "base64url" ;
10
+
8
11
/**
9
12
* Hashes a string using the SHA-256 algorithm and encodes it in Base64URL format.
10
13
*
@@ -14,14 +17,14 @@ const fastHash = /*@__PURE__*/ (() =>
14
17
*/
15
18
export function digest ( data : string ) : string {
16
19
if ( fastHash ) {
17
- return fastHash ( "sha256" , data , "base64url" ) ;
20
+ return fastHash ( algorithm , data , encoding ) ;
18
21
}
19
22
20
- const h = createHash ( "sha256" ) . update ( data ) ;
23
+ const h = createHash ( algorithm ) . update ( data ) ;
21
24
22
25
// Use digest().toString("base64url") as workaround for stackblitz
23
26
// https://github.com/unjs/ohash/issues/115
24
27
return globalThis . process ?. versions ?. webcontainer
25
- ? h . digest ( ) . toString ( "base64url" )
26
- : h . digest ( "base64url" ) ;
28
+ ? h . digest ( ) . toString ( encoding )
29
+ : h . digest ( encoding ) ;
27
30
}
You can’t perform that action at this time.
0 commit comments