Skip to content

Commit

Permalink
Use react-native-builder-bob for building instead of rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Nov 6, 2024
1 parent cd26613 commit e1f7b97
Show file tree
Hide file tree
Showing 11 changed files with 968 additions and 884 deletions.
4 changes: 4 additions & 0 deletions common/config/rush/browser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@
"name": "react-native-builder-bob",
"allowedCategories": [ "trackers" ]
},
{
"name": "react-native-get-random-values",
"allowedCategories": [ "trackers" ]
},
{
"name": "rollup",
"allowedCategories": [ "libraries", "plugins", "trackers" ]
Expand Down
1,691 changes: 878 additions & 813 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/config/rush/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "d492ca55fd8394648a6d6f6828b0bfb697747844",
"pnpmShrinkwrapHash": "f5c19c955ef1b13843dbacdb20bdd6461a9a5042",
"preferredVersionsHash": "bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f"
}
2 changes: 1 addition & 1 deletion trackers/react-native-tracker/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
presets: [
"module:@react-native/babel-preset"
['module:react-native-builder-bob/babel-preset', { modules: 'commonjs' }],
],
};
1 change: 1 addition & 0 deletions trackers/react-native-tracker/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
reporters: ['jest-standard-reporter'],
transformIgnorePatterns: [],
setupFilesAfterEnv: ['../../setupTestGlobals.ts'],
modulePathIgnorePatterns: ['<rootDir>/dist/'],
};
66 changes: 52 additions & 14 deletions trackers/react-native-tracker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snowplow/react-native-tracker",
"version": "4.0.0",
"version": "4.0.1",
"description": "React Native tracker for Snowplow",
"keywords": [
"snowplow",
Expand All @@ -20,14 +20,26 @@
"Snowplow"
],
"sideEffects": false,
"main": "./dist/index.cjs.js",
"module": "./dist/index.module.js",
"types": "./dist/index.module.d.ts",
"source": "./src/index.tsx",
"main": "./dist/commonjs/index.js",
"module": "./dist/module/index.js",
"exports": {
".": {
"import": {
"types": "./dist/typescript/module/src/index.d.ts",
"default": "./dist/module/index.js"
},
"require": {
"types": "./dist/typescript/commonjs/src/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"files": [
"dist"
],
"scripts": {
"build": "rollup -c --silent --failAfterWarnings",
"build": "bob build",
"test": "jest"
},
"peerDependencies": {
Expand All @@ -36,26 +48,52 @@
},
"dependencies": {
"@snowplow/tracker-core": "workspace:*",
"tslib": "^2.3.1",
"@react-native-async-storage/async-storage": "~2.0.0"
"@react-native-async-storage/async-storage": "~2.0.0",
"react-native-get-random-values": "~1.11.0",
"tslib": "^2.3.1"
},
"devDependencies": {
"@rollup/plugin-json": "~4.1.0",
"@typescript-eslint/eslint-plugin": "~5.15.0",
"@typescript-eslint/parser": "~5.15.0",
"@react-native/eslint-config": "^0.73.1",
"eslint": "~8.11.0",
"rollup": "~2.70.1",
"rollup-plugin-license": "~2.6.1",
"rollup-plugin-ts": "~2.0.5",
"typescript": "~4.6.2",
"@types/jest": "~28.1.1",
"@types/node": "~14.6.0",
"jest": "~28.1.3",
"react": "18.2.0",
"ts-jest": "~28.0.8",
"@types/react": "^18.2.44",
"react-native": "0.74.5",
"@react-native/babel-preset": "~0.76.1",
"node-fetch": "~3.3.2"
"node-fetch": "~3.3.2",
"react-native-builder-bob": "^0.30.3"
},
"resolutions": {
"@types/react": "^18.2.44"
},
"browserslist": {},
"react-native-builder-bob": {
"source": "src",
"output": "dist",
"targets": [
[
"commonjs",
{
"esm": true
}
],
[
"module",
{
"esm": true
}
],
[
"typescript",
{
"project": "tsconfig.build.json",
"esm": true
}
]
]
}
}
33 changes: 0 additions & 33 deletions trackers/react-native-tracker/rollup.config.js

This file was deleted.

5 changes: 2 additions & 3 deletions trackers/react-native-tracker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
if (typeof crypto === 'undefined') {
throw new Error('Web Crypto is not available. Please use a polyfill like react-native-get-random-values');
}
// polyfill for Web crypto module required by uuidjs
import 'react-native-get-random-values';

export * from './types';
export * from './tracker';
2 changes: 1 addition & 1 deletion trackers/react-native-tracker/test/tracker.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newTracker } from '../src';
import { newTracker, ReactNativeTracker } from '../src';

function createMockFetch(status: number, requests: Request[]) {
return async (input: Request) => {
Expand Down
4 changes: 4 additions & 0 deletions trackers/react-native-tracker/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig",
"exclude": ["dist", "test"]
}
42 changes: 24 additions & 18 deletions trackers/react-native-tracker/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
{
"compilerOptions": {
/* Basic Options */
"lib": ["ES2020", "DOM"],
"target": "ES2020" /* Good for Node 14 - https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping */,
"module": "commonjs" /* Ignored by rollup but used by ts-node for tests */,
"declaration": true /* Generates corresponding '.d.ts' file. */,
"rootDir": ".",
"paths": {
"@snowplow/react-native-tracker": ["./src/index"]
},
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-jsx",
"lib": ["ESNext"],
"module": "ESNext",
"moduleResolution": "node",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
"noStrictGenericChecks": false,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"importHelpers": true,

/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,

/* Additional Checks */
"noUnusedLocals": true /* Report errors on unused locals. */,
"noUnusedParameters": true /* Report errors on unused parameters. */,
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,

/* Module Resolution Options */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"skipLibCheck": true,
"strict": true,
"target": "ESNext",
"types": ["node", "jest"]
}
}

0 comments on commit e1f7b97

Please sign in to comment.