Skip to content

Commit

Permalink
[BUGFIX] cleanup rollup warnings (#6809)
Browse files Browse the repository at this point in the history
* [BUGFIX] cleanup rollup warnings

* fix lint

* make throw
  • Loading branch information
runspired authored Nov 26, 2019
1 parent 0524099 commit de8f4ff
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/-ember-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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(),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/record-data/addon/-private/record-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/store/addon/-private/system/core-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/store/addon/-private/system/ds-model-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/store/addon/-private/system/record-data-for.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/store/addon/-private/ts-interfaces/record-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit de8f4ff

Please sign in to comment.