Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start work on #166 #177

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@
"rollup-plugin-typescript2": "^0.29.0",
"tslib": "^2.0.3",
"typescript": "^4.0.3"
},
"dependencies": {
"@rollup/plugin-sucrase": "^3.1.0"
}
}
10 changes: 7 additions & 3 deletions packages/adapter-netlify/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import sucrase from '@rollup/plugin-sucrase';

export default [
{
Expand All @@ -9,7 +9,9 @@ export default [
file: 'index.js',
format: 'cjs'
},
plugins: [nodeResolve(), commonjs(), typescript()],
plugins: [nodeResolve(), commonjs(), sucrase({
transforms: ['typescript']
})],
external: require('module').builtinModules
},
{
Expand All @@ -18,7 +20,9 @@ export default [
file: 'render.js',
format: 'cjs'
},
plugins: [nodeResolve(), commonjs(), typescript()],
plugins: [nodeResolve(), commonjs(), sucrase({
transforms: ['typescript']
})],
external: require('module').builtinModules
}
];
10 changes: 7 additions & 3 deletions packages/adapter-node/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import sucrase from '@rollup/plugin-sucrase';

export default [
{
Expand All @@ -9,7 +9,9 @@ export default [
file: 'index.js',
format: 'cjs'
},
plugins: [nodeResolve(), commonjs(), typescript()],
plugins: [nodeResolve(), commonjs(), sucrase({
transforms: ['typescript']
})],
external: require('module').builtinModules
},
{
Expand All @@ -18,7 +20,9 @@ export default [
file: 'server.js',
format: 'cjs'
},
plugins: [nodeResolve(), commonjs(), typescript()],
plugins: [nodeResolve(), commonjs(), sucrase({
transforms: ['typescript']
})],
external: require('module').builtinModules
}
];
6 changes: 4 additions & 2 deletions packages/adapter-static/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import sucrase from '@rollup/plugin-sucrase';

export default {
input: 'src/index.ts',
output: {
file: 'server.js',
format: 'cjs'
},
plugins: [nodeResolve(), commonjs(), typescript()],
plugins: [nodeResolve(), commonjs(), sucrase({
transforms: ['typescript']
})],
external: require('module').builtinModules
};
10 changes: 7 additions & 3 deletions packages/adapter-vercel/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import sucrase from '@rollup/plugin-sucrase';

export default [
{
Expand All @@ -9,7 +9,9 @@ export default [
file: 'index.js',
format: 'cjs'
},
plugins: [nodeResolve(), commonjs(), typescript()],
plugins: [nodeResolve(), commonjs(), sucrase({
transforms: ['typescript']
})],
external: require('module').builtinModules
},
{
Expand All @@ -18,7 +20,9 @@ export default [
file: 'server.js',
format: 'cjs'
},
plugins: [nodeResolve(), commonjs(), typescript()],
plugins: [nodeResolve(), commonjs(), sucrase({
transforms: ['typescript']
})],
external: require('module').builtinModules
}
];
2 changes: 1 addition & 1 deletion packages/app-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
"prepublishOnly": "npm run build",
"test": "uvu -r ts-node/register"
"test": "uvu -r sucrase/register/ts"
},
"dependencies": {
"mime": "^2.4.6"
Expand Down
6 changes: 4 additions & 2 deletions packages/app-utils/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import sucrase from '@rollup/plugin-sucrase';
import pkg from './package.json';
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -29,7 +29,9 @@ export default {
],
plugins: [
nodeResolve(),
typescript()
sucrase({
transforms: ['typescript']
})
],
external: [...require('module').builtinModules, ...Object.keys(pkg.dependencies)]
};
18 changes: 9 additions & 9 deletions packages/app-utils/src/http/get_body/read_only_form_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,50 @@ export function read_only_form_data() {
}

