Skip to content

Commit

Permalink
✅ Import buffer via aliased name
Browse files Browse the repository at this point in the history
Up-to-now we have been importing buffer while it's a known native package in node.

So in order to avoid node from pulling its own, we were relying on path import. We switched to a way safer approach: we alias the buffer package with another name and we import it via its other name. It avoid path related hazards and let the package manager and node responsible to tell the code where to find the relevant package.

Satellite PR for #4368
  • Loading branch information
dubzzz committed Oct 24, 2023
1 parent 342638a commit f5e7bb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/fast-check/package.json
Expand Up @@ -72,10 +72,10 @@
"@types/jest": "^29.5.6",
"@types/node": "^18.18.6",
"babel-jest": "^29.7.0",
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
"glob": "^10.3.10",
"jest": "^29.7.0",
"not-node-buffer": "npm:buffer@^6.0.3",
"regexp-tree": "^0.1.27",
"replace-in-file": "^7.0.1",
"typedoc": "^0.25.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-check/test/unit/utils/stringify.spec.ts
Expand Up @@ -2,7 +2,7 @@ import * as fc from 'fast-check';

// Importing 'buffer' imports the real implementation from node
// Instead we want 'buffer' from our node_modules - the most used polyfill for Buffer on browser-side
import { Buffer as NotNodeBuffer } from '../../../../../node_modules/buffer';
import { Buffer as NotNodeBuffer } from 'not-node-buffer';

import {
asyncStringify,
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Expand Up @@ -6103,7 +6103,7 @@ __metadata:
languageName: node
linkType: hard

"buffer@npm:^6.0.3":
"buffer@npm:^6.0.3, not-node-buffer@npm:buffer@^6.0.3":
version: 6.0.3
resolution: "buffer@npm:6.0.3"
dependencies:
Expand Down Expand Up @@ -8617,10 +8617,10 @@ __metadata:
"@types/jest": ^29.5.6
"@types/node": ^18.18.6
babel-jest: ^29.7.0
buffer: ^6.0.3
cross-env: ^7.0.3
glob: ^10.3.10
jest: ^29.7.0
not-node-buffer: "npm:buffer@^6.0.3"
pure-rand: ^6.0.0
regexp-tree: ^0.1.27
replace-in-file: ^7.0.1
Expand Down

0 comments on commit f5e7bb9

Please sign in to comment.