Skip to content

Commit

Permalink
* Replaced snowpack with just tsc.
Browse files Browse the repository at this point in the history
* Symlinked "@pg-lq/postgraphile-plugin" package. (needed for temp local-fix of this issue: Starcounter-Jack/JSON-Patch#277)
  • Loading branch information
Venryx committed Jun 22, 2021
1 parent 8faa47f commit a2e39eb
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 160 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/node_modules
/.env
/Packages/*/node_modules
/Packages/*/Dist

# yarn
.yarn/*
Expand All @@ -9,8 +10,4 @@
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# snowpack
/Packages/*/Build
/Packages/data-helpers/Data
.pnp.*
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"javascript.preferences.quoteStyle": "double",
"typescript.preferences.importModuleSpecifierEnding": "js",
"javascript.preferences.importModuleSpecifierEnding": "js",
"typescript.preferences.quoteStyle": "double",
"javascript.preferences.quoteStyle": "double",
// needed for "Packages/common", since the others import its source files directly (which would break any non-relative paths it was using)
"javascript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.importModuleSpecifier": "relative",
"javascript.preferences.importModuleSpecifier": "relative",
"eslint.validate": [
"javascript",
"javascriptreact",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "#1 snowpack",
"label": "#1 server compile",
"type": "npm",
"script": "start server.dev",
"problemMatcher": [],
Expand Down
30 changes: 4 additions & 26 deletions Packages/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
// general
"rootDir": "Source",
"baseUrl": "Source",
"resolveJsonModule": true,

//"noEmit": false,
"outDir": "Source_JS",
"esModuleInterop": true,

/*"paths": { // ("paths" is relative to "baseUrl")
"*": [
// prefer "/node_modules/@types" over "/node_modules/[something]/node_modules/@types" (eg. for when using npm link)
//"../node_modules/@types/*",
// prefer "/node_modules/X" over "/node_modules/[something]/node_modules/X"
// (for when using npm link; fixes auto-importer sometimes using SomeLib/node_modules/TargetLib)
"../node_modules/*",
"*"
],
// remove @types/node and such (conflicts with typescript web definitions)
"@types/node": ["../Typings/empty.d.ts"],
// remove @types/react/global.d.ts, as it breaks the auto-import-finder for react-vcomponents/Text
"react/global.d.ts": ["../Typings/empty.d.ts"],
"react-vextensions/node_modules/react/global.d.ts": ["../Typings/empty.d.ts"],
"react-vcomponents/node_modules/react/global.d.ts": ["../Typings/empty.d.ts"],
// temp removals (lib definitions need updating)
//"mst-decorators": ["../Typings/empty.d.ts"],
// consolidating for these wouldn't throw errors necessarily, but we do so to keep things tidy (since we know the different versions will be compatible anyway)
//"js-vextensions": ["../node_modules/js-vextensions"],
//"mobx-graphlink": ["../node_modules/mobx-graphlink"], // fixes odd ts issue
},*/

// compilation
"esModuleInterop": true,
//"strict": true, // enables all of the below (other than noImplicitReturns)
//"noImplicitAny": true,
//"noImplicitThis": true,
Expand All @@ -50,8 +29,7 @@
//"Source/**/*.jsx"
//"node_modules/web-vcore/Source/**/*.ts",
//"node_modules/@debate-map/server-link/Source/**/*.ts",
],
"compileOnSave": true
]
/*"references": [
{"path": "node_modules/@debate-map/server-link"},
{"path": "node_modules/web-vcore"}
Expand Down
18 changes: 8 additions & 10 deletions Packages/server/Scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
// general
"watch": true,
"forceConsistentCasingInFileNames": true, // creates duplicates in import-helper plugins otherwise

// modules/paths
"module": "ESNext",
//"module": "commonjs", // needed, since ts-node does not yet support imports from es2015-modules
"moduleResolution": "node",
//"rootDir": ".",
//"baseUrl": ".",

"resolveJsonModule": true,

// compiler options
"target": "ES2015",
"jsx": "react",
"noImplicitAny": false,
"alwaysStrict": true, // alternative: "@babel/plugin-transform-strict-mode"; went with this since doesn't require another npm package

"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
"esModuleInterop": true,

// modules/paths
"module": "ESNext",
//"module": "commonjs", // needed, since ts-node does not yet support imports from es2015-modules
"moduleResolution": "node",
//"rootDir": ".",
//"baseUrl": ".",
},
"include": [
"../Typings/**/*.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion Packages/server/Source/AuthHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import passport from "passport";
import {Strategy as GoogleStrategy} from "passport-google-oauth20";
import express from "express";
import cookieSession from "cookie-session";
import {pgClient, pgPool} from ".";
import {pgClient, pgPool} from "./index.js";

