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

Commit 255829e

Browse files
author
Je
committed
refactor: improve nomodule
1 parent b7d9317 commit 255829e

File tree

3 files changed

+53
-36
lines changed

3 files changed

+53
-36
lines changed

nomodule.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

nomodule.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/// <reference lib="dom" />
2+
var el = document.createElement('div')
3+
var hEl = document.createElement('h2')
4+
var pEl = document.createElement('p')
5+
var style: Partial<CSSStyleDeclaration> = {
6+
position: 'fixed',
7+
top: '0',
8+
left: '0',
9+
zIndex: '999',
10+
width: '100%',
11+
margin: '0',
12+
padding: '24px 0',
13+
lineHeight: '1.5',
14+
fontSize: '14px',
15+
color: '#666',
16+
backgroundColor: '#fff9cc',
17+
textAlign: 'center',
18+
boxShadow: '0 1px 5px rgba(0,0,0,0.1)'
19+
}
20+
var hStyle: Partial<CSSStyleDeclaration> = {
21+
margin: '0',
22+
padding: '0',
23+
lineHeight: '1.2',
24+
fontSize: '24px',
25+
fontWeight: '700',
26+
color: '#000',
27+
}
28+
for (var key in style) {
29+
(el.style as any)[key] = style[key]
30+
}
31+
for (var key in hStyle) {
32+
(hEl.style as any)[key] = hStyle[key]
33+
}
34+
hEl.innerText = 'Your browser is out of date.'
35+
var isDev = false
36+
var scripts = document.getElementsByTagName('script')
37+
for (var i = 0; i < scripts.length; i++) {
38+
var s = scripts[i]
39+
if (/nomodule\.js\?dev$/.test(s.src)) {
40+
isDev = true
41+
break
42+
}
43+
}
44+
if (isDev) {
45+
pEl.innerHTML = 'Aleph.js requires <a href="https://caniuse.com/es6-module" style="font-weight:500;color:#000;">ES module</a> support during development.'
46+
} else {
47+
pEl.innerHTML = 'Update your browser for more security, speed and the best experience on this site.'
48+
}
49+
el.appendChild(hEl)
50+
el.appendChild(pEl)
51+
document.body.appendChild(el)

project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class Project {
189189
head: head,
190190
scripts: [
191191
{ src: path.join(baseUrl, `/_aleph/main.${mainModule.hash.slice(0, hashShort)}.js`), type: 'module' },
192-
{ src: path.join(baseUrl, `/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`), nomodule: true },
192+
{ src: path.join(baseUrl, `/_aleph/-/deno.land/x/aleph/nomodule.js${this.isDev ? '?dev' : ''}`) },
193193
],
194194
body,
195195
minify: !this.isDev
@@ -435,7 +435,7 @@ export class Project {
435435
const precompileUrls = [
436436
'https://deno.land/x/aleph/bootstrap.ts',
437437
'https://deno.land/x/aleph/renderer.ts',
438-
'https://deno.land/x/aleph/nomodule.js',
438+
'https://deno.land/x/aleph/nomodule.ts',
439439
'https://deno.land/x/aleph/tsc/tslib.js',
440440
]
441441
if (this.isDev) {

0 commit comments

Comments
 (0)