diff --git a/packages/core/core/src/Parcel.js b/packages/core/core/src/Parcel.js index 6aad0bab6d7..861f726fbdf 100644 --- a/packages/core/core/src/Parcel.js +++ b/packages/core/core/src/Parcel.js @@ -31,7 +31,7 @@ import ReporterRunner from './ReporterRunner'; import dumpGraphToGraphViz from './dumpGraphToGraphViz'; import resolveOptions from './resolveOptions'; import {ValueEmitter} from '@parcel/events'; -import {registerCoreWithSerializer} from './utils'; +import {registerCoreWithSerializer} from './registerCoreWithSerializer'; import {AbortController} from 'abortcontroller-polyfill/dist/cjs-ponyfill'; import {PromiseQueue} from '@parcel/utils'; import ParcelConfig from './ParcelConfig'; diff --git a/packages/core/core/src/registerCoreWithSerializer.js b/packages/core/core/src/registerCoreWithSerializer.js new file mode 100644 index 00000000000..17690b85276 --- /dev/null +++ b/packages/core/core/src/registerCoreWithSerializer.js @@ -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]>)) { + registerSerializableClass(packageVersion + ':' + name, ctor); + } + coreRegistered = true; +} diff --git a/packages/core/core/src/utils.js b/packages/core/core/src/utils.js index 19e161b1292..546a758e0b4 100644 --- a/packages/core/core/src/utils.js +++ b/packages/core/core/src/utils.js @@ -17,18 +17,8 @@ import type {PackageManager} from '@parcel/package-manager'; import invariant from 'assert'; import baseX from 'base-x'; -import {Graph} from '@parcel/graph'; import {hashObject} from '@parcel/utils'; - -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 {fromProjectPath, toProjectPath} from './projectPath'; -// flowlint-next-line untyped-import:off -import packageJson from '../package.json'; const base62 = baseX( '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', @@ -48,33 +38,6 @@ export class BuildAbortError extends Error { name: string = 'BuildAbortError'; } -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]>)) { - registerSerializableClass(packageVersion + ':' + name, ctor); - } - - coreRegistered = true; -} - export function getPublicId( id: string, alreadyExists: string => boolean, diff --git a/packages/core/core/src/worker.js b/packages/core/core/src/worker.js index 596d7f7d587..63465d09e60 100644 --- a/packages/core/core/src/worker.js +++ b/packages/core/core/src/worker.js @@ -21,7 +21,7 @@ import {reportWorker, report} from './ReporterRunner'; import PackagerRunner, {type PackageRequestResult} from './PackagerRunner'; import Validation, {type ValidationOpts} from './Validation'; import ParcelConfig from './ParcelConfig'; -import {registerCoreWithSerializer} from './utils'; +import {registerCoreWithSerializer} from './registerCoreWithSerializer'; import {clearBuildCaches} from './buildCache'; import {init as initSourcemaps} from '@parcel/source-map'; import {init as initRust} from '@parcel/rust';