Skip to content

Add path aliases for cleaner imports #1184

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ module.exports = function (config) {
},
],
},
resolve: {
alias: {
'@rollbar': path.resolve(__dirname, 'src'),
'@browser': path.resolve(__dirname, 'src/browser'),
'@server': path.resolve(__dirname, 'src/server'),
'@tracing': path.resolve(__dirname, 'src/tracing'),
'@utility': path.resolve(__dirname, 'src/utility'),
'@react-native': path.resolve(__dirname, 'src/react-native')
},
extensions: ['.js', '.json']
},
},

webpackMiddleware: {
Expand Down
2 changes: 1 addition & 1 deletion src/browser/replay/replayMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spanExportQueue } from '../../tracing/exporter.js';
import { spanExportQueue } from '@tracing/exporter.js';

/**
* ReplayMap - Manages the mapping between error occurrences and their associated
Expand Down
2 changes: 1 addition & 1 deletion test/replay/integration/api.spans.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { expect } from 'chai';
import sinon from 'sinon';

import Api from '../../../src/api.js';
import Api from '@rollbar/api.js';

describe('API Span Transport', function () {
let api;
Expand Down
16 changes: 8 additions & 8 deletions test/replay/integration/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
import { expect } from 'chai';
import sinon from 'sinon';

import Tracing from '../../../src/tracing/tracing.js';
import { SpanExporter } from '../../../src/tracing/exporter.js';
import { spanExportQueue } from '../../../src/tracing/exporter.js';
import Recorder from '../../../src/browser/replay/recorder.js';
import ReplayMap from '../../../src/browser/replay/replayMap.js';
import recorderDefaults from '../../../src/browser/replay/defaults.js';
import Api from '../../../src/api.js';
import Queue from '../../../src/queue.js';
import Tracing from '@tracing/tracing.js';
import { SpanExporter } from '@tracing/exporter.js';
import { spanExportQueue } from '@tracing/exporter.js';
import Recorder from '@browser/replay/recorder.js';
import ReplayMap from '@browser/replay/replayMap.js';
import recorderDefaults from '@browser/replay/defaults.js';
import Api from '@rollbar/api.js';
import Queue from '@rollbar/queue.js';
import { mockRecordFn } from '../util';

const options = {
Expand Down
4 changes: 2 additions & 2 deletions test/replay/integration/queue.replayMap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import { expect } from 'chai';
import sinon from 'sinon';

import Queue from '../../../src/queue.js';
import Api from '../../../src/api.js';
import Queue from '@rollbar/queue.js';
import Api from '@rollbar/api.js';

describe('Queue ReplayMap Integration', function () {
let queue;
Expand Down
12 changes: 6 additions & 6 deletions test/replay/integration/replayMap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import { expect } from 'chai';
import sinon from 'sinon';

import ReplayMap from '../../../src/browser/replay/replayMap.js';
import Recorder from '../../../src/browser/replay/recorder.js';
import Tracing from '../../../src/tracing/tracing.js';
import { SpanExporter } from '../../../src/tracing/exporter.js';
import { spanExportQueue } from '../../../src/tracing/exporter.js';
import Api from '../../../src/api.js';
import ReplayMap from '@browser/replay/replayMap.js';
import Recorder from '@browser/replay/recorder.js';
import Tracing from '@tracing/tracing.js';
import { SpanExporter } from '@tracing/exporter.js';
import { spanExportQueue } from '@tracing/exporter.js';
import Api from '@rollbar/api.js';
import { mockRecordFn } from '../util';

const options = {
Expand Down
20 changes: 10 additions & 10 deletions test/replay/integration/sessionRecording.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import { expect } from 'chai';
import { EventType } from '@rrweb/types';
import sinon from 'sinon';

import Tracing from '../../../src/tracing/tracing.js';
import { Span } from '../../../src/tracing/span.js';
import { Context } from '../../../src/tracing/context.js';
import { SpanExporter } from '../../../src/tracing/exporter.js';
import Recorder from '../../../src/browser/replay/recorder.js';
import ReplayMap from '../../../src/browser/replay/replayMap.js';
import recorderDefaults from '../../../src/browser/replay/defaults.js';
import { spanExportQueue } from '../../../src/tracing/exporter.js';
import Tracing from '@tracing/tracing.js';
import { Span } from '@tracing/span.js';
import { Context } from '@tracing/context.js';
import { SpanExporter } from '@tracing/exporter.js';
import Recorder from '@browser/replay/recorder.js';
import ReplayMap from '@browser/replay/replayMap.js';
import recorderDefaults from '@browser/replay/defaults.js';
import { spanExportQueue } from '@tracing/exporter.js';
import { mockRecordFn } from '../util';
import Api from '../../../src/api.js';
import Queue from '../../../src/queue.js';
import Api from '@rollbar/api.js';
import Queue from '@rollbar/queue.js';

const options = {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion test/replay/unit/api.postSpans.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { expect } from 'chai';
import sinon from 'sinon';

// We need to use require since the API module is a CommonJS module
const Api = require('../../../src/api');
const Api = require('@rollbar/api');

describe('Api', function () {
let api;
Expand Down
2 changes: 1 addition & 1 deletion test/replay/unit/queue.replayMap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { expect } from 'chai';
import sinon from 'sinon';

// We need to use require since the Queue module is CommonJS
const Queue = require('../../../src/queue');
const Queue = require('@rollbar/queue');

// Mock ReplayMap implementation
class MockReplayMap {
Expand Down
4 changes: 2 additions & 2 deletions test/replay/unit/replayMap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import { expect } from 'chai';
import sinon from 'sinon';
import ReplayMap from '../../../src/browser/replay/replayMap.js';
import { spanExportQueue } from '../../../src/tracing/exporter.js';
import ReplayMap from '@browser/replay/replayMap.js';
import { spanExportQueue } from '@tracing/exporter.js';

// Mock objects for testing
class MockSpan {
Expand Down
34 changes: 34 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var defaults = require('./defaults');
var TerserPlugin = require('terser-webpack-plugin');

var outputPath = path.resolve(__dirname, 'dist');
var srcPath = path.resolve(__dirname, 'src');

var defaultsPlugin = new webpack.DefinePlugin(defaults);
var uglifyPlugin = new TerserPlugin({
Expand All @@ -30,6 +31,17 @@ var snippetConfig = {
},
],
},
resolve: {
alias: {
'@rollbar': srcPath,
'@browser': path.resolve(srcPath, 'browser'),
'@server': path.resolve(srcPath, 'server'),
'@tracing': path.resolve(srcPath, 'tracing'),
'@utility': path.resolve(srcPath, 'utility'),
'@react-native': path.resolve(srcPath, 'react-native')
},
extensions: ['.js', '.json']
},
};

var pluginConfig = {
Expand Down Expand Up @@ -72,6 +84,17 @@ var vanillaConfigBase = {
},
],
},
resolve: {
alias: {
'@rollbar': srcPath,
'@browser': path.resolve(srcPath, 'browser'),
'@server': path.resolve(srcPath, 'server'),
'@tracing': path.resolve(srcPath, 'tracing'),
'@utility': path.resolve(srcPath, 'utility'),
'@react-native': path.resolve(srcPath, 'react-native')
},
extensions: ['.js', '.json']
},
};

var UMDConfigBase = {
Expand All @@ -95,6 +118,17 @@ var UMDConfigBase = {
},
],
},
resolve: {
alias: {
'@rollbar': srcPath,
'@browser': path.resolve(srcPath, 'browser'),
'@server': path.resolve(srcPath, 'server'),
'@tracing': path.resolve(srcPath, 'tracing'),
'@utility': path.resolve(srcPath, 'utility'),
'@react-native': path.resolve(srcPath, 'react-native')
},
extensions: ['.js', '.json']
},
};

var noConflictConfigBase = extend({}, UMDConfigBase);
Expand Down
Loading