-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert to exportig derby instance from index; not publishing types
- Loading branch information
Showing
4 changed files
with
31 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { AppBase } from './App'; | ||
import { AppForServer } from './AppForServer'; | ||
import { DerbyBase } from './Derby'; | ||
import { PageForServer } from './PageForServer'; | ||
|
||
export class DerbyForServer extends DerbyBase { | ||
App: typeof AppForServer = AppForServer; | ||
Page: typeof PageForServer = PageForServer; | ||
|
||
createApp(name: string, filename: string, options: any): AppBase<object> { | ||
return new this.App(this, name, filename, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,9 @@ | ||
import { util } from 'racer'; | ||
import { Derby } from './Derby'; | ||
|
||
import { AppBase as AppClass, type App } from './App'; | ||
import { type AppForServer } from './AppForServer'; | ||
import { PageBase as PageClass } from './Page'; | ||
|
||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
if (util.isServer) { | ||
// @ts-expect-error Required tomfoolery for isomorphic things | ||
AppClass = require('./App').App; | ||
// @ts-expect-error Required tomfoolery for isomorphic things | ||
PageClass = require('./Page').Page; | ||
} else { | ||
// @ts-expect-error Required tomfoolery for isomorphic things | ||
AppClass = require('./AppForServer').AppForServer; | ||
// @ts-expect-error Required tomfoolery for isomorphic things | ||
PageClass = require('./PageForServer').PageForServer; | ||
} | ||
/* eslint-enable @typescript-eslint/no-var-requires */ | ||
|
||
export { Component } from './components'; | ||
export { AppClass as App }; | ||
export { PageClass as Page }; | ||
export { type PageParams, type QueryParams } from './routes'; | ||
export { Dom } from './Dom'; | ||
export { util }; | ||
|
||
export function createApp(name: string, filename: string, options) { | ||
if (util.isServer) { | ||
return new (AppClass as unknown as typeof AppForServer)({ Page: PageClass }, name, filename, options); | ||
} else { | ||
return new (AppClass as unknown as typeof App)({ Page: PageClass }, name, filename, options); | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const util = require('racer').util; | ||
|
||
const DerbyClass = util.isServer | ||
? util.serverRequire(module, './DerbyForServer').DerbyForServer | ||
: Derby; | ||
export = new DerbyClass(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters