Much simpler project structure

This commit is contained in:
Jake Archibald
2020-11-09 10:54:35 +00:00
parent 4da1887826
commit 5a027c7727
44 changed files with 47 additions and 331 deletions

2
.gitignore vendored
View File

@@ -7,7 +7,5 @@ build
# Auto-generated by lib/feature-plugin.js # Auto-generated by lib/feature-plugin.js
src/features-worker/index.ts src/features-worker/index.ts
src/features-worker/tsconfig.json
src/client/lazy-app/worker-bridge/meta.ts src/client/lazy-app/worker-bridge/meta.ts
src/client/lazy-app/feature-meta/index.ts src/client/lazy-app/feature-meta/index.ts
src/client/tsconfig.json

12
client-tsconfig.json Normal file
View File

@@ -0,0 +1,12 @@
{
"extends": "./generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"src/features/**/client/**/*",
"src/features/**/shared/**/*",
"src/shared/**/*"
]
}

View File

@@ -59,23 +59,7 @@ export default function () {
.flat(Infinity) .flat(Infinity)
.join('\n'); .join('\n');
const workerTsConfig = { await fsp.writeFile(path.join(workerBasePath, 'index.ts'), workerFile);
extends: '../../generic-tsconfig.json',
compilerOptions: {
lib: ['webworker', 'esnext'],
},
references: featuresWorkerTsNames.map(([tsImport]) => ({
path: path.dirname(tsImport),
})),
};
await Promise.all([
fsp.writeFile(
path.join(workerBasePath, 'tsconfig.json'),
autoGenComment + JSON.stringify(workerTsConfig, null, ' '),
),
fsp.writeFile(path.join(workerBasePath, 'index.ts'), workerFile),
]);
} }
/** /**
@@ -171,7 +155,6 @@ export default function () {
'lazy-app', 'lazy-app',
'feature-meta', 'feature-meta',
); );
const clientBasePath = path.join(process.cwd(), 'src', 'client');
const joinedMetas = metas.flat().join(); const joinedMetas = metas.flat().join();
@@ -194,13 +177,6 @@ export default function () {
const preprocessorMetaTsNames = preprocessorMetas.map((tsImport) => const preprocessorMetaTsNames = preprocessorMetas.map((tsImport) =>
getTsName(tsImport), getTsName(tsImport),
); );
const tsConfigEncoderPaths = encoderMetas.flatMap((tsImport) => [
path.relative(clientBasePath, tsImport.replace(/\/meta$/, '')),
path.relative(
clientBasePath,
tsImport.replace(/shared\/meta$/, 'client'),
),
]);
const featureMeta = [ const featureMeta = [
autoGenComment, autoGenComment,
@@ -267,29 +243,10 @@ export default function () {
.flat(Infinity) .flat(Infinity)
.join('\n'); .join('\n');
const lazyTsConfig = { await fsp.writeFile(
extends: '../../generic-tsconfig.json', path.join(featureMetaBasePath, 'index.ts'),
compilerOptions: { featureMeta,
lib: ['esnext', 'dom', 'dom.iterable'], );
types: [],
},
references: [
{ path: '../features-worker' },
{ path: '../shared' },
{ path: '../features/processors/resize/client' },
...tsConfigEncoderPaths.map((projectPath) => ({
path: projectPath,
})),
],
};
await Promise.all([
fsp.writeFile(
path.join(process.cwd(), 'src', 'client', 'tsconfig.json'),
autoGenComment + JSON.stringify(lazyTsConfig, null, ' '),
),
fsp.writeFile(path.join(featureMetaBasePath, 'index.ts'), featureMeta),
]);
} }
return { return {

View File

@@ -12,7 +12,7 @@
*/ */
import avifDecoder, { AVIFModule } from 'codecs/avif/dec/avif_dec'; import avifDecoder, { AVIFModule } from 'codecs/avif/dec/avif_dec';
import wasmUrl from 'url:codecs/avif/dec/avif_dec.wasm'; import wasmUrl from 'url:codecs/avif/dec/avif_dec.wasm';
import { initEmscriptenModule, blobToArrayBuffer } from 'features/util'; import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils';
let emscriptenModule: Promise<AVIFModule>; let emscriptenModule: Promise<AVIFModule>;

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -12,7 +12,7 @@
*/ */
import webpDecoder, { WebPModule } from 'codecs/webp/dec/webp_dec'; import webpDecoder, { WebPModule } from 'codecs/webp/dec/webp_dec';
import wasmUrl from 'url:codecs/webp/dec/webp_dec.wasm'; import wasmUrl from 'url:codecs/webp/dec/webp_dec.wasm';
import { initEmscriptenModule, blobToArrayBuffer } from 'features/util'; import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils';
let emscriptenModule: Promise<WebPModule>; let emscriptenModule: Promise<WebPModule>;

View File

@@ -1,13 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"./*.ts",
"../../../../client/lazy-app/worker-bridge/index.ts",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -13,7 +13,7 @@
import avifEncoder, { AVIFModule } from 'codecs/avif/enc/avif_enc'; import avifEncoder, { AVIFModule } from 'codecs/avif/enc/avif_enc';
import type { EncodeOptions } from '../shared/meta'; import type { EncodeOptions } from '../shared/meta';
import wasmUrl from 'url:codecs/avif/enc/avif_enc.wasm'; import wasmUrl from 'url:codecs/avif/enc/avif_enc.wasm';
import { initEmscriptenModule } from 'features/util'; import { initEmscriptenModule } from 'features/worker-utils';
let emscriptenModule: Promise<AVIFModule>; let emscriptenModule: Promise<AVIFModule>;

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }, { "path": "../shared" }]
}

