diff --git a/.changeset/hungry-donuts-wave.md b/.changeset/hungry-donuts-wave.md new file mode 100644 index 0000000..2d0031c --- /dev/null +++ b/.changeset/hungry-donuts-wave.md @@ -0,0 +1,5 @@ +--- +"@noriginmedia/norigin-spatial-navigation-react-native-tvos": patch +--- + +- Add extra compatibility for web bundlers like Vite or Webpack when using with React Native Web diff --git a/packages/react-native-tvos/package.json b/packages/react-native-tvos/package.json index bcc900e..5ab2bcf 100644 --- a/packages/react-native-tvos/package.json +++ b/packages/react-native-tvos/package.json @@ -7,6 +7,8 @@ "types": "dist/index.d.ts", "exports": { ".": { + "react-native": "./dist/index.mjs", + "browser": "./dist/index.web.mjs", "import": "./dist/index.mjs", "require": "./dist/index.cjs", "types": "./dist/index.d.ts" diff --git a/packages/react-native-tvos/rollup.config.mjs b/packages/react-native-tvos/rollup.config.mjs index 1d9ca3f..57faaf3 100644 --- a/packages/react-native-tvos/rollup.config.mjs +++ b/packages/react-native-tvos/rollup.config.mjs @@ -4,12 +4,7 @@ import commonjs from '@rollup/plugin-commonjs'; import typescript from '@rollup/plugin-typescript'; import { defineConfig } from 'rollup'; -export default defineConfig({ - input: 'src/index.ts', - output: [ - { file: 'dist/index.mjs', format: 'es' }, - { file: 'dist/index.cjs', format: 'cjs' } - ], +const baseConfig = { external: [ '@noriginmedia/norigin-spatial-navigation-core', '@noriginmedia/norigin-spatial-navigation-react', @@ -18,4 +13,23 @@ export default defineConfig({ 'react-native' ], plugins: [resolve(), commonjs(), typescript({ tsconfig: './tsconfig.json' })] -}); +}; + +export default defineConfig([ + { + input: 'src/index.ts', + output: [ + { file: 'dist/index.mjs', format: 'es' }, + { file: 'dist/index.cjs', format: 'cjs' } + ], + ...baseConfig + }, + { + input: 'src/index.web.ts', + output: [ + { file: 'dist/index.web.mjs', format: 'es' }, + { file: 'dist/index.web.cjs', format: 'cjs' } + ], + ...baseConfig + } +]); diff --git a/packages/react-native-tvos/src/index.web.ts b/packages/react-native-tvos/src/index.web.ts new file mode 100644 index 0000000..8f44801 --- /dev/null +++ b/packages/react-native-tvos/src/index.web.ts @@ -0,0 +1,2 @@ +export { BaseWebAdapter as ReactNativeLayoutAdapter } from '@noriginmedia/norigin-spatial-navigation-core'; +export * from '@noriginmedia/norigin-spatial-navigation-react';