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

fix: deprecate jest-serializer #12391

Merged
merged 1 commit into from Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -39,6 +39,7 @@
- `[jest-phabricator]` [**BREAKING**] Migrate to ESM ([#12341](https://github.com/facebook/jest/pull/12341))
- `[jest-resolve]` [**BREAKING**] Make `requireResolveFunction` argument mandatory ([#12353](https://github.com/facebook/jest/pull/12353))
- `[jest-runner]` [**BREAKING**] Remove some type exports from `@jest/test-result` ([#12353](https://github.com/facebook/jest/pull/12353))
- `[jest-serializer]` [**BREAKING**] Deprecate package in favour of using `v8` APIs directly ([#12391](https://github.com/facebook/jest/pull/12391))
- `[jest-snapshot]` [**BREAKING**] Migrate to ESM ([#12342](https://github.com/facebook/jest/pull/12342))
- `[jest-transform]` Update `write-file-atomic` to v4 ([#12357](https://github.com/facebook/jest/pull/12357))
- `[jest]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329))
Expand Down
1 change: 0 additions & 1 deletion packages/jest-haste-map/package.json
Expand Up @@ -24,7 +24,6 @@
"fb-watchman": "^2.0.0",
"graceful-fs": "^4.2.9",
"jest-regex-util": "^28.0.0-alpha.0",
"jest-serializer": "^28.0.0-alpha.0",
"jest-util": "^28.0.0-alpha.0",
"jest-worker": "^28.0.0-alpha.0",
"micromatch": "^4.0.4",
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-haste-map/src/index.ts
Expand Up @@ -12,10 +12,10 @@ import {createHash} from 'crypto';
import {EventEmitter} from 'events';
import {tmpdir} from 'os';
import * as path from 'path';
import type {Stats} from 'graceful-fs';
import {deserialize, serialize} from 'v8';
import {Stats, readFileSync, writeFileSync} from 'graceful-fs';
import type {Config} from '@jest/types';
import {escapePathForRegex} from 'jest-regex-util';
import serializer from 'jest-serializer';
import {Worker} from 'jest-worker';
import HasteFS from './HasteFS';
import HasteModuleMap from './ModuleMap';
Expand Down Expand Up @@ -402,7 +402,7 @@ export default class HasteMap extends EventEmitter {
let hasteMap: InternalHasteMap;

try {
hasteMap = serializer.readFileSync(this._cachePath) as any;
hasteMap = deserialize(readFileSync(this._cachePath));
} catch {
hasteMap = this._createEmptyMap();
}
Expand Down Expand Up @@ -729,7 +729,7 @@ export default class HasteMap extends EventEmitter {
* 4. serialize the new `HasteMap` in a cache file.
*/
private _persist(hasteMap: InternalHasteMap) {
serializer.writeFileSync(this._cachePath, hasteMap);
writeFileSync(this._cachePath, serialize(hasteMap));
}

/**
Expand Down
1 change: 0 additions & 1 deletion packages/jest-haste-map/tsconfig.json
Expand Up @@ -8,7 +8,6 @@
"exclude": ["./**/__tests__/**/*"],
"references": [
{"path": "../jest-regex-util"},
{"path": "../jest-serializer"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../jest-worker"},
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-serializer/README.md
@@ -1,6 +1,8 @@
# jest-serializer

Module for serializing and deserializing object into memory and disk. By default, the `v8` implementations are used, but if not present, it defaults to `JSON` implementation. Both serializers have the advantage of being able to serialize `Map`, `Set`, `undefined`, `NaN`, etc, although the JSON one does it through a replacer/reviver.
> DEPRECATED: Use `v8` APIs directly: https://nodejs.org/api/v8.html#serialization-api
Module for serializing and deserializing object into memory and disk. The Node core `v8` implementations are used. This seriializer have the advantage of being able to serialize `Map`, `Set`, `undefined`, `NaN`, etc..

## Install

Expand Down
21 changes: 10 additions & 11 deletions yarn.lock
Expand Up @@ -13110,7 +13110,6 @@ __metadata:
fsevents: ^2.3.2
graceful-fs: ^4.2.9
jest-regex-util: ^28.0.0-alpha.0
jest-serializer: ^28.0.0-alpha.0
jest-util: ^28.0.0-alpha.0
jest-worker: ^28.0.0-alpha.0
micromatch: ^4.0.4
Expand Down Expand Up @@ -13430,16 +13429,6 @@ __metadata:
languageName: unknown
linkType: soft

"jest-serializer@^28.0.0-alpha.0, jest-serializer@workspace:packages/jest-serializer":
version: 0.0.0-use.local
resolution: "jest-serializer@workspace:packages/jest-serializer"
dependencies:
"@types/graceful-fs": ^4.1.3
"@types/node": "*"
graceful-fs: ^4.2.9
languageName: unknown
linkType: soft

"jest-serializer@npm:^26.6.2":
version: 26.6.2
resolution: "jest-serializer@npm:26.6.2"
Expand All @@ -13450,6 +13439,16 @@ __metadata:
languageName: node
linkType: hard

"jest-serializer@workspace:packages/jest-serializer":
version: 0.0.0-use.local
resolution: "jest-serializer@workspace:packages/jest-serializer"
dependencies:
"@types/graceful-fs": ^4.1.3
"@types/node": "*"
graceful-fs: ^4.2.9
languageName: unknown
linkType: soft

"jest-silent-reporter@npm:^0.5.0":
version: 0.5.0
resolution: "jest-silent-reporter@npm:0.5.0"
Expand Down