Skip to content

feat: atomic @sentry/utils used only with submodule imports #1413

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

Merged
merged 5 commits into from
Jun 26, 2018
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
1 change: 0 additions & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"rimraf": "^2.6.2",
"rollup": "^0.58.2",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-npm": "^2.0.0",
"rollup-plugin-typescript2": "^0.13.0",
Expand Down
12 changes: 1 addition & 11 deletions packages/browser/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import builtins from 'rollup-plugin-node-builtins';

export default [
{
Expand All @@ -13,14 +12,8 @@ export default [
exports: 'named',
interop: false,
},
external: [
'@sentry/core',
'@sentry/hub',
'@sentry/minimal',
'@sentry/utils',
],
external: ['@sentry/core', '@sentry/hub', '@sentry/minimal'],
plugins: [
builtins(),
typescript({
tsconfig: 'tsconfig.build.json',
}),
Expand All @@ -39,12 +32,9 @@ export default [
format: 'iife',
name: 'Sentry',
sourcemap: true,
interop: false,
extend: true,
},
context: 'window',
plugins: [
builtins(),
typescript({
tsconfig: 'tsconfig.build.json',
tsconfigOverride: { compilerOptions: { declaration: false } },
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Backend, DSN, Options, SentryError } from '@sentry/core';
import { addBreadcrumb, captureEvent } from '@sentry/minimal';
import { SentryEvent } from '@sentry/types';
import { supportsFetch } from '@sentry/utils';
import { supportsFetch } from '@sentry/utils/supports';
import { Raven } from './raven';
import { FetchTransport, XHRTransport } from './transports';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/onunhandledrejection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { captureException } from '@sentry/minimal';
import { Integration } from '@sentry/types';
import { getGlobalObject } from '@sentry/utils';
import { getGlobalObject } from '@sentry/utils/misc';

const global: any = getGlobalObject();

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/tracekit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isError, isErrorEvent } from '@sentry/utils/dist/is';
import { isError, isErrorEvent } from '@sentry/utils/is';

/*
TraceKit - Cross brower stack traces
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/transports/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Transport,
TransportOptions,
} from '@sentry/types';
import { urlEncode } from '@sentry/utils';
import { urlEncode } from '@sentry/utils/object';

/** Base Transport class implementation */
export abstract class BaseTransport implements Transport {
Expand Down
8 changes: 3 additions & 5 deletions packages/browser/src/transports/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { SentryEvent } from '@sentry/types';
import {
getGlobalObject,
serialize,
supportsReferrerPolicy,
} from '@sentry/utils';
import { getGlobalObject } from '@sentry/utils/misc';
import { serialize } from '@sentry/utils/object';
import { supportsReferrerPolicy } from '@sentry/utils/supports';
import { BaseTransport } from './base';

const global: any = getGlobalObject();
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/transports/xhr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SentryEvent } from '@sentry/types';
import { serialize } from '@sentry/utils';
import { serialize } from '@sentry/utils/object';
import { BaseTransport } from './base';

/** `XHR` based transport */
Expand Down
12 changes: 0 additions & 12 deletions packages/core/jest.config.js

This file was deleted.

12 changes: 12 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,17 @@
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "jest",
"test:watch": "jest --watch --notify"
},
"jest": {
"collectCoverage": true,
"transform": { "^.+\\.ts$": "ts-jest" },
"moduleFileExtensions": ["js", "ts"],
"testEnvironment": "node",
"testMatch": ["**/*.test.ts"],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.json"
}
}
}
}
3 changes: 2 additions & 1 deletion packages/core/src/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Scope } from '@sentry/hub';
import { Breadcrumb, SdkInfo, SentryEvent } from '@sentry/types';
import { truncate, uuid4 } from '@sentry/utils';
import { uuid4 } from '@sentry/utils/misc';
import { truncate } from '@sentry/utils/string';
import { DSN } from './dsn';
import { Backend, Client, Options } from './interfaces';
import { SendStatus } from './status';
Expand Down
5 changes: 4 additions & 1 deletion packages/core/test/lib/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { TEST_SDK, TestClient } from '../mocks/client';

const PUBLIC_DSN = 'https://username@domain/path';

jest.mock('@sentry/utils', () => ({
jest.mock('@sentry/utils/misc', () => ({
uuid4(): string {
return '42';
},
}));

jest.mock('@sentry/utils/string', () => ({
truncate(str: string): string {
return str;
},
Expand Down
12 changes: 0 additions & 12 deletions packages/hub/jest.config.js

This file was deleted.

12 changes: 12 additions & 0 deletions packages/hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,17 @@
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "jest",
"test:watch": "jest --watch --notify"
},
"jest": {
"collectCoverage": true,
"transform": { "^.+\\.ts$": "ts-jest" },
"moduleFileExtensions": ["js", "ts"],
"testEnvironment": "node",
"testMatch": ["**/*.test.ts"],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.json"
}
}
}
}
12 changes: 0 additions & 12 deletions packages/minimal/jest.config.js

This file was deleted.

12 changes: 12 additions & 0 deletions packages/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,17 @@
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "jest",
"test:watch": "jest --watch --notify"
},
"jest": {
"collectCoverage": true,
"transform": { "^.+\\.ts$": "ts-jest" },
"moduleFileExtensions": ["js", "ts"],
"testEnvironment": "node",
"testMatch": ["**/*.test.ts"],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.json"
}
}
}
}
12 changes: 0 additions & 12 deletions packages/node/jest.config.js

