-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set
process.env.NXJS
via esbuild's --define
option in tests app
So that non-nx.js code will be removed at build time
- Loading branch information
1 parent
7edd81f
commit 816d284
Showing
5 changed files
with
36 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* `NXJS` env var is defined via esbuild's `--define` option. | ||
*/ | ||
declare var process: { | ||
env: { | ||
NXJS: string; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export function toHex(arr: ArrayBuffer): string { | ||
return Array.from(new Uint8Array(arr)) | ||
.map((v) => v.toString(16).padStart(2, '0')) | ||
.join(''); | ||
} | ||
|
||
export function fromHex(hex: string): ArrayBuffer { | ||
const arr = new Uint8Array(hex.length / 2); | ||
for (let i = 0; i < hex.length; i += 2) { | ||
arr[i / 2] = parseInt(hex.substr(i, 2), 16); | ||
} | ||
return arr.buffer; | ||
} | ||
|
||
export function concat(...buffers: ArrayBuffer[]): ArrayBuffer { | ||
const size = buffers.reduce((acc, buf) => acc + buf.byteLength, 0); | ||
let offset = 0; | ||
const result = new Uint8Array(size); | ||
for (const buf of buffers) { | ||
result.set(new Uint8Array(buf), offset); | ||
offset += buf.byteLength; | ||
} | ||
return result.buffer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters