Skip to content
Merged
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 .changepacks/changepack_log_a-ISwIdvOV7dIVUK64mjV.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"changes":{"packages/next-plugin/package.json":"Patch"},"note":"Fix load issue","date":"2026-01-05T10:24:06.886526500Z"}
60 changes: 30 additions & 30 deletions apps/landing/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { Box } from '@devup-ui/react'
import { Metadata } from 'next'

import { Container } from '@/components/Container'
import { Discord } from '@/components/Discord'

import { Bench } from './Bench'
import { Feature } from './Feature'
import { TopBanner } from './TopBanner'

export const metadata: Metadata = {
alternates: {
canonical: '/',
},
}

export default function HomePage() {
return (
<>
<TopBanner />
<Bench />
<Feature />
<Container>
<Box px={4} py="40px">
<Discord />
</Box>
</Container>
</>
)
}
import { Box } from '@devup-ui/react'
import { Metadata } from 'next'
import { Container } from '@/components/Container'
import { Discord } from '@/components/Discord'
import { Bench } from './Bench'
import { Feature } from './Feature'
import { TopBanner } from './TopBanner'
export const metadata: Metadata = {
alternates: {
canonical: '/',
},
}
export default function HomePage() {
return (
<>
<TopBanner />
<Bench />
<Feature />
<Container>
<Box px={4} py="40px">
<Discord />
</Box>
</Container>
</>
)
}
20 changes: 10 additions & 10 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions packages/next-plugin/src/__tests__/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
spyOn,
} from 'bun:test'

import devupUILoader from '../loader'
import devupUILoader, { resetInit } from '../loader'

let existsSyncSpy: ReturnType<typeof spyOn>
let readFileSyncSpy: ReturnType<typeof spyOn>
Expand All @@ -30,6 +30,7 @@ let registerThemeSpy: ReturnType<typeof spyOn>
let dateNowSpy: ReturnType<typeof spyOn>

beforeEach(() => {
resetInit()
existsSyncSpy = spyOn(fs, 'existsSync').mockReturnValue(false)
readFileSyncSpy = spyOn(fs, 'readFileSync').mockReturnValue('{}')
writeFileSpy = spyOn(fsPromises, 'writeFile').mockResolvedValue(undefined)
Expand Down Expand Up @@ -75,9 +76,7 @@ const waitFor = async (fn: () => void, timeout = 1000) => {
}

describe('devupUILoader', () => {
// TEST ORDER MATTERS: First test for each mode initializes that mode

// 1. First test for BUILD mode (watch: false) - covers non-watch init (lines 70-74)
// Test BUILD mode init (lines 68-73)
it('should use default maps in non-watch mode on init', async () => {
const asyncCallback = mock()
const defaultClassMap = { test: 'classMap' }
Expand Down Expand Up @@ -116,14 +115,14 @@ describe('devupUILoader', () => {
expect(asyncCallback).toHaveBeenCalledWith(null, 'code', null)
})

// Verify non-watch init was executed
// Verify non-watch init was executed (lines 68-73)
expect(importFileMapSpy).toHaveBeenCalledWith(defaultFileMap)
expect(importClassMapSpy).toHaveBeenCalledWith(defaultClassMap)
expect(importSheetSpy).toHaveBeenCalledWith(defaultSheet)
expect(registerThemeSpy).toHaveBeenCalledWith(theme)
})

// 2. First test for WATCH mode - covers watch init (lines 57-69) AND css writing (lines 96-112)
// Test WATCH mode init (lines 55-67) + CSS writing (lines 94-111)
it('should initialize watch mode and write css files', async () => {
existsSyncSpy.mockReturnValue(true)
readFileSyncSpy.mockReturnValue(
Expand Down Expand Up @@ -167,20 +166,23 @@ describe('devupUILoader', () => {
expect(asyncCallback).toHaveBeenCalledWith(null, 'code', {})
})

// Verify watch mode init was executed
// Verify watch mode init was executed (lines 55-67)
expect(existsSyncSpy).toHaveBeenCalledWith('sheetFile')
expect(existsSyncSpy).toHaveBeenCalledWith('classMapFile')
expect(existsSyncSpy).toHaveBeenCalledWith('fileMapFile')
expect(existsSyncSpy).toHaveBeenCalledWith('themeFile')
expect(registerThemeSpy).toHaveBeenCalledWith({
colors: { primary: '#fff' },
})

// Verify updatedBaseStyle && watch branch (lines 96-100)
// Verify updatedBaseStyle && watch branch (lines 94-99)
expect(writeFileSpy).toHaveBeenCalledWith(
join('cssDir', 'devup-ui.css'),
'base-css',
'utf-8',
)

// Verify cssFile && watch branch (lines 102-112)
// Verify cssFile && watch branch (lines 100-111)
expect(writeFileSpy).toHaveBeenCalledWith(
join('cssDir', 'devup-ui-1.css'),
'/* watch-init.tsx 0 */',
Expand All @@ -190,8 +192,6 @@ describe('devupUILoader', () => {
expect(writeFileSpy).toHaveBeenCalledWith('fileMapFile', 'fileMap')
})

// Remaining tests - init already done for both modes

it('should extract code without css in watch mode', async () => {
const asyncCallback = mock()
const t = {
Expand Down
13 changes: 8 additions & 5 deletions packages/next-plugin/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export interface DevupUILoaderOptions {
defaultClassMap: object
defaultFileMap: object
}
// Track initialization per mode (watch vs non-watch are separate configurations)
const initialized = { watch: false, build: false }
let init = false

const devupUILoader: RawLoaderDefinitionFunction<DevupUILoaderOptions> =
function (source) {
Expand All @@ -51,9 +50,8 @@ const devupUILoader: RawLoaderDefinitionFunction<DevupUILoaderOptions> =
} = this.getOptions()

const promises: Promise<void>[] = []
const mode = watch ? 'watch' : 'build'
if (!initialized[mode]) {
initialized[mode] = true
if (!init) {
init = true
if (watch) {
// restart loader issue
// loader should read files when they exist in watch mode
Expand Down Expand Up @@ -122,3 +120,8 @@ const devupUILoader: RawLoaderDefinitionFunction<DevupUILoaderOptions> =
return
}
export default devupUILoader

/** @internal Reset init state for testing purposes only */
export const resetInit = () => {
init = false
}