//type ExpressApp = Express.Application;
type ExpressApp = ReturnType<typeof express>;
Expand Down
4 changes: 2 additions & 2 deletions Packages/server/Source/Mutations/Authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export const AuthenticationPlugin = makeExtendSchemaPlugin(build=>{
resolvers: {
Mutation: {
authenticate: async(parent, args, ctx: Context, info)=>{
const { rows } = await ctx.pgClient.query(
/*const { rows } = await ctx.pgClient.query(
sqlText, // e.g. "select * from users where id = $1"
optionalVariables // e.g. [27]
);
);*/
return {id: "tbd"};
},
test1: ((parent, args, ctx: Context, info)=>{
Expand Down
16 changes: 8 additions & 8 deletions Packages/server/Source/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import "./Start_0";
import "./Start_0.js";

import commander from "commander";
const {program} = commander;
import express from "express";
import postgraphile_ from "postgraphile";
const postgraphile = postgraphile_["postgraphile"] as typeof import("postgraphile").postgraphile;
const makePluginHook = postgraphile_["makePluginHook"] as typeof import("postgraphile").makePluginHook;
import {postgraphile, makePluginHook} from "postgraphile";
import {GeneratePatchesPlugin} from "@pg-lq/postgraphile-plugin";
import {Pool, PoolClient} from "pg";
import pg from "pg";
import {createRequire} from "module";
import {AuthenticationPlugin} from "./Mutations/Authentication";
import {SetUpAuthHandling} from "./AuthHandling";
import {AuthenticationPlugin} from "./Mutations/Authentication.js";
import {SetUpAuthHandling} from "./AuthHandling.js";
type PoolClient = import("pg").PoolClient;
const {Pool} = pg;
const require = createRequire(import.meta.url);

//program.option("-v, --variant <type>", "Which server variant to use (base, patches)");
Expand All @@ -25,7 +25,7 @@ const dbURL = process.env.DATABASE_URL || `postgres://${process.env.PGUSER}:${pr
const dbPort = process.env.PORT || 3105 as number;

const pluginHook = makePluginHook([
variant == "patches" && GeneratePatchesPlugin,
variant == "patches" && new GeneratePatchesPlugin(),
]);

export const pgPool = new Pool({
Expand Down
6 changes: 3 additions & 3 deletions Packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"devDependencies": {
"@types/passport": "^1.0.6",
"concurrently": "^6.1.0",
"nps": "^5.10.0",
"snowpack": "^3.4.0"
"nps": "^5.10.0"
},
"dependencies": {
"@graphile-contrib/pg-simplify-inflector": "^6.1.0",
"@graphile/subscriptions-lds": "^4.11.0",
"@n1ru4l/graphql-live-query": "^0.7.1",
"@n1ru4l/graphql-live-query-patch": "^0.3.1",
"@pg-lq/postgraphile-plugin": "^0.0.3",
"@pg-lq/postgraphile-plugin": "^0.0.5",
"@types/express": "^4.17.12",
"@types/node": "^15.3.0",
"buffer": "^6.0.3",
Expand Down
66 changes: 0 additions & 66 deletions Packages/server/snowpack.config.js

This file was deleted.

7 changes: 6 additions & 1 deletion Packages/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
// general
"rootDir": "Source",
"baseUrl": "Source"
"baseUrl": "Source",
"outDir": "Dist",

// compilation
"esModuleInterop": true,
},
"include": [
"Source/**/*.ts",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For more information, visit the website at: <https://debatemap.app>

### Part 1 (general)

1) Ensure [NodeJS](https://nodejs.org) (v8.6+) is installed, as well as [Yarn](https://yarnpkg.com/getting-started/migration) (needed for Yarn workspaces).
1) Ensure [NodeJS](https://nodejs.org) (v14.13.0+) is installed, as well as [Yarn](https://yarnpkg.com/getting-started/migration) (needed for Yarn workspaces).

2) Clone/download this repo to disk. (https://github.com/debate-map/app.git)

Expand Down
10 changes: 8 additions & 2 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Object.assign(scripts, {
initDB: TSScript("server", "Scripts/InitDB.ts"),

// first terminal
dev: "cd Packages/server && snowpack build --watch",
//dev: "cd Packages/server && snowpack build --watch",
dev: "cd Packages/server && tsc --watch",

// second terminal
run: GetStartServerCommand(),
Expand All @@ -78,5 +79,10 @@ function GetStartServerCommand() {
/*const variantPath = serverVariantPaths[server];
return `node ${variantPath}`;*/
//return `node ./Packages/server/Build/esm/Source/index.js`;
return `cd Packages/server && node ./Build/esm/Source/index.js`;
//return `cd Packages/server && node ./Build/esm/Source/index.js`;

return `cd Packages/server && node ./Dist/index.js`;
//return `cd Packages/server && node --experimental-modules ./Dist/index.js`;
//return `cd Packages/server && node -r esm ./Dist/index.js`; // didn't enable named-exports from common-js, despite this suggesting it would: https://github.com/standard-things/esm/issues/897
//return TSScript("server", "Source/index.ts");
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@resolutions_c": "The 'version locks' below (after portals) are for deps that are also subdeps (eg. under symlinked deps), 'locking' to the 'as subdep' version, to keep their types aligned. [not sure if actually needed/useful]",
"resolutions": {
"web-vcore": "portal:/C:/Root/Apps/@V/@Modules/web-vcore/Main",
"@pg-lq/postgraphile-plugin": "portal:/C:/Root/Apps/@V/@Modules/postgraphile-live-query/Main/Packages/postgraphile-plugin",
"@types/react": "17.0.9",
"react": "17.0.2",
"react-dom": "17.0.2"
Expand Down
28 changes: 14 additions & 14 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
{
"compilerOptions": {
// general
"sourceMap": true,
//"sourceMap": true,
"watch": true,
//"noEmit": true,
"forceConsistentCasingInFileNames": true, // creates duplicates in import-helper plugins otherwise

// compilation
"target": "esnext",
"lib": [
"es6",
"es5",
"dom"
],
"jsx": "react",
"noImplicitAny": false,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
//"esModuleInterop": true, // enable this within packages that aren't using webpack for compilation

// modules/paths
"module": "esnext",
"moduleResolution": "node",
Expand Down Expand Up @@ -40,18 +53,6 @@
"../../../node_modules/codemirror/*",
]
},

// compiler options
"target": "esnext",
"lib": [
"es6",
"es5",
"dom"
],
"jsx": "react",
"noImplicitAny": false,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true
},
"include": [
// these are relative to this file's folder (repo root)
Expand All @@ -70,5 +71,4 @@
"Tests",
"node_modules",
],*/
"compileOnSave": true
}

0 comments on commit a2e39eb

Please sign in to comment.