Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sandbox, show breaking react-native-webview #214

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"fix": "manypkg fix",
"lint:fix": "ultra -r --no-pretty lint:fix",
"lint": "ultra -r --no-pretty lint",
"sandbox": "yarn workspace test-sandbox dev",
"dev:example": "node -r esbuild-register ./scripts/dev.ts example",
"dev:test": "node -r esbuild-register ./scripts/dev.ts test",
"upgrade:tamagui": "yarn up '*tamagui*' '@tamagui/*'",
Expand Down
4 changes: 4 additions & 0 deletions packages/vite-native-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ async function fetchUpdate({

if (!mod) {
console.info(` ❶ hmr - No module found`)
console.info(` looked for ${path} in:`)
hotModulesMap.forEach((value, key) => {
console.info(` - ${key}`)
})
// In a code-splitting project,
// it is common that the hot-updating module is not loaded yet.
// https://github.com/vitejs/vite/issues/721
Expand Down
44 changes: 44 additions & 0 deletions tests/sandbox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.turbo

tmp
dist
node_modules

*.tsbuildinfo
*.tmp.js

yarn-error.log
tsconfig.tsbuildinfo
.DS_Store

.tamagui

.idea

.env
# local env files
.env.local
.env.development.local
.env.test.localp
.env.production.local

.expo

# generated code
/build
/ios
/android

# testing
/xcodebuild.log
/dev-server.pid
/dev-server.log
/maestro-screenshots
/test-bundle-output
28 changes: 28 additions & 0 deletions tests/sandbox/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import '@tamagui/core/reset.css'
import { SchemeProvider, useColorScheme } from '@vxrn/color-scheme'
import { TamaguiProvider } from 'tamagui'
import { LoadProgressBar, Slot } from 'one'
import config from '../src/tamagui.config'

export default function Layout() {
return (
<>
<LoadProgressBar />
<SchemeProvider>
<TamaguiRootProvider>
<Slot />
</TamaguiRootProvider>
</SchemeProvider>
</>
)
}

const TamaguiRootProvider = ({ children }: { children: React.ReactNode }) => {
const [scheme] = useColorScheme()

return (
<TamaguiProvider disableInjectCSS config={config} defaultTheme={scheme}>
{children}
</TamaguiProvider>
)
}
26 changes: 26 additions & 0 deletions tests/sandbox/app/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Text, View } from 'react-native'
import WebView from 'react-native-webview'

const filename = import.meta.dirname + '/static.html'
console.log('filename', filename)

export default () => (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Welcome to VXS</Text>
<Text>Welcome to VXS</Text>
<Text>Welcome to VXS</Text>
<Text>Welcome to VXS</Text>

<WebView
style={{
flex: 1,
width: '100%',
height: '100%',
}}
source={{
uri: './static.html',
}}
originWhitelist={['*']}
/>
</View>
)
1 change: 1 addition & 0 deletions tests/sandbox/app/static.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>hello world hello world hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world</div>
78 changes: 78 additions & 0 deletions tests/sandbox/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.1/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"ignore": ["**/*/generated-new.ts", "**/*/generated-v2.ts", ".tamagui"],
"rules": {
"correctness": {
"useExhaustiveDependencies": "off",
"noInnerDeclarations": "off",
"noUnnecessaryContinue": "off",
"noConstructorReturn": "off"
},
"suspicious": {
"noImplicitAnyLet": "off",
"noConfusingVoidType": "off",
"noEmptyInterface": "off",
"noExplicitAny": "off",
"noArrayIndexKey": "off",
"noDoubleEquals": "off",
"noConsoleLog": "error",
"noAssignInExpressions": "off",
"noRedeclare": "off"
},
"style": {
"noParameterAssign": "off",
"noNonNullAssertion": "off",
"noArguments": "off",
"noUnusedTemplateLiteral": "off",
"useDefaultParameterLast": "off",
"useConst": "off",
"useEnumInitializers": "off",
"useTemplate": "off",
"useSelfClosingElements": "off"
},
"security": {
"noDangerouslySetInnerHtml": "off",
"noDangerouslySetInnerHtmlWithChildren": "off"
},
"performance": {
"noDelete": "off",
"noAccumulatingSpread": "off"
},
"complexity": {
"noForEach": "off",
"noBannedTypes": "off",
"useLiteralKeys": "off",
"useSimplifiedLogicExpression": "off",
"useOptionalChain": "off"
},
"a11y": {
"noSvgWithoutTitle": "off",
"useMediaCaption": "off",
"noHeaderScope": "off",
"useAltText": "off",
"useButtonType": "off"
}
}
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100,
"ignore": ["**/*/generated-new.ts", "**/*/generated-v2.ts", ".tamagui"]
},
"javascript": {
"formatter": {
"trailingComma": "es5",
"jsxQuoteStyle": "double",
"semicolons": "asNeeded",
"quoteStyle": "single"
}
}
}
31 changes: 31 additions & 0 deletions tests/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "test-sandbox",
"version": "1.1.327",
"private": true,
"type": "module",
"scripts": {
"dev": "one dev",
"prod": "one build && one serve",
"dev:clean": "one dev --clean",
"clean": "one clean",
"build:web": "one build",
"serve": "one serve"
},
"dependencies": {
"@tamagui/config": "^1.116.7",
"@tamagui/image-next": "^1.116.7",
"@tamagui/lucide-icons": "^1.116.7",
"@tamagui/vite-plugin": "^1.116.7",
"@vxrn/color-scheme": "1.1.327",
"one": "1.1.327",
"react": "^18.3.1",
"react-native": "0.74.5",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
"react-native-web": "^0.19.12",
"react-native-webview": "^13.11.1",
"tamagui": "^1.116.7"
}
}
12 changes: 12 additions & 0 deletions tests/sandbox/routes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { OneRouter } from 'one'

