Skip to content

Commit

Permalink
Fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Jan 16, 2024
1 parent 8187864 commit 9efc0cf
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 193 deletions.
12 changes: 8 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"presets": ["@babel/env", ["@babel/typescript", { "jsxPragma": "h" }]],
"plugins": [
["@babel/transform-react-jsx", {
"pragma": "h"
}]
]
[
"@babel/transform-react-jsx",
{
"pragma": "Preact.h",
"pragmaFrag": "Preact.Fragment"
}
]
]
}
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const rules = {
const extend = [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'prettier',
'plugin:compat/recommended',
'plugin:posthog-js/all',
Expand Down Expand Up @@ -72,6 +70,10 @@ module.exports = {
'no-restricted-globals': 'off',
},
},
{
files: 'react/src/**/',
extends: [...extend, 'plugin:react/recommended', 'plugin:react-hooks/recommended'],
},
{
files: 'eslint-rules/**/*',
extends: ['eslint:recommended', 'prettier'],
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@
"react/package.json"
],
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.23.4",
"fflate": "^0.4.1",
"preact": "^10.19.3"
},
"devDependencies": {
"@babel/core": "7.18.9",
"@babel/plugin-syntax-decorators": "^7.23.3",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/preset-env": "7.18.9",
"@babel/preset-typescript": "^7.18.6",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^8.3.3",
"@rrweb/types": "^2.0.0-alpha.11",
Expand All @@ -52,12 +53,12 @@
"@types/react-dom": "^18.0.10",
"@types/sinon": "^17.0.1",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"babel-eslint": "10.1.0",
"babel-jest": "^26.6.3",
"cypress": "13.5.1",
"eslint": "8.20.0",
"eslint": "8.56.0",
"eslint-config-posthog-js": "link:./eslint-rules",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-compat": "^4.1.4",
Expand All @@ -79,7 +80,7 @@
"node-fetch": "^2.6.1",
"posthog-js": "link:.",
"prettier": "^2.7.1",
"rollup": "^2.77.0",
"rollup": "^2.78.0",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-visualizer": "^5.9.0",
"rrweb": "2.0.0-alpha.11",
Expand Down
6 changes: 4 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { visualizer } from 'rollup-plugin-visualizer'

const plugins = [
json(),
resolve({ browser: true, modulesOnly: true }),
resolve({ browser: true }),
typescript({ sourceMap: true }),
babel({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
Expand Down Expand Up @@ -47,13 +47,15 @@ export default [
},
{
input: 'src/loader-surveys.ts',
external: ['preact'],
output: [
{
file: 'dist/surveys.js',
sourcemap: true,
format: 'iife',
name: 'posthog',
globals: {
preact: 'preact',
},
},
],
plugins: [...plugins],
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/surveys.ts → src/extensions/surveys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
posthogLogo,
style,
} from './surveys/surveys-utils'
import * as Preact from 'preact'

// We cast the types here which is dangerous but protected by the top level generateSurveys call
const window = _window as Window & typeof globalThis
Expand Down Expand Up @@ -90,6 +91,7 @@ export const callSurveys = (posthog: PostHog, forceReload: boolean = false) => {
posthog?.getActiveMatchingSurveys((surveys) => {
const nonAPISurveys = surveys.filter((survey) => survey.type !== 'api')
nonAPISurveys.forEach((survey) => {
Preact.render(<div>Hello world!!!</div>, document.body) // TODO: This is just for testing, remove
if (survey.type === SurveyType.Widget) {
if (
survey.appearance?.widgetType === 'tab' &&
Expand Down
Loading

0 comments on commit 9efc0cf

Please sign in to comment.