OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix: replay splitting for web sdk (when used as a module) #336
Carl-Gerhard Lindesvärd586c90047f2f
diff --git a/packages/sdks/web/tsup.config.ts b/packages/sdks/web/tsup.config.tsindex 2fa3f42fa..6fe7cd606 100644--- a/packages/sdks/web/tsup.config.ts+++ b/packages/sdks/web/tsup.config.ts@@ -8,7 +8,7 @@ export default defineConfig([entry: ['index.ts'],format: ['cjs', 'esm'],dts: true,- splitting: false,+ splitting: true,sourcemap: false,clean: true,minify: true,diff --git a/tooling/publish/publish.ts b/tooling/publish/publish.tsindex cd012b5e2..2c957b88e 100644--- a/tooling/publish/publish.ts+++ b/tooling/publish/publish.ts@@ -178,27 +178,30 @@ const updatePackageJsonForRelease = (};const searchAndReplace = (path: string, search: RegExp, replace: string) => {- const files = fs.readdirSync(path);- for (const file of files) {- const fullpath = join(path, file);- if (file === 'node_modules') {+ const entries = fs.readdirSync(path, { withFileTypes: true });+ for (const entry of entries) {+ if (entry.name === 'node_modules') {continue;}- if (file.includes('.')) {- const content = fs.readFileSync(fullpath, {+ const fullpath = join(path, entry.name);+ if (entry.isDirectory()) {+ searchAndReplace(fullpath, search, replace);+ continue;+ }+ if (!entry.isFile()) {+ continue;+ }+ const content = fs.readFileSync(fullpath, {+ encoding: 'utf-8',+ });++ const match = content.match(search);+ if (match) {+ console.log(`✏️ Will replace ${search} with ${replace} in ${entry.name}`);+ const newContent = content.replaceAll(search, replace);+ fs.writeFileSync(fullpath, newContent, {encoding: 'utf-8',});-- const match = content.match(search);- if (match) {- console.log(`✏️ Will replace ${search} with ${replace} in ${file}`);- const newContent = content.replaceAll(search, replace);- fs.writeFileSync(fullpath, newContent, {- encoding: 'utf-8',- });- }- } else {- searchAndReplace(fullpath, search, replace);}}};