diff --git a/core-web/libs/sdk/analytics/package.json b/core-web/libs/sdk/analytics/package.json index 6b878359226..cef4094b8ee 100644 --- a/core-web/libs/sdk/analytics/package.json +++ b/core-web/libs/sdk/analytics/package.json @@ -1,6 +1,7 @@ { "name": "@dotcms/analytics", "version": "0.0.1-alpha.54", + "type": "module", "description": "Official JavaScript library for Content Analytics with DotCMS.", "repository": { "type": "git", @@ -21,11 +22,17 @@ "homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/analytics/README.md", "dependencies": { "analytics": "^0.8.14", - "react": "^18.2.0" + "vite": "~5.0.0" }, "peerDependencies": { - "vite": "^5.0.0" + "react": "^18.2.0" }, "main": "./index.cjs.js", - "module": "./index.esm.js" + "module": "./index.esm.js", + "exports": { + "./react": { + "import": "./lib/react/index.js", + "types": "./lib/react/index.d.ts" + } + } } diff --git a/core-web/libs/sdk/analytics/project.json b/core-web/libs/sdk/analytics/project.json index fc9563bd879..9b51ff62cd0 100644 --- a/core-web/libs/sdk/analytics/project.json +++ b/core-web/libs/sdk/analytics/project.json @@ -10,11 +10,25 @@ "options": { "outputPath": "dist/libs/sdk/analytics", "main": "libs/sdk/analytics/src/index.ts", - "tsConfig": "libs/sdk/analytics/tsconfig.lib.json", "project": "libs/sdk/analytics/package.json", - "rollupConfig": "@nx/react/plugins/bundle-rollup", + "additionalEntryPoints": ["libs/sdk/analytics/src/lib/react/index.ts"], + "tsConfig": "libs/sdk/analytics/tsconfig.lib.json", + "format": ["esm"], + "external": ["react"], + "preserveModules": true, + "preserveModulesRoot": "libs/sdk/analytics/src", + "rollupConfig": "libs/sdk/analytics/rollup.config.js", "compiler": "swc", - "format": ["esm", "cjs"] + "assets": [ + { + "glob": "README.md", + "input": "libs/sdk/analytics", + "output": "." + } + ], + "sourceMap": true, + "skipTypeCheck": false, + "deleteOutputPath": true } }, "build:standalone": { diff --git a/core-web/libs/sdk/analytics/rollup.config.js b/core-web/libs/sdk/analytics/rollup.config.js new file mode 100644 index 00000000000..b4ab2109886 --- /dev/null +++ b/core-web/libs/sdk/analytics/rollup.config.js @@ -0,0 +1,12 @@ +export default { + input: { + 'index.esm': 'libs/sdk/analytics/src/index.ts', + 'react/index': 'libs/sdk/analytics/src/lib/react/index.ts' + }, + output: { + dir: 'dist/libs/sdk/analytics', + format: 'esm', + preserveModules: true, + preserveModulesRoot: 'libs/sdk/analytics/src' + } +}; diff --git a/core-web/libs/sdk/analytics/src/index.ts b/core-web/libs/sdk/analytics/src/index.ts index 04d85b2460c..241d66113b2 100644 --- a/core-web/libs/sdk/analytics/src/index.ts +++ b/core-web/libs/sdk/analytics/src/index.ts @@ -1,2 +1 @@ -export * from './lib/react/components/DotContentAnalyticsProvider'; -export * from './lib/react/hook/useContentAnalytics'; +export * from './lib/react'; diff --git a/core-web/libs/sdk/analytics/src/lib/react/index.ts b/core-web/libs/sdk/analytics/src/lib/react/index.ts new file mode 100644 index 00000000000..7e1a213e3ea --- /dev/null +++ b/core-web/libs/sdk/analytics/src/lib/react/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/core-web/libs/sdk/analytics/src/lib/react/public-api.ts b/core-web/libs/sdk/analytics/src/lib/react/public-api.ts new file mode 100644 index 00000000000..321711860b2 --- /dev/null +++ b/core-web/libs/sdk/analytics/src/lib/react/public-api.ts @@ -0,0 +1,3 @@ +export { DotContentAnalyticsProvider } from './components/DotContentAnalyticsProvider'; + +export { useContentAnalytics } from './hook/useContentAnalytics'; diff --git a/core-web/libs/sdk/analytics/tsconfig.lib.json b/core-web/libs/sdk/analytics/tsconfig.lib.json index 051080f3b99..ed793751aab 100644 --- a/core-web/libs/sdk/analytics/tsconfig.lib.json +++ b/core-web/libs/sdk/analytics/tsconfig.lib.json @@ -4,7 +4,7 @@ "module": "ES2015", "target": "es2015", "declaration": true, - "outDir": "../../../dist/out-tsc", + "outDir": "../../../dist/libs/sdk/analytics", "types": ["node", "jest"], "moduleResolution": "node", "esModuleInterop": true,