This file was deleted.

12 changes: 12 additions & 0 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,17 @@
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "jest",
"test:watch": "jest --watch --notify"
},
"jest": {
"collectCoverage": true,
"transform": { "^.+\\.ts$": "ts-jest" },
"moduleFileExtensions": ["js", "ts"],
"testEnvironment": "node",
"testMatch": ["**/*.test.ts"],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.json"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/node/src/integrations/console.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addBreadcrumb } from '@sentry/minimal';
import { Integration, Severity } from '@sentry/types';
import { fill } from '@sentry/utils';
import { fill } from '@sentry/utils/object';
import { format } from 'util';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/http.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addBreadcrumb } from '@sentry/minimal';
import { Integration } from '@sentry/types';
import { fill } from '@sentry/utils';
import { fill } from '@sentry/utils/object';
import { ClientRequest, ClientRequestArgs, ServerResponse } from 'http';
import { inherits } from 'util';
import { getDefaultHub } from '../hub';
Expand Down
2 changes: 2 additions & 0 deletions packages/typescript/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// This rule has side effects and must be disabled
"no-unused-variable": false,

"no-submodule-imports": false,

// We don't want these
"newline-before-return": false,
"no-any": false,
Expand Down
3 changes: 3 additions & 0 deletions packages/utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.js.map
*.d.ts
*.js
5 changes: 4 additions & 1 deletion packages/utils/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*
!/dist/**/*
!*.js.map
!*.d.ts
!*.js
jest.config.js
3 changes: 2 additions & 1 deletion packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
[![npm dm](https://img.shields.io/npm/dm/@sentry/utils.svg)](https://www.npmjs.com/package/@sentry/utils)
[![npm dt](https://img.shields.io/npm/dt/@sentry/utils.svg)](https://www.npmjs.com/package/@sentry/utils)

Common utilities used by the Sentry JavaScript SDKs.
Common utilities used by the Sentry JavaScript SDKs. **Warning, only submodule
imports are allowed here.**
12 changes: 0 additions & 12 deletions packages/utils/jest.config.js

This file was deleted.

16 changes: 13 additions & 3 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"engines": {
"node": ">=6"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
Expand All @@ -29,7 +27,7 @@
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"clean": "rimraf dist coverage",
"clean": "rimraf dist coverage *.js *.js.map *.d.ts",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check '{src,test}/**/*.ts'",
"lint:tslint": "tslint -t stylish -p .",
Expand All @@ -38,5 +36,17 @@
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "jest",
"test:watch": "jest --watch --notify"
},
"jest": {
"collectCoverage": true,
"transform": { "^.+\\.ts$": "ts-jest" },
"moduleFileExtensions": ["js", "ts"],
"testEnvironment": "node",
"testMatch": ["**/*.test.ts"],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.json"
}
}
}
}
16 changes: 2 additions & 14 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
export { forget, filterAsync } from './async';
export { mkdirp, mkdirpSync } from './fs';
export { clone, deserialize, fill, serialize, urlEncode } from './object';
export { Store } from './store';
export { isError, isErrorEvent, isDOMError, isDOMException } from './is';
export { truncate } from './string';
export {
supportsDOMError,
supportsDOMException,
supportsErrorEvent,
supportsFetch,
supportsReferrerPolicy,
} from './supports';
export { getGlobalObject, uuid4 } from './misc';
// We do not export anything by default since we always want to deep import
// like: import { getGlobalObject } from '@sentry/utils/misc';
7 changes: 6 additions & 1 deletion packages/utils/src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export function fill(
): void {
const orig = source[name];
source[name] = replacement(orig);
// tslint:disable-next-line:no-unsafe-any
source[name].__raven__ = true;
// tslint:disable-next-line:no-unsafe-any
source[name].__orig__ = orig;
if (track) {
track.push([source, name, orig]);
Expand All @@ -152,6 +154,9 @@ export function fill(
*/
export function urlEncode(object: { [key: string]: any }): string {
return Object.keys(object)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(object[key])}`)
.map(
// tslint:disable-next-line:no-unsafe-any
key => `${encodeURIComponent(key)}=${encodeURIComponent(object[key])}`,
)
.join('&');
}
2 changes: 1 addition & 1 deletion packages/utils/test/async.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { filterAsync, forget } from '../src';
import { filterAsync, forget } from '../src/async';

describe('forget', () => {
const console = {
Expand Down
7 changes: 2 additions & 5 deletions packages/utils/test/is.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { isDOMError, isDOMException, isError, isErrorEvent } from '../src/is';
import {
isDOMError,
isDOMException,
isError,
isErrorEvent,
supportsDOMError,
supportsDOMException,
supportsErrorEvent,
} from '../src';
} from '../src/supports';

class SentryError extends Error {
public name: string;
Expand Down
Loading