Skip to content

Commit

Permalink
Merge 96e00d1 into c893420
Browse files Browse the repository at this point in the history
  • Loading branch information
Bingliang Zh committed Aug 14, 2019
2 parents c893420 + 96e00d1 commit 9b62b2c
Show file tree
Hide file tree
Showing 30 changed files with 12,279 additions and 11,662 deletions.
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
registry=https://registry.npmjs.org
3 changes: 3 additions & 0 deletions CHANGELOG.txt
@@ -0,0 +1,3 @@
- add tsconfig.json (with strict on)
- convert all js files to ts
- remove applyMatrix3 from Vector3
55 changes: 42 additions & 13 deletions config/karma/karma-base.js
Expand Up @@ -20,24 +20,53 @@ webpackConfig.module.rules.push({

module.exports = {
basePath: '../../',
frameworks: ['mocha'],
reporters: ['progress', 'coverage'],
frameworks: ['mocha', 'karma-typescript'],
// reporters: ['progress', 'coverage'],
// reporters: ['progress', 'mocha', 'karma-typescript'],
reporters: ['karma-typescript', 'progress', 'coverage'],
files: [
'test/*_test.js',
'test/**/*_test.js'
'src/**/*.ts',
'test/**/*_test.ts'
],

plugins: [
'karma-webpack',
'karma-mocha',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-coverage'
],
// plugins: [
// 'karma-webpack',
// 'karma-mocha',
// 'karma-chrome-launcher',
// 'karma-firefox-launcher',
// 'karma-coverage'
// ],

// karma typescript configuration
karmaTypescriptConfig: {
// tsconfig: "../../tsconfig.json",
bundlerOptions: {
// set *.spec.ts files as entrypoints
// for correct code coverage
entrypoints: /_test\.ts$/
},
coverageOptions: {
// exclude the index.ts and *.spec.ts files
// for correct code coverage
exclude: [/index\.ts$/, /_test\.ts$/]
},
reports: {
html: "coverage",
text: ""
},
compilerOptions: {
baseUrl: ".",
// paths: {
// "*": [ "src/helper/*" ]
// }
}
},

preprocessors: {
'src/**/*.js': ['webpack'],
'test/**/*_test.js': ['webpack']
'src/**/*.ts': ['karma-typescript'],
'test/**/*_test.ts': ['karma-typescript']
// 'src/**/*.js': ['webpack'],
// 'test/**/*_test.js': ['webpack']
},

webpack: webpackConfig,
Expand Down
48 changes: 48 additions & 0 deletions config/karma/karma-ts.js
@@ -0,0 +1,48 @@
// module.exports = function(config) {
// config.set({
// frameworks: ["jasmine", "karma-typescript"],
// files: [
// "src/**/*.ts" // *.tsx for React Jsx
// ],
// preprocessors: {
// "**/*.ts": "karma-typescript" // *.tsx for React Jsx
// },
// reporters: ["progress", "karma-typescript"],
// browsers: ["Chrome"]
// });
// };

module.exports = function(config) {
config.set({

basePath: '../../',
frameworks: ["jasmine", "karma-typescript"],
plugins: ['karma-jasmine', "karma-typescript",
'karma-webpack',
'karma-mocha',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-coverage'],

files: [
// 'test/*_test.ts',
'test/**/*_test.ts'
],

karmaTypescriptConfig: {
compilerOptions: {
module: "commonjs"
},
tsconfig: "./tsconfig.json",
},

preprocessors: {
"**/*.ts": ["karma-typescript"]
},
reporters: ["progress", "karma-typescript"],

// reporters: ["progress", "kjhtml", "spec", "karma-typescript"],

// browsers: ["Chrome"]
});
};
47 changes: 31 additions & 16 deletions config/webpack/webpack-base.js
Expand Up @@ -8,7 +8,7 @@ module.exports = {
mode: 'development',
context: context,
entry: {
cornerstoneMath: './index.js'
cornerstoneMath: './index.ts'
},
target: 'web',
output: {
Expand All @@ -22,23 +22,38 @@ module.exports = {
path: outputPath,
umdNamedDefine: true
},
devtool: 'source-map',
resolve: {
// Add '.ts' as resolvable extensions.
extensions: ['.ts'],
modules: ['./src', 'node_modules']
},
// A SourceMap is added as a DataUrl to the bundle.
devtool: '#inline-source-map',
// devtool: 'source-map',
module: {
rules: [{
enforce: 'pre',
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'eslint-loader',
options: {
failOnError: false
rules: [
// All files with a '.ts' extension will be handled by 'ts-loader'.
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/
}
}, {
test: /\.js$/,
exclude: /(node_modules)/,
use: [{
loader: 'babel-loader'
}]
}]
]
// rules: [{
// enforce: 'pre',
// test: /\.js$/,
// exclude: /(node_modules)/,
// loader: 'eslint-loader',
// options: {
// failOnError: false
// }
// }, {
// test: /\.js$/,
// exclude: /(node_modules)/,
// use: [{
// loader: 'babel-loader'
// }]
// }]
},
plugins: [
bannerPlugin()
Expand Down
21 changes: 21 additions & 0 deletions config/webpack/webpack-ts.js
@@ -0,0 +1,21 @@
const path = require('path');

module.exports = {
entry: './src/index.ts',
devtool: 'inline-source-map',
module: {
rules: [
{
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: [ '.ts' ]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
}
};

0 comments on commit 9b62b2c

Please sign in to comment.