Files
insights-js/packages/react/rollup.config.mjs
zooqueen a93e642791 chore: complete posthog->insights rebrand (zero @posthog/* identity)
Decomplect the half-finished fork so the dependency graph has ONE source
with no posthog package identity, living under github.com/hanzoinsights.

LAYER 1 (package identity): rename straggler package.json names —
@posthog/next->@hanzo/insights-next (Next.js SDK; distinct from the existing
@hanzo/insights-nextjs config helper), @posthog/mcp->@hanzo/insights-mcp,
@posthog/plugin-utils->@hanzo/insights-plugin-utils,
@posthog/react-slim->@hanzo/react-slim, @posthog-tooling/release->
@hanzo/insights-tooling-release, and the @posthog/rrweb* family->@hanzo/rrweb*
(matching the already-published @hanzo/rrweb*@0.0.47 + minimumReleaseAgeExclude).
Repoint every repository.url/homepage/bugs to github.com/hanzoinsights/insights-js
and rebrand the PostHog author/description identity to Hanzo AI.

LAYER 2 (cross-package imports): rewrite every internal @posthog/* import to its
@hanzo/insights*|@hanzo/rrweb* equivalent and the bare module specifiers
posthog-js->@hanzo/insights, posthog-node->@hanzo/insights-node, mirrored in
package.json deps + the pnpm-lock importer keys. Result: 0 @posthog/* specifiers
in packages/tooling/examples/playground source.

LAYER 4 (wire protocol) PRESERVED: window.posthog global, ph_* keys,
$-prefixed event names, distinct_id, /decide, /e/, /flags, and the
__PosthogExtensions__ hook are left unchanged — the Insights server expects them.

Also repair pre-existing fork merge damage that blocked compilation (unrelated to
naming; identical to origin/main): restore the @hanzo/insights-core ./process
subpath (spawn-local/utils, re-matching the published artifact), the lost
constructor/var declarations in core + node clients, the mangled
external-scripts-loader, the missing TreeShakeable/isPlainError imports, the
DeviceId enum member, and stale ../posthog-core-stateless module paths. 26/34
turbo build tasks now pass; remaining failures (browser/react-native and their
dependents) are pre-existing fork damage, not rebrand-caused.
2026-06-19 18:44:26 -07:00

169 lines
3.7 KiB
JavaScript

import { resolve, typescript, commonjs, dts } from '@hanzo/insights-tooling-rollup-utils'
import copy from 'rollup-plugin-copy'
const extensions = ['.js', '.jsx', '.ts', '.tsx']
const plugins = [
// Resolve modules from node_modules
resolve({
preferBuiltins: false,
mainFields: ['module', 'main', 'jsnext:main', 'browser'],
extensions,
}),
commonjs(),
// Compile typescript to javascript
typescript({
tsconfig: './tsconfig.json',
}),
]
/**
* Configuration for the ESM build
*/
const buildEsm = {
external: ['@hanzo/insights', 'react'],
input: [
// Split modules so they can be tree-shaken
'src/index.ts',
],
output: {
file: 'dist/esm/index.js',
format: 'esm',
sourcemap: true,
},
plugins,
}
/**
* Configuration for the UMD build
*/
const buildUmd = {
external: ['@hanzo/insights', 'react'],
input: './src/index.ts',
output: {
file: 'dist/umd/index.js',
name: 'InsightsReact',
format: 'umd',
sourcemap: true,
esModule: false,
globals: {
react: 'React',
'@hanzo/insights': 'insights',
},
},
plugins,
}
const buildTypes = {
external: ['@hanzo/insights', 'react'],
input: './src/index.ts',
output: {
file: 'dist/types/index.d.ts',
format: 'es',
},
plugins: [resolve(), dts()],
}
/**
* Configuration for the slim build (no posthog-js runtime dependency)
*/
const buildSlimEsm = {
external: ['@hanzo/insights', 'react'],
input: 'src/slim.ts',
output: {
file: 'dist/esm/slim/index.js',
format: 'esm',
sourcemap: true,
},
plugins,
}
const buildSlimUmd = {
external: ['@hanzo/insights', 'react'],
input: 'src/slim.ts',
output: {
file: 'dist/umd/slim/index.js',
name: 'PosthogReactSlim',
format: 'umd',
sourcemap: true,
esModule: false,
globals: {
react: 'React',
'@hanzo/insights': 'posthog',
},
},
plugins,
}
const buildSlimTypes = {
external: ['@hanzo/insights', 'react'],
input: 'src/slim.ts',
output: {
file: 'dist/types/slim/index.d.ts',
format: 'es',
},
plugins: [resolve(), dts()],
}
const buildSurveysEsm = {
external: ['@hanzo/insights', 'react'],
input: 'src/surveys/index.ts',
output: {
file: 'dist/esm/surveys/index.js',
format: 'esm',
sourcemap: true,
},
plugins,
}
const buildSurveysUmd = {
external: ['@hanzo/insights', 'react'],
input: 'src/surveys/index.ts',
output: {
file: 'dist/umd/surveys/index.js',
name: 'InsightsReactSurveys',
format: 'umd',
sourcemap: true,
esModule: false,
globals: {
react: 'React',
'@hanzo/insights': 'insights',
},
},
plugins,
}
const buildSurveysTypes = {
external: ['@hanzo/insights', 'react'],
input: 'src/surveys/index.ts',
output: {
file: 'dist/types/surveys/index.d.ts',
format: 'es',
},
plugins: [
resolve(),
dts(),
copy({
hook: 'writeBundle',
targets: [
{ src: 'dist/*', dest: '../browser/react/dist' },
{ src: 'src/*', dest: '../browser/react/src' },
{ src: 'surveys', dest: '../browser/react' },
{ src: 'slim', dest: '../browser/react' },
],
}),
],
}
export default [
buildEsm,
buildUmd,
buildTypes,
buildSlimEsm,
buildSlimUmd,
buildSlimTypes,
buildSurveysEsm,
buildSurveysUmd,
buildSurveysTypes,
]