Skip to content

Commit c78c297

Browse files
committed
Stopped bundling navigation react
Can't bundle navigation react and support 'use client'. Bundling puts all components into a single file but 'use client' needs to be applied at the file level. So switched the package task of navigation react to transpile using typescript instead of bundle using rollup. Kept rollup for all other libraries and tasks. Without bundling typescript puts some helper stuff at the top of each file - it used appear just once when it was one big file. To keep this to a minimum removed 'import * as React from 'react';' - this isn't needed anymore because react/typescript adds 'react/jsx-runtime'. Removing this removes the importStar typescript helper stuff. Don't want to 'importHelpers' because then dependent on tslib and don't want any 3rd party dependencies. This stopped the build task from working because it didn't recognise 'react/jsx-runtime'. So added it as an external but there is no umd build for it so the index.html sample won't work anymore. But noticed that [react doesn't support umd builds anymore](facebook/react#28735 (comment)) anyway so will either ditch the build task and index.html sample or switch to esm?! will investigate later. Haven't tried the unbundled navigation react package but the files are generated at least
1 parent 75c867d commit c78c297

17 files changed

+219
-22
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build/dist
2-
build/npm/**/navigation*.js
2+
build/npm/**/*.js
33
build/npm/**/android
44
build/npm/**/ios
55
build/npm/**/cpp

NavigationReact/src/FluentLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
'use client'
12
import LinkUtility from './LinkUtility';
23
import withStateNavigator from './withStateNavigator';
34
import { FluentLinkProps } from './Props';
4-
import * as React from 'react';
55

66
var FluentLink = (props: FluentLinkProps) => {
77
var htmlProps = LinkUtility.toHtmlProps(props);

NavigationReact/src/NavigationBackLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import LinkUtility from './LinkUtility';
1+
'use client'
2+
import LinkUtility from './LinkUtility';
23
import withStateNavigator from './withStateNavigator';
34
import { NavigationBackLinkProps } from './Props';
4-
import * as React from 'react';
55

66
var NavigationBackLink = (props: NavigationBackLinkProps) => {
77
var htmlProps = LinkUtility.toHtmlProps(props);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
import { createContext } from 'react';
12
import { StateNavigator } from 'navigation';
2-
import * as React from 'react';
33

4-
export default React.createContext({ oldState: null, state: null, data: {}, stateNavigator: new StateNavigator() });
4+
export default createContext({ oldState: null, state: null, data: {}, stateNavigator: new StateNavigator() });

NavigationReact/src/NavigationHandler.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
'use client'
2+
import { Component } from 'react';
13
import AsyncStateNavigator from './AsyncStateNavigator';
24
import NavigationContext from './NavigationContext';
35
import { StateNavigator, State } from 'navigation';
4-
import * as React from 'react';
56
type NavigationHandlerState = { context: { oldState: State, state: State, data: any, asyncData: any, stateNavigator: AsyncStateNavigator } };
67

7-
class NavigationHandler extends React.Component<{ stateNavigator: StateNavigator, children: any }, NavigationHandlerState> {
8+
class NavigationHandler extends Component<{ stateNavigator: StateNavigator, children: any }, NavigationHandlerState> {
89
constructor(props) {
910
super(props);
1011
var { stateNavigator } = this.props;

NavigationReact/src/NavigationLink.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import LinkUtility from './LinkUtility';
33
import withStateNavigator from './withStateNavigator';
44
import { NavigationLinkProps } from './Props';
5-
import * as React from 'react';
65

76
var NavigationLink = (props: NavigationLinkProps) => {
87
var htmlProps = LinkUtility.toHtmlProps(props);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import AsyncStateNavigator from './AsyncStateNavigator';
2+
import NavigationContext from './NavigationContext.server';
3+
import NavigationHandler from './NavigationHandler';
4+
import NavigationBackLink from './NavigationBackLink';
5+
import NavigationLink from './NavigationLink';
6+
import RefreshLink from './RefreshLink';
7+
import FluentLink from './FluentLink';
8+
import SceneView from './SceneView.server';
9+
10+
export { AsyncStateNavigator, NavigationContext, NavigationHandler, NavigationBackLink, NavigationLink, RefreshLink, FluentLink, SceneView };

NavigationReact/src/RefreshLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import LinkUtility from './LinkUtility';
1+
'use client'
2+
import LinkUtility from './LinkUtility';
23
import withStateNavigator from './withStateNavigator';
34
import { RefreshLinkProps } from './Props';
4-
import * as React from 'react';
55

66
var RefreshLink = (props: RefreshLinkProps) => {
77
var htmlProps = LinkUtility.toHtmlProps(props);

NavigationReact/src/SceneRSCView.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const SceneRSCView = ({children}) => children;
32

43
export default SceneRSCView;

NavigationReact/src/SceneView.server.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { SceneViewProps } from './Props';
32
import useNavigationEvent from './useNavigationEvent';
43
import SceneRSCView from './SceneRSCView';

0 commit comments

Comments
 (0)