initial commit

fix-build-duplicate-code
Ryan Carniato 3 years ago
commit 1996b65b0d

@ -0,0 +1,8 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = LF
charset = utf-8
insert_final_newline = true

8
.gitignore vendored

@ -0,0 +1,8 @@
node_modules/
dist/
lib/
.vscode/
coverage/
types/
packages/solid-start/bin

@ -0,0 +1,8 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"arrowParens": "avoid",
"printWidth": 100
}

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Ryan Carniato
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,3 @@
# Solid Start
This is the home of the new official starter for Solid. This is still a work in progress.

16
example/.gitignore vendored

@ -0,0 +1,16 @@
dist
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/
#System Files
.DS_Store
Thumbs.db

@ -0,0 +1,32 @@
# SolidStart
Everything you need to build a Solid project, powered by [`solid-start`](https://github.com/ryansolid/solid-start/tree/master/packages/solid-start);
## Creating a project
```bash
# create a new project in the current directory
npm init solid@next
# create a new project in my-app
npm init solid@next my-app
```
> Note: the `@next` is temporary
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
Solid apps are built with _adapters_, which optimise your project for deployment to different environments.
By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="/favicon.ico" />
<!--app-head-->
<script type="module" src="@solid-start/entry.jsx"></script>
</head>
<body>
<div id="app"><!--app-html--></div>
</body>
</html>

@ -0,0 +1,305 @@
{
"name": "example",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"devDependencies": {
"solid-app-router": "0.0.36",
"solid-js": "0.24.15",
"vite": "^2.1.3"
},
"engines": {
"node": ">=12"
}
},
"node_modules/colorette": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz",
"integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==",
"dev": true
},
"node_modules/esbuild": {
"version": "0.9.7",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.9.7.tgz",
"integrity": "sha512-VtUf6aQ89VTmMLKrWHYG50uByMF4JQlVysb8dmg6cOgW8JnFCipmz7p+HNBl+RR3LLCuBxFGVauAe2wfnF9bLg==",
"dev": true,
"hasInstallScript": true,
"bin": {
"esbuild": "bin/esbuild"
}
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.1"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/is-core-module": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz",
"integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==",
"dev": true,
"dependencies": {
"has": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/nanoid": {
"version": "3.1.22",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.22.tgz",
"integrity": "sha512-/2ZUaJX2ANuLtTvqTlgqBQNJoQO398KyJgZloL0PZkC0dpysjncRUPsFe3DUPzz/y3h+u7C46np8RMuvF3jsSQ==",
"dev": true,
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
"dev": true
},
"node_modules/postcss": {
"version": "8.2.9",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.9.tgz",
"integrity": "sha512-b+TmuIL4jGtCHtoLi+G/PisuIl9avxs8IZMSmlABRwNz5RLUUACrC+ws81dcomz1nRezm5YPdXiMEzBEKgYn+Q==",
"dev": true,
"dependencies": {
"colorette": "^1.2.2",
"nanoid": "^3.1.22",
"source-map": "^0.6.1"
},
"engines": {
"node": "^10 || ^12 || >=14"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
}
},
"node_modules/resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"dev": true,
"dependencies": {
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/rollup": {
"version": "2.44.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.44.0.tgz",
"integrity": "sha512-rGSF4pLwvuaH/x4nAS+zP6UNn5YUDWf/TeEU5IoXSZKBbKRNTCI3qMnYXKZgrC0D2KzS2baiOZt1OlqhMu5rnQ==",
"dev": true,
"bin": {
"rollup": "dist/bin/rollup"
},
"engines": {
"node": ">=10.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.1"
}
},
"node_modules/solid-app-router": {
"version": "0.0.36",
"resolved": "https://registry.npmjs.org/solid-app-router/-/solid-app-router-0.0.36.tgz",
"integrity": "sha512-x6ssnVcwTWO8JKv6qeYDCL94ie0wCmBd4yhX03xCmfMawRzQGp5nQq08rXlT8OXDawUjGyewxM4SHtg3R45Mhw==",
"dev": true,
"peerDependencies": {
"solid-js": "^0.24.0"
}
},
"node_modules/solid-js": {
"version": "0.24.15",
"resolved": "https://registry.npmjs.org/solid-js/-/solid-js-0.24.15.tgz",
"integrity": "sha512-p+Cv3AZBwpeQTRoCoJNXvmpl8nt9oOx2Xj6/zsrImul1lLGCgBqlyg+pKByOECG48Oe5oNAQOooe3Ba8zovVXA==",
"dev": true
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/vite": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-2.1.5.tgz",
"integrity": "sha512-tYU5iaYeUgQYvK/CNNz3tiJ8vYqPWfCE9IQ7K0iuzYovWw7lzty7KRYGWwV3CQPh0NKxWjOczAqiJsCL0Xb+Og==",
"dev": true,
"dependencies": {
"esbuild": "^0.9.3",
"postcss": "^8.2.1",
"resolve": "^1.19.0",
"rollup": "^2.38.5"
},
"bin": {
"vite": "bin/vite.js"
},
"engines": {
"node": ">=12.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.1"
}
}
},
"dependencies": {
"colorette": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz",
"integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==",
"dev": true
},
"esbuild": {
"version": "0.9.7",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.9.7.tgz",
"integrity": "sha512-VtUf6aQ89VTmMLKrWHYG50uByMF4JQlVysb8dmg6cOgW8JnFCipmz7p+HNBl+RR3LLCuBxFGVauAe2wfnF9bLg==",
"dev": true
},
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"is-core-module": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz",
"integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==",
"dev": true,
"requires": {
"has": "^1.0.3"
}
},
"nanoid": {
"version": "3.1.22",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.22.tgz",
"integrity": "sha512-/2ZUaJX2ANuLtTvqTlgqBQNJoQO398KyJgZloL0PZkC0dpysjncRUPsFe3DUPzz/y3h+u7C46np8RMuvF3jsSQ==",
"dev": true
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
"dev": true
},
"postcss": {
"version": "8.2.9",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.9.tgz",
"integrity": "sha512-b+TmuIL4jGtCHtoLi+G/PisuIl9avxs8IZMSmlABRwNz5RLUUACrC+ws81dcomz1nRezm5YPdXiMEzBEKgYn+Q==",
"dev": true,
"requires": {
"colorette": "^1.2.2",
"nanoid": "^3.1.22",
"source-map": "^0.6.1"
}
},
"resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"dev": true,
"requires": {
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
}
},
"rollup": {
"version": "2.44.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.44.0.tgz",
"integrity": "sha512-rGSF4pLwvuaH/x4nAS+zP6UNn5YUDWf/TeEU5IoXSZKBbKRNTCI3qMnYXKZgrC0D2KzS2baiOZt1OlqhMu5rnQ==",
"dev": true,
"requires": {
"fsevents": "~2.3.1"
}
},
"solid-app-router": {
"version": "0.0.36",
"resolved": "https://registry.npmjs.org/solid-app-router/-/solid-app-router-0.0.36.tgz",
"integrity": "sha512-x6ssnVcwTWO8JKv6qeYDCL94ie0wCmBd4yhX03xCmfMawRzQGp5nQq08rXlT8OXDawUjGyewxM4SHtg3R45Mhw==",
"dev": true,
"requires": {}
},
"solid-js": {
"version": "0.24.15",
"resolved": "https://registry.npmjs.org/solid-js/-/solid-js-0.24.15.tgz",
"integrity": "sha512-p+Cv3AZBwpeQTRoCoJNXvmpl8nt9oOx2Xj6/zsrImul1lLGCgBqlyg+pKByOECG48Oe5oNAQOooe3Ba8zovVXA==",
"dev": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"vite": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-2.1.5.tgz",
"integrity": "sha512-tYU5iaYeUgQYvK/CNNz3tiJ8vYqPWfCE9IQ7K0iuzYovWw7lzty7KRYGWwV3CQPh0NKxWjOczAqiJsCL0Xb+Og==",
"dev": true,
"requires": {
"esbuild": "^0.9.3",
"fsevents": "~2.3.1",
"postcss": "^8.2.1",
"resolve": "^1.19.0",
"rollup": "^2.38.5"
}
}
}
}

@ -0,0 +1,17 @@
{
"name": "example",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
},
"type": "module",
"devDependencies": {
"solid-app-router": "0.0.36",
"solid-js": "0.24.15",
"vite": "^2.1.3"
},
"engines": {
"node": ">=12"
}
}

@ -0,0 +1,9 @@
import { Route } from "solid-app-router";
export default function Layout({ App }) {
return (
<App>
<Route />
</App>
);
}

@ -0,0 +1,37 @@
import { defineConfig } from "vite";
import solid from "vite-plugin-solid";
import manifest from "rollup-route-manifest";
import path from "path";
export default defineConfig({
resolve: {
alias: [{
find: "~",
replacement: path.join(process.cwd(), "src")
}]
},
plugins: [
solid({ ssr: true }),
{
name: "html-async",
enforce: "post",
transformIndexHtml(html) {
return html.replace('type="module"', 'type="module" async');
}
},
manifest({
inline: false,
merge: false,
publicPath: "/",
routes: (file) => {
file = file.replace(path.join(__dirname, "src"), "").replace(/\.[tj]sx?$/, "");
if (!file.includes("/pages/")) return "*"; // commons
return "/" + file.replace("/pages/", "").toLowerCase();
}
})
],
build: {
polyfillDynamicImport: false,
target: "esnext"
}
});