declare module 'one' {
export namespace OneRouter {
export interface __routes<T extends string = string> extends Record<string, unknown> {
StaticRoutes: `/` | `/_sitemap`
DynamicRoutes: never
DynamicRouteTemplate: never
IsTyped: true
}
}
}
40 changes: 40 additions & 0 deletions tests/sandbox/src/tamagui.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { config as configOptions } from '@tamagui/config/v3'
import { createTamagui } from '@tamagui/core'

export const config = createTamagui({
...configOptions,
themes: {
...configOptions.themes,
light: {
...configOptions.themes.light,
background: 'white',
color: 'black',
},
dark: {
...configOptions.themes.dark,
background: 'black',
color: 'white',
},
},
media: {
...configOptions.media,
xsTouch: {
maxWidth: configOptions.media.xs.maxWidth,
pointer: 'coarse',
},
},
settings: {
...configOptions.settings,
fastSchemeChange: true,
// avoids CSS bloat so long as you don't need nesting of dark/light themes
maxDarkLightNesting: 2,
},
})

export type Conf = typeof config

declare module '@tamagui/core' {
interface TamaguiCustomConfig extends Conf {}
}

export default config
55 changes: 55 additions & 0 deletions tests/sandbox/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"outDir": "dist",
"paths": {
"~/*": ["./*"]
},
"importHelpers": true,
"allowJs": false,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"downlevelIteration": true,
"strict": true,
"esModuleInterop": true,
"inlineSourceMap": true,
"preserveSymlinks": true,
"jsx": "react-jsx",
"module": "Preserve",
"moduleResolution": "Bundler",
"noEmit": false,
"noEmitOnError": false,
"noImplicitAny": false,
"noImplicitReturns": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveConstEnums": true,
"removeComments": false,
"skipLibCheck": true,
"sourceMap": false,
"strictNullChecks": true,
"target": "es2020",
"types": [
"node",
"react",
"vite/client"
],
"lib": [
"dom",
"esnext"
]
},
"exclude": [
"node_modules",
".expo",
"**/test",
"**/dist",
"**/types",
"**/__tests__"
],
"typeAcquisition": {
"enable": true
}
}
24 changes: 24 additions & 0 deletions tests/sandbox/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { UserConfig } from 'vite'
import { one } from 'one/vite'

export default {
plugins: [
one({
web: {
defaultRenderMode: 'ssg',
},

app: {
key: 'one-example',
},

config: {
tsConfigPaths: {
// On CI, the mono-repo may be partially installed and built.
// While the `tsconfig-paths` plugin might attempt to parsing `tsconfig.json` other apps in the mono-repo and give us errors such as `failed to resolve "extends":"expo/tsconfig.base"`, we will ignore these errors.
ignoreConfigErrors: true,
},
},
}),
],
} satisfies UserConfig
Loading
Loading