forked from parcel-bundler/parcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move registerCoreWithSerializer to its own file (parcel-bundler#9396)
- Loading branch information
1 parent
015eb36
commit d741b10
Showing
4 changed files
with
36 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// @flow | ||
import {Graph} from '@parcel/graph'; | ||
import {registerSerializableClass} from './serializer'; | ||
import AssetGraph from './AssetGraph'; | ||
import BundleGraph from './BundleGraph'; | ||
import ParcelConfig from './ParcelConfig'; | ||
import {RequestGraph} from './RequestTracker'; | ||
import Config from './public/Config'; | ||
import packageJson from '../package.json'; | ||
|
||
let coreRegistered; | ||
export function registerCoreWithSerializer() { | ||
if (coreRegistered) { | ||
return; | ||
} | ||
const packageVersion: mixed = packageJson.version; | ||
if (typeof packageVersion !== 'string') { | ||
throw new Error('Expected package version to be a string'); | ||
} | ||
|
||
// $FlowFixMe[incompatible-cast] | ||
for (let [name, ctor] of (Object.entries({ | ||
AssetGraph, | ||
Config, | ||
BundleGraph, | ||
Graph, | ||
ParcelConfig, | ||
RequestGraph, | ||
// $FlowFixMe[unclear-type] | ||
}): Array<[string, Class<any>]>)) { | ||
registerSerializableClass(packageVersion + ':' + name, ctor); | ||
} | ||
coreRegistered = true; | ||
} |
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