@ -0,0 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "0.0.12"
}

13728
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,33 @@
{
"name": "solid-start",
"description": "Official starter for SolidJS",
"version": "0.1.0",
"author": "Ryan Carniato",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ryansolid/solid-start"
},
"private": true,
"scripts": {
"postinstall": "lerna bootstrap --hoist --no-ci",
"clean": "npm run clean:artifacts && npm run clean:packages && npm run clean:root",
"clean:artifacts": "lerna run clean --parallel",
"clean:packages": "lerna clean --yes",
"clean:root": "rimraf node_modules",
"test": "lerna run test --concurrency=1 --stream",
"test:coverage": "lerna run test:coverage --parallel",
"build": "lerna run build --concurrency=1 --stream",
"publish:release": "lerna run build && lerna publish"
},
"devDependencies": {
"@rollup/plugin-commonjs": "18.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "11.2.1",
"coveralls": "^3.1.0",
"lerna": "^4.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.41.1",
"typescript": "~4.2.3"
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,100 @@
import fs from "fs";
import parser from "gitignore-parser";
import { bold, cyan, gray, green, red } from "kleur/colors";
import path from "path";
import prompts from "prompts/lib/index";
import glob from "tiny-glob/sync.js";
import { version } from "../package.json";
const disclaimer = `
Welcome to the SolidStart setup wizard!
There are definitely bugs and some feature might not work yet.
If you encounter an issue, have a look at https://github.com/ryansolid/solid-start/issues and open a new one, if it is not already tracked.
`;
function mkdirp(dir) {
try {
fs.mkdirSync(dir, { recursive: true });
} catch (e) {
if (e.code === "EEXIST") return;
throw e;
}
}
async function main() {
console.log(gray(`\ncreate-solid version ${version}`));
console.log(red(disclaimer));
const target = process.argv[2] || ".";
const ts_response = await prompts({
type: "confirm",
name: "value",
message: "Use TypeScript?",
initial: false
});
if (fs.existsSync(target)) {
if (fs.readdirSync(target).length > 0) {
const response = await prompts({
type: "confirm",
name: "value",
message: "Directory not empty. Continue?",
initial: false
});
if (!response.value) {
process.exit(1);
}
}
} else {
mkdirp(target);
}
const cwd = path.join(__dirname, "templates/" + (ts_response.value ? "app-ts" : "app"));
const gitignore_contents = fs.readFileSync(path.join(cwd, ".gitignore"), "utf-8");
const gitignore = parser.compile(gitignore_contents);
const files = glob("**/*", { cwd }).filter(gitignore.accepts);
files.forEach(file => {
const src = path.join(cwd, file);
const dest = path.join(target, file);
if (fs.statSync(src).isDirectory()) {
mkdirp(dest);
} else {
fs.copyFileSync(src, dest);
}
});
fs.writeFileSync(path.join(target, ".gitignore"), gitignore_contents);
const name = path.basename(path.resolve(target));
const pkg_file = path.join(target, "package.json");
const pkg_json = fs
.readFileSync(pkg_file, "utf-8")
.replace("~TODO~", name)
.replace(/"(.+)": "workspace:.+"/g, (_m, name) => `"${name}": "next"`); // TODO ^${versions[name]}
fs.writeFileSync(pkg_file, pkg_json);
console.log(bold(green("✔ Copied project files")));
console.log("\nNext steps:");
let i = 1;
const relative = path.relative(process.cwd(), target);
if (relative !== "") {
console.log(` ${i++}: ${bold(cyan(`cd ${relative}`))}`);
}
console.log(` ${i++}: ${bold(cyan("npm install"))} (or pnpm install, or yarn)`);
console.log(` ${i++}: ${bold(cyan("npm run dev -- --open"))}`);
console.log(`\nTo close the dev server, hit ${bold(cyan("Ctrl-C"))}`);
}
main();

@ -0,0 +1,21 @@
{
"name": "create-solid",
"version": "0.0.12",
"description": "Create Solid apps with low configuration",
"author": "Ryan Carniato",
"license": "MIT",
"bin": "./bin",
"scripts": {
"build": "rollup -c"
},
"devDependencies": {
"gitignore-parser": "^0.0.2",
"kleur": "^4.1.4",
"prompts": "^2.4.0",
"tiny-glob": "^0.2.8"
},
"files": [
"bin",
"templates"
]
}

@ -0,0 +1,19 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
export default {
input: 'cli/index.js',
output: {
file: 'bin',
format: 'cjs',
banner: '#!/usr/bin/env node',
interop: false
},
plugins: [
nodeResolve(),
commonjs(),
json(),
],
external: require('module').builtinModules
};

@ -0,0 +1,16 @@
dist
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/
#System Files
.DS_Store
Thumbs.db

@ -0,0 +1,32 @@
# SolidStart
Everything you need to build a Solid project, powered by [`solid-start`](https://github.com/ryansolid/solid-start/tree/master/packages/solid-start);
## Creating a project
```bash
# create a new project in the current directory
npm init solid@next
# create a new project in my-app
npm init solid@next my-app
```
> Note: the `@next` is temporary
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
Solid apps are built with _adapters_, which optimise your project for deployment to different environments.
By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="/favicon.ico" />
<!--app-head-->
<script type="module" src="@solid-start/entry.jsx"></script>
</head>
<body>
<div id="app"><!--app-html--></div>
</body>
</html>

@ -0,0 +1,17 @@
{
"name": "~TODO~",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
},
"type": "module",
"devDependencies": {
"solid-js": "0.25.0",
"typescript": "^4.2.3",
"vite": "^2.1.3"
},
"engines": {
"node": ">=12"
}
}

@ -0,0 +1,10 @@
import { Route } from "solid-app-router";
// Add any context providers, and top level navigation here
export default function Layout({ App }) {
return (
<App>
<Route />
</App>
);
}

@ -0,0 +1,12 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"jsxImportSource": "solid-js",
"jsx": "preserve",
"types": ["vite/client"]
}
}

