Skip to content

Commit 2a43306

Browse files
committed
feat: switch to esm
1 parent 5083d53 commit 2a43306

16 files changed

Lines changed: 2383 additions & 674 deletions

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "all",
3+
"singleQuote": true,
4+
"semi": true,
5+
"printWidth": 150,
6+
"tabWidth": 2
7+
}

babel.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
module.exports = {
1+
export default {
22
overrides: [
33
{
44
exclude: /\/node_modules\//,
5-
presets: ['module:react-native-builder-bob/babel-preset'],
6-
plugins: ['babel-plugin-react-compiler'],
5+
presets: ["module:react-native-builder-bob/babel-preset"],
6+
plugins: ["babel-plugin-react-compiler"],
77
},
88
{
99
include: /\/node_modules\//,
10-
presets: ['module:@react-native/babel-preset'],
10+
presets: ["module:@react-native/babel-preset"],
1111
},
1212
],
1313
};

eslint.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { reactNativeConfigs } from "@goatjs/react-native-eslint";
2+
import { defineConfig, globalIgnores } from "@eslint/config-helpers";
3+
4+
// TODO move the rules on the eslint package or remove them
5+
6+
export default defineConfig(
7+
globalIgnores([".yarn/**", "android/**", "ios/**", "lib"]),
8+
...reactNativeConfigs({ tsconfigRootDir: import.meta.dirname }),
9+
);

eslint.config.mjs

Lines changed: 0 additions & 27 deletions
This file was deleted.

example/babel.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const path = require('path');
2-
const { getConfig } = require('react-native-builder-bob/babel-config');
3-
const pkg = require('../package.json');
1+
import path from 'node:path';
2+
import { getConfig } from 'react-native-builder-bob/babel-config';
3+
import pkg from '../package.json' with { type: 'json' };
44

5-
const root = path.resolve(__dirname, '..');
5+
const root = path.resolve(import.meta.dirname, '..');
66

7-
module.exports = getConfig(
7+
export default getConfig(
88
{
99
presets: ['module:@react-native/babel-preset'],
1010
plugins: ['babel-plugin-react-compiler'],

example/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module.exports = {
1+
export default {
22
preset: '@react-native/jest-preset',
33
};

example/metro.config.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
const path = require('path');
2-
const { getDefaultConfig } = require('@react-native/metro-config');
3-
const { withMetroConfig } = require('react-native-monorepo-config');
1+
import path from 'node:path';
2+
import { getDefaultConfig } from '@react-native/metro-config';
3+
/** @ts-expect-error idk man, ok. */
4+
import { withMetroConfig } from 'react-native-monorepo-config';
45

5-
const root = path.resolve(__dirname, '..');
6+
const root = path.resolve(import.meta.dirname, '..');
67

78
/**
89
* Metro configuration
910
* https://facebook.github.io/metro/docs/configuration
1011
*
1112
* @type {import('metro-config').MetroConfig}
1213
*/
13-
const config = withMetroConfig(getDefaultConfig(__dirname), {
14+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
15+
const config = withMetroConfig(getDefaultConfig(import.meta.dirname), {
1416
root,
15-
dirname: __dirname,
17+
dirname: import.meta.dirname,
1618
resetCache: true,
1719
});
1820

19-
module.exports = config;
21+
export default config;

example/package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
"name": "react-native-nitro-notification-example",
33
"version": "0.0.1",
44
"private": true,
5+
"description": "React Native Nitro Notification Example",
6+
"type": "module",
57
"scripts": {
68
"android": "react-native run-android",
7-
"ios": "react-native run-ios",
8-
"start": "node tools/metro.ts",
9-
"pod": "cd ios && pod install",
109
"build:android": "react-native build-android --extra-params \"--no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a\"",
1110
"build:ios": "react-native build-ios --mode Debug",
11+
"ios": "react-native run-ios",
12+
"maestro": "node tools/maestro.ts",
13+
"pod": "cd ios && pod install",
1214
"push-relay": "node --env-file .env.push tools/push-relay.ts",
13-
"maestro": "node tools/maestro.ts"
15+
"start": "node tools/metro.ts"
1416
},
1517
"dependencies": {
16-
"@react-navigation/native": "^7.2.5",
17-
"@react-navigation/native-stack": "^7.16.0",
18+
"@react-navigation/native": "^7.3.2",
19+
"@react-navigation/native-stack": "^7.17.4",
1820
"react": "19.2.3",
19-
"react-native": "0.85.3",
21+
"react-native": "0.86.0",
2022
"react-native-nitro-modules": "^0.35.9",
2123
"react-native-safe-area-context": "^5.8.0",
2224
"react-native-screens": "^4.25.2"
@@ -28,14 +30,14 @@
2830
"@react-native-community/cli": "20.1.3",
2931
"@react-native-community/cli-platform-android": "20.1.3",
3032
"@react-native-community/cli-platform-ios": "20.1.3",
31-
"@react-native/babel-preset": "0.85.3",
32-
"@react-native/jest-preset": "0.85.3",
33-
"@react-native/metro-config": "0.85.3",
34-
"@react-native/typescript-config": "0.85.3",
33+
"@react-native/babel-preset": "0.86.0",
34+
"@react-native/jest-preset": "0.86.0",
35+
"@react-native/metro-config": "0.86.0",
36+
"@react-native/typescript-config": "0.86.0",
3537
"@types/react": "^19.2.17",
3638
"babel-plugin-react-compiler": "1.0.0",
3739
"execa": "^9.6.1",
38-
"react-native-builder-bob": "^0.41.0",
40+
"react-native-builder-bob": "^0.42.1",
3941
"react-native-monorepo-config": "^0.3.5"
4042
},
4143
"engines": {

example/react-native.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const path = require('path');
2-
const pkg = require('../package.json');
1+
import path from 'node:path';
2+
import pkg from '../package.json' with { type: 'json' };
33

4-
module.exports = {
4+
export default {
55
dependencies: {
66
[pkg.name]: {
7-
root: path.join(__dirname, '..'),
7+
root: path.join(import.meta.dirname, '..'),
88
platforms: {
99
// Codegen script incorrectly fails without this
1010
// So we explicitly specify the platforms with empty object

example/tools/maestro.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
/* eslint-disable no-restricted-properties */
2+
/* eslint-disable no-console */
13
import { execa } from 'execa';
2-
import path from 'node:path';
34
import { createPushRelay } from './push-relay.ts';
5+
import path from 'node:path';
46

57
const EXAMPLE_DIR = path.resolve(import.meta.dirname, '..');
68
const MAESTRO_DIR = path.join(EXAMPLE_DIR, '.maestro');
7-
const RELAY_PORT = process.env.PUSH_RELAY_PORT ?? '8765';
9+
const RELAY_PORT = process.env['PUSH_RELAY_PORT'] ?? '8765';
810

911
const startRelay = async (): Promise<{ stop: () => Promise<void> }> => {
1012
const server = createPushRelay();
@@ -13,17 +15,18 @@ const startRelay = async (): Promise<{ stop: () => Promise<void> }> => {
1315
});
1416
console.log(`[push-relay] listening on http://127.0.0.1:${RELAY_PORT}`);
1517
return {
16-
stop: () => new Promise((resolve) => server.close(resolve)),
18+
stop: () =>
19+
new Promise((resolve, reject) =>
20+
server.close((err) => {
21+
if (err) reject(err);
22+
resolve();
23+
}),
24+
),
1725
};
1826
};
1927

2028
const runMaestroTests = async (): Promise<void> => {
21-
const flows = [
22-
'01_permissions_denied.yaml',
23-
'02_permissions_granted.yaml',
24-
'03_foreground_notification.yaml',
25-
'04_background_notification.yaml',
26-
];
29+
const flows = ['01_permissions_denied.yaml', '02_permissions_granted.yaml', '03_foreground_notification.yaml', '04_background_notification.yaml'];
2730

2831
for (const flow of flows) {
2932
console.log(`\n[maestro] running ${flow}...`);
@@ -34,21 +37,17 @@ const runMaestroTests = async (): Promise<void> => {
3437
}
3538
};
3639

37-
const main = async (): Promise<void> => {
38-
console.log('[maestro] starting push relay...');
39-
const relay = await startRelay();
40-
41-
try {
42-
console.log('[maestro] running tests...');
43-
await runMaestroTests();
44-
console.log('[maestro] all tests passed');
45-
} catch (err) {
46-
console.error('[maestro] test run failed:', err);
47-
process.exitCode = 1;
48-
} finally {
49-
console.log('[maestro] stopping push relay...');
50-
await relay.stop();
51-
}
52-
};
40+
console.log('[maestro] starting push relay...');
41+
const relay = await startRelay();
5342

54-
await main();
43+
try {
44+
console.log('[maestro] running tests...');
45+
await runMaestroTests();
46+
console.log('[maestro] all tests passed');
47+
} catch (err) {
48+
console.error('[maestro] test run failed:', err);
49+
process.exitCode = 1;
50+
} finally {
51+
console.log('[maestro] stopping push relay...');
52+
await relay.stop();
53+
}

0 commit comments

Comments
 (0)