GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — :construction: minify improvements · nullstack/nullstack@6e815a1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • package.json
  • scripts
    • index.js
  • server
    • registry.js
    • runtime.js
  • tests
    • package.json
    • src
      • Element.njs
      • Element.test.js
      • LazyComponent.njs
      • LazyComponentLoader.njs
      • RenderableComponent.njs
    • webpack.config.js
  • webpack
    • devtool.js
    • module.js
    • optimization.js
    • output.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@
4646
"webpack-dev-server": "4.11.1",
4747
"webpack-hot-middleware": "^2.25.3",
4848
"ws": "8.12.0"
49+
},
50+
"resolutions": {
51+
"terser": "npm:@swc/core"
4952
}
5053
}
Collapse file

‎scripts/index.js‎

Copy file name to clipboardExpand all lines: scripts/index.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async function start({ port, env, disk, loader = 'swc' }) {
5858

5959
function build({ output, cache, env, mode = 'ssr' }) {
6060
const environment = 'production'
61-
const compiler = getCompiler({ environment, cache })
61+
const compiler = getCompiler({ environment, cache, loader: 'swc' })
6262
if (env) {
6363
process.env.NULLSTACK_ENVIRONMENT_NAME = env
6464
}
Collapse file

‎server/registry.js‎

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,47 @@
11
const registry = {}
22
export default registry
3+
import reqres from "./reqres"
4+
import { generateContext } from "./context"
35

46
export function register(klass, functionName) {
57
if (functionName) {
68
registry[`${klass.hash}.${functionName}`] = klass[functionName]
79
} else {
810
registry[klass.hash] = klass
11+
bindStaticProps(klass)
12+
}
13+
}
14+
15+
function bindStaticProps(klass) {
16+
let parent = klass
17+
while (parent.name !== 'Nullstack') {
18+
const props = Object.getOwnPropertyNames(parent)
19+
for (const prop of props) {
20+
const underscored = prop.startsWith('_')
21+
if (typeof klass[prop] === 'function') {
22+
if (!underscored && !registry[`${parent.hash}.${prop}`]) {
23+
return
24+
}
25+
const propName = `__NULLSTACK_${prop}`
26+
if (!klass[propName]) {
27+
klass[propName] = klass[prop]
28+
}
29+
function _invoke(...args) {
30+
if (underscored) {
31+
return klass[propName].call(klass, ...args)
32+
}
33+
const params = args[0] || {}
34+
const { request, response } = reqres
35+
const subcontext = generateContext({ request, response, ...params })
36+
return klass[propName].call(klass, subcontext)
37+
}
38+
if (module.hot) {
39+
_invoke.hash = klass[prop].hash
40+
}
41+
klass[prop] = _invoke
42+
klass.prototype[prop] = _invoke
43+
}
44+
}
45+
parent = Object.getPrototypeOf(parent)
946
}
1047
}
Collapse file

‎server/runtime.js‎

Copy file name to clipboardExpand all lines: server/runtime.js
+2-36Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import element from '../shared/element'
22
import fragment from '../shared/fragment'
3-
import registry, { register } from './registry'
4-
import reqres from "./reqres"
5-
import { generateContext } from "./context"
3+
import { register } from './registry'
4+
65
import Nullstack from './index'
76

87
const $runtime = {
@@ -14,39 +13,6 @@ const $runtime = {
1413
if (module.hot) {
1514
$runtime.accept = function accept(target, ...klasses) {
1615
target.hot.accept();
17-
for (const klass in klasses) {
18-
let parent = klass
19-
while (parent.name !== 'Nullstack') {
20-
const props = Object.getOwnPropertyNames(parent)
21-
for (const prop of props) {
22-
const underscored = prop.startsWith('_')
23-
if (typeof klass[prop] === 'function') {
24-
if (!underscored && !registry[`${parent.hash}.${prop}`]) {
25-
return
26-
}
27-
const propName = `__NULLSTACK_${prop}`
28-
if (!klass[propName]) {
29-
klass[propName] = klass[prop]
30-
}
31-
function _invoke(...args) {
32-
if (underscored) {
33-
return klass[propName].call(klass, ...args)
34-
}
35-
const params = args[0] || {}
36-
const { request, response } = reqres
37-
const subcontext = generateContext({ request, response, ...params })
38-
return klass[propName].call(klass, subcontext)
39-
}
40-
if (module.hot) {
41-
_invoke.hash = klass[prop].hash
42-
}
43-
klass[prop] = _invoke
44-
klass.prototype[prop] = _invoke
45-
}
46-
}
47-
parent = Object.getPrototypeOf(parent)
48-
}
49-
}
5016
}
5117

5218
$runtime.restart = function restart(target, path) {
Collapse file

‎tests/package.json‎

Copy file name to clipboardExpand all lines: tests/package.json
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"author": "",
66
"license": "ISC",
77
"devDependencies": {
8+
"@swc/core": "1.3.35",
89
"cors": "2.8.5",
910
"eslint-plugin-jest": "^27.1.6",
10-
"eslint-plugin-nullstack": "0.0.12",
1111
"glob": "^8.0.3",
1212
"jest": "29.4.1",
1313
"jest-puppeteer": "7.0.0",
@@ -16,7 +16,11 @@
1616
},
1717
"types": "../../types/index.d.ts",
1818
"overrides": {
19-
"webpack": "5.75.0"
19+
"webpack": "5.75.0",
20+
"terser": "npm:@swc/core"
21+
},
22+
"resolutions": {
23+
"terser": "npm:@swc/core"
2024
},
2125
"scripts": {
2226
"start": "node ../scripts/index.js start --port=6969 --env=test --disk",
Collapse file

‎tests/src/Element.njs‎

Copy file name to clipboardExpand all lines: tests/src/Element.njs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Element extends Nullstack {
2929
abbr
3030
</element>
3131
</element>
32-
<element tag={InnerElement} prop />
32+
<element tag={this.renderInnerElement} prop />
3333
<element tag={ClassElement} prop />
3434
<element tag={FunctionalElement} prop />
3535
</>
Collapse file

‎tests/src/Element.test.js‎

Copy file name to clipboardExpand all lines: tests/src/Element.test.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ beforeAll(async () => {
22
await page.goto('http://localhost:6969/element')
33
})
44

5-
describe('FullStackLifecycle', () => {
5+
describe('Element', () => {
66
test('elements can receive any tag b', async () => {
77
const element = await page.$('b[data-tag="b"]')
88
expect(element).toBeTruthy()
Collapse file

‎tests/src/LazyComponent.njs‎

Copy file name to clipboardExpand all lines: tests/src/LazyComponent.njs
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ class LazyComponent extends Nullstack {
1414
render() {
1515
return (
1616
<div data-lazy data-safelisted={this.safelisted}>
17-
{' '}
18-
LazyComponent{' '}
17+
LazyComponent
1918
</div>
2019
)
2120
}
Collapse file

‎tests/src/LazyComponentLoader.njs‎

Copy file name to clipboardExpand all lines: tests/src/LazyComponentLoader.njs
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ class LazyComponentLoader extends Nullstack {
1111
}
1212

1313
async hydrate() {
14-
LazyComponent = (await import('./LazyComponent')).default
14+
this.LazyComponent = (await import('./LazyComponent')).default
15+
console.log(LazyComponent)
16+
this.should = true
1517
}
1618

1719
render() {
18-
if (!this.hydrated) return false
19-
return <LazyComponent />
20+
console.log("RENDER", this.LazyComponent)
21+
if (!this.LazyComponent) return false
22+
return <this.LazyComponent />
2023
}
2124

2225
}
Collapse file

‎tests/src/RenderableComponent.njs‎

Copy file name to clipboardExpand all lines: tests/src/RenderableComponent.njs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RenderableComponent extends Nullstack {
3232
<div class="RenderableComponent">
3333
<Falsy />
3434
<div data-object={{ a: 1 }} />
35-
<div data-function={RenderableComponent} />
35+
<div data-function={this.renderRenderableComponent} />
3636
<div> this is a normal tag </div>
3737
<label for="input"> label </label>
3838
<button disabled> disabled button </button>
@@ -42,7 +42,7 @@ class RenderableComponent extends Nullstack {
4242
<element class="element" tag={params.condition ? 'div' : 'span'}>
4343
element tag
4444
</element>
45-
<InnerComponent reference={InnerReference}>
45+
<InnerComponent reference={this.renderInnerReference}>
4646
<span class="children"> children </span>
4747
</InnerComponent>
4848
<ul>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.