class ReadOnlyFormData {
#map: FormDataMap;
private map: FormDataMap;

constructor(map: FormDataMap) {
this.#map = map;
this.map = map;
}

get(key: string) {
return this.#map.get(key)?.[0];
return this.map.get(key)?.[0];
}

getAll(key: string) {
return this.#map.get(key);
return this.map.get(key);
}

has(key: string) {
return this.#map.has(key);
return this.map.has(key);
}

*[Symbol.iterator]() {
for (const [key, value] of this.#map) {
for (const [key, value] of this.map) {
for (let i = 0; i < value.length; i += 1) {
yield [key, value[i]];
}
}
}

*entries() {
for (const [key, value] of this.#map) {
for (const [key, value] of this.map) {
for (let i = 0; i < value.length; i += 1) {
yield [key, value[i]];
}
}
}

*keys() {
for (const [key, value] of this.#map) {
for (const [key, value] of this.map) {
for (let i = 0; i < value.length; i += 1) {
yield key;
}
}
}

*values() {
for (const [, value] of this.#map) {
for (const [, value] of this.map) {
for (let i = 0; i < value.length; i += 1) {
yield value;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-utils/src/renderer/render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function render(
request: IncomingRequest,
options: RenderOptions
): Promise<EndpointResponse | PageResponse | undefined> {
const { context, headers = {} } = (await options.setup.prepare?.(request.headers)) || {};
const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {};

try {
const response = await (render_endpoint(request, context, options) ||
Expand Down
2 changes: 1 addition & 1 deletion packages/app-utils/src/renderer/render/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default async function render_page(

const baseUrl = ''; // TODO

const session = await options.setup.getSession?.(context);
const session = await (options.setup.getSession && options.setup.getSession(context));

const serialized_session = try_serialize(session, (err: Error) => {
throw new Error(`Failed to serialize session data: ${err.message}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/app-utils/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export type RouteParams = Record<string, string | string[]>;
export interface PageComponentManifest {
default?: boolean;
type?: string;
file?: string;
url: string;
name: string;
file: string;
}

export interface PageManifestPart {
Expand Down
7 changes: 6 additions & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"devDependencies": {
"@types/node": "^14.11.10",
"@types/rimraf": "^3.0.0",
"@types/sade": "^1.7.2",
"estree-walker": "^2.0.1",
"kleur": "^4.1.3",
Expand All @@ -24,9 +25,12 @@
"periscopic": "^2.0.2",
"port-authority": "^1.1.1",
"require-relative": "^0.8.7",
"rimraf": "^3.0.2",
"sirv": "^1.0.7",
"source-map-support": "^0.5.19",
"svelte": "^3.29.0",
"tiny-glob": "^0.2.8",
"ts-node": "^9.0.0",
"typescript": "^4.0.5"
},
"bin": {
Expand All @@ -43,6 +47,7 @@
"lint": "eslint --ignore-pattern node_modules/ --ignore-pattern dist/ \"**/*.{ts,mjs,js,svelte}\" && npm run check-format",
"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"test": "uvu -r sucrase/register/ts"
}
}
16 changes: 11 additions & 5 deletions packages/kit/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import sucrase from '@rollup/plugin-sucrase';
import pkg from './package.json';
import { readFileSync, writeFileSync } from 'fs';

Expand Down Expand Up @@ -31,7 +31,10 @@ export default [
resolve({
extensions: ['.mjs', '.js', '.ts']
}),
typescript(/*{
sucrase({
transforms: ['typescript']
})
/*typescript({
tsconfigDefaults: {
compilerOptions: {
// create typings. these options do not apply to the other build target
Expand All @@ -41,8 +44,8 @@ export default [
}
},
useTsconfigDeclarationDir: true
}*/),
/*{
}),
{
name: 'adjust-typings',
resolveId: () => null,
load: () => null,
Expand All @@ -69,7 +72,10 @@ export default [
extensions: ['.mjs', '.js', '.ts']
}),
commonjs(),
typescript()
sucrase({
transforms: ['typescript']
})
//typescript()
],
preserveEntrySignatures: false
}
Expand Down
60 changes: 60 additions & 0 deletions packages/kit/src/api/build/Builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { copy } from '@sveltejs/app-utils/files';
import { prerender } from '@sveltejs/app-utils/renderer';
import { Logger } from '@sveltejs/app-utils/renderer/prerender'; // TODO this is in the wrong place
import { ManifestData } from '../../interfaces';

export type BuilderOptions = {
generated_files: string;
static_files: string;
log: Logger,
manifest: ManifestData;
};

export default class Builder {
log: Logger;

private generated_files: string;
private static_files: string;
private manifest: ManifestData;

constructor({
generated_files,
static_files,
log,
manifest
}: BuilderOptions) {
this.generated_files = generated_files;
this.static_files = static_files;
this.manifest = manifest;

this.log = log;
}

copy_generated_files(dest: string) {
copy(this.generated_files, dest);
}

copy_static_files(dest: string) {
copy(this.static_files, dest);
}

prerender({
force = false,
dest
}: {
force: boolean;
dest: string;
}) {
prerender({
out: dest,
force,
dir: this.generated_files,
manifest: this.manifest,
log: this.log
});
}

foo() {
console.log(this.manifest);
}
}
Loading