@ -0,0 +1,40 @@
import { defineConfig } from "vite";
import solid from "vite-plugin-solid";
import manifest from "rollup-route-manifest";
import path from "path";
export default defineConfig({
resolve: {
alias: [{
find: "~",
replacement: path.join(process.cwd(), "src")
}, {
find: "@solid-start",
replacement: path.join(process.cwd(), "node_modules", "solid-start", "runtime")
}]
},
plugins: [
solid({ ssr: true }),
{
name: "html-async",
enforce: "post",
transformIndexHtml(html) {
return html.replace('type="module"', 'type="module" async');
}
},
manifest({
inline: false,
merge: false,
publicPath: "/",
routes: (file) => {
file = file.replace(path.join(__dirname, "src"), "").replace(/\.[tj]sx?$/, "");
if (!file.includes("/pages/")) return "*"; // commons
return "/" + file.replace("/pages/", "").toLowerCase();
}
})
],
build: {
polyfillDynamicImport: false,
target: "esnext"
}
});

@ -0,0 +1,16 @@
dist
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/
#System Files
.DS_Store
Thumbs.db

@ -0,0 +1,32 @@
# SolidStart
Everything you need to build a Solid project, powered by [`solid-start`](https://github.com/ryansolid/solid-start/tree/master/packages/solid-start);
## Creating a project
```bash
# create a new project in the current directory
npm init solid@next
# create a new project in my-app
npm init solid@next my-app
```
> Note: the `@next` is temporary
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
Solid apps are built with _adapters_, which optimise your project for deployment to different environments.
By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="/favicon.ico" />
<!--app-head-->
<script type="module" src="@solid-start/entry.jsx"></script>
</head>
<body>
<div id="app"><!--app-html--></div>
</body>
</html>

@ -0,0 +1,16 @@
{
"name": "~TODO~",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
},
"type": "module",
"devDependencies": {
"solid-js": "0.25.0",
"vite": "^2.1.3"
},
"engines": {
"node": ">=12"
}
}

