Stable SSR with esbuild
This commit is contained in:
parent
0b2351f39c
commit
c6b782ff8b
70
esbuild.js
70
esbuild.js
@ -1,14 +1,59 @@
|
||||
const {build} = require("esbuild");
|
||||
const {solidPlugin} = require("esbuild-plugin-solid");
|
||||
const { build, context } = require("esbuild");
|
||||
const { solidPlugin } = require("esbuild-plugin-solid");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const glob = require("glob");
|
||||
const { glob } = require("glob");
|
||||
|
||||
glob.glob("./src/**/*.{ts,tsx}")
|
||||
.then((files) => {
|
||||
console.log(files);
|
||||
build({
|
||||
(async() => {
|
||||
const files = await glob("dist/**/*.jsx");
|
||||
const ctx = await context({
|
||||
platform: "node",
|
||||
entryPoints: files,
|
||||
bundle: false,
|
||||
minify: false,
|
||||
logLevel: "info",
|
||||
plugins: [solidPlugin({
|
||||
solid: {
|
||||
generate: "ssr",
|
||||
hydratable: true,
|
||||
},
|
||||
})],
|
||||
outdir: "dist/src",
|
||||
format: "cjs",
|
||||
});
|
||||
|
||||
await ctx.watch();
|
||||
console.log("Watching...");
|
||||
})();
|
||||
|
||||
/*
|
||||
glob("dist/** /*.jsx")
|
||||
.then((files) => {
|
||||
build({
|
||||
platform: "node",
|
||||
entryPoints: files,
|
||||
bundle: false,
|
||||
minify: false,
|
||||
logLevel: "info",
|
||||
plugins: [solidPlugin({
|
||||
solid: {
|
||||
generate: "ssr",
|
||||
hydratable: true,
|
||||
},
|
||||
})],
|
||||
outdir: "dist/src",
|
||||
format: "cjs",
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
/*
|
||||
build({
|
||||
platform: "node",
|
||||
entryPoints: [
|
||||
"src/main.ts",
|
||||
],
|
||||
bundle: true,
|
||||
minify: false,
|
||||
logLevel: "info",
|
||||
plugins: [solidPlugin({
|
||||
@ -19,5 +64,12 @@ glob.glob("./src/**/*.{ts,tsx}")
|
||||
})],
|
||||
outdir: "dist",
|
||||
format: "cjs",
|
||||
});
|
||||
});
|
||||
external: [
|
||||
"@nestjs/*",
|
||||
"@fastify/*",
|
||||
"class-validator",
|
||||
"class-transformer",
|
||||
"cache-manager",
|
||||
],
|
||||
});
|
||||
*/
|
||||
|
51
esbuild2.js
51
esbuild2.js
@ -1,51 +0,0 @@
|
||||
const { build } = require("esbuild");
|
||||
const { solidPlugin } = require("esbuild-plugin-solid");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { glob } = require("glob");
|
||||
|
||||
glob("dist/**/*.jsx")
|
||||
.then((files) => {
|
||||
build({
|
||||
platform: "node",
|
||||
entryPoints: files,
|
||||
bundle: false,
|
||||
minify: false,
|
||||
logLevel: "info",
|
||||
plugins: [solidPlugin({
|
||||
solid: {
|
||||
generate: "ssr",
|
||||
hydratable: true,
|
||||
},
|
||||
})],
|
||||
outdir: "dist/src",
|
||||
format: "cjs",
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
build({
|
||||
platform: "node",
|
||||
entryPoints: [
|
||||
"src/main.ts",
|
||||
],
|
||||
bundle: true,
|
||||
minify: false,
|
||||
logLevel: "info",
|
||||
plugins: [solidPlugin({
|
||||
solid: {
|
||||
generate: "ssr",
|
||||
hydratable: true,
|
||||
},
|
||||
})],
|
||||
outdir: "dist",
|
||||
format: "cjs",
|
||||
external: [
|
||||
"@nestjs/*",
|
||||
"@fastify/*",
|
||||
"class-validator",
|
||||
"class-transformer",
|
||||
"cache-manager",
|
||||
],
|
||||
});
|
||||
*/
|
17
package.json
17
package.json
@ -7,7 +7,6 @@
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
@ -17,7 +16,8 @@
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||
"ssr:watch": "node esbuild.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
@ -31,20 +31,10 @@
|
||||
"typeorm": "^0.3.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.21.8",
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
"@babel/preset-env": "^7.21.5",
|
||||
"@nestjs/cli": "^9.0.0",
|
||||
"@nestjs/platform-fastify": "^9.4.0",
|
||||
"@nestjs/schematics": "^9.0.0",
|
||||
"@nestjs/testing": "^9.0.0",
|
||||
"@rollup/plugin-babel": "^6.0.3",
|
||||
"@rollup/plugin-commonjs": "^24.1.0",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.2",
|
||||
"@rollup/plugin-replace": "^5.0.2",
|
||||
"@rollup/plugin-terser": "^0.4.1",
|
||||
"@rollup/plugin-typescript": "^11.1.0",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/jest": "29.5.0",
|
||||
"@types/node": "18.15.11",
|
||||
@ -52,8 +42,6 @@
|
||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||
"@typescript-eslint/parser": "^5.0.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"babel-loader": "^9.1.2",
|
||||
"babel-preset-solid": "^1.6.9",
|
||||
"esbuild": "^0.17.18",
|
||||
"esbuild-plugin-solid": "^0.5.0",
|
||||
"eslint": "^8.0.1",
|
||||
@ -61,7 +49,6 @@
|
||||
"glob": "^10.2.2",
|
||||
"jest": "29.5.0",
|
||||
"postcss": "^8.4.23",
|
||||
"rollup": "^3.21.5",
|
||||
"rollup-plugin-copy": "^3.4.0",
|
||||
"rollup-route-manifest": "^1.0.0",
|
||||
"source-map-support": "^0.5.20",
|
||||
|
@ -1,7 +0,0 @@
|
||||
export function App() {
|
||||
return (
|
||||
<div>
|
||||
SSR :D
|
||||
</div>
|
||||
)
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
import { hydrate } from "solid-js/web";
|
||||
import {App} from "./App";
|
||||
|
||||
// entry point for browser
|
||||
hydrate(() => <App/>, document);
|
@ -1,6 +0,0 @@
|
||||
import {renderToString} from "solid-js/web";
|
||||
import {App} from "../shared/src/App";
|
||||
|
||||
const html = renderToString(() => <App />)
|
||||
|
||||
console.log(html);
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"allowJs": true,
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
@ -20,5 +19,9 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"jsx": "preserve",
|
||||
"jsxImportSource": "solid-js"
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user