├── .gitignore
├── packages
├── SSR
│ ├── python-django-server
│ │ ├── server
│ │ │ ├── db.sqlite3
│ │ │ ├── polls
│ │ │ │ ├── __init__.py
│ │ │ │ ├── migrations
│ │ │ │ │ └── __init__.py
│ │ │ │ ├── models.py
│ │ │ │ ├── tests.py
│ │ │ │ ├── admin.py
│ │ │ │ ├── urls.py
│ │ │ │ ├── apps.py
│ │ │ │ ├── views.py
│ │ │ │ └── templates
│ │ │ │ │ └── polls
│ │ │ │ │ └── index.html
│ │ │ ├── server
│ │ │ │ ├── __init__.py
│ │ │ │ ├── asgi.py
│ │ │ │ ├── wsgi.py
│ │ │ │ ├── urls.py
│ │ │ │ └── settings.py
│ │ │ └── manage.py
│ │ ├── .gitignore
│ │ ├── client
│ │ │ ├── client.css
│ │ │ ├── client-entry.js
│ │ │ ├── render.ts
│ │ │ └── vite.config.ts
│ │ ├── README.md
│ │ ├── requirements.txt
│ │ ├── vite.config.ts
│ │ ├── package.json
│ │ └── dev.js
│ ├── share-index-html
│ │ ├── client
│ │ │ ├── all.css
│ │ │ └── client-entry.ts
│ │ ├── dist
│ │ │ ├── client
│ │ │ │ ├── assets
│ │ │ │ │ ├── index.499cda43.css
│ │ │ │ │ └── index.6540b25d.js
│ │ │ │ └── index.html
│ │ │ └── server-entry.js
│ │ ├── vite.config.ts
│ │ ├── index.html
│ │ ├── server
│ │ │ ├── server-entry.ts
│ │ │ └── server.ts
│ │ ├── package.json
│ │ └── dev.js
│ ├── dev-client-server-together
│ │ ├── dist
│ │ │ ├── client
│ │ │ │ ├── style.css
│ │ │ │ └── client-entry.js
│ │ │ └── server-entry.js
│ │ ├── client
│ │ │ ├── client.css
│ │ │ ├── client-entry.js
│ │ │ ├── render.ts
│ │ │ └── vite.config.ts
│ │ ├── vite.config.ts
│ │ ├── server
│ │ │ ├── server-entry.ts
│ │ │ ├── vite.config.ts
│ │ │ └── server.ts
│ │ ├── package.json
│ │ └── dev.js
│ ├── generate-static-website
│ │ ├── client
│ │ │ ├── pages
│ │ │ │ ├── page1.css
│ │ │ │ ├── page2.css
│ │ │ │ ├── page2.ts
│ │ │ │ └── page1.ts
│ │ │ ├── vite.d.ts
│ │ │ ├── loadBackInitialState.ts
│ │ │ ├── render.ts
│ │ │ ├── getWebsiteConfig.ts
│ │ │ └── client-entry.ts
│ │ ├── dist
│ │ │ ├── website
│ │ │ │ ├── assets
│ │ │ │ │ ├── page1.260c2d15.css
│ │ │ │ │ ├── page2.4cb761c5.css
│ │ │ │ │ ├── loadBackInitialState.8c7710d3.js
│ │ │ │ │ ├── page2.6b797fad.js
│ │ │ │ │ ├── page1.6e09e3c6.js
│ │ │ │ │ └── index.e6166fda.js
│ │ │ │ ├── website-config.js
│ │ │ │ ├── page2.html
│ │ │ │ └── page1.html
│ │ │ ├── index.html
│ │ │ └── ssr-manifest.json
│ │ ├── vite.config.ts
│ │ ├── index.html
│ │ ├── tsconfig.json
│ │ ├── package.json
│ │ ├── server
│ │ │ ├── server.ts
│ │ │ └── generate.ts
│ │ ├── generate.js
│ │ └── dev.js
│ ├── isomorphic-render
│ │ ├── client
│ │ │ ├── initialState.json
│ │ │ ├── page1.module.css
│ │ │ ├── page1.module.css.d.ts
│ │ │ ├── page1.ts
│ │ │ ├── client-entry.ts
│ │ │ └── render.ts
│ │ ├── dist
│ │ │ └── client
│ │ │ │ ├── assets
│ │ │ │ ├── page1.9e27fc78.css
│ │ │ │ ├── page1.db0834d7.js
│ │ │ │ └── index.84017a7f.js
│ │ │ │ ├── ssr-manifest.json
│ │ │ │ └── index.html
│ │ ├── vite.config.ts
│ │ ├── index.html
│ │ ├── server
│ │ │ ├── server-entry.ts
│ │ │ └── server.ts
│ │ ├── package.json
│ │ └── dev.js
│ └── auto-reload-node-server
│ │ ├── dist
│ │ ├── client
│ │ │ └── client-entry.js
│ │ └── server-entry.js
│ │ ├── server
│ │ ├── vite.config.ts
│ │ ├── server-entry.ts
│ │ └── server.ts
│ │ ├── package.json
│ │ ├── dev.js
│ │ └── README.md
├── CSR
│ ├── html-dependencies
│ │ ├── src
│ │ │ ├── demo.css
│ │ │ ├── h1.css
│ │ │ ├── mov_bbb.mp4
│ │ │ ├── mov_bbb.ogg
│ │ │ ├── some-ts.ts
│ │ │ ├── some-js
│ │ │ │ └── demo.js
│ │ │ └── index.html
│ │ ├── dist
│ │ │ ├── assets
│ │ │ │ ├── index.499cda43.css
│ │ │ │ ├── mov_bbb.3bb938fb.mp4
│ │ │ │ ├── mov_bbb.e5288e98.ogg
│ │ │ │ ├── index.b15437e8.js
│ │ │ │ └── index.3bd70e40.js
│ │ │ └── index.html
│ │ ├── vite.config.ts
│ │ ├── package.json
│ │ └── README.md
│ ├── everything-in-js
│ │ ├── src
│ │ │ ├── demo.css
│ │ │ ├── demo.json
│ │ │ ├── pages
│ │ │ │ ├── index.tsx
│ │ │ │ └── home
│ │ │ │ │ └── about.tsx
│ │ │ ├── example.module.css
│ │ │ ├── demo.wasm
│ │ │ ├── some-js
│ │ │ │ └── demo.js
│ │ │ └── index.html
│ │ ├── dist
│ │ │ ├── assets
│ │ │ │ ├── demo.9d04e1f3.json
│ │ │ │ ├── index.be424d4d.css
│ │ │ │ ├── demo.47f9337a.wasm
│ │ │ │ └── index.91a509f3.js
│ │ │ └── index.html
│ │ ├── vite.config.ts
│ │ ├── package.json
│ │ └── README.md
│ ├── multiple-html-pages
│ │ ├── src
│ │ │ ├── index.css
│ │ │ ├── index.js
│ │ │ ├── common.css
│ │ │ ├── about
│ │ │ │ ├── about.css
│ │ │ │ └── about.html
│ │ │ ├── layout
│ │ │ │ └── header.partial.html
│ │ │ ├── shared.js
│ │ │ ├── contactus.html
│ │ │ ├── index.html
│ │ │ └── handleLink.js
│ │ ├── dist
│ │ │ ├── assets
│ │ │ │ ├── main.2193a552.css
│ │ │ │ ├── about.1b39ea8a.css
│ │ │ │ ├── common.dc7b67c0.css
│ │ │ │ ├── contactus.c63e8635.js
│ │ │ │ ├── about.269f141e.js
│ │ │ │ ├── main.58cc4dac.js
│ │ │ │ └── handleLink.8671e50f.js
│ │ │ ├── contactus.html
│ │ │ ├── about
│ │ │ │ └── about.html
│ │ │ └── index.html
│ │ ├── package.json
│ │ └── vite.config.ts
│ ├── react-tsx
│ │ ├── vite.config.ts
│ │ ├── tsconfig.node.json
│ │ ├── src
│ │ │ ├── main.tsx
│ │ │ ├── LayersPanel.tsx
│ │ │ ├── PropertyEditor.tsx
│ │ │ ├── App.css
│ │ │ ├── App.tsx
│ │ │ └── ViewModel.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ └── tsconfig.json
│ └── reduce-homepage-size
│ │ ├── dist
│ │ ├── assets
│ │ │ ├── page1.94dc12f6.js
│ │ │ ├── page2.c361720d.js
│ │ │ └── index.5a0821eb.js
│ │ └── index.html
│ │ ├── pages
│ │ ├── page1.js
│ │ └── page2.js
│ │ ├── package.json
│ │ ├── index.html
│ │ └── README.md
├── STATIC-LINKING
│ ├── multiple-ts-libs
│ │ ├── lib1
│ │ │ ├── .gitignore
│ │ │ ├── src
│ │ │ │ └── index.ts
│ │ │ ├── tsconfig.cjs.json
│ │ │ ├── tsconfig.json
│ │ │ ├── package.json
│ │ │ └── vite.config.ts
│ │ ├── lib2
│ │ │ ├── dist
│ │ │ │ ├── typings
│ │ │ │ │ └── src
│ │ │ │ │ │ └── index.d.ts
│ │ │ │ ├── esm
│ │ │ │ │ └── src
│ │ │ │ │ │ ├── index.js
│ │ │ │ │ │ └── index.js.map
│ │ │ │ └── lib
│ │ │ │ │ └── src
│ │ │ │ │ ├── index.js.map
│ │ │ │ │ └── index.js
│ │ │ ├── src
│ │ │ │ └── index.ts
│ │ │ ├── tsconfig.cjs.json
│ │ │ ├── tsconfig.json
│ │ │ ├── package.json
│ │ │ └── vite.config.ts
│ │ ├── libs.tsconfig.json
│ │ ├── libs.tsconfig.cjs.json
│ │ ├── cli
│ │ │ ├── some-cli.js
│ │ │ └── package.json
│ │ ├── app
│ │ │ └── package.json
│ │ ├── package.json
│ │ └── README.md
│ ├── inversion-of-control
│ │ ├── demo-motherboard
│ │ │ ├── src
│ │ │ │ ├── index.ts
│ │ │ │ ├── plugin2.abstract.ts
│ │ │ │ ├── SomePage.tsx
│ │ │ │ └── plugin1.abstract.ts
│ │ │ ├── package.json
│ │ │ └── tsconfig.json
│ │ ├── demo-plugin2
│ │ │ ├── src
│ │ │ │ ├── index.ts
│ │ │ │ └── ComponentProvidedByPlugin2.tsx
│ │ │ ├── package.json
│ │ │ └── tsconfig.json
│ │ ├── demo-plugin1
│ │ │ ├── src
│ │ │ │ ├── index.ts
│ │ │ │ ├── spiExportedByPlugin1ForOtherPlugins.ts
│ │ │ │ └── ComponentProvidedByPlugin1.tsx
│ │ │ ├── package.json
│ │ │ └── tsconfig.json
│ │ └── demo-app
│ │ │ ├── public
│ │ │ └── favicon.ico
│ │ │ ├── src
│ │ │ ├── App.vue
│ │ │ ├── env.d.ts
│ │ │ └── main.ts
│ │ │ ├── tsconfig.node.json
│ │ │ ├── .gitignore
│ │ │ ├── index.html
│ │ │ ├── tsconfig.json
│ │ │ ├── package.json
│ │ │ └── vite.config.ts
│ └── library-with-assets
│ │ ├── lib-publisher
│ │ ├── dist
│ │ │ ├── style.css
│ │ │ └── index.js
│ │ ├── src
│ │ │ ├── assets.d.ts
│ │ │ ├── demo.module.css
│ │ │ ├── demo.wasm
│ │ │ └── index.ts
│ │ ├── vite.config.ts
│ │ └── package.json
│ │ ├── src-publisher
│ │ ├── src
│ │ │ ├── assets.d.ts
│ │ │ ├── demo.module.css
│ │ │ ├── demo.wasm
│ │ │ └── index.ts
│ │ └── package.json
│ │ ├── src-consumer
│ │ ├── dist
│ │ │ ├── assets
│ │ │ │ ├── index.bd1b7d52.css
│ │ │ │ ├── demo.47f9337a.wasm
│ │ │ │ └── index.9bc889cd.js
│ │ │ └── index.html
│ │ ├── vite.config.ts
│ │ ├── package.json
│ │ └── index.html
│ │ └── lib-consumer
│ │ ├── vite.config.ts
│ │ ├── dist
│ │ ├── index.html
│ │ └── assets
│ │ │ └── index.892a969a.js
│ │ ├── package.json
│ │ └── index.html
└── DYNAMIC-LINKING
│ ├── hybrid-npm-package
│ ├── publisher
│ │ ├── .gitignore
│ │ ├── src
│ │ │ ├── index.ts
│ │ │ ├── awesomeFunction1.ts
│ │ │ ├── awesomeFunction2.ts
│ │ │ └── __tests__
│ │ │ │ └── awesomeFunction2.spec.ts
│ │ ├── tsconfig.cjs.json
│ │ ├── tsconfig.json
│ │ ├── vite.config.ts
│ │ └── package.json
│ └── consumer
│ │ ├── use-from-browser
│ │ ├── hybrid-npm-package
│ │ └── index.html
│ │ ├── use-from-node.js
│ │ ├── vite.config.ts
│ │ └── package.json
│ ├── remote-package
│ ├── shared-store
│ │ ├── dist
│ │ │ ├── typings
│ │ │ │ └── src
│ │ │ │ │ └── index.d.ts
│ │ │ ├── esm
│ │ │ │ └── src
│ │ │ │ │ └── index.js
│ │ │ └── lib
│ │ │ │ └── src
│ │ │ │ └── index.js
│ │ ├── src
│ │ │ └── index.ts
│ │ ├── tsconfig.cjs.json
│ │ ├── tsconfig.json
│ │ ├── vite.config.ts
│ │ └── package.json
│ ├── publisher
│ │ ├── index.html
│ │ ├── dist
│ │ │ ├── index.html
│ │ │ └── assets
│ │ │ │ ├── __federation_expose_PlusButton.js
│ │ │ │ ├── __federation_expose_MinusButton.js
│ │ │ │ ├── preload-helper.a983d976.js
│ │ │ │ ├── remoteEntry.js
│ │ │ │ └── __federation_fn_import.js
│ │ ├── src
│ │ │ ├── minusButton.ts
│ │ │ └── plusButton.ts
│ │ ├── package.json
│ │ └── vite.config.ts
│ ├── consumer
│ │ ├── tsconfig.json
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.ts
│ │ ├── dist
│ │ │ └── index.html
│ │ └── vite.config.ts
│ └── README.md
│ └── use-big-library-via-cdn
│ ├── dist
│ ├── assets
│ │ ├── index.afd9424a.js
│ │ └── index.a8af7f97.js
│ └── index.html
│ ├── index.ts
│ ├── package.json
│ ├── index.html
│ ├── vite.config.ts
│ └── README.md
├── pnpm-workspace.yaml
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/db.sqlite3:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/server/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/src/demo.css:
--------------------------------------------------------------------------------
1 | @import url('./h1.css');
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib1/.gitignore:
--------------------------------------------------------------------------------
1 | /dist
2 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/demo.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/src/h1.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/demo.json:
--------------------------------------------------------------------------------
1 | {
2 | "hello": "world"
3 | }
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/pages/index.tsx:
--------------------------------------------------------------------------------
1 | export default 'Index Page';
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/index.css:
--------------------------------------------------------------------------------
1 | main {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('just index.html');
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/.gitignore:
--------------------------------------------------------------------------------
1 | /dist
2 |
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/client/all.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/pages/home/about.tsx:
--------------------------------------------------------------------------------
1 | export default 'About Page'
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/dist/assets/index.499cda43.css:
--------------------------------------------------------------------------------
1 | h1{color:red}
2 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/assets/main.2193a552.css:
--------------------------------------------------------------------------------
1 | main{color:red}
2 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/common.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-size: large;
3 | }
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/dist/client/style.css:
--------------------------------------------------------------------------------
1 | body{color:red}
2 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/.gitignore:
--------------------------------------------------------------------------------
1 | /dist
2 | /venv
3 | __pycache__
4 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/client/client.css:
--------------------------------------------------------------------------------
1 | body {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/assets/about.1b39ea8a.css:
--------------------------------------------------------------------------------
1 | main{color:#00f}
2 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/assets/common.dc7b67c0.css:
--------------------------------------------------------------------------------
1 | *{font-size:large}
2 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/about/about.css:
--------------------------------------------------------------------------------
1 | main {
2 | color: blue;
3 | }
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/layout/header.partial.html:
--------------------------------------------------------------------------------
1 |
===header===
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/dist/client/assets/index.499cda43.css:
--------------------------------------------------------------------------------
1 | h1{color:red}
2 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/dist/assets/demo.9d04e1f3.json:
--------------------------------------------------------------------------------
1 | {
2 | "hello": "world"
3 | }
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/client/client.css:
--------------------------------------------------------------------------------
1 | body {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/pages/page1.css:
--------------------------------------------------------------------------------
1 | div {
2 | color: blue;
3 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/pages/page2.css:
--------------------------------------------------------------------------------
1 | div {
2 | color: red;
3 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/vite.d.ts:
--------------------------------------------------------------------------------
1 | ///
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/client/initialState.json:
--------------------------------------------------------------------------------
1 | {
2 | "greeting": "hello"
3 | }
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/client/page1.module.css:
--------------------------------------------------------------------------------
1 | .page1Text {
2 | color: red
3 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/assets/page1.260c2d15.css:
--------------------------------------------------------------------------------
1 | div{color:#00f}
2 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/assets/page2.4cb761c5.css:
--------------------------------------------------------------------------------
1 | div{color:red}
2 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/README.md:
--------------------------------------------------------------------------------
1 | # How to write javascript in python django framework
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/dist/client/assets/page1.9e27fc78.css:
--------------------------------------------------------------------------------
1 | ._page1Text_1vc12_1{color:red}
2 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-motherboard/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './SomePage';
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/shared.js:
--------------------------------------------------------------------------------
1 | export function sharedFunc1() {
2 | return 'hello'
3 | }
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/client/client-entry.js:
--------------------------------------------------------------------------------
1 | import { render } from './render';
2 |
3 | render();
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/example.module.css:
--------------------------------------------------------------------------------
1 | /* example.module.css */
2 | .blue {
3 | color: blue;
4 | }
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/client/client-entry.js:
--------------------------------------------------------------------------------
1 | import { render } from './render';
2 |
3 | render();
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/website-config.js:
--------------------------------------------------------------------------------
1 | export default {"someConfigKey":"=== blah ==="}
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin2/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './ComponentProvidedByPlugin2'
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/consumer/use-from-browser/hybrid-npm-package:
--------------------------------------------------------------------------------
1 | ../node_modules/hybrid-npm-package
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | })
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | })
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-publisher/dist/style.css:
--------------------------------------------------------------------------------
1 | ._blue_6duqs_1{color:#00f}._red_6duqs_5{color:red}
2 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib1/src/index.ts:
--------------------------------------------------------------------------------
1 | export function lib1Function(): string {
2 | return 'lib1';
3 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/dist/typings/src/index.d.ts:
--------------------------------------------------------------------------------
1 | export declare function lib2Function(): string;
2 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/src/index.ts:
--------------------------------------------------------------------------------
1 | export function lib2Function(): string {
2 | return 'lib2';
3 | }
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-publisher/src/assets.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.wasm';
2 | declare module '*.module.css';
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-publisher/src/assets.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.wasm';
2 | declare module '*.module.css';
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/requirements.txt:
--------------------------------------------------------------------------------
1 | asgiref==3.5.2
2 | backports.zoneinfo==0.2.1
3 | Django==4.0.4
4 | sqlparse==0.4.2
5 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/demo.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/CSR/everything-in-js/src/demo.wasm
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './awesomeFunction1';
2 | export * from './awesomeFunction2';
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-consumer/dist/assets/index.bd1b7d52.css:
--------------------------------------------------------------------------------
1 | ._blue_6duqs_1{color:#00f}._red_6duqs_5{color:red}
2 |
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/src/mov_bbb.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/CSR/html-dependencies/src/mov_bbb.mp4
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/src/mov_bbb.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/CSR/html-dependencies/src/mov_bbb.ogg
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/consumer/use-from-node.js:
--------------------------------------------------------------------------------
1 | console.log(require('@hybrid-npm-package/publisher').awesomeFunction2());
2 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/src/awesomeFunction1.ts:
--------------------------------------------------------------------------------
1 | export function awesomeFunction1() {
2 | return 'function 1';
3 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/dist/typings/src/index.d.ts:
--------------------------------------------------------------------------------
1 | export declare const store: {
2 | counter: number;
3 | };
4 |
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/client/page1.module.css.d.ts:
--------------------------------------------------------------------------------
1 | declare const styles: {
2 | readonly page1Text: string;
3 | };
4 | export = styles;
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-publisher/src/demo.module.css:
--------------------------------------------------------------------------------
1 | .blue {
2 | color: blue;
3 | }
4 |
5 | .red {
6 | color: red;
7 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-publisher/src/demo.module.css:
--------------------------------------------------------------------------------
1 | .blue {
2 | color: blue;
3 | }
4 |
5 | .red {
6 | color: red;
7 | }
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/dist/assets/index.be424d4d.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: red;
3 | }/* example.module.css */
4 | ._blue_15qkp_2 {
5 | color: blue;
6 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/dist/esm/src/index.js:
--------------------------------------------------------------------------------
1 | export function lib2Function() {
2 | return 'lib2';
3 | }
4 | //# sourceMappingURL=index.js.map
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/dist/assets/demo.47f9337a.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/CSR/everything-in-js/dist/assets/demo.47f9337a.wasm
--------------------------------------------------------------------------------
/packages/SSR/auto-reload-node-server/dist/client/client-entry.js:
--------------------------------------------------------------------------------
1 | function render() {
2 | document.querySelector("main").innerHTML = "hello world";
3 | }
4 | render();
5 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin1/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './ComponentProvidedByPlugin1'
2 | export * from './spiExportedByPlugin1ForOtherPlugins';
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/src/index.ts:
--------------------------------------------------------------------------------
1 | import { reactive } from '@vue/reactivity';
2 |
3 | export const store = reactive({
4 | counter: 0
5 | })
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | // shared config between client and server
4 | export default defineConfig({
5 | })
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/dist/assets/mov_bbb.3bb938fb.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/CSR/html-dependencies/dist/assets/mov_bbb.3bb938fb.mp4
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/dist/assets/mov_bbb.e5288e98.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/CSR/html-dependencies/dist/assets/mov_bbb.e5288e98.ogg
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | // shared config between client and server
4 | export default defineConfig({
5 | })
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/dist/client/assets/page1.db0834d7.js:
--------------------------------------------------------------------------------
1 | const a="_page1Text_1vc12_1";function t(e){return`${e.greeting}
`}export{t as default};
2 |
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/src/some-ts.ts:
--------------------------------------------------------------------------------
1 | const div: HTMLDivElement = document.createElement('div');
2 | div.innerHTML = 'hello from some-ts.ts';
3 | document.body.appendChild(div);
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/assets/contactus.c63e8635.js:
--------------------------------------------------------------------------------
1 | import{s as e}from"./handleLink.8671e50f.js";document.querySelector("main").innerHTML=`${e()} from contact us page`;
2 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/client/render.ts:
--------------------------------------------------------------------------------
1 | import './client.css'
2 |
3 | export function render(): any {
4 | document.querySelector('main').innerHTML = 'hello world';
5 | }
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path('', views.index, name='index'),
7 | ]
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/client/render.ts:
--------------------------------------------------------------------------------
1 | import './client.css'
2 |
3 | export function render(): any {
4 | document.querySelector('main').innerHTML = 'hello world';
5 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/dist/esm/src/index.js:
--------------------------------------------------------------------------------
1 | import { reactive } from "@vue/reactivity";
2 | const store = reactive({
3 | counter: 0
4 | });
5 | export { store };
6 |
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/dist/client/client-entry.js:
--------------------------------------------------------------------------------
1 | var client = "";
2 | function render() {
3 | document.querySelector("main").innerHTML = "hello world";
4 | }
5 | render();
6 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | outDir: 'dist/website'
6 | }
7 | })
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/client/client-entry.ts:
--------------------------------------------------------------------------------
1 | import './all.css';
2 |
3 | export function render(): any {
4 | document.querySelector('main').innerHTML = 'hello world';
5 | }
6 | render();
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/STATIC-LINKING/inversion-of-control/demo-app/public/favicon.ico
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-publisher/src/demo.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/STATIC-LINKING/library-with-assets/lib-publisher/src/demo.wasm
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-publisher/src/demo.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/STATIC-LINKING/library-with-assets/src-publisher/src/demo.wasm
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | root: 'src',
5 | build: {
6 | outDir: '../dist'
7 | }
8 | })
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/assets/about.269f141e.js:
--------------------------------------------------------------------------------
1 | import{s as r}from"./handleLink.8671e50f.js";/* empty css */document.querySelector("main").innerHTML=`${r()} from about page`;
2 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/src/awesomeFunction2.ts:
--------------------------------------------------------------------------------
1 | import { capitalize } from 'lodash';
2 |
3 | export function awesomeFunction2() {
4 | return capitalize('function 2');
5 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/src/App.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-consumer/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | assetsInlineLimit: 0
6 | }
7 | })
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-consumer/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | assetsInlineLimit: 0
6 | }
7 | })
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/consumer/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | outDir: 'use-from-browser'
6 | }
7 | })
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib1/tsconfig.cjs.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs",
5 | "outDir": "dist/lib"
6 | }
7 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/tsconfig.cjs.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs",
5 | "outDir": "dist/lib"
6 | }
7 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/tsconfig.cjs.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs",
5 | "outDir": "dist/lib"
6 | }
7 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/tsconfig.cjs.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs",
5 | "outDir": "dist/lib"
6 | }
7 | }
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class PollsConfig(AppConfig):
5 | default_auto_field = 'django.db.models.BigAutoField'
6 | name = 'polls'
7 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/views.py:
--------------------------------------------------------------------------------
1 | from urllib.request import Request
2 | from django.shortcuts import render
3 |
4 | def index(request: Request):
5 | return render(request, 'polls/index.html', {})
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/libs.tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "files": [],
3 | "references": [{
4 | "path": "./lib1/tsconfig.json"
5 | }, {
6 | "path": "./lib2/tsconfig.json"
7 | }]
8 | }
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import react from '@vitejs/plugin-react'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [react()]
7 | })
8 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-consumer/dist/assets/demo.47f9337a.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taowen/vite-howto/HEAD/packages/STATIC-LINKING/library-with-assets/src-consumer/dist/assets/demo.47f9337a.wasm
--------------------------------------------------------------------------------
/packages/CSR/reduce-homepage-size/dist/assets/page1.94dc12f6.js:
--------------------------------------------------------------------------------
1 | var e="/assets/page1.d3480e7a.svg";function a(){document.querySelector("main").innerHTML=`
2 |
3 | `}export{a as default};
4 |
--------------------------------------------------------------------------------
/packages/CSR/reduce-homepage-size/dist/assets/page2.c361720d.js:
--------------------------------------------------------------------------------
1 | var e="/assets/page2.1e3fe69b.svg";function a(){document.querySelector("main").innerHTML=`
2 |
3 | `}export{a as default};
4 |
--------------------------------------------------------------------------------
/packages/CSR/reduce-homepage-size/pages/page1.js:
--------------------------------------------------------------------------------
1 | import mySvg from './page1.svg';
2 |
3 | export default function() {
4 | document.querySelector('main').innerHTML = `
5 |
6 | `
7 | }
--------------------------------------------------------------------------------
/packages/CSR/reduce-homepage-size/pages/page2.js:
--------------------------------------------------------------------------------
1 | import mySvg from './page2.svg';
2 |
3 | export default function() {
4 | document.querySelector('main').innerHTML = `
5 |
6 | `
7 | }
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/client/page1.ts:
--------------------------------------------------------------------------------
1 | import { page1Text } from './page1.module.css';
2 |
3 | export default function(props: { greeting: string }) {
4 | return `${props.greeting}
`
5 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/dist/esm/src/index.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY;IACxB,OAAO,MAAM,CAAC;AAClB,CAAC"}
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/assets/main.58cc4dac.js:
--------------------------------------------------------------------------------
1 | import{s as e}from"./handleLink.8671e50f.js";/* empty css */console.log("just index.html");document.querySelector("main").innerHTML=`${e()} from index page`;
2 |
--------------------------------------------------------------------------------
/packages/SSR/auto-reload-node-server/server/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | ssr: './server-entry.ts',
6 | outDir: '../dist'
7 | },
8 | })
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/libs.tsconfig.cjs.json:
--------------------------------------------------------------------------------
1 | {
2 | "files": [],
3 | "references": [{
4 | "path": "./lib1/tsconfig.cjs.json"
5 | }, {
6 | "path": "./lib2/tsconfig.cjs.json"
7 | }]
8 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/dist/lib/src/index.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY;IACxB,OAAO,MAAM,CAAC;AAClB,CAAC;AAFD,oCAEC"}
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/src/some-js/demo.js:
--------------------------------------------------------------------------------
1 | const img = document.createElement('img');
2 | img.setAttribute('src', new URL('./demo-dynamic.svg', import.meta.url).href);
3 | img.setAttribute('width', '300');
4 | document.body.appendChild(img);
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "esnext",
5 | "moduleResolution": "node"
6 | },
7 | "include": ["vite.config.ts"]
8 | }
9 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/src/__tests__/awesomeFunction2.spec.ts:
--------------------------------------------------------------------------------
1 | import { awesomeFunction2 } from "../awesomeFunction2"
2 |
3 | test('expected result', () => {
4 | expect(awesomeFunction2()).toEqual('Function 2');
5 | })
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/use-big-library-via-cdn/dist/assets/index.afd9424a.js:
--------------------------------------------------------------------------------
1 | var o=window.monaco;function e(){o.editor.create(document.body,{value:`function hello() {
2 | alert('Hello world!');
3 | }`,language:"javascript"})}export{e as renderApp};
4 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/cli/some-cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | const lib1 = require('@multiple-ts-libs/lib1');
4 | const lib2 = require('@multiple-ts-libs/lib2');
5 |
6 | console.log(`app => ${lib1.lib1Function()} ${lib2.lib2Function()}`)
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "ESNext",
5 | "moduleResolution": "Node",
6 | "allowSyntheticDefaultImports": true
7 | },
8 | "include": ["vite.config.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | root: 'src',
5 | build: {
6 | outDir: '../dist',
7 | assetsInlineLimit: 0,
8 | minify: false
9 | }
10 | })
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/loadBackInitialState.ts:
--------------------------------------------------------------------------------
1 | export function loadBackInitialState(): any {
2 | // in browser
3 | const node = document.getElementById('initialState') as HTMLTemplateElement;
4 | return JSON.parse(node.content.textContent!);
5 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/use-big-library-via-cdn/index.ts:
--------------------------------------------------------------------------------
1 | import monaco from 'monaco-editor';
2 |
3 | export function renderApp() {
4 | monaco.editor.create(document.body, {
5 | value: "function hello() {\n\talert('Hello world!');\n}",
6 | language: 'javascript'
7 | });
8 | }
9 |
--------------------------------------------------------------------------------
/packages/SSR/auto-reload-node-server/server/server-entry.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import path from 'path';
3 | import server from './server';
4 |
5 | const app = express();
6 | app.use('/client', express.static(path.join(__dirname, 'client')));
7 | app.use(server);
8 | app.listen(3000);
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/server/server-entry.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import path from 'path';
3 | import server from './server';
4 |
5 | const app = express();
6 | app.use('/client', express.static(path.join(__dirname, 'client')));
7 | app.use(server);
8 | app.listen(3000);
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-publisher/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@library-with-assets/src-publisher",
3 | "private": true,
4 | "version": "1.0.0",
5 | "main": "src/index.ts",
6 | "dependencies": {
7 | },
8 | "devDependencies": {
9 | }
10 | }
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/src/main.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom/client'
3 | import App from './App'
4 |
5 | ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
6 |
7 |
8 |
9 | )
10 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/dist/lib/src/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | exports.lib2Function = void 0;
4 | function lib2Function() {
5 | return 'lib2';
6 | }
7 | exports.lib2Function = lib2Function;
8 | //# sourceMappingURL=index.js.map
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/server/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, mergeConfig } from 'vite'
2 | import sharedConfig from '../vite.config';
3 |
4 | export default defineConfig(mergeConfig(sharedConfig, {
5 | build: {
6 | ssr: './server-entry.ts',
7 | outDir: '../dist'
8 | },
9 | }))
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@multiple-ts-libs/app",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "@multiple-ts-libs/cli": "workspace:*"
7 | },
8 | "scripts": {
9 | "try-some-cli": "some-cli"
10 | }
11 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin1/src/spiExportedByPlugin1ForOtherPlugins.ts:
--------------------------------------------------------------------------------
1 | import * as plugin1 from '@plugin1';
2 |
3 | export const spiExportedByPlugin1ForOtherPlugins: typeof plugin1.spiExportedByPlugin1ForOtherPlugins = () => {
4 | return 'plugin2 can call plugin1, as long as motherboard declare a spi'
5 | }
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/some-js/demo.js:
--------------------------------------------------------------------------------
1 | import demoDynamicSvg from './demo-dynamic.svg';
2 | const img = document.createElement('img');
3 | img.setAttribute('src', demoDynamicSvg);
4 | // img.setAttribute('src', new URL('./demo-dynamic.svg', import.meta.url).href);
5 | img.setAttribute('width', '300');
6 | document.body.appendChild(img);
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/src/minusButton.ts:
--------------------------------------------------------------------------------
1 | import { store } from 'remote-package-shared-store';
2 |
3 | export default function(target: HTMLElement) {
4 | target.innerHTML = '- '
5 | target.querySelector('button')!.addEventListener('click', () => {
6 | store.counter -= 1;
7 | });
8 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/src/plusButton.ts:
--------------------------------------------------------------------------------
1 | import { store } from 'remote-package-shared-store';
2 |
3 | export default function(target: HTMLElement) {
4 | target.innerHTML = '+ '
5 | target.querySelector('button')!.addEventListener('click', () => {
6 | store.counter += 1;
7 | })
8 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo-plugin1",
3 | "private": true,
4 | "version": "0.0.0",
5 | "main": "src/index.ts",
6 | "dependencies": {
7 | "vue": "^3.2.25",
8 | "demo-motherboard": "workspace:*"
9 | },
10 | "devDependencies": {
11 | "typescript": "^4.5.4"
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo-plugin2",
3 | "private": true,
4 | "version": "0.0.0",
5 | "main": "src/index.ts",
6 | "dependencies": {
7 | "vue": "^3.2.25",
8 | "demo-motherboard": "workspace:*"
9 | },
10 | "devDependencies": {
11 | "typescript": "^4.5.4"
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/consumer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@hybrid-npm-package/consumer",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "@hybrid-npm-package/publisher": "workspace:*"
7 | },
8 | "devDependencies": {
9 | "vite": "^2.9.1"
10 | },
11 | "scripts": {
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/src/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.vue' {
4 | import type { DefineComponent } from 'vue'
5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6 | const component: DefineComponent<{}, {}, any>
7 | export default component
8 | }
9 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-publisher/src/index.ts:
--------------------------------------------------------------------------------
1 | import initWasm from './demo.wasm'
2 | import { blue, red } from './demo.module.css'
3 |
4 | export async function render(): Promise {
5 | const { add } = await initWasm();
6 | console.log('1+1', add(1, 1));
7 | return `hello
world
`;
8 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-publisher/src/index.ts:
--------------------------------------------------------------------------------
1 | import initWasm from './demo.wasm'
2 | import { blue, red } from './demo.module.css'
3 |
4 | export async function render(): Promise {
5 | const { add } = await initWasm();
6 | console.log('1+1', add(1, 1));
7 | return `hello
world
`;
8 | }
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "html-dependencies",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | },
7 | "devDependencies": {
8 | "vite": "^2.9.1"
9 | },
10 | "scripts": {
11 | "dev": "vite dev",
12 | "build": "vite build",
13 | "preview": "vite preview"
14 | }
15 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-motherboard/src/plugin2.abstract.ts:
--------------------------------------------------------------------------------
1 | import { defineComponent } from "vue";
2 |
3 | // interface declaration
4 | export const ComponentProvidedByPlugin2 = defineComponent({
5 | props: {
6 | position: {
7 | type: String,
8 | required: true
9 | }
10 | },
11 | methods: {} as any
12 | })
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/assets/loadBackInitialState.8c7710d3.js:
--------------------------------------------------------------------------------
1 | import{_ as n}from"./index.e6166fda.js";let e;async function a(){return e||(e=await i()),e}async function i(){{const t="/website-config.js";return(await n(()=>import(t),[])).default}}function c(){const t=document.getElementById("initialState");return JSON.parse(t.content.textContent)}export{a as g,c as l};
2 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "everything-in-js",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | },
7 | "devDependencies": {
8 | "vite": "^2.9.1"
9 | },
10 | "scripts": {
11 | "dev": "vite dev",
12 | "build": "vite build --emptyOutDir",
13 | "preview": "vite preview"
14 | }
15 | }
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "multiple-html-pages",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | },
7 | "devDependencies": {
8 | "vite": "^2.9.1"
9 | },
10 | "scripts": {
11 | "dev": "vite dev",
12 | "build": "vite build --emptyOutDir",
13 | "preview": "vite preview"
14 | }
15 | }
--------------------------------------------------------------------------------
/packages/CSR/reduce-homepage-size/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reduce-homepage-size",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | },
7 | "devDependencies": {
8 | "vite": "^2.9.1"
9 | },
10 | "scripts": {
11 | "dev": "vite dev",
12 | "build": "vite build --emptyOutDir",
13 | "preview": "vite preview"
14 | }
15 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/cli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@multiple-ts-libs/cli",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "@multiple-ts-libs/lib1": "workspace:*",
7 | "@multiple-ts-libs/lib2": "workspace:*"
8 | },
9 | "devDependencies": {
10 | },
11 | "bin": {
12 | "some-cli": "./some-cli.js"
13 | }
14 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/assets/page2.6b797fad.js:
--------------------------------------------------------------------------------
1 | import{l as a,g as i}from"./loadBackInitialState.8c7710d3.js";import"./index.e6166fda.js";async function c(){let t={content:""};t=a();const e=await i();return{title:"Page 2",view:`${t.content}
`,initialState:t,hydrate:()=>{document.body.addEventListener("click",()=>{alert(`clicked page 2
2 | `+e.someConfigKey)})}}}export{c as default};
3 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-publisher/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | lib: {
6 | entry: './src/index.ts',
7 | formats: ['es'],
8 | fileName: () => 'index.js'
9 | },
10 | outDir: 'dist',
11 | assetsInlineLimit: 0,
12 | },
13 | plugins: []
14 | })
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/assets/page1.6e09e3c6.js:
--------------------------------------------------------------------------------
1 | import{l as i,g as a}from"./loadBackInitialState.8c7710d3.js";import"./index.e6166fda.js";async function c(){let t={content:""};t=i();const e=await a();return{title:"Page 1",view:`${t.content}
${e.someConfigKey}
`,initialState:t,hydrate:()=>{document.body.addEventListener("click",()=>{alert("clicked page 1")})}}}export{c as default};
2 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - 'packages/CSR/*'
3 | - 'packages/SSR/*'
4 | - 'packages/DYNAMIC-LINKING/*'
5 | - 'packages/DYNAMIC-LINKING/hybrid-npm-package/*'
6 | - 'packages/DYNAMIC-LINKING/remote-package/*'
7 | - 'packages/STATIC-LINKING/*'
8 | - 'packages/STATIC-LINKING/library-with-assets/*'
9 | - 'packages/STATIC-LINKING/multiple-ts-libs/*'
10 | - 'packages/STATIC-LINKING/inversion-of-control/*'
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Server is a destiny
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Vite App
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/server/server-entry.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import path from 'path';
3 | import server, { config } from './server';
4 | import fs from 'fs';
5 |
6 | config.indexHtml = fs.readFileSync(path.join(__dirname, 'client', 'index.html'), 'utf-8');
7 |
8 | const app = express();
9 | app.use('/assets', express.static(path.join(__dirname, 'client', 'assets')));
10 | app.use(server);
11 | app.listen(3000);
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/use-big-library-via-cdn/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "use-big-library-via-cdn",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "monaco-editor": "0.33.0"
7 | },
8 | "devDependencies": {
9 | "vite": "^2.9.1"
10 | },
11 | "scripts": {
12 | "dev": "vite dev",
13 | "build": "vite build",
14 | "preview": "vite preview"
15 | }
16 | }
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/client/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, mergeConfig } from 'vite'
2 | import sharedConfig from '../vite.config';
3 |
4 | export default defineConfig(mergeConfig(sharedConfig, {
5 | build: {
6 | lib: {
7 | entry: './client-entry.js',
8 | formats: ['es'],
9 | fileName: () => 'client-entry.js'
10 | },
11 | outDir: '../dist/client'
12 | },
13 | }))
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite + React + TS
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/client/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, mergeConfig } from 'vite'
2 | import sharedConfig from '../vite.config';
3 |
4 | export default defineConfig(mergeConfig(sharedConfig, {
5 | build: {
6 | lib: {
7 | entry: './client-entry.js',
8 | formats: ['es'],
9 | fileName: () => 'client-entry.js'
10 | },
11 | outDir: '../dist/client'
12 | },
13 | }))
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-motherboard/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo-motherboard",
3 | "private": true,
4 | "version": "0.0.0",
5 | "main": "src/index.ts",
6 | "dependencies": {
7 | "vue": "^3.2.25"
8 | },
9 | "devDependencies": {
10 | "@vitejs/plugin-vue": "^2.2.0",
11 | "typescript": "^4.5.4",
12 | "vite": "^2.8.0",
13 | "vue-tsc": "^0.29.8"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/dist/client/ssr-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "vite/modulepreload-polyfill": [],
3 | "vite/preload-helper": [],
4 | "client/render.ts": [],
5 | "client/client-entry.ts": [],
6 | "index.html": [],
7 | "client/page1.module.css?used": [
8 | "/assets/page1.db0834d7.js",
9 | "/assets/page1.9e27fc78.css"
10 | ],
11 | "client/page1.ts": [
12 | "/assets/page1.db0834d7.js",
13 | "/assets/page1.9e27fc78.css"
14 | ]
15 | }
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/src/LayersPanel.tsx:
--------------------------------------------------------------------------------
1 | import PropertyEditor from "./PropertyEditor";
2 | import { useViewModel } from "./ViewModel";
3 |
4 | function ViewModel() {
5 | return {
6 | layers: [] as string[]
7 | }
8 | }
9 | export default useViewModel(ViewModel, (props: { blah?: number }, viewModel) => {
10 | return
11 | {
12 | viewModel.layers.map(layer =>
)
13 | }
14 |
;
15 | });
16 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/dist/assets/__federation_expose_PlusButton.js:
--------------------------------------------------------------------------------
1 | import {importShared} from './__federation_fn_import.js'
2 | const {store} = await importShared('remote-package-shared-store')
3 |
4 | function plusButton(target) {
5 | target.innerHTML = "+ ";
6 | target.querySelector("button").addEventListener("click", () => {
7 | store.counter += 1;
8 | });
9 | }
10 |
11 | export { plusButton as default };
12 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/dist/assets/__federation_expose_MinusButton.js:
--------------------------------------------------------------------------------
1 | import {importShared} from './__federation_fn_import.js'
2 | const {store} = await importShared('remote-package-shared-store')
3 |
4 | function minusButton(target) {
5 | target.innerHTML = "- ";
6 | target.querySelector("button").addEventListener("click", () => {
7 | store.counter -= 1;
8 | });
9 | }
10 |
11 | export { minusButton as default };
12 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "module": "esnext",
5 | "moduleResolution": "node",
6 | "strict": true,
7 | "noEmit": true,
8 | "allowSyntheticDefaultImports": true,
9 | "types": ["express"],
10 | "lib": ["ESNext", "DOM"],
11 | },
12 | "include": [
13 | "server/**/*.ts",
14 | "client/**/*.ts"
15 | ]
16 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-publisher/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@library-with-assets/lib-publisher",
3 | "private": true,
4 | "version": "1.0.0",
5 | "main": "dist/index.js",
6 | "dependencies": {
7 | },
8 | "devDependencies": {
9 | "vite": "^2.9.1"
10 | },
11 | "files": ["dist", "src"],
12 | "scripts": {
13 | "dev": "vite build --watch",
14 | "build": "vite build --emptyOutDir"
15 | }
16 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "multiple-ts-libs",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | },
7 | "devDependencies": {
8 | "npm-run-all": "^4.1.5",
9 | "typescript": "^4.6.4"
10 | },
11 | "scripts": {
12 | "dev": "run-p dev:**",
13 | "dev:cjs": "tsc -b libs.tsconfig.cjs.json --watch",
14 | "dev:esm": "tsc -b libs.tsconfig.json --watch"
15 | }
16 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-consumer/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Javascript is all you need
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Server is a destiny
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-consumer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@library-with-assets/lib-consumer",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "@library-with-assets/lib-publisher": "workspace:*"
7 | },
8 | "devDependencies": {
9 | "vite": "^2.9.1"
10 | },
11 | "scripts": {
12 | "dev": "vite dev",
13 | "build": "vite build --emptyOutDir",
14 | "preview": "vite preview"
15 | }
16 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-consumer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@library-with-assets/src-consumer",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "@library-with-assets/src-publisher": "workspace:*"
7 | },
8 | "devDependencies": {
9 | "vite": "^2.9.1"
10 | },
11 | "scripts": {
12 | "dev": "vite dev",
13 | "build": "vite build --emptyOutDir",
14 | "preview": "vite preview"
15 | }
16 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/dist/lib/src/index.js:
--------------------------------------------------------------------------------
1 | (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@vue/reactivity")):typeof define=="function"&&define.amd?define(["exports","@vue/reactivity"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["example-lib"]={},e.reactivity))})(this,function(e,t){"use strict";const i=t.reactive({counter:0});e.store=i,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
2 |
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/client/client-entry.ts:
--------------------------------------------------------------------------------
1 | import { render } from './render';
2 |
3 | async function hydrate({ url, main }: { url: string, main: HTMLElement }) {
4 | const { view } = await render(url);
5 | if (main.innerHTML === view) {
6 | return;
7 | }
8 | console.warn('found server result inconsistent with client result during hydration');
9 | main.innerHTML = view;
10 | }
11 |
12 | hydrate({
13 | url: '/',
14 | main: document.querySelector('main')
15 | });
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/server/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for server project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/server/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for server project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/consumer/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "module": "esnext",
5 | "moduleResolution": "node",
6 | "strict": true,
7 | "noEmit": true,
8 | "types": ["jest"],
9 | "lib": ["ESNext", "DOM"],
10 | "baseUrl": ".",
11 | "paths": {
12 | "@publisher/*": ["../publisher/src/*"]
13 | }
14 | },
15 | "include": [
16 | "src/**/*.ts"
17 | ]
18 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-motherboard/src/SomePage.tsx:
--------------------------------------------------------------------------------
1 | import { ComponentProvidedByPlugin1 } from '@plugin1';
2 | import { ComponentProvidedByPlugin2 } from '@plugin2';
3 | import * as vue from 'vue';
4 |
5 | export const SomePage = vue.defineComponent({
6 | render() {
7 | return
8 | ===
9 |
10 | ===
11 |
12 |
13 | }
14 | })
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/dist/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Server is a destiny
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Javascript is all you need
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/dist/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Server is a destiny
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/polls/templates/polls/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Server is a destiny
6 |
7 |
8 |
9 |
10 |
11 | HTML5 Example Page
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/SSR/auto-reload-node-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "auto-reload-node-server",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "body-parser": "^1.20.0",
7 | "express": "^5.0.0-beta.1"
8 | },
9 | "devDependencies": {
10 | "@types/express": "^4.17.13",
11 | "vite": "^2.9.1"
12 | },
13 | "scripts": {
14 | "dev": "node dev.js",
15 | "build": "vite build server --emptyOutDir",
16 | "preview": "node dist/server-entry.js"
17 | }
18 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-consumer/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Javascript is all you need
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/server/server-entry.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import fs from 'fs';
3 | import path from 'path';
4 | import server, { config } from './server';
5 |
6 | config.indexHtml = fs.readFileSync(path.join(__dirname, 'client', 'index.html'), 'utf-8');
7 | config.manifest = JSON.parse(fs.readFileSync(
8 | path.join(__dirname, 'client', 'ssr-manifest.json'), 'utf-8'))
9 |
10 | const app = express();
11 | app.use('/assets', express.static(path.join(__dirname, 'client', 'assets')));
12 | app.use(server);
13 | app.listen(3000);
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib1/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "target": "esnext",
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "incremental": true,
8 | "strict": true,
9 | "sourceMap": true,
10 | "declaration": true,
11 | "declarationDir": "dist/typings",
12 | "outDir": "dist/esm",
13 | "types": [],
14 | "lib": ["ESNext"]
15 | },
16 | "include": [
17 | "src/**/*.ts"
18 | ]
19 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "target": "esnext",
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "incremental": true,
8 | "strict": true,
9 | "sourceMap": true,
10 | "declaration": true,
11 | "declarationDir": "dist/typings",
12 | "outDir": "dist/esm",
13 | "types": [],
14 | "lib": ["ESNext"]
15 | },
16 | "include": [
17 | "src/**/*.ts"
18 | ]
19 | }
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/contactus.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Contact Us
7 |
8 |
9 |
10 |
11 |
12 |
13 | ===header===
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "target": "esnext",
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "incremental": true,
8 | "strict": true,
9 | "sourceMap": true,
10 | "declaration": true,
11 | "declarationDir": "dist/typings",
12 | "outDir": "dist/esm",
13 | "types": ["jest"],
14 | "lib": ["ESNext"]
15 | },
16 | "include": [
17 | "src/**/*.ts"
18 | ]
19 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "target": "esnext",
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "incremental": true,
8 | "strict": true,
9 | "sourceMap": true,
10 | "declaration": true,
11 | "declarationDir": "dist/typings",
12 | "outDir": "dist/esm",
13 | "types": ["jest"],
14 | "lib": ["ESNext"]
15 | },
16 | "include": [
17 | "src/**/*.ts"
18 | ]
19 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/consumer/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Dynamic composition is just lazy
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "useDefineForClassFields": true,
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "jsx": "preserve",
9 | "sourceMap": true,
10 | "resolveJsonModule": true,
11 | "esModuleInterop": true,
12 | "lib": ["esnext", "dom"]
13 | },
14 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "../demo-motherboard/ext/**/*.d.ts"],
15 | "references": [{ "path": "./tsconfig.node.json" }]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/render.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | export const pages = import.meta.glob('./pages/**/*.ts')
4 |
5 | export async function render(url: string) {
6 | const loadPage = pages[`./pages${url}.ts`];
7 | if (!loadPage) {
8 | return undefined;
9 | }
10 | const { default: page } = await loadPage();
11 | const renderResult = await page();
12 | if (!renderResult) {
13 | return undefined;
14 | }
15 | return {
16 | modules: [`client/pages${url}.ts`],
17 | ...renderResult
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/consumer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-package-consumer",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "remote-package-shared-store": "workspace:*",
7 | "@vue/reactivity": "^3.2.33"
8 | },
9 | "devDependencies": {
10 | "@originjs/vite-plugin-federation": "^1.1.5",
11 | "typescript": "^4.6.4",
12 | "vite": "^2.9.1"
13 | },
14 | "scripts": {
15 | "dev": "vite dev",
16 | "build": "vite build",
17 | "preview": "vite preview --port 3000"
18 | }
19 | }
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-tsx",
3 | "private": true,
4 | "version": "0.0.0",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite",
8 | "build": "tsc && vite build",
9 | "preview": "vite preview"
10 | },
11 | "dependencies": {
12 | "react": "^18.2.0",
13 | "react-dom": "^18.2.0"
14 | },
15 | "devDependencies": {
16 | "@types/react": "^18.0.15",
17 | "@types/react-dom": "^18.0.6",
18 | "@vitejs/plugin-react": "^2.0.0",
19 | "typescript": "^4.6.4",
20 | "vite": "^3.0.2"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/consumer/src/index.ts:
--------------------------------------------------------------------------------
1 | import { store } from 'remote-package-shared-store';
2 | import { effect } from '@vue/reactivity';
3 |
4 | export async function render() {
5 | effect(() => {
6 | document.querySelector('main')!.innerHTML = `counter value: ${store.counter}`;
7 | });
8 | const { default: plusButton } = await import('@publisher/plusButton')
9 | plusButton(document.getElementById('slot1')!);
10 | const { default: minusButton } = await import('@publisher/minusButton');
11 | minusButton(document.getElementById('slot2')!);
12 | }
13 |
14 | render();
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/contactus.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Contact Us
7 |
8 |
9 |
10 |
11 |
12 |
13 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/src/PropertyEditor.tsx:
--------------------------------------------------------------------------------
1 | import { useViewModel } from "./ViewModel";
2 |
3 | function ViewModel() {
4 | return {
5 | myValue: '',
6 | isTyping: false
7 | }
8 | }
9 | export default useViewModel(ViewModel, (props: { blah?: number }, viewModel) => {
10 | return
11 | {
12 | viewModel.myValue = e.target.value;
13 | }} onFocus={() => {
14 | viewModel.isTyping = true;
15 | }} onBlur={() => {
16 | viewModel.isTyping = false;
17 | }}/>
18 | characters count: {viewModel.myValue.length}
19 |
;
20 | });
21 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-motherboard/src/plugin1.abstract.ts:
--------------------------------------------------------------------------------
1 | import { defineComponent } from "vue";
2 |
3 | // interface declaration
4 | export const ComponentProvidedByPlugin1 = defineComponent({
5 | props: {
6 | msg: {
7 | type: String,
8 | required: true
9 | }
10 | },
11 | data() {
12 | return {
13 | hello: ''
14 | }
15 | },
16 | methods: {
17 | onClick() {
18 | }
19 | }
20 | })
21 |
22 | export function spiExportedByPlugin1ForOtherPlugins(): string {
23 | throw new Error('abstract');
24 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo-app",
3 | "private": true,
4 | "version": "0.0.0",
5 | "scripts": {
6 | "dev": "vite",
7 | "build": "vue-tsc --noEmit && vite build",
8 | "preview": "vite preview"
9 | },
10 | "dependencies": {
11 | "vue": "^3.2.25",
12 | "demo-motherboard": "workspace:*",
13 | "demo-plugin1": "workspace:*",
14 | "demo-plugin2": "workspace:*"
15 | },
16 | "devDependencies": {
17 | "@vitejs/plugin-vue": "^2.2.0",
18 | "typescript": "^4.5.4",
19 | "vite": "^2.8.0",
20 | "vue-tsc": "^0.29.8"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/src-consumer/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Javascript is all you need
6 |
7 |
8 |
9 |
10 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@multiple-ts-libs/lib1",
3 | "private": true,
4 | "version": "1.0.0",
5 | "main": "dist/lib/src/index.js",
6 | "module": "dist/esm/src/index.js",
7 | "typings": "dist/typings/src/index.d.ts",
8 | "dependencies": {
9 | },
10 | "devDependencies": {
11 | "typescript": "^4.6.4",
12 | "vite": "^2.9.1"
13 | },
14 | "scripts": {
15 | "build": "rm -rf dist && run-p build:*",
16 | "build:typings": "tsc --emitDeclarationOnly --tsBuildInfoFile /dev/null",
17 | "build:lib": "vite build"
18 | }
19 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@multiple-ts-libs/lib2",
3 | "private": true,
4 | "version": "1.0.0",
5 | "main": "dist/lib/src/index.js",
6 | "module": "dist/esm/src/index.js",
7 | "typings": "dist/typings/src/index.d.ts",
8 | "dependencies": {
9 | },
10 | "devDependencies": {
11 | "typescript": "^4.6.4",
12 | "vite": "^2.9.1"
13 | },
14 | "scripts": {
15 | "build": "rm -rf dist && run-p build:*",
16 | "build:typings": "tsc --emitDeclarationOnly --tsBuildInfoFile /dev/null",
17 | "build:lib": "vite build"
18 | }
19 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-package-publisher",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "remote-package-shared-store": "workspace:*"
7 | },
8 | "devDependencies": {
9 | "npm-run-all": "^4.1.5",
10 | "@originjs/vite-plugin-federation": "^1.1.5",
11 | "typescript": "^4.6.4",
12 | "vite": "^2.9.1"
13 | },
14 | "scripts": {
15 | "dev": "run-p build:watch preview",
16 | "build:watch": "pnpm vite build --watch",
17 | "build": "pnpm vite build",
18 | "preview": "vite preview --port 3001"
19 | }
20 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib1/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import pkg from './package.json'
3 |
4 | export default defineConfig({
5 | build: {
6 | lib: {
7 | // will be loaded as window['example-lib']
8 | name: 'example-lib',
9 | entry: './src/index.ts',
10 | formats: ['es', 'umd'],
11 | fileName: (format) => format === 'es' ? `esm/src/index.js` : `lib/src/index.js`,
12 | },
13 | outDir: 'dist',
14 | rollupOptions: {
15 | external: [...Object.keys(pkg.dependencies), ...Object.keys(pkg.devDependencies)]
16 | }
17 | },
18 | })
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/multiple-ts-libs/lib2/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import pkg from './package.json'
3 |
4 | export default defineConfig({
5 | build: {
6 | lib: {
7 | // will be loaded as window['example-lib']
8 | name: 'example-lib',
9 | entry: './src/index.ts',
10 | formats: ['es', 'umd'],
11 | fileName: (format) => format === 'es' ? `esm/src/index.js` : `lib/src/index.js`,
12 | },
13 | outDir: 'dist',
14 | rollupOptions: {
15 | external: [...Object.keys(pkg.dependencies), ...Object.keys(pkg.devDependencies)]
16 | }
17 | },
18 | })
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dev-client-server-together",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "body-parser": "^1.20.0",
7 | "express": "^5.0.0-beta.1"
8 | },
9 | "devDependencies": {
10 | "@types/express": "^4.17.13",
11 | "vite": "^2.9.1"
12 | },
13 | "scripts": {
14 | "dev": "node dev.js",
15 | "build:client": "vite build client --emptyOutDir",
16 | "build:server": "vite build server --emptyOutDir",
17 | "build": "pnpm build:server && pnpm build:client",
18 | "preview": "node dist/server-entry.js"
19 | }
20 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import pkg from './package.json'
3 |
4 | export default defineConfig({
5 | build: {
6 | lib: {
7 | // will be loaded as window['example-lib']
8 | name: 'example-lib',
9 | entry: './src/index.ts',
10 | formats: ['es', 'umd'],
11 | fileName: (format) => format === 'es' ? `esm/src/index.js` : `lib/src/index.js`,
12 | },
13 | outDir: 'dist',
14 | rollupOptions: {
15 | external: [...Object.keys(pkg.dependencies), ...Object.keys(pkg.devDependencies)]
16 | }
17 | },
18 | })
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import pkg from './package.json'
3 |
4 | export default defineConfig({
5 | build: {
6 | lib: {
7 | // will be loaded as window['example-lib']
8 | name: 'example-lib',
9 | entry: './src/index.ts',
10 | formats: ['es', 'umd'],
11 | fileName: (format) => format === 'es' ? `esm/src/index.js` : `lib/src/index.js`,
12 | },
13 | outDir: 'dist',
14 | rollupOptions: {
15 | external: [...Object.keys(pkg.dependencies), ...Object.keys(pkg.devDependencies)]
16 | }
17 | },
18 | })
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "share-index-html",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "body-parser": "^1.20.0",
7 | "express": "^5.0.0-beta.1"
8 | },
9 | "devDependencies": {
10 | "@types/express": "^4.17.13",
11 | "vite": "^2.9.1"
12 | },
13 | "scripts": {
14 | "dev": "node dev.js",
15 | "build:client": "vite build --outDir dist/client",
16 | "build:server": "vite build --ssr server/server-entry.ts --outDir dist",
17 | "build": "pnpm build:server && pnpm build:client",
18 | "preview": "node dist/server-entry.js"
19 | }
20 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/getWebsiteConfig.ts:
--------------------------------------------------------------------------------
1 | let cache: any;
2 |
3 | export async function getWebsiteConfig() {
4 | if (!cache) {
5 | cache = await loadWebsiteConfig();
6 | }
7 | return cache;
8 | }
9 |
10 | async function loadWebsiteConfig() {
11 | if (import.meta.env.SSR) {
12 | // simulate reading from database
13 | return { someConfigKey: '=== blah ===' };
14 | } else {
15 | // generate.ts will generate website-config.js
16 | // server.ts will provide route for /website-config.js
17 | const loc = '/website-config.js' as any;
18 | return (await import(/* @vite-ignore */loc)).default;
19 | }
20 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/client-entry.ts:
--------------------------------------------------------------------------------
1 | import { render } from './render';
2 |
3 | async function hydrate({ url, main }: { url: string, main: HTMLElement }) {
4 | const renderResult = await render(url);
5 | if (!renderResult) {
6 | throw new Error('failed to render: ' + url);
7 | }
8 | const { view, hydrate } = renderResult;
9 | if (main.innerHTML.trim() !== view.trim()) {
10 | console.warn('found server result inconsistent with client result during hydration');
11 | main.innerHTML = view;
12 | }
13 | hydrate();
14 | }
15 |
16 | hydrate({
17 | url: window.location.pathname,
18 | main: document.querySelector('main')!
19 | });
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/page2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page 2
8 |
9 |
10 |
11 |
12 | this is page 2
13 |
14 | {"content":"this is page 2"}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "isomorphic-render",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "body-parser": "^1.20.0",
7 | "express": "^5.0.0-beta.1"
8 | },
9 | "devDependencies": {
10 | "@types/express": "^4.17.13",
11 | "vite": "^2.9.1"
12 | },
13 | "scripts": {
14 | "dev": "node dev.js",
15 | "build:client": "vite build --outDir dist/client --ssrManifest",
16 | "build:server": "vite build --ssr server/server-entry.ts --outDir dist",
17 | "build": "pnpm build:server && pnpm build:client",
18 | "preview": "node dist/server-entry.js"
19 | }
20 | }
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/src/main.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue';
2 | import App from './App.vue';
3 | import * as plugin1_inf from '@plugin1';
4 | import * as plugin1_impl from 'demo-plugin1';
5 | import * as plugin2_inf from '@plugin2';
6 | import * as plugin2_impl from 'demo-plugin2';
7 |
8 | function checkPlugin(a: A, b: B) {
9 | }
10 |
11 | // ensure all spi declared by @plugin1 has been implemented by demo-plugin1
12 | checkPlugin(plugin1_inf, plugin1_impl);
13 | // ensure all spi declared by @plugin2 has been implemented by demo-plugin2
14 | checkPlugin(plugin2_inf, plugin2_impl);
15 |
16 | export const app = createApp(App);
17 | app.mount('#app')
18 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/library-with-assets/lib-consumer/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Javascript is all you need
6 |
7 |
8 |
9 |
10 |
11 |
18 |
19 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/consumer/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Dynamic composition is just lazy
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "useDefineForClassFields": true,
5 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
6 | "allowJs": false,
7 | "skipLibCheck": true,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react-jsx"
18 | },
19 | "include": ["src"],
20 | "references": [{ "path": "./tsconfig.node.json" }]
21 | }
22 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/website/page1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page 1
8 |
9 |
10 |
11 |
12 | this is page 1
=== blah ===
13 |
14 | {"content":"this is page 1"}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generate-static-website",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "express": "^5.0.0-beta.1"
7 | },
8 | "devDependencies": {
9 | "@types/express": "^4.17.13",
10 | "vite": "^2.9.1"
11 | },
12 | "scripts": {
13 | "dev": "node dev.js",
14 | "build:client": "vite build --ssrManifest && mv dist/website/index.html dist/index.html && mv dist/website/ssr-manifest.json dist/ssr-manifest.json",
15 | "build:generate": "node generate.js",
16 | "build": "pnpm build:client && pnpm build:generate",
17 | "preview": "vite preview --port 3000"
18 | }
19 | }
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/consumer/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import federation from '@originjs/vite-plugin-federation'
3 |
4 | export default defineConfig({
5 | plugins: [federation({
6 | remotes: {
7 | '@publisher': 'http://localhost:3001/assets/remoteEntry.js'
8 | },
9 | shared: ['remote-package-shared-store']
10 | })],
11 | build: {
12 | target: 'esnext',
13 | minify: false,
14 | cssCodeSplit: true,
15 | rollupOptions: {
16 | output: {
17 | minifyInternalExports: false
18 | }
19 | }
20 | },
21 | optimizeDeps: {
22 | include: ['remote-package-shared-store']
23 | }
24 | })
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin1/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "useDefineForClassFields": true,
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "jsx": "react",
9 | "jsxFactory": "vue.h",
10 | "jsxFragmentFactory": "vue.Fragment",
11 | "sourceMap": true,
12 | "resolveJsonModule": true,
13 | "esModuleInterop": true,
14 | "lib": ["esnext", "dom"],
15 | "paths": {
16 | "@plugin1": ["../demo-motherboard/src/plugin1.abstract.ts"],
17 | "@plugin2": ["../demo-motherboard/src/plugin2.abstract.ts"]
18 | }
19 | },
20 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
21 | }
22 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin2/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "useDefineForClassFields": true,
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "jsx": "react",
9 | "jsxFactory": "vue.h",
10 | "jsxFragmentFactory": "vue.Fragment",
11 | "sourceMap": true,
12 | "resolveJsonModule": true,
13 | "esModuleInterop": true,
14 | "lib": ["esnext", "dom"],
15 | "paths": {
16 | "@plugin1": ["../demo-motherboard/src/plugin1.abstract.ts"],
17 | "@plugin2": ["../demo-motherboard/src/plugin2.abstract.ts"]
18 | }
19 | },
20 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
21 | }
22 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/about/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | About
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ===header===
18 | Contact Us
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-motherboard/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "useDefineForClassFields": true,
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "jsx": "react",
9 | "jsxFactory": "vue.h",
10 | "jsxFragmentFactory": "vue.Fragment",
11 | "sourceMap": true,
12 | "resolveJsonModule": true,
13 | "esModuleInterop": true,
14 | "lib": ["esnext", "dom"],
15 | "composite": true,
16 | "paths": {
17 | "@plugin1": ["./src/plugin1.abstract.ts"],
18 | "@plugin2": ["./src/plugin2.abstract.ts"]
19 | }
20 | },
21 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "ext/**/*.d.ts"]
22 | }
23 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/about/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | About
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Contact Us
15 |
16 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-app/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import vue from '@vitejs/plugin-vue'
3 |
4 | export default defineConfig({
5 | plugins: [vue(), {
6 | // we can inject different implementation,
7 | // as long as @plugin1 interface has been implemented
8 | name: 'inject @plugin1',
9 | resolveId(id) {
10 | if (id === '@plugin1') {
11 | return 'demo-plugin1';
12 | }
13 | }
14 | }, {
15 | // we can inject different implementation,
16 | // as long as @plugin2 interface has been implemented
17 | name: 'inject @plugin2',
18 | resolveId(id) {
19 | if (id === '@plugin2') {
20 | return 'demo-plugin2';
21 | }
22 | }
23 | }],
24 | base: '',
25 | })
26 |
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/dist/client/assets/index.6540b25d.js:
--------------------------------------------------------------------------------
1 | const l=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))n(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function i(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerpolicy&&(r.referrerPolicy=e.referrerpolicy),e.crossorigin==="use-credentials"?r.credentials="include":e.crossorigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(e){if(e.ep)return;e.ep=!0;const r=i(e);fetch(e.href,r)}};l();function s(){document.querySelector("main").innerHTML="hello world"}s();
2 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Index
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ===header===
18 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/packages/SSR/auto-reload-node-server/server/server.ts:
--------------------------------------------------------------------------------
1 | import bodyParser from 'body-parser';
2 | import express from 'express';
3 |
4 | const server = express.Router();
5 | server.use(bodyParser.urlencoded({ extended: false }));
6 | server.use(bodyParser.json());
7 |
8 | server.get('/', async (req, resp) => {
9 | resp.send(`
10 |
11 |
12 |
13 |
14 | Server is a destiny
15 |
16 |
17 |
18 |
19 |
20 | HTML5 Example Page
21 |
22 |
23 |
24 |
25 |
26 | `)
27 | })
28 |
29 | export default server;
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/server/server.ts:
--------------------------------------------------------------------------------
1 | import bodyParser from 'body-parser';
2 | import express from 'express';
3 |
4 | const server = express.Router();
5 | server.use(bodyParser.urlencoded({ extended: false }));
6 | server.use(bodyParser.json());
7 |
8 | server.get('/', async (req, resp) => {
9 | resp.send(`
10 |
11 |
12 |
13 |
14 | Server is a destiny
15 |
16 |
17 |
18 |
19 |
20 | HTML5 Example Page
21 |
22 |
23 |
24 |
25 |
26 | `)
27 | })
28 |
29 | export default server;
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/server/server.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import { getWebsiteConfig } from '../client/getWebsiteConfig';
3 | import { generate } from './generate';
4 |
5 | export const config = { indexHtml: '', manifest: {} }
6 |
7 | const server = express.Router();
8 |
9 | server.get('/website-config.js', async (req, resp) => {
10 | resp.set('Content-Type', 'application/javascript');
11 | resp.write(`export default ${JSON.stringify(await getWebsiteConfig())}`);
12 | resp.end();
13 | })
14 |
15 | server.get('/(.*)', async (req, resp) => {
16 | let rendered = await generate({
17 | url: req.url,
18 | ...config
19 | });
20 | if (!rendered) {
21 | resp.status(404).end();
22 | return;
23 | }
24 | resp.send(rendered);
25 | })
26 |
27 | export default server;
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/shared-store/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "remote-package-shared-store",
3 | "private": true,
4 | "version": "1.0.0",
5 | "main": "dist/lib/src/index.js",
6 | "module": "dist/esm/src/index.js",
7 | "typings": "dist/typings/src/index.d.ts",
8 | "dependencies": {
9 | "@vue/reactivity": "^3.2.33"
10 | },
11 | "devDependencies": {
12 | "npm-run-all": "^4.1.5",
13 | "typescript": "^4.6.4",
14 | "vite": "^2.9.1"
15 | },
16 | "scripts": {
17 | "dev": "run-p dev:**",
18 | "dev:cjs": "tsc -b tsconfig.cjs.json --watch",
19 | "dev:esm": "tsc -b --watch",
20 | "build": "rm -rf dist && run-p build:*",
21 | "build:typings": "tsc --emitDeclarationOnly --tsBuildInfoFile /dev/null",
22 | "build:lib": "vite build"
23 | }
24 | }
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HTML5 Example Page
6 |
7 |
8 |
9 |
10 |
11 |
12 | HTML5 Example Page
13 |
14 |
15 |
16 |
17 | Your browser does not support HTML5 video.
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/src/App.css:
--------------------------------------------------------------------------------
1 | #root {
2 | max-width: 1280px;
3 | margin: 0 auto;
4 | padding: 2rem;
5 | text-align: center;
6 | }
7 |
8 | .logo {
9 | height: 6em;
10 | padding: 1.5em;
11 | will-change: filter;
12 | }
13 | .logo:hover {
14 | filter: drop-shadow(0 0 2em #646cffaa);
15 | }
16 | .logo.react:hover {
17 | filter: drop-shadow(0 0 2em #61dafbaa);
18 | }
19 |
20 | @keyframes logo-spin {
21 | from {
22 | transform: rotate(0deg);
23 | }
24 | to {
25 | transform: rotate(360deg);
26 | }
27 | }
28 |
29 | @media (prefers-reduced-motion: no-preference) {
30 | a:nth-of-type(2) .logo {
31 | animation: logo-spin infinite 20s linear;
32 | }
33 | }
34 |
35 | .card {
36 | padding: 2em;
37 | }
38 |
39 | .read-the-docs {
40 | color: #888;
41 | }
42 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Index
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
18 |
19 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/pages/page2.ts:
--------------------------------------------------------------------------------
1 | import { getWebsiteConfig } from "../getWebsiteConfig";
2 | import { loadBackInitialState } from "../loadBackInitialState";
3 | import './page2.css'
4 |
5 | export default async function() {
6 | let initialState = { content: '' }
7 | if (import.meta.env.SSR) {
8 | // simulate reading from database
9 | initialState.content = 'this is page 2'
10 | } else {
11 | initialState = loadBackInitialState();
12 | }
13 | const config = await getWebsiteConfig();
14 | return {
15 | title: 'Page 2',
16 | view: `${initialState.content}
`,
17 | initialState,
18 | hydrate: () => {
19 | document.body.addEventListener('click', () => {
20 | alert('clicked page 2\n' + config.someConfigKey);
21 | })
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/client/pages/page1.ts:
--------------------------------------------------------------------------------
1 | import { getWebsiteConfig } from "../getWebsiteConfig";
2 | import { loadBackInitialState } from "../loadBackInitialState"
3 | import './page1.css';
4 |
5 | export default async function() {
6 | let initialState = { content: '' }
7 | if (import.meta.env.SSR) {
8 | // simulate reading from database
9 | initialState.content = 'this is page 1'
10 | } else {
11 | initialState = loadBackInitialState();
12 | }
13 | const config = await getWebsiteConfig();
14 | return {
15 | title: 'Page 1',
16 | view: `${initialState.content}
${config.someConfigKey}
`,
17 | initialState,
18 | hydrate: () => {
19 | document.body.addEventListener('click', () => {
20 | alert('clicked page 1');
21 | })
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/dist/ssr-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "vite/modulepreload-polyfill": [],
3 | "vite/preload-helper": [],
4 | "client/render.ts": [],
5 | "client/client-entry.ts": [],
6 | "index.html": [],
7 | "client/pages/page1.css": [
8 | "/assets/page1.6e09e3c6.js",
9 | "/assets/page1.260c2d15.css"
10 | ],
11 | "client/pages/page1.ts": [
12 | "/assets/page1.6e09e3c6.js",
13 | "/assets/page1.260c2d15.css"
14 | ],
15 | "client/getWebsiteConfig.ts": [
16 | "/assets/loadBackInitialState.8c7710d3.js"
17 | ],
18 | "client/loadBackInitialState.ts": [
19 | "/assets/loadBackInitialState.8c7710d3.js"
20 | ],
21 | "client/pages/page2.css": [
22 | "/assets/page2.6b797fad.js",
23 | "/assets/page2.4cb761c5.css"
24 | ],
25 | "client/pages/page2.ts": [
26 | "/assets/page2.6b797fad.js",
27 | "/assets/page2.4cb761c5.css"
28 | ]
29 | }
--------------------------------------------------------------------------------
/packages/SSR/share-index-html/server/server.ts:
--------------------------------------------------------------------------------
1 | import bodyParser from 'body-parser';
2 | import express from 'express';
3 |
4 | export const config = { indexHtml: '' }
5 | const server = express.Router();
6 | server.use(bodyParser.urlencoded({ extended: false }));
7 | server.use(bodyParser.json());
8 |
9 | server.get('/', async (req, resp) => {
10 | const markerPos = config.indexHtml.indexOf('');
11 | if (markerPos === -1) {
12 | throw new Error('maker not found, can not inject server generated content');
13 | }
14 | resp.write(config.indexHtml.substring(0, markerPos));
15 | // we can stream output here as well
16 | resp.write(`
17 |
18 | HTML5 Example Page
19 |
20 |
21 | `);
22 | resp.write(config.indexHtml.substring(markerPos));
23 | resp.end();
24 | })
25 |
26 | export default server;
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "python-django-server",
3 | "private": true,
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "body-parser": "^1.20.0",
7 | "express": "^5.0.0-beta.1",
8 | "http-proxy": "^1.18.1"
9 | },
10 | "devDependencies": {
11 | "@types/express": "^4.17.13",
12 | "vite": "^2.9.1"
13 | },
14 | "scripts": {
15 | "dev": "node dev.js",
16 | "build:client": "vite build client --emptyOutDir",
17 | "build:server": "vite build server --emptyOutDir",
18 | "build": "pnpm build:server && pnpm build:client",
19 | "preview": "node dist/server-entry.js",
20 | "venv": "python -m venv venv && bash -c 'source venv/bin/activate; pip install -r requirements.txt'",
21 | "dev:server": "bash -c 'source venv/bin/activate; python server/hello.py'"
22 | }
23 | }
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HTML5 Example Page
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | HTML5 Example Page
15 |
16 |
17 |
18 |
19 | Your browser does not support HTML5 video.
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/packages/SSR/generate-static-website/generate.js:
--------------------------------------------------------------------------------
1 | const vite = require('vite');
2 | const fs = require('fs');
3 | const path = require('path');
4 |
5 | async function main() {
6 | const { generateAllPages } = await loadModule('./server/generate.ts');
7 | const indexHtml = fs.readFileSync(
8 | path.join(__dirname, 'dist', 'index.html'), 'utf-8');
9 | const manifest = JSON.parse(fs.readFileSync(
10 | path.join(__dirname, 'dist', 'ssr-manifest.json'), 'utf-8'))
11 | await generateAllPages({
12 | outDir: path.join(__dirname, 'dist', 'website'),
13 | indexHtml,
14 | manifest
15 | });
16 | }
17 |
18 | async function loadModule(path) {
19 | const server = await vite.createServer({ server: { middlewareMode: 'ssr' } });
20 | try {
21 | return await server.ssrLoadModule(path);
22 | } finally {
23 | await server.close();
24 | }
25 | }
26 |
27 | main();
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/server/urls.py:
--------------------------------------------------------------------------------
1 | """server URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/4.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path('', include('polls.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/dist/assets/index.b15437e8.js:
--------------------------------------------------------------------------------
1 | const c=function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))i(e);new MutationObserver(e=>{for(const t of e)if(t.type==="childList")for(const o of t.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function s(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerpolicy&&(t.referrerPolicy=e.referrerpolicy),e.crossorigin==="use-credentials"?t.credentials="include":e.crossorigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function i(e){if(e.ep)return;e.ep=!0;const t=s(e);fetch(e.href,t)}};c();const n=document.createElement("img");n.setAttribute("src",new URL("/assets/demo-dynamic.d3480e7a.svg",self.location).href);n.setAttribute("width","300");document.documentElement.appendChild(n);
2 |
--------------------------------------------------------------------------------
/packages/CSR/reduce-homepage-size/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Laziness is a virtue
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/consumer/use-from-browser/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HTML5 Example Page
6 |
7 |
8 |
9 |
10 |
11 | HTML5 Example Page
12 |
13 |
14 |
17 |
24 |
28 |
29 |
--------------------------------------------------------------------------------
/packages/CSR/react-tsx/src/App.tsx:
--------------------------------------------------------------------------------
1 | import PropertyEditor from './PropertyEditor';
2 | import './App.css';
3 | import { getViewModel } from './ViewModel';
4 | import LayersPanel from './LayersPanel';
5 |
6 | function sleep(ms: number) {
7 | return new Promise(resolve => setTimeout(resolve, 1000));
8 | }
9 |
10 | function syncViewModels() {
11 | syncLayer1();
12 | getViewModel(PropertyEditor, "layer2").myValue = "world~~";
13 | getViewModel(LayersPanel).layers = ['layer1', 'layer2'];
14 | }
15 |
16 | function syncLayer1() {
17 | const viewModel = getViewModel(PropertyEditor, "layer1");
18 | viewModel.myValue = 'hello12';
19 | setTimeout(async () => {
20 | for (let i = 0; i < 100; i++) {
21 | if (!viewModel.isTyping) {
22 | viewModel.myValue = 'v: ' + i;
23 | }
24 | await sleep(1000);
25 | }
26 | }, 1000);
27 | }
28 |
29 | function App() {
30 | syncViewModels();
31 | return ;
32 | }
33 |
34 | export default App;
35 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/remote-package/publisher/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import federation from '@originjs/vite-plugin-federation'
3 | import fs from 'fs'
4 |
5 | const exposes: Record = {};
6 | for (const file of fs.readdirSync('src')) {
7 | if (file.endsWith('.ts')) {
8 | exposes[`./${file.replace('.ts', '')}`] = `src/${file}`;
9 | }
10 | }
11 |
12 | export default defineConfig({
13 | plugins: [federation({
14 | filename: 'remoteEntry.js',
15 | // exposes: {
16 | // './minusButton': 'src/minusButton.ts',
17 | // './plusButton': 'src/plusButton.ts'
18 | // },
19 | exposes,
20 | shared: ['remote-package-shared-store']
21 | })],
22 | build: {
23 | target: 'esnext',
24 | minify: false,
25 | cssCodeSplit: true,
26 | rollupOptions: {
27 | output: {
28 | minifyInternalExports: false
29 | }
30 | }
31 | }
32 | })
--------------------------------------------------------------------------------
/packages/CSR/html-dependencies/dist/assets/index.3bd70e40.js:
--------------------------------------------------------------------------------
1 | const d=function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))i(e);new MutationObserver(e=>{for(const t of e)if(t.type==="childList")for(const r of t.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function c(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerpolicy&&(t.referrerPolicy=e.referrerpolicy),e.crossorigin==="use-credentials"?t.credentials="include":e.crossorigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function i(e){if(e.ep)return;e.ep=!0;const t=c(e);fetch(e.href,t)}};d();const n=document.createElement("img");n.setAttribute("src",new URL("/assets/demo-dynamic.d3480e7a.svg",self.location).href);n.setAttribute("width","300");document.body.appendChild(n);const s=document.createElement("div");s.innerHTML="hello from some-ts.ts";document.body.appendChild(s);
2 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/vite.config.ts:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import { defineConfig } from 'vite'
3 | import fs from 'fs';
4 |
5 | module.exports = defineConfig({
6 | root: 'src',
7 | build: {
8 | rollupOptions: {
9 | input: {
10 | main: path.resolve(__dirname, 'src', 'index.html'),
11 | about: path.resolve(__dirname, 'src', 'about', 'about.html'),
12 | contactus: path.resolve(__dirname, 'src', 'contactus.html'),
13 | }
14 | },
15 | outDir: path.resolve(__dirname, 'dist')
16 | },
17 | plugins: [{
18 | name: 'server side include',
19 | transformIndexHtml: async (html, ctx) => {
20 | console.log('transform', ctx.filename);
21 | const header = await new Promise((resolve, reject) => fs.readFile('src/layout/header.partial.html', 'utf-8', (err, data) => {
22 | if (err) {
23 | reject(err);
24 | } else {
25 | resolve(data);
26 | }
27 | }))
28 | html = html.replace('', `${header}`);
29 | return html;
30 | }
31 | }]
32 | })
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/use-big-library-via-cdn/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Too big to host
7 |
8 |
9 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/packages/STATIC-LINKING/inversion-of-control/demo-plugin1/src/ComponentProvidedByPlugin1.tsx:
--------------------------------------------------------------------------------
1 | import * as vue from 'vue';
2 | import * as plugin1 from '@plugin1';
3 |
4 | // demo-motherboard does not depend on demo-plugin1
5 | // demo-plugin2 does not depend on demo-plugin1
6 | // even if we export this function, they can not import it
7 | export function secretHiddenByPlugin1() {
8 | return 'is secret'
9 | }
10 |
11 | // implement the abstract declaration of @plugin1
12 | // if the implementation does not match declaration, typescript will complain type incompatible
13 | export const ComponentProvidedByPlugin1: typeof plugin1.ComponentProvidedByPlugin1 = vue.defineComponent({
14 | props: {
15 | msg: {
16 | type: String,
17 | required: true
18 | }
19 | },
20 | data() {
21 | return {
22 | hello: 'world'
23 | }
24 | },
25 | methods: {
26 | onClick(): void {
27 | secretHiddenByPlugin1();
28 | }
29 | },
30 | render() {
31 | return ComponentProvidedByPlugin1
32 | }
33 | });
34 |
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Tao Wen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/use-big-library-via-cdn/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Too big to host
7 |
8 |
9 |
16 |
17 |
18 |
19 |
25 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/use-big-library-via-cdn/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import pkg from './package.json';
3 |
4 | export default defineConfig({
5 | plugins: [{
6 | name: 'provide monaco',
7 | load(id) {
8 | if (id === '@monaco') {
9 | return 'export default window.monaco'
10 | }
11 | },
12 | transformIndexHtml(html) {
13 | html = html.replace('', `
14 |
15 |
20 | `);
21 | return html;
22 | }
23 | }],
24 | resolve: {
25 | alias: {
26 | 'monaco-editor': '@monaco'
27 | }
28 | }
29 | })
--------------------------------------------------------------------------------
/packages/SSR/isomorphic-render/client/render.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | const page1 = () => import('./page1');
4 | const pages = {
5 | 'client/page1.ts': page1
6 | }
7 |
8 | export async function render(url: string) {
9 | let initialState: { greeting: string };
10 |
11 | if (import.meta.env.SSR) {
12 | // in node.js
13 | const fs = await import('fs');
14 | // simulate reading data from backend
15 | fs.writeFileSync('/tmp/initialState.json', JSON.stringify({
16 | greeting: 'hello world'
17 | }))
18 | initialState = JSON.parse(fs.readFileSync('/tmp/initialState.json', 'utf-8'));
19 | } else {
20 | // in browser
21 | const node = document.getElementById('initialState') as HTMLTemplateElement;
22 | initialState = JSON.parse(node.content.textContent);
23 | // simulate slow client side rendering causing FOUC problem
24 | await new Promise(resolve => setTimeout(resolve, 3000));
25 | }
26 | const moduleId = 'client/page1.ts';
27 | const { default: page } = await pages[moduleId]()
28 | return {
29 | modules: ['client/page1.ts'],
30 | view: `${page(initialState)}`,
31 | initialState
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/hybrid-npm-package/publisher/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@hybrid-npm-package/publisher",
3 | "private": true,
4 | "version": "1.0.0",
5 | "main": "dist/lib/src/index.js",
6 | "module": "dist/esm/src/index.js",
7 | "typings": "dist/typings/src/index.d.ts",
8 | "exports": {
9 | ".": {
10 | "require": "./dist/lib/src/index.js",
11 | "import": "./dist/esm/src/index.js"
12 | }
13 | },
14 | "dependencies": {
15 | "lodash": "^4.17.21"
16 | },
17 | "devDependencies": {
18 | "@types/jest": "^27.4.1",
19 | "@types/lodash": "^4.14.182",
20 | "jest": "^28.0.3",
21 | "npm-run-all": "^4.1.5",
22 | "typescript": "^4.6.4",
23 | "vite": "^2.9.1"
24 | },
25 | "scripts": {
26 | "dev": "run-p dev:**",
27 | "dev:cjs": "tsc -b tsconfig.cjs.json --watch",
28 | "dev:esm": "tsc -b --watch",
29 | "dev:test": "pnpm jest --watchAll --roots=dist/lib",
30 | "build": "rm -rf dist && run-p build:*",
31 | "build:typings": "tsc --emitDeclarationOnly --tsBuildInfoFile /dev/null",
32 | "build:lib": "vite build",
33 | "test": "pnpm tsc -b tsconfig.cjs.json && pnpm jest --roots=dist/lib"
34 | }
35 | }
--------------------------------------------------------------------------------
/packages/SSR/auto-reload-node-server/dev.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const { createServer: createViteServer } = require('vite');
3 |
4 | async function main() {
5 | const app = express()
6 | // auto reload in dev mode
7 | const vite = await createViteServer({
8 | server: {
9 | middlewareMode: 'ssr',
10 | watch: {
11 | // During tests we edit the files too fast and sometimes chokidar
12 | // misses change events, so enforce polling for consistency
13 | usePolling: true,
14 | interval: 100
15 | }
16 | }
17 | });
18 | app.all('/(.*)', async (req, resp) => {
19 | req.url = req.originalUrl;
20 | console.log(req.method, req.url);
21 | const { default: handle } = await vite.ssrLoadModule('./server/server.ts');
22 | handle(req, resp, (e) => {
23 | if (e) {
24 | vite.ssrFixStacktrace(e)
25 | console.error(e.stack)
26 | resp.status(500).end(e.stack);
27 | } else {
28 | resp.status(404).end();
29 | }
30 | });
31 | })
32 | app.listen(3000, () => {
33 | console.log('http://localhost:3000')
34 | });
35 | }
36 |
37 | main();
--------------------------------------------------------------------------------
/packages/CSR/reduce-homepage-size/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Laziness is a virtue
7 |
8 |
9 |
19 |
20 |
21 |
22 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/packages/SSR/dev-client-server-together/dev.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const { createServer: createViteServer } = require('vite');
3 |
4 | async function main() {
5 | const app = express()
6 | // auto reload in dev mode
7 | const vite = await createViteServer({
8 | server: {
9 | middlewareMode: 'ssr',
10 | watch: {
11 | // During tests we edit the files too fast and sometimes chokidar
12 | // misses change events, so enforce polling for consistency
13 | usePolling: true,
14 | interval: 100
15 | }
16 | }
17 | });
18 | app.use(vite.middlewares);
19 | app.all('/(.*)', async (req, resp) => {
20 | req.url = req.originalUrl;
21 | console.log(req.method, req.url);
22 | const { default: handle } = await vite.ssrLoadModule('./server/server.ts');
23 | handle(req, resp, (e) => {
24 | if (e) {
25 | vite.ssrFixStacktrace(e)
26 | console.error(e.stack)
27 | resp.status(500).end(e.stack);
28 | } else {
29 | resp.status(404).end();
30 | }
31 | });
32 | })
33 | app.listen(3000, () => {
34 | console.log('http://localhost:3000')
35 | });
36 | }
37 |
38 | main();
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Javascript is all you need
6 |
7 |
8 |
9 |
10 |
11 |
34 |
35 |
--------------------------------------------------------------------------------
/packages/DYNAMIC-LINKING/use-big-library-via-cdn/dist/assets/index.a8af7f97.js:
--------------------------------------------------------------------------------
1 | const a=function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&t(o)}).observe(document,{childList:!0,subtree:!0});function i(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerpolicy&&(r.referrerPolicy=e.referrerpolicy),e.crossorigin==="use-credentials"?r.credentials="include":e.crossorigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function t(e){if(e.ep)return;e.ep=!0;const r=i(e);fetch(e.href,r)}};a();const d="modulepreload",l={},f="/",m=function(n,i){return!i||i.length===0?n():Promise.all(i.map(t=>{if(t=`${f}${t}`,t in l)return;l[t]=!0;const e=t.endsWith(".css"),r=e?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${t}"]${r}`))return;const o=document.createElement("link");if(o.rel=e?"stylesheet":d,e||(o.as="script",o.crossOrigin=""),o.href=t,document.head.appendChild(o),e)return new Promise((c,u)=>{o.addEventListener("load",c),o.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${t}`)))})})).then(()=>n())};window.onMonacoLoaded=async()=>{const{renderApp:s}=await m(()=>import("./index.afd9424a.js"),[]);s()};
2 |
--------------------------------------------------------------------------------
/packages/CSR/multiple-html-pages/src/handleLink.js:
--------------------------------------------------------------------------------
1 | function handleLink() {
2 | const links = document.querySelectorAll('a[href^="/"]');
3 | for (const link of links) {
4 | link.addEventListener('click', async (e) => {
5 | e.preventDefault();
6 | const url = link.getAttribute('href');
7 | window.history.pushState(undefined, '', url);
8 | replaceHtml(url);
9 | });
10 | }
11 | }
12 |
13 | async function replaceHtml(url) {
14 | const resp = await fetch(url)
15 | const html = await resp.text();
16 | document.documentElement.innerHTML = html;
17 | handleLink();
18 | for (const node of document.querySelectorAll('script')) {
19 | const script = document.createElement('script');
20 | for (let i = 0; i < node.attributes.length; i++) {
21 | script.setAttribute(node.attributes.item(i).name, node.attributes.item(i).value);
22 | }
23 | const src = new URL(script.getAttribute('src'), window.location.href);
24 | src.searchParams.append('t', new Date().getTime());
25 | script.setAttribute('src', src.toString());
26 | node.replaceWith(script);
27 | }
28 | }
29 |
30 | if (!window.handleLinkEnabled) {
31 | window.handleLinkEnabled = true;
32 | handleLink();
33 | window.addEventListener('popstate', () => {
34 | replaceHtml(window.location.href);
35 | })
36 | }
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/dev.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const { createServer: createViteServer } = require('vite');
3 | const httpProxy = require('http-proxy');
4 |
5 | var proxy = httpProxy.createProxyServer({});
6 |
7 | async function main() {
8 | const app = express()
9 | // auto reload in dev mode
10 | const vite = await createViteServer({
11 | server: {
12 | middlewareMode: 'ssr',
13 | watch: {
14 | // During tests we edit the files too fast and sometimes chokidar
15 | // misses change events, so enforce polling for consistency
16 | usePolling: true,
17 | interval: 100
18 | }
19 | }
20 | });
21 | app.use(vite.middlewares);
22 | app.all('/(.*)', async (req, resp) => {
23 | req.url = req.originalUrl;
24 | console.log(req.method, req.url);
25 | proxy.web(req, resp, {
26 | target: 'http://localhost:8000'
27 | }, (e) => {
28 | if (e) {
29 | vite.ssrFixStacktrace(e)
30 | console.error(e.stack)
31 | resp.status(500).end(e.stack);
32 | } else {
33 | resp.status(404).end();
34 | }
35 | });
36 | })
37 | app.listen(3000, () => {
38 | console.log('http://localhost:3000')
39 | });
40 | }
41 |
42 | main();
--------------------------------------------------------------------------------
/packages/SSR/auto-reload-node-server/dist/server-entry.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var express = require("express");
3 | var path = require("path");
4 | var bodyParser = require("body-parser");
5 | function _interopDefaultLegacy(e) {
6 | return e && typeof e === "object" && "default" in e ? e : { "default": e };
7 | }
8 | var express__default = /* @__PURE__ */ _interopDefaultLegacy(express);
9 | var path__default = /* @__PURE__ */ _interopDefaultLegacy(path);
10 | var bodyParser__default = /* @__PURE__ */ _interopDefaultLegacy(bodyParser);
11 | const server = express__default["default"].Router();
12 | server.use(bodyParser__default["default"].urlencoded({ extended: false }));
13 | server.use(bodyParser__default["default"].json());
14 | server.get("/", async (req, resp) => {
15 | resp.send(`
16 |
17 |
18 |
19 |
20 | Server is a destiny
21 |
22 |
23 |
24 |
25 |
26 | HTML5 Example Page
27 |
28 |
29 |
69 |
70 |
75 | ```
76 |
77 | Before our application code execute, we need to load the actual library code into `window.monaco`.
78 |
79 | ### match package.json version
80 |
81 | ```ts
82 | import { defineConfig } from 'vite'
83 | import pkg from './package.json';
84 |
85 | export default defineConfig({
86 | plugins: [{
87 | name: 'provide monaco',
88 | load(id) {
89 | if (id === '@monaco') {
90 | return 'export default window.monaco'
91 | }
92 | },
93 | transformIndexHtml(html) {
94 | html = html.replace('', `
95 |
96 |
101 | `);
102 | return html;
103 | }
104 | }],
105 | resolve: {
106 | alias: {
107 | 'monaco-editor': '@monaco'
108 | }
109 | }
110 | })
111 | ```
112 |
113 | we can read the monaco-editor version from package.json, to ensure the version used in type checking matches the actual runtime version.
--------------------------------------------------------------------------------
/packages/SSR/python-django-server/server/server/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for server project.
3 |
4 | Generated by 'django-admin startproject' using Django 4.0.4.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.0/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/4.0/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = 'django-insecure-dso5ed%n3x@&&+zitjls0#vw3!4th+5+9vgp9g88tmdq9dncvx'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'polls.apps.PollsConfig',
35 | 'django.contrib.admin',
36 | 'django.contrib.auth',
37 | 'django.contrib.contenttypes',
38 | 'django.contrib.sessions',
39 | 'django.contrib.messages',
40 | 'django.contrib.staticfiles',
41 | ]
42 |
43 | MIDDLEWARE = [
44 | 'django.middleware.security.SecurityMiddleware',
45 | 'django.contrib.sessions.middleware.SessionMiddleware',
46 | 'django.middleware.common.CommonMiddleware',
47 | 'django.middleware.csrf.CsrfViewMiddleware',
48 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
49 | 'django.contrib.messages.middleware.MessageMiddleware',
50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 | ]
52 |
53 | ROOT_URLCONF = 'server.urls'
54 |
55 | TEMPLATES = [
56 | {
57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
58 | 'DIRS': [],
59 | 'APP_DIRS': True,
60 | 'OPTIONS': {
61 | 'context_processors': [
62 | 'django.template.context_processors.debug',
63 | 'django.template.context_processors.request',
64 | 'django.contrib.auth.context_processors.auth',
65 | 'django.contrib.messages.context_processors.messages',
66 | ],
67 | },
68 | },
69 | ]
70 |
71 | WSGI_APPLICATION = 'server.wsgi.application'
72 |
73 |
74 | # Database
75 | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases
76 |
77 | DATABASES = {
78 | 'default': {
79 | 'ENGINE': 'django.db.backends.sqlite3',
80 | 'NAME': BASE_DIR / 'db.sqlite3',
81 | }
82 | }
83 |
84 |
85 | # Password validation
86 | # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
87 |
88 | AUTH_PASSWORD_VALIDATORS = [
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 | },
101 | ]
102 |
103 |
104 | # Internationalization
105 | # https://docs.djangoproject.com/en/4.0/topics/i18n/
106 |
107 | LANGUAGE_CODE = 'en-us'
108 |
109 | TIME_ZONE = 'UTC'
110 |
111 | USE_I18N = True
112 |
113 | USE_TZ = True
114 |
115 |
116 | # Static files (CSS, JavaScript, Images)
117 | # https://docs.djangoproject.com/en/4.0/howto/static-files/
118 |
119 | STATIC_URL = 'static/'
120 |
121 | # Default primary key field type
122 | # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
123 |
124 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
125 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/dist/assets/index.91a509f3.js:
--------------------------------------------------------------------------------
1 | const p = function polyfill() {
2 | const relList = document.createElement("link").relList;
3 | if (relList && relList.supports && relList.supports("modulepreload")) {
4 | return;
5 | }
6 | for (const link of document.querySelectorAll('link[rel="modulepreload"]')) {
7 | processPreload(link);
8 | }
9 | new MutationObserver((mutations) => {
10 | for (const mutation of mutations) {
11 | if (mutation.type !== "childList") {
12 | continue;
13 | }
14 | for (const node of mutation.addedNodes) {
15 | if (node.tagName === "LINK" && node.rel === "modulepreload")
16 | processPreload(node);
17 | }
18 | }
19 | }).observe(document, { childList: true, subtree: true });
20 | function getFetchOpts(script) {
21 | const fetchOpts = {};
22 | if (script.integrity)
23 | fetchOpts.integrity = script.integrity;
24 | if (script.referrerpolicy)
25 | fetchOpts.referrerPolicy = script.referrerpolicy;
26 | if (script.crossorigin === "use-credentials")
27 | fetchOpts.credentials = "include";
28 | else if (script.crossorigin === "anonymous")
29 | fetchOpts.credentials = "omit";
30 | else
31 | fetchOpts.credentials = "same-origin";
32 | return fetchOpts;
33 | }
34 | function processPreload(link) {
35 | if (link.ep)
36 | return;
37 | link.ep = true;
38 | const fetchOpts = getFetchOpts(link);
39 | fetch(link.href, fetchOpts);
40 | }
41 | };
42 | p();
43 | var index = "Index Page";
44 | var __glob_7_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
45 | __proto__: null,
46 | "default": index
47 | }, Symbol.toStringTag, { value: "Module" }));
48 | var about = "About Page";
49 | var __glob_7_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50 | __proto__: null,
51 | "default": about
52 | }, Symbol.toStringTag, { value: "Module" }));
53 | var demo = "";
54 | const blue = "_blue_15qkp_2";
55 | var example_module = {
56 | blue
57 | };
58 | const hello = "world";
59 | var demoJson = {
60 | hello
61 | };
62 | var demoJsonUrl = "/assets/demo.9d04e1f3.json";
63 | var demoJsonRaw = '{\n "hello": "world"\n}';
64 | var demoDynamicSvg = "/assets/demo-dynamic.d3480e7a.svg";
65 | const img = document.createElement("img");
66 | img.setAttribute("src", demoDynamicSvg);
67 | img.setAttribute("width", "300");
68 | document.body.appendChild(img);
69 | var initWasm$1 = async (opts = {}, url) => {
70 | let result;
71 | if (url.startsWith("data:")) {
72 | const binaryString = atob(url.replace(/^data:.*?base64,/, ""));
73 | const bytes = new Uint8Array(binaryString.length);
74 | for (let i = 0; i < binaryString.length; i++) {
75 | bytes[i] = binaryString.charCodeAt(i);
76 | }
77 | result = await WebAssembly.instantiate(bytes, opts);
78 | } else {
79 | const response = await fetch(url);
80 | const contentType = response.headers.get("Content-Type") || "";
81 | if ("instantiateStreaming" in WebAssembly && contentType.startsWith("application/wasm")) {
82 | result = await WebAssembly.instantiateStreaming(response, opts);
83 | } else {
84 | const buffer = await response.arrayBuffer();
85 | result = await WebAssembly.instantiate(buffer, opts);
86 | }
87 | }
88 | return result.instance.exports;
89 | };
90 | var initWasm = (opts) => initWasm$1(opts, "/assets/demo.47f9337a.wasm");
91 | const pages = { "./pages/index.tsx": __glob_7_0, "./pages/home/about.tsx": __glob_7_1 };
92 | document.querySelector("main").innerHTML = `
93 | hello
94 | this is blue
95 | ${demoJsonUrl} ${JSON.stringify(demoJson)}
96 | ${demoJsonRaw}
97 | ${JSON.stringify(pages)}
98 | `;
99 | async function loadWasm() {
100 | const { add } = await initWasm();
101 | console.log("1+1", add(1, 1));
102 | }
103 | loadWasm();
104 |
--------------------------------------------------------------------------------
/packages/CSR/everything-in-js/README.md:
--------------------------------------------------------------------------------
1 | # How to centralize logic/style and other related dependencies into one javascript file
2 |
3 | ## Code Structure & Motivation
4 |
5 | A typical client side rendering application is consisted by:
6 |
7 | * a nearly blank html file, referencing
8 | * a javascript entry file, which references
9 | * all other javascript files rendering the application pages
10 |
11 | The motivation to leave html blank, and move logic and style into javascript is to allow
12 |
13 | * Component reuse: html is not good at deduplicate repeated content structure
14 | * Shared layout: every page rendered from same javascript file makes sharing top level layout easier.
15 | * Make style, content, behavior close to each other, for better maintainability. It is more likely to keep names in sync
16 | * Declaractive style view enabled by framework like React
17 |
18 | ## DX Problems
19 |
20 | Stylesheet can only be declared in `