Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit a9a328c

Browse files
committed
refactor: clean up
1 parent a9614ed commit a9a328c

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

server/app.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { colors, createHash, ensureDir, path, walk } from '../deps.ts'
33
import { EventEmitter } from '../framework/core/events.ts'
44
import { moduleExts, toPagePath, trimModuleExt } from '../framework/core/module.ts'
55
import { Routing, RouteModule } from '../framework/core/routing.ts'
6-
import {
7-
defaultReactVersion,
8-
minDenoVersion,
9-
10-
} from '../shared/constants.ts'
6+
import { defaultReactVersion, minDenoVersion } from '../shared/constants.ts'
117
import {
128
ensureTextFile,
139
existsDirSync,
@@ -65,7 +61,8 @@ export class Application implements ServerApplication {
6561
reload = false
6662
) {
6763
if (Deno.version.deno < minDenoVersion) {
68-
log.fatal(`need Deno ${minDenoVersion}+, but got ${Deno.version.deno}`)
64+
log.error(`Aleph.js needs Deno ${minDenoVersion}+, please upgrade Deno.`)
65+
Deno.exit(1)
6966
}
7067
this.workingDir = path.resolve(workingDir)
7168
this.mode = mode
@@ -90,6 +87,24 @@ export class Application implements ServerApplication {
9087
Deno.env.set('ALEPH_VERSION', VERSION)
9188
Deno.env.set('BUILD_MODE', this.mode)
9289

90+
// inject browser navigator polyfill
91+
Object.assign((globalThis as any).navigator, {
92+
connection: {
93+
downlink: 10,
94+
effectiveType: "4g",
95+
onchange: null,
96+
rtt: 50,
97+
saveData: false,
98+
},
99+
cookieEnabled: false,
100+
language: 'en',
101+
languages: ['en'],
102+
onLine: true,
103+
platform: Deno.build.os,
104+
userAgent: `Deno/${Deno.version.deno}`,
105+
vendor: 'Deno Land'
106+
})
107+
93108
const alephPkgUri = getAlephPkgUri()
94109
const buildManifestFile = path.join(this.buildDir, 'build.manifest.json')
95110
const configHash = computeHash(JSON.stringify({

server/helper.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@ import { VERSION } from '../version.ts'
77
export const reLocaleID = /^[a-z]{2}(-[a-zA-Z0-9]+)?$/
88
export const reFullVersion = /@v?\d+\.\d+\.\d+/i
99

10-
// inject browser navigator polyfill
11-
Object.assign(globalThis.navigator, {
12-
connection: {
13-
downlink: 10,
14-
effectiveType: "4g",
15-
onchange: null,
16-
rtt: 50,
17-
saveData: false,
18-
},
19-
cookieEnabled: false,
20-
language: 'en',
21-
languages: ['en'],
22-
onLine: true,
23-
platform: Deno.build.os,
24-
userAgent: `Deno/${Deno.version.deno}`,
25-
vendor: 'Deno Land'
26-
})
27-
2810
/** check the plugin whether is a loader plugin. */
2911
export function isLoaderPlugin(plugin: Plugin): plugin is LoaderPlugin {
3012
return plugin.type === 'loader'

0 commit comments

Comments
 (0)