Skip to content

Commit b0604b5

Browse files
mrkishiConduitry
authored andcommitted
split typescript projects
1 parent 453b9ac commit b0604b5

13 files changed

+84
-50
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
"posttest": "agadoo internal/index.mjs",
3838
"prepublishOnly": "export PUBLISH=true && npm test && npm run create-stubs",
3939
"create-stubs": "node scripts/create-stubs.js",
40-
"tsd": "tsc -p . --emitDeclarationOnly",
41-
"typecheck": "tsc -p . --noEmit",
40+
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
4241
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
4342
},
4443
"repository": {

src/compiler/compile/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assign } from '../../runtime/internal/index';
1+
import { assign } from '../../runtime/internal/utils';
22
import Stats from '../Stats';
33
import parse from '../parse/index';
44
import render_dom from './render-dom/index';

src/compiler/tsconfig.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["."],
4+
5+
"compilerOptions": {
6+
"lib": ["es2017", "webworker"]
7+
8+
// TODO: remove mocha types from the whole project
9+
// "types": ["node", "estree"]
10+
}
11+
}

src/runtime/internal/animations.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { identity as linear, noop, now } from './utils';
1+
import { identity as linear, noop } from './utils';
2+
import { now } from './environment';
23
import { loop } from './loop';
34
import { create_rule, delete_rule } from './style_manager';
45
import { AnimationConfig } from '../animate';

src/runtime/internal/environment.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const is_client = typeof window !== 'undefined';
2+
3+
export let now: () => number = is_client
4+
? () => window.performance.now()
5+
: () => Date.now();
6+
7+
export let raf = cb => requestAnimationFrame(cb);
8+
9+
// used internally for testing
10+
export function set_now(fn) {
11+
now = fn;
12+
}
13+
14+
export function set_raf(fn) {
15+
raf = fn;
16+
}

src/runtime/internal/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from './animations';
22
export * from './await-block';
33
export * from './dom';
4+
export * from './environment';
45
export * from './keyed-each';
56
export * from './lifecycle';
67
export * from './loop';

src/runtime/internal/loop.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { now, raf } from './utils';
1+
import { now, raf } from './environment';
22

33
export interface Task { abort(): void; promise: Promise<void> }
44

src/runtime/internal/style_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { element } from './dom';
2-
import { raf } from './utils';
2+
import { raf } from './environment';
33

44
let stylesheet;
55
let active = 0;

src/runtime/internal/transitions.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { identity as linear, is_function, noop, now, run_all } from './utils';
1+
import { identity as linear, is_function, noop, run_all } from './utils';
2+
import { now } from "./environment";
23
import { loop } from './loop';
34
import { create_rule, delete_rule } from './style_manager';
45
import { custom_event } from './dom';

src/runtime/internal/utils.ts

-17
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,3 @@ export function once(fn) {
8989
fn.call(this, ...args);
9090
};
9191
}
92-
93-
const is_client = typeof window !== 'undefined';
94-
95-
export let now: () => number = is_client
96-
? () => window.performance.now()
97-
: () => Date.now();
98-
99-
export let raf = cb => requestAnimationFrame(cb);
100-
101-
// used internally for testing
102-
export function set_now(fn) {
103-
now = fn;
104-
}
105-
106-
export function set_raf(fn) {
107-
raf = fn;
108-
}

src/runtime/tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["."],
4+
5+
"compilerOptions": {
6+
"lib": ["es2015", "dom", "dom.iterable"],
7+
"target": "es2015",
8+
"types": [],
9+
10+
"baseUrl": ".",
11+
"paths": {
12+
"svelte/*": ["*"]
13+
}
14+
}
15+
}

test/tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["."],
4+
5+
"compilerOptions": {
6+
"allowJs": true,
7+
"checkJs": true,
8+
"noEmit": true
9+
}
10+
}

tsconfig.json

+23-26
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
{
2+
"include": [],
3+
24
"compilerOptions": {
3-
"target": "es2015",
4-
"module": "es6",
5+
"rootDir": "src",
6+
7+
// target node v8+ (https://node.green/)
8+
// the only missing feature is Array.prototype.values
9+
"lib": ["es2017"],
10+
"target": "es2017",
11+
512
"declaration": true,
613
"declarationDir": "types",
7-
"noImplicitThis": true,
8-
"noUnusedLocals": true,
9-
"noUnusedParameters": true,
14+
1015
"noEmitOnError": true,
11-
"lib": [
12-
"es5",
13-
"es6",
14-
"dom",
15-
"es2015"
16-
],
17-
"importHelpers": true,
16+
"noErrorTruncation": true,
17+
18+
// rollup takes care of these
19+
"module": "esnext",
1820
"moduleResolution": "node",
19-
"baseUrl": ".",
20-
"paths": {
21-
"svelte/internal": ["./src/runtime/internal/index"],
22-
"svelte/easing": ["./src/runtime/easing/index"],
23-
"svelte/motion": ["./src/runtime/motion/index"],
24-
"svelte/store": ["./src/runtime/store/index"]
25-
},
26-
"typeRoots": [
27-
"node_modules/@types"
28-
]
29-
},
30-
"include": [
31-
"src/**/*"
32-
]
21+
"resolveJsonModule": true,
22+
"allowSyntheticDefaultImports": true,
23+
24+
// TODO: error all the things
25+
//"strict": true,
26+
"noImplicitThis": true,
27+
"noUnusedLocals": true,
28+
"noUnusedParameters": true
29+
}
3330
}

0 commit comments

Comments
 (0)