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

React server component support #121

Merged
merged 2 commits into from
Mar 21, 2024
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
2 changes: 1 addition & 1 deletion examples/nextjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/react-17/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"rollbar": "^2.26.3",
"rollup": "^4.12.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-preserve-directives": "^0.4.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5",
Expand Down
32 changes: 29 additions & 3 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import resolve from '@rollup/plugin-node-resolve';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import babel from '@rollup/plugin-babel';
import pkg from './package.json' assert { type: 'json' };
import preserveDirectives from 'rollup-plugin-preserve-directives';

const COMMON_PLUGINS = [
resolve(),
Expand All @@ -14,6 +15,22 @@ const COMMON_PLUGINS = [
babel({ babelHelpers: 'bundled', exclude: ['node_modules/**'] }),
];

const entryFileNames = (chunkInfo) => {
if (chunkInfo.name.includes('node_modules')) {
return chunkInfo.name.replace(/node_modules/g, 'external') + '.js';
}

return '[name].js';
};

const onwarn = (warning, warn) => {
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
return;
}

warn(warning);
};

export default [
{
input: 'src/index.js',
Expand All @@ -30,6 +47,7 @@ export default [
},
},
plugins: [...COMMON_PLUGINS, commonjs()],
onwarn,
},

{
Expand All @@ -51,16 +69,24 @@ export default [
dir: pkg.module,
format: 'es',
sourcemap: true,
entryFileNames: '[name].js',
preserveModules: true,
preserveModulesRoot: 'src',
entryFileNames,
},
{
dir: pkg.main,
format: 'cjs',
sourcemap: true,
entryFileNames: '[name].js',
exports: 'named',
preserveModules: true,
preserveModulesRoot: 'src',
entryFileNames
},
],
plugins: [...COMMON_PLUGINS],
plugins: [
...COMMON_PLUGINS,
preserveDirectives({ suppressPreserveModulesWarning: true }),
],
onwarn,
},
];
2 changes: 2 additions & 0 deletions src/error-boundary.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import invariant from 'tiny-invariant';
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-rollbar-capture-event.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { useEffect } from 'react';
import invariant from 'tiny-invariant';
import { LEVEL_INFO } from '../constants';
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-rollbar-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { useRollbar } from './use-rollbar';

export function useRollbarConfiguration(config) {
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-rollbar-context.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import invariant from 'tiny-invariant';
import { useEffect, useLayoutEffect } from 'react';
import { useRollbar } from './use-rollbar';
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-rollbar-logs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

// EXPERIMENTAL
// NOT EXPORTED AS PART OF PUBLIC API YET
// NO TEST COVERAGE
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-rollbar-person.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { useRollbarConfiguration } from './use-rollbar-config';

export function useRollbarPerson(person) {
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-rollbar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { useContext } from 'react';
import { Context, getRollbarFromContext } from '../provider';

Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-scoped-rollbar-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

// EXPERIMENTAL
// NOT EXPORTED AS PART OF PUBLIC API YET
// NO TEST COVERAGE
Expand Down
2 changes: 2 additions & 0 deletions src/provider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React, { Component, createContext } from 'react';
import PropTypes from 'prop-types';
import Rollbar from 'rollbar';
Expand Down
2 changes: 2 additions & 0 deletions src/rollbar-configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

// EXPERIMENTAL
// NOT EXPORTED AS PART OF PUBLIC API YET: no current test coverage

Expand Down
2 changes: 2 additions & 0 deletions src/rollbar-context.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Component } from 'react';
import PropTypes from 'prop-types';
import { Context, getRollbarFromContext } from './provider';
Expand Down
Loading