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

Update AppOptions to include script* attributes #647

Merged
merged 2 commits into from
Oct 24, 2024
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
21 changes: 20 additions & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,26 @@ export function createAppPage(derby): typeof Page {

export interface AppOptions {
appMetadata?: Record<string, string>,
scriptHash?: string,
/**
* Base URL that the JS bundles are served from, with no trailing slash.
* Used by bundler plugins such as derby-webpack and derby-browserify.
*/
scriptBaseUrl?: string,
/**
* If true, then Derby's <script> tags have the `crossorigin` attribute set by the bundler plugin.
*/
scriptCrossOrigin?: boolean,
/**
* If set, this is used for auto-refresh in development to determine whether the browser
* should auto-refresh due to running different code than the server. Some bundler plugins,
* such as derby-webpack, do their own hot reload and don't use this mechanism.
*/
scriptHash?: string;
/**
* Base URL for js.map files, if different from scriptBaseUrl.
*/
scriptMapBaseUrl?: string,
[key: string]: unknown,
}

type OnRouteCallback = (this: Page, page: Page, model: Model, params: PageParams, done?: () => void) => void;
Expand Down
4 changes: 2 additions & 2 deletions src/AppForServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import * as racer from 'racer';

import { App } from './App';
import { App, AppOptions } from './App';
import { type Derby } from './Derby';
import { type StyleCompilerOptions } from './files';
import { PageForServer } from './PageForServer';
Expand Down Expand Up @@ -79,7 +79,7 @@ export class AppForServer extends App {
watchFiles: boolean;
router: any;

constructor(derby: Derby, name: string, filename: string, options) {
constructor(derby: Derby, name: string, filename: string, options?: AppOptions) {
super(derby, name, filename, options);
this._init(options);
}
Expand Down
Loading