Skip to content

Commit b3234d0

Browse files
committed
fix rebase
1 parent 5cfc8e2 commit b3234d0

File tree

3 files changed

+23
-210
lines changed

3 files changed

+23
-210
lines changed

libs/code-demos/src/lib/runner/compile-ts-files.ts

Lines changed: 0 additions & 204 deletions
This file was deleted.

libs/sandbox-runner/src/lib/runners/compile-ts-files.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { BehaviorSubject, Observable, OperatorFunction } from 'rxjs';
22
import * as TsTypes from 'typescript';
3+
import { map, tap } from 'rxjs/operators';
34
import { getTypeScript } from '../loaders/loaders';
45

56
const ts = getTypeScript();
67

7-
// TODO(sancheez): Duplication
8-
98
export interface Files {
109
[key: string]: string;
1110
}
@@ -30,8 +29,9 @@ interface Output {
3029
}
3130

3231
const compilerOptions: TsTypes.CompilerOptions = {
32+
baseUrl: './',
3333
module: ts.ModuleKind.System,
34-
target: ts.ScriptTarget.ES2017,
34+
target: ts.ScriptTarget.ES2022,
3535
experimentalDecorators: true,
3636
emitDecoratorMetadata: true,
3737
noImplicitAny: true,
@@ -67,11 +67,13 @@ function watch(
6767
return undefined;
6868
}
6969

70+
const baseName = fileName.replace('.ts', '');
71+
7072
return ts.ScriptSnapshot.fromString(
71-
`/// <amd-module name="${fileName.replace('.ts', '')}" />\n` + file.file
73+
`/// <amd-module name="./${baseName}" />\n` + file.file
7274
);
7375
},
74-
getCurrentDirectory: () => '/',
76+
getCurrentDirectory: () => options.baseUrl,
7577
getCompilationSettings: () => options,
7678
getDefaultLibFileName: () => 'lib.d.ts',
7779
fileExists: (a) => !!files[a],
@@ -190,6 +192,14 @@ export function compileTsFilesWatch(
190192
options = compilerOptions
191193
): OperatorFunction<Record<string, string>, Output> {
192194
return (source: Observable<Record<string, string>>) => {
193-
return watch(source, options);
195+
return watch(
196+
source.pipe(
197+
map((files) => ({
198+
'code.ts': 'export class Code {}', // TODO(sancheez): code file, maybe needs another files
199+
...files,
200+
}))
201+
),
202+
options
203+
).pipe(tap(console.log));
194204
};
195205
}

lint-staged.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const commands = ['npm run affected:lint:write', 'npm run format:write'];
2+
3+
const pattern = `{libs,apps}/!(code-demos/assets)**/*.{ts,json,md,html,?(s)css}`;
4+
5+
module.exports = {
6+
[pattern]: commands,
7+
};

0 commit comments

Comments
 (0)