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: Strip Symbol from production builds (#6389) #6436

Merged
merged 1 commit into from
Sep 11, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/store/addon/-private/system/fetch-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import RequestCache from './request-cache';
import { CollectionResourceDocument, SingleResourceDocument } from '../ts-interfaces/ember-data-json-api';
import { RecordIdentifier } from '../ts-interfaces/identifier';
import { FindRecordQuery, SaveRecordMutation, Request } from '../ts-interfaces/fetch-manager';
import { symbol } from '../ts-interfaces/utils/symbol';
import Store from './store';
import recordDataFor from './record-data-for';

Expand All @@ -27,7 +28,7 @@ function payloadIsNotBlank(adapterPayload): boolean {
}

const emberRun = emberRunLoop.backburner;
export const SaveOp = Symbol('SaveOp');
export const SaveOp: unique symbol = symbol('SaveOp');

interface PendingFetchItem {
identifier: RecordIdentifier;
Expand Down
5 changes: 3 additions & 2 deletions packages/store/addon/-private/system/request-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
Operation,
RequestStateEnum,
} from '../ts-interfaces/fetch-manager';
import { symbol } from '../ts-interfaces/utils/symbol';

import { _findHasMany, _findBelongsTo, _findAll, _query, _queryRecord } from './store/finders';

const Touching = Symbol('touching');
export const RequestPromise = Symbol('promise');
export const Touching: unique symbol = symbol('touching');
export const RequestPromise: unique symbol = symbol('promise');

export interface InternalRequest extends RequestState {
[Touching]: RecordIdentifier[];
Expand Down
5 changes: 4 additions & 1 deletion packages/store/addon/-private/ts-interfaces/utils/brand.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { symbol } from './symbol';

/**
@module @ember-data/store
*/
Expand All @@ -14,4 +16,5 @@
*
* @internal
*/
export const BRAND_SYMBOL = Symbol(`DEBUG-ts-brand`);

export const BRAND_SYMBOL: unique symbol = symbol('DEBUG-ts-brand');
19 changes: 19 additions & 0 deletions packages/store/addon/-private/ts-interfaces/utils/symbol.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
@module @ember-data/store
*/

/**
* This symbol provides a Symbol replacement for browsers that do not have it
* (eg. IE 11).
*
* The replacement is different from the native Symbol in some ways. It is a
* function that produces an output:
* - iterable;
* - that is a string, not a symbol.
*
* @internal
*/
export const symbol =
typeof Symbol !== 'undefined'
? Symbol
: (key: string) => `__${key}${Math.floor(Math.random() * Date.now())}__` as any;