@ -0,0 +1,9 @@
import { Route } from "solid-app-router";
export default function Layout({ App }) {
return (
<App>
<Route />
</App>
);
}

@ -0,0 +1,40 @@
import { defineConfig } from "vite";
import solid from "vite-plugin-solid";
import manifest from "rollup-route-manifest";
import path from "path";
export default defineConfig({
resolve: {
alias: [{
find: "~",
replacement: path.join(process.cwd(), "src")
}, {
find: "@solid-start",
replacement: path.join(process.cwd(), "node_modules", "solid-start", "runtime")
}]
},
plugins: [
solid({ ssr: true }),
{
name: "html-async",
enforce: "post",
transformIndexHtml(html) {
return html.replace('type="module"', 'type="module" async');
}
},
manifest({
inline: false,
merge: false,
publicPath: "/",
routes: (file) => {
file = file.replace(path.join(__dirname, "src"), "").replace(/\.[tj]sx?$/, "");
if (!file.includes("/pages/")) return "*"; // commons
return "/" + file.replace("/pages/", "").toLowerCase();
}
})
],
build: {
polyfillDynamicImport: false,
target: "esnext"
}
});

@ -0,0 +1,23 @@
#!/usr/bin/env node
"use strict";
const path = require("path");
const exec = require("child_process").exec;
const script = process.argv[2];
switch (script) {
case "dev":
exec("node " + path.join(__dirname, "runtime", "server.cjs"), (e, stdout, stderr) => {
if (e instanceof Error) {
console.error(e);
throw e;
}
console.log("stdout ", stdout);
console.log("stderr ", stderr);
});
break;
case "build":
break;
case "start":
break;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,23 @@
{
"name": "solid-start",
"version": "0.0.12",
"description": "Create Solid apps with low configuration",
"author": "Ryan Carniato",
"license": "MIT",
"bin": "./bin.cjs",
"type": "module",
"files": [
"bin.cjs",
"plugin.js",
"runtime"
],
"dependencies": {
"node-fetch": "^2.6.1",
"rollup-route-manifest": "^1.0.0",
"solid-app-router": "^0.0.36"
},
"peerDependencies": {
"vite": "*",
"solid-js": "*"
}
}

@ -0,0 +1,16 @@
import { renderToNodeStream } from "solid-js/web";
import { Router } from "solid-app-router";
import Layout from "~/layout";
import { routes } from "./routes";
import fetch from "node-fetch";
globalThis.fetch = fetch;
export function render(initialURL, ctx) {
const App = (props) => (
<Router routes={routes} initialURL={initialURL} out={ctx}>
{props.children}
</Router>
);
return renderToNodeStream(() => <Layout App={App} />);
}

@ -0,0 +1,11 @@
import { hydrate } from "solid-js/web";
import { Router } from "solid-app-router";
import Layout from "~/layout";
import { routes } from "./routes";
const App = (props) => <Router routes={routes}>{props.children}</Router>
hydrate(
() => <Layout App={App} />,
document.getElementById("app")
);

@ -0,0 +1,17 @@
module.exports = function preload(handlers, manifest) {
const url = handlers
.map((h) =>
h.path.replace(/:(\w+)/, (f, g) => `[${g}]`).replace(/\*(\w+)/, (f, g) => `[...${g}]`)
)
.join("");
return (
manifest[url] &&
manifest[url]
.slice(0) //clone
.reverse()
.slice(1)
.map((m) => `<link rel="modulepreload" href="${m.href}" />`)
.join("")
);
}

@ -0,0 +1,27 @@
import { lazy } from "solid-js";
import { RouteDefinition } from "solid-app-router";
const dataModules = import.meta.globEager("/src/pages/**/*.data.(js|ts)");
const pages = import.meta.glob("/src/pages/**/*.(jsx|tsx)");
function toIdentifier(source: string) {
return source.slice(10).replace(/(.jsx|.tsx|.data.js|.data.ts)/, "");
}
function toPath(id: string) {
return id.replace(/\[(.+)\]/, (_, m) => (m.startsWith("...") ? `*${m.slice(3)}` : `:${m}`));
}
const data = Object.entries(dataModules).reduce((memo, [key, value]) => {
memo[toIdentifier(key)] = value;
return memo;
}, {});
export const routes: RouteDefinition[] = Object.entries(pages).map(([key, fn]) => {
const id = toIdentifier(key);
return {
path: toPath(id),
component: lazy(fn as any),
data: data[id] ? data[id].default : undefined
};
});

@ -0,0 +1,63 @@
const path = require("path");
const http = require("http");
const { parse } = require("url");
const { readFileSync } = require("fs");
async function createServer(root = process.cwd()) {
const resolve = p => path.resolve(process.cwd(), p);
const ctx = {};
const vite = await require("vite").createServer({
root,
logLevel: "info",
server: {
middlewareMode: true
}
});
const app = http.createServer((req, res) => {
vite.middlewares(req, res, async () => {
try {
const parsed = parse(req.url);
if (req.url === "/favicon.ico") return;
let template;
let render;
// always read fresh template in dev
template = readFileSync(resolve("./index.html"), "utf-8");
template = await vite.transformIndexHtml(url, template);
render = (await vite.ssrLoadModule("./lib/entry-server.jsx")).render;
const { stream, script } = render(parsed.pathname + parsed.search, ctx);
const [htmlStart, htmlEnd] = template
.replace(`<!--app-head-->`, script)
.split(`<!--app-html-->`);
res.status(200).set({ "content-type": "text/html" });
res.write(htmlStart);
stream.pipe(res, { end: false });
stream.on("end", () => {
res.write(htmlEnd);
res.end();
});
} catch (e) {
vite && vite.ssrFixStacktrace(e);
console.log(e.stack);
res.status(500).end(e.stack);
}
});
});
return { app, vite };
}
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log("http://localhost:3000");
})
);
Loading…
Cancel
Save