View File

@@ -1,14 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"./*.ts",
"../../../../client/lazy-app/util.ts",
"../../../../client/lazy-app/worker-bridge/index.ts",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,14 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"./*.ts",
"../../../../client/lazy-app/util.ts",
"../../../../client/lazy-app/worker-bridge/index.ts",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,14 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"./*.ts",
"../../../../client/lazy-app/util.ts",
"../../../../client/lazy-app/worker-bridge/index.ts",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,13 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"*.ts",
"../../../../client/lazy-app/worker-bridge/index.ts",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -13,7 +13,7 @@
import mozjpeg_enc, { MozJPEGModule } from 'codecs/mozjpeg_enc/mozjpeg_enc'; import mozjpeg_enc, { MozJPEGModule } from 'codecs/mozjpeg_enc/mozjpeg_enc';
import { EncodeOptions } from '../shared/meta'; import { EncodeOptions } from '../shared/meta';
import wasmUrl from 'url:codecs/mozjpeg_enc/mozjpeg_enc.wasm'; import wasmUrl from 'url:codecs/mozjpeg_enc/mozjpeg_enc.wasm';
import { initEmscriptenModule } from 'features/util'; import { initEmscriptenModule } from 'features/worker-utils';
let emscriptenModule: Promise<MozJPEGModule>; let emscriptenModule: Promise<MozJPEGModule>;

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }, { "path": "../shared" }]
}

View File

@@ -1,14 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"./*.ts",
"../../../../client/lazy-app/util.ts",
"../../../../client/lazy-app/worker-bridge/index.ts",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }, { "path": "../shared" }]
}

View File

@@ -1,13 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"./*.ts",
"../../../../client/lazy-app/worker-bridge/index.ts",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }, { "path": "../shared" }]
}

View File

@@ -12,7 +12,7 @@
*/ */
import webpEncoder, { WebPModule } from 'codecs/webp/enc/webp_enc'; import webpEncoder, { WebPModule } from 'codecs/webp/enc/webp_enc';
import wasmUrl from 'url:codecs/webp/enc/webp_enc.wasm'; import wasmUrl from 'url:codecs/webp/enc/webp_enc.wasm';
import { initEmscriptenModule } from 'features/util'; import { initEmscriptenModule } from 'features/worker-utils';
import type { EncodeOptions } from '../shared/meta'; import type { EncodeOptions } from '../shared/meta';
let emscriptenModule: Promise<WebPModule>; let emscriptenModule: Promise<WebPModule>;

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }, { "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -12,7 +12,7 @@
*/ */
import imagequant, { QuantizerModule } from 'codecs/imagequant/imagequant'; import imagequant, { QuantizerModule } from 'codecs/imagequant/imagequant';
import wasmUrl from 'url:codecs/imagequant/imagequant.wasm'; import wasmUrl from 'url:codecs/imagequant/imagequant.wasm';
import { initEmscriptenModule } from 'features/util'; import { initEmscriptenModule } from 'features/worker-utils';
import { Options } from '../shared/meta'; import { Options } from '../shared/meta';
let emscriptenModule: Promise<QuantizerModule>; let emscriptenModule: Promise<QuantizerModule>;

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }, { "path": "../shared" }]
}

View File

@@ -1,14 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
},
"include": [
"./*.ts",
"../../../../client/lazy-app/util.ts",
"../../../../client/lazy-app/Compress/index.tsx",
"../shared/*.ts"
],
"references": [{ "path": "../shared" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }]
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../../../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"references": [{ "path": "../../../" }, { "path": "../shared" }]
}

View File

@@ -1,8 +0,0 @@
{
"extends": "../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"include": ["util.ts", "*.d.ts"],
"references": []
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"],
"types": []
}
}

View File

@@ -1,8 +0,0 @@
{
"extends": "../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom"],
"types": ["node"]
},
"references": [{ "path": "../shared" }]
}

View File

@@ -1,6 +0,0 @@
{
"extends": "../../generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
}
}

View File

@@ -0,0 +1,8 @@
{
"extends": "./generic-tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom"],
"types": ["node"]
},
"include": ["src/shared/**/*", "src/static-build/**/*"]
}

View File

@@ -2,9 +2,8 @@
"extends": "./generic-tsconfig.json", "extends": "./generic-tsconfig.json",
"files": [], "files": [],
"references": [ "references": [
{ "path": "./src/client" }, { "path": "./client-tsconfig.json" },
{ "path": "./src/static-build" }, { "path": "./worker-tsconfig.json" },
{ "path": "./src/shared" }, { "path": "./static-build-tsconfig.json" }
{ "path": "./src/sw" }
] ]
} }

13
worker-tsconfig.json Normal file
View File

@@ -0,0 +1,13 @@
{
"extends": "./generic-tsconfig.json",
"compilerOptions": {
"lib": ["webworker", "esnext"]
},
"include": [
"src/features/**/worker/**/*",
"src/features/**/shared/**/*",
"src/features/worker-utils/**/*",
"src/features-worker/**/*",
"src/sw/**/*"
]
}