Skip to content

Commit

Permalink
feat: move to typescript (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viatorus authored Nov 20, 2017
1 parent 14b9947 commit d47f190
Show file tree
Hide file tree
Showing 93 changed files with 4,360 additions and 10,895 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ node_modules/
# Tests
coverage/

# Typescript
.ts/

# Publish
dist/packages-dist/
site/
10 changes: 5 additions & 5 deletions config/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const stream = require("stream");
const conventionalChangelog = require("conventional-changelog");

const PACKAGES = [
// "loki",
// "partitioning-adapter",
// "local-storage",
// "indexed-storage",
// "fs-storage",
"loki",
"partitioning-adapter",
"local-storage",
"indexed-storage",
"fs-storage",
"full-text-search"
];

Expand Down
28 changes: 0 additions & 28 deletions config/eslintrc.js

This file was deleted.

5 changes: 3 additions & 2 deletions config/jasmine.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"spec_dir": "packages/*/spec",
"spec_files": [
"generic/**/*.spec.js",
"node/**/*.spec.js"
"generic/**/*.spec.[jt]s",
"node/**/*.spec.[jt]s"
],
"helpers": [
"helpers/**/*.js",
"../../../node_modules/ts-node/register.js",
"../../../node_modules/babel-register/lib/node.js",
"../../../node_modules/jasmine-expect/index.js"
],
Expand Down
45 changes: 28 additions & 17 deletions config/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = function (config) {
frameworks: ["jasmine", "jasmine-matchers"],
browsers: ["Chrome"],
files: [
{pattern: "../packages/*/spec/generic/**/*.spec.js", watched: false},
{pattern: "../packages/*/spec/web/**/*.spec.js", watched: false},
{pattern: "../packages/*/spec/generic/**/*.spec.ts", watched: false},
{pattern: "../packages/*/spec/web/**/*.spec.ts", watched: false}
],
preprocessors: {
"../packages/*/spec/generic/**/*.spec.js": ["webpack"],
"../packages/*/spec/web/**/*.spec.js": ["webpack"],
"../packages/*/spec/generic/**/*.spec.ts": ["webpack"],
"../packages/*/spec/web/**/*.spec.ts": ["webpack"]
},

// coverage reporter generates the coverage
Expand All @@ -21,25 +21,36 @@ module.exports = function (config) {
reports: ["text-summary", "lcov", "html", "json"],
fixWebpackSourcePaths: false
},

mime: {
'text/x-typescript': ['ts']
},
webpack: {
externals: {
"fs": "fs"
},
devtool: "source-map",
resolve: {
extensions: ['.ts', '.js'],
},
devtool: "inline-source-map",
module: {
rules: [
// rules: [
// {
// test: /\.js$/,
// use: [
// {
// loader: "istanbul-instrumenter-loader",
// options: {
// esModules: true
// }
// },
// ]
// }
// ],
loaders: [
{
test: /\.js$/,
use: [
{
loader: "istanbul-instrumenter-loader",
options: {
esModules: true
}
},
]
}
test: /\.ts$/,
loader: "ts-loader"
},
]
}
},
Expand Down
21 changes: 21 additions & 0 deletions config/tsconfig.webpack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "../types/",
"sourceMap": true,
"declaration": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es6",
"lib": [
"es2017",
"dom"
]
},
"include": [
"../packages/*/src/**/*.ts"
]
}
31 changes: 31 additions & 0 deletions config/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"rulesDirectory": [
"../node_modules/vrsource-tslint-rules/rules",
"../node_modules/tslint-eslint-rules/dist/rules"
],
"extends": [
"tslint-eslint-rules"
],
"rules": {
"no-console": [true, "log"],
"no-duplicate-imports": true,
"no-duplicate-variable": true,
"no-jasmine-focus": true,
"no-var-keyword": true,
"semicolon": [true],
"variable-name": [true, "ban-keywords"],
"no-inner-declarations": [true, "function"],
"quotemark": [true, "double"]
},
"jsRules": {
"no-console": [true, "log"],
"no-duplicate-imports": true,
"no-duplicate-variable": true,
"no-jasmine-focus": true,
"require-internal-with-underscore": true,
"semicolon": [true],
"variable-name": [true, "ban-keywords"],
"no-inner-declarations": [true, "function"],
"quotemark": [true, "double"]
}
}
50 changes: 50 additions & 0 deletions config/webpack-config-creator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* global __dirname, module, require */
const path = require("path");

module.exports = (options) => {
if (options.entry === undefined) {
throw Error("options.entry must be specified.")
}
if (options.filename === undefined) {
throw Error("options.Filename must be specified.")
}
if (options.library === undefined) {
throw Error("options.library must be specified.")
}

return {
entry: options.entry,
output: {
filename: options.filename,
library: options.library,
libraryTarget: "umd2",
umdNamedDefine: false
},
externals: options.externals,
resolve: {
extensions: [".ts", ".js"]
},
devtool: "source-map",
module: {
loaders: [
{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
exclude: /node_modules/,
options: {
failOnHint: true,
configFile: path.join("config", "tslint.json"),
}
},
{
test: /\.ts$/,
loader: "ts-loader",
options: {
configFile: path.join("config", "tsconfig.webpack.json")
}
}
]
},
};
};
Loading

0 comments on commit d47f190

Please sign in to comment.