From de8f4ff14d6b362bcca5ec2a134a07ca4a93bc46 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Tue, 26 Nov 2019 13:43:49 -0800 Subject: [PATCH] [BUGFIX] cleanup rollup warnings (#6809) * [BUGFIX] cleanup rollup warnings * fix lint * make throw --- packages/-ember-data/index.js | 1 + .../record-data/record-data-errors-test.ts | 2 +- .../record-data/record-data-state-test.ts | 2 +- .../custom-class-model-test.ts | 2 +- .../addon-build-config-for-data-package.js | 33 ++++++++++++++++--- .../record-data/addon/-private/record-data.ts | 2 +- .../ts-interfaces/relationship-record-data.ts | 2 +- .../store/addon/-private/system/core-store.ts | 4 +-- .../addon/-private/system/ds-model-store.ts | 2 +- .../-private/system/model/internal-model.ts | 2 +- .../addon/-private/system/record-data-for.ts | 2 +- .../system/store/record-data-store-wrapper.ts | 2 +- .../record-data-record-wrapper.ts | 2 +- .../-private/ts-interfaces/record-data.ts | 2 +- 14 files changed, 43 insertions(+), 17 deletions(-) diff --git a/packages/-ember-data/index.js b/packages/-ember-data/index.js index 0b177d0974e..62381a84cda 100644 --- a/packages/-ember-data/index.js +++ b/packages/-ember-data/index.js @@ -14,6 +14,7 @@ module.exports = Object.assign({}, addonBaseConfig, { '@ember-data/store/-private', '@ember-data/store', '@ember-data/model', + '@ember-data/model/-private', ]; }, treeForAddon(tree) { diff --git a/packages/-ember-data/tests/integration/record-data/record-data-errors-test.ts b/packages/-ember-data/tests/integration/record-data/record-data-errors-test.ts index fb78c8203dc..93f49bc4320 100644 --- a/packages/-ember-data/tests/integration/record-data/record-data-errors-test.ts +++ b/packages/-ember-data/tests/integration/record-data/record-data-errors-test.ts @@ -6,7 +6,7 @@ import EmberObject from '@ember/object'; import { attr } from '@ember-data/model'; import { InvalidError } from '@ember-data/adapter/error'; import { JsonApiValidationError } from '@ember-data/store/-private/ts-interfaces/record-data-json-api'; -import RecordData from '@ember-data/store/-private/ts-interfaces/record-data'; +import { RecordData } from '@ember-data/store/-private/ts-interfaces/record-data'; import { RecordIdentifier } from '@ember-data/store/-private/ts-interfaces/identifier'; import { RECORD_DATA_ERRORS } from '@ember-data/canary-features'; import JSONAPISerializer from '@ember-data/serializer/json-api'; diff --git a/packages/-ember-data/tests/integration/record-data/record-data-state-test.ts b/packages/-ember-data/tests/integration/record-data/record-data-state-test.ts index 1f20738b265..254ddcc7ea7 100644 --- a/packages/-ember-data/tests/integration/record-data/record-data-state-test.ts +++ b/packages/-ember-data/tests/integration/record-data/record-data-state-test.ts @@ -5,7 +5,7 @@ import { module, test } from 'qunit'; import EmberObject from '@ember/object'; import { attr } from '@ember-data/model'; import Ember from 'ember'; -import RecordData from '@ember-data/store/-private/ts-interfaces/record-data'; +import { RecordData } from '@ember-data/store/-private/ts-interfaces/record-data'; import { RECORD_DATA_STATE } from '@ember-data/canary-features'; import JSONAPISerializer from '@ember-data/serializer/json-api'; diff --git a/packages/-ember-data/tests/unit/custom-class-support/custom-class-model-test.ts b/packages/-ember-data/tests/unit/custom-class-support/custom-class-model-test.ts index d0553df6238..33618abaf3f 100644 --- a/packages/-ember-data/tests/unit/custom-class-support/custom-class-model-test.ts +++ b/packages/-ember-data/tests/unit/custom-class-support/custom-class-model-test.ts @@ -9,7 +9,7 @@ import { CUSTOM_MODEL_CLASS } from '@ember-data/canary-features'; import CoreStore from '@ember-data/store/-private/system/core-store'; import { StableRecordIdentifier, RecordIdentifier } from '@ember-data/store/-private/ts-interfaces/identifier'; import NotificationManager from '@ember-data/store/-private/system/record-notification-manager'; -import RecordDataRecordWrapper from '@ember-data/store/-private/ts-interfaces/record-data-record-wrapper'; +import { RecordDataRecordWrapper } from '@ember-data/store/-private/ts-interfaces/record-data-record-wrapper'; let CustomStore, store, schemaDefinition; if (CUSTOM_MODEL_CLASS) { diff --git a/packages/private-build-infra/src/addon-build-config-for-data-package.js b/packages/private-build-infra/src/addon-build-config-for-data-package.js index 952e9ad1de1..7fca7962609 100644 --- a/packages/private-build-infra/src/addon-build-config-for-data-package.js +++ b/packages/private-build-infra/src/addon-build-config-for-data-package.js @@ -45,10 +45,35 @@ function addonBuildConfigForDataPackage(PackageName) { } }, - _suppressCircularDependencyWarnings(message, next) { - if (message.code !== 'CIRCULAR_DEPENDENCY') { - next(message); + _suppressUneededRollupWarnings(message, next) { + if (message.code === 'CIRCULAR_DEPENDENCY') { + return; + } else if (message.code === 'NON_EXISTENT_EXPORT') { + // ignore ts-interface imports + if (message.message.indexOf(`/ts-interfaces/`) !== -1) { + return; + } + } else if (message.code === 'UNRESOLVED_IMPORT') { + if (!this.isDevelopingAddon()) { + // don't print these for consumers + return; + } else { + const chalk = require('chalk'); + // make warning actionable + // eslint-disable-next-line no-console + console.log( + chalk.yellow( + `\n\n⚠️ Add ${chalk.white( + message.source + )} to the array returned by externalDependenciesForPrivateModule in index.js of ${chalk.white( + this.name + )}\n\n` + ) + ); + throw message.message; + } } + next(message); }, getOutputDirForVersion() { @@ -116,7 +141,7 @@ function addonBuildConfigForDataPackage(PackageName) { packageName: PackageName, babelCompiler: babel, babelOptions: this.options.babel, - onWarn: this._suppressCircularDependencyWarnings, + onWarn: this._suppressUneededRollupWarnings.bind(this), externalDependencies: this.externalDependenciesForPrivateModule(), destDir: this.getOutputDirForVersion(), }); diff --git a/packages/record-data/addon/-private/record-data.ts b/packages/record-data/addon/-private/record-data.ts index 9c6a27a9f3e..aa7745fb7af 100644 --- a/packages/record-data/addon/-private/record-data.ts +++ b/packages/record-data/addon/-private/record-data.ts @@ -11,7 +11,7 @@ import coerceId from './coerce-id'; import BelongsToRelationship from './relationships/state/belongs-to'; import ManyRelationship from './relationships/state/has-many'; import Relationship from './relationships/state/relationship'; -import RecordData, { ChangedAttributesHash } from '@ember-data/store/-private/ts-interfaces/record-data'; +import { RecordData, ChangedAttributesHash } from '@ember-data/store/-private/ts-interfaces/record-data'; import { JsonApiResource, JsonApiValidationError, diff --git a/packages/record-data/addon/-private/ts-interfaces/relationship-record-data.ts b/packages/record-data/addon/-private/ts-interfaces/relationship-record-data.ts index 5530f8ed0d0..29411888d44 100644 --- a/packages/record-data/addon/-private/ts-interfaces/relationship-record-data.ts +++ b/packages/record-data/addon/-private/ts-interfaces/relationship-record-data.ts @@ -1,6 +1,6 @@ import Relationships from '../relationships/state/create'; import Relationship from '../relationships/state/relationship'; -import RecordData from '@ember-data/store/-private/ts-interfaces/record-data'; +import { RecordData } from '@ember-data/store/-private/ts-interfaces/record-data'; import { SingleResourceRelationship, CollectionResourceRelationship, diff --git a/packages/store/addon/-private/system/core-store.ts b/packages/store/addon/-private/system/core-store.ts index 4e910d6e724..d5b0ea3aa19 100644 --- a/packages/store/addon/-private/system/core-store.ts +++ b/packages/store/addon/-private/system/core-store.ts @@ -78,8 +78,8 @@ import NotificationManager from './record-notification-manager'; import { AttributesSchema } from '../ts-interfaces/record-data-schemas'; import { SchemaDefinitionService } from '../ts-interfaces/schema-definition-service'; import ShimModelClass, { getShimClass } from './model/shim-model-class'; -import RecordDataRecordWrapper from '../ts-interfaces/record-data-record-wrapper'; -import RecordData from '../ts-interfaces/record-data'; +import { RecordDataRecordWrapper } from '../ts-interfaces/record-data-record-wrapper'; +import { RecordData } from '../ts-interfaces/record-data'; import { Dict } from '../ts-interfaces/utils'; import constructResource from '../utils/construct-resource'; diff --git a/packages/store/addon/-private/system/ds-model-store.ts b/packages/store/addon/-private/system/ds-model-store.ts index a79406e3213..2918da27247 100644 --- a/packages/store/addon/-private/system/ds-model-store.ts +++ b/packages/store/addon/-private/system/ds-model-store.ts @@ -17,7 +17,7 @@ import NotificationManager from './record-notification-manager'; import { StableRecordIdentifier } from '../ts-interfaces/identifier'; import { DSModelSchemaDefinitionService, getModelFactory } from './schema-definition-service'; import { CUSTOM_MODEL_CLASS } from '@ember-data/canary-features'; -import RecordDataRecordWrapper from '../ts-interfaces/record-data-record-wrapper'; +import { RecordDataRecordWrapper } from '../ts-interfaces/record-data-record-wrapper'; import { SchemaDefinitionService } from '../ts-interfaces/schema-definition-service'; import { RelationshipsSchema } from '../ts-interfaces/record-data-schemas'; import notifyChanges from './model/notify-changes'; diff --git a/packages/store/addon/-private/system/model/internal-model.ts b/packages/store/addon/-private/system/model/internal-model.ts index 6e4bdf05da2..b34a96a6a8f 100644 --- a/packages/store/addon/-private/system/model/internal-model.ts +++ b/packages/store/addon/-private/system/model/internal-model.ts @@ -17,7 +17,7 @@ import { errorsHashToArray } from '../errors-utils'; import RecordArray from '../record-arrays/record-array'; import { RecordReference, BelongsToReference, HasManyReference } from '../references'; -import RecordData from '../../ts-interfaces/record-data'; +import { RecordData } from '../../ts-interfaces/record-data'; import { JsonApiResource, JsonApiValidationError } from '../../ts-interfaces/record-data-json-api'; import { RecordInstance } from '../../ts-interfaces/record-instance'; import { ConfidentDict } from '../../ts-interfaces/utils'; diff --git a/packages/store/addon/-private/system/record-data-for.ts b/packages/store/addon/-private/system/record-data-for.ts index 84c47991d71..68055a9d8a3 100644 --- a/packages/store/addon/-private/system/record-data-for.ts +++ b/packages/store/addon/-private/system/record-data-for.ts @@ -1,4 +1,4 @@ -import RecordData from '../ts-interfaces/record-data'; +import { RecordData } from '../ts-interfaces/record-data'; /* * Returns the RecordData instance associated with a given * Model or InternalModel. diff --git a/packages/store/addon/-private/system/store/record-data-store-wrapper.ts b/packages/store/addon/-private/system/store/record-data-store-wrapper.ts index 25235a5c05b..864d6fa8333 100644 --- a/packages/store/addon/-private/system/store/record-data-store-wrapper.ts +++ b/packages/store/addon/-private/system/store/record-data-store-wrapper.ts @@ -2,7 +2,7 @@ import { RecordDataStoreWrapper as IRecordDataStoreWrapper } from '../../ts-inte import { AttributesSchema, RelationshipsSchema } from '../../ts-interfaces/record-data-schemas'; import { BRAND_SYMBOL } from '../../ts-interfaces/utils/brand'; import { upgradeForInternal } from '../ts-upgrade-map'; -import RecordData from '../../ts-interfaces/record-data'; +import { RecordData } from '../../ts-interfaces/record-data'; import { internalModelFactoryFor } from './internal-model-factory'; import { IDENTIFIERS, CUSTOM_MODEL_CLASS } from '@ember-data/canary-features'; import { identifierCacheFor, IdentifierCache } from '../../identifiers/cache'; diff --git a/packages/store/addon/-private/ts-interfaces/record-data-record-wrapper.ts b/packages/store/addon/-private/ts-interfaces/record-data-record-wrapper.ts index c92f1906484..93dd36d1bf6 100644 --- a/packages/store/addon/-private/ts-interfaces/record-data-record-wrapper.ts +++ b/packages/store/addon/-private/ts-interfaces/record-data-record-wrapper.ts @@ -7,7 +7,7 @@ import { ChangedAttributesHash } from './record-data'; @module @ember-data/store */ -export default interface RecordDataRecordWrapper { +export interface RecordDataRecordWrapper { rollbackAttributes(): string[]; changedAttributes(): ChangedAttributesHash; hasChangedAttributes(): boolean; diff --git a/packages/store/addon/-private/ts-interfaces/record-data.ts b/packages/store/addon/-private/ts-interfaces/record-data.ts index f3b30220ce7..7de9677598e 100644 --- a/packages/store/addon/-private/ts-interfaces/record-data.ts +++ b/packages/store/addon/-private/ts-interfaces/record-data.ts @@ -11,7 +11,7 @@ export interface ChangedAttributesHash { [key: string]: [string, string]; } -export default interface RecordData { +export interface RecordData { pushData(data: JsonApiResource, calculateChange?: boolean): void; clientDidCreate(): void; willCommit(): void;