Skip to content

Commit

Permalink
fix(one): remove top level unused imports from api routes in esm mode…
Browse files Browse the repository at this point in the history
… by default
  • Loading branch information
natew committed Oct 6, 2024
1 parent fe66a14 commit aa99c57
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/one-fullstack/app/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function SignIn() {

if (!user)
return (
<YStack mih="100vh" miw="100vw" ai="center" jc="center" p="$2">
<YStack mih="100%" miw="100%" ai="center" jc="center" p="$2">
<YStack miw={300} maw={320} jc="space-between" p="$2" gap="$4">
<YStack mb="$4">
<LogoIcon />
Expand Down
2 changes: 2 additions & 0 deletions next.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ should have some sprints with "challenges":

# backlog

- need a way ton configure the api + server etc during production builds

- style tag to CSS, we could have a mode that takes style tags with precedense/key set and have a mode to optimize that to css

- perf - in dev mode collectStyle is called a ton on each load
Expand Down
14 changes: 13 additions & 1 deletion packages/one/src/vite/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import Path, { join, relative } from 'node:path'
import type { OutputAsset } from 'rollup'
import { nodeExternals } from 'rollup-plugin-node-externals'
import { mergeConfig, build as viteBuild, type InlineConfig } from 'vite'
import { fillOptions, getOptimizeDeps, build as vxrnBuild, type ClientManifestEntry } from 'vxrn'
import {
fillOptions,
getOptimizeDeps,
rollupRemoveUnusedImportsPlugin,
build as vxrnBuild,
type ClientManifestEntry,
} from 'vxrn'
import { getLoaderPath, getPreloadPath } from '../cleanUrl'
import type { RouteInfo } from '../server/createRoutesManifest'
import type { LoaderProps, RenderApp } from '../types'
Expand Down Expand Up @@ -117,6 +123,12 @@ export async function build(args: {
treeshake: {
moduleSideEffects: 'no-external',
},

plugins: [
// otherwise rollup is leaving commonjs-only top level imports...
apiOutputFormat === 'esm' ? rollupRemoveUnusedImportsPlugin : null,
].filter(Boolean),

// too many issues
// treeshake: {
// moduleSideEffects: false,
Expand Down

0 comments on commit aa99c57

Please sign in to comment.