Skip to content

Commit a9a0e45

Browse files
authored
Merge pull request #59 from Lemoncode/issue#55-ts-to-babel-to-es5
Issue#55 ts to babel to es5
2 parents e82a6c7 + d35601d commit a9a0e45

49 files changed

Lines changed: 332 additions & 292 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"modules": false
7+
}
8+
]
9+
]
10+
}

lib/karma.conf.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var webpack = require('webpack');
12
module.exports = function (config) {
23
config.set({
34
basePath: '',
@@ -13,42 +14,41 @@ module.exports = function (config) {
1314
webpack: {
1415
devtool: 'inline-source-map',
1516
module: {
16-
loaders: [
17-
{
18-
test: /\.(ts|tsx)$/,
19-
exclude: /node_modules/,
20-
loader: 'ts-loader'
21-
},
22-
//Configuration required by enzyme
23-
{
24-
test: /\.json$/,
25-
loader: 'json'
17+
rules: [
18+
{
19+
test: /\.(ts|tsx)$/,
20+
exclude: /node_modules/,
21+
use: {
22+
loader: 'awesome-typescript-loader',
23+
options: {
24+
useBabel: true,
25+
}
2626
}
27-
],
28-
//Configuration required to import sinon on spec.ts files
29-
noParse: [
30-
/node_modules(\\|\/)sinon/,
31-
]
27+
},
28+
],
29+
//Configuration required to import sinon on spec.ts files
30+
noParse: [
31+
/node_modules(\\|\/)sinon/,
32+
]
3233
},
34+
plugins: [
35+
new webpack.ProvidePlugin({
36+
Promise: 'es6-promise'
37+
}),
38+
],
3339
resolve: {
34-
//Added .json extension required by cheerio (enzyme dependency)
35-
extensions: ['', '.js', '.ts', '.tsx', '.json'],
36-
//Configuration required to import sinon on spec.ts files
37-
// https://github.com/webpack/webpack/issues/304
38-
alias: {
39-
sinon: 'sinon/pkg/sinon'
40-
}
40+
//Added .json extension required by cheerio (enzyme dependency)
41+
extensions: ['.js', '.ts'],
42+
//Configuration required to import sinon on spec.ts files
43+
// https://github.com/webpack/webpack/issues/304
44+
alias: {
45+
sinon: 'sinon/pkg/sinon'
46+
}
4147
},
42-
//Configuration required by enzyme
43-
externals: {
44-
'react/lib/ExecutionEnvironment': true,
45-
'react/lib/ReactContext': 'window',
46-
}
4748
},
4849
webpackMiddleware: {
49-
// webpack-dev-middleware configuration
50-
// i. e.
51-
noInfo: true
50+
// webpack-dev-middleware configuration
51+
noInfo: true
5252
},
5353

5454
reporters: ['progress'],

lib/package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test": "karma start --browsers PhantomJS --single-run",
88
"test:watch": "karma start",
99
"clean": "rimraf dist ReadmeResources",
10-
"build:prod": "cross-env NODE_ENV=production webpack --output-filename dist/lc-form-validation.min.js",
11-
"build:dev": "cross-env NODE_ENV=development webpack --output-filename dist/lc-form-validation.js",
10+
"build:prod": "webpack -p --output-filename dist/lc-form-validation.min.js",
11+
"build:dev": "webpack --output-filename dist/lc-form-validation.js",
1212
"build": "npm run clean && npm run build:dev && npm run build:prod",
1313
"prepublish": "npm run build"
1414
},
@@ -31,34 +31,31 @@
3131
"devDependencies": {
3232
"@types/chai": "^3.4.35",
3333
"@types/chai-as-promised": "^0.0.30",
34-
"@types/core-js": "0.9.36",
3534
"@types/karma-chai-sinon": "^0.1.5",
36-
"@types/mocha": "^2.2.39",
37-
"@types/sinon": "^1.16.31",
35+
"@types/mocha": "^2.2.40",
36+
"@types/sinon": "^1.16.35",
37+
"awesome-typescript-loader": "^3.1.2",
38+
"babel-core": "^6.24.0",
39+
"babel-preset-env": "^1.2.2",
3840
"chai": "^3.5.0",
3941
"chai-as-promised": "^5.3.0",
40-
"copy-webpack-plugin": "^1.1.1",
41-
"cross-env": "^3.1.3",
42+
"copy-webpack-plugin": "^4.0.1",
4243
"json-loader": "^0.5.4",
43-
"karma": "^1.3.0",
44+
"karma": "^1.5.0",
4445
"karma-chai": "^0.1.0",
4546
"karma-chai-as-promised": "^0.1.2",
4647
"karma-chrome-launcher": "^2.0.0",
47-
"karma-mocha": "^0.2.2",
48-
"karma-phantomjs-launcher": "^1.0.0",
48+
"karma-mocha": "^1.3.0",
49+
"karma-phantomjs-launcher": "^1.0.4",
4950
"karma-sinon": "^1.0.5",
5051
"karma-sourcemap-loader": "^0.3.7",
51-
"karma-webpack": "^1.7.0",
52-
"mocha": "^2.4.5",
53-
"phantomjs-prebuilt": "^2.1.7",
54-
"rimraf": "^2.5.2",
52+
"karma-webpack": "^2.0.3",
53+
"mocha": "^3.2.0",
54+
"phantomjs-prebuilt": "^2.1.14",
55+
"rimraf": "^2.6.1",
5556
"sinon": "^1.17.6",
56-
"ts-loader": "^1.2.0",
57-
"typescript": "^2.0.7",
58-
"webpack": "^1.13.0"
59-
},
60-
"dependencies": {
61-
"core-js": "^2.4.1"
57+
"typescript": "^2.2.1",
58+
"webpack": "^2.2.1"
6259
},
6360
"typings": "./lcformvalidation.d.ts",
6461
"keywords": [
@@ -81,5 +78,8 @@
8178
"name": "Jaime Salas",
8279
"email": "jaime.salas@lemoncode.net"
8380
}
84-
]
81+
],
82+
"dependencies": {
83+
"es6-promise": "^4.1.0"
84+
}
8585
}

lib/src/spec/validationEngineValidateSingleField.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('lcFormValidation simple form', () => {
6565
}
6666
);
6767

68-
return formValidationBase
68+
formValidationBase
6969
.triggerFieldValidation(viewModel, 'fullname', '')
7070
.then((fieldValidationResult: FieldValidationResult) => {
7171
// Assert

lib/src/validationEngine.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Promise } from 'core-js';
21
import {
32
FormValidationResult,
43
FieldValidationResult,

lib/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
4-
"module": "commonjs",
3+
"target": "es6",
4+
"moduleResolution": "node",
55
"noImplicitAny": false,
66
"removeComments": true,
77
"sourceMap": true,
@@ -13,7 +13,6 @@
1313
"suppressImplicitAnyIndexErrors": true,
1414
"types": [
1515
"mocha",
16-
"core-js",
1716
"chai-as-promised",
1817
"karma-chai-sinon"
1918
]

lib/webpack.config.js

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@ var CopyWebpackPlugin = require('copy-webpack-plugin');
55

66
var basePath = __dirname;
77

8-
var env = process.env.NODE_ENV;
9-
var production = 'production';
10-
118
var config = {
129
context: path.join(basePath, "src"),
10+
1311
resolve: {
14-
// .js is required for react imports.
15-
// .tsx is for our app entry point.
16-
// .ts is optional, in case you will be importing any regular ts files.
17-
extensions: ['', '.js', '.ts', '.tsx']
12+
extensions: ['.js', '.ts']
1813
},
1914

2015
entry: [
21-
'./index.ts'
16+
'es6-promise',
17+
'./index.ts',
2218
],
2319

2420
output: {
@@ -28,38 +24,27 @@ var config = {
2824
},
2925

3026
module: {
31-
loaders: [
27+
rules: [
3228
{
3329
test: /\.(ts|tsx)$/,
3430
exclude: /node_modules/,
35-
loader: 'ts-loader'
31+
use:
32+
{
33+
loader: 'awesome-typescript-loader',
34+
options: {
35+
useBabel: true
36+
}
37+
}
3638
}
3739
]
3840
},
3941

4042
plugins: [
41-
new webpack.optimize.OccurenceOrderPlugin(),
42-
new webpack.DefinePlugin({
43-
'process.env.NODE_ENV': JSON.stringify(env)
44-
}),
4543
new CopyWebpackPlugin([
4644
{ from: '../../README.md', to: 'README.md' },
4745
{ from: '../../ReadmeResources', to: 'ReadmeResources' }
4846
])
4947
]
5048
};
5149

52-
if (env === production) {
53-
config.plugins.push(
54-
new webpack.optimize.UglifyJsPlugin({
55-
compressor: {
56-
pure_getters: true,
57-
unsafe: true,
58-
unsafe_comps: true,
59-
warnings: false
60-
}
61-
})
62-
)
63-
}
64-
6550
module.exports = config;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"modules": false
7+
}
8+
]
9+
]
10+
}

samples/react/00 SimpleForm/package.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,33 @@
88
"author": "Braulio Diez",
99
"license": "ISC",
1010
"dependencies": {
11-
"bootstrap": "^3.3.5",
11+
"bootstrap": "^3.3.7",
1212
"core-js": "^2.4.1",
13-
"jquery": "^2.1.4",
13+
"jquery": "^3.2.0",
1414
"lc-form-validation": "file:../../../lib/",
15-
"react": "~0.14.7",
16-
"react-dom": "^0.14.7",
17-
"react-redux": "^4.4.1",
18-
"redux": "^3.3.1",
19-
"redux-thunk": "^2.0.1"
15+
"react": "^15.4.2",
16+
"react-dom": "^15.4.2",
17+
"react-redux": "^5.0.3",
18+
"redux": "^3.6.0",
19+
"redux-thunk": "^2.2.0"
2020
},
2121
"devDependencies": {
22-
"@types/core-js": "0.9.36",
23-
"@types/react": "^0.14.47",
24-
"@types/react-dom": "^0.14.18",
25-
"@types/react-redux": "^4.4.32",
26-
"@types/redux": "^3.6.31",
27-
"@types/redux-thunk": "^2.1.31",
28-
"css-loader": "^0.23.1",
29-
"extract-text-webpack-plugin": "^1.0.1",
30-
"file-loader": "^0.8.5",
31-
"html-webpack-plugin": "^2.9.0",
32-
"style-loader": "^0.13.0",
33-
"ts-loader": "^0.8.1",
34-
"typescript": "^2.0.9",
35-
"url-loader": "^0.5.7",
36-
"webpack": "^1.12.13",
37-
"webpack-dev-server": "~1.10.1"
22+
"@types/react": "^15.0.16",
23+
"@types/react-dom": "^0.14.23",
24+
"@types/react-redux": "^4.4.37",
25+
"@types/redux": "^3.6.0",
26+
"@types/redux-thunk": "^2.1.0",
27+
"awesome-typescript-loader": "^3.1.2",
28+
"babel-core": "^6.24.0",
29+
"babel-preset-env": "^1.2.2",
30+
"css-loader": "^0.27.3",
31+
"extract-text-webpack-plugin": "^2.1.0",
32+
"file-loader": "^0.10.1",
33+
"html-webpack-plugin": "^2.28.0",
34+
"style-loader": "^0.14.1",
35+
"typescript": "^2.2.1",
36+
"url-loader": "^0.5.8",
37+
"webpack": "^2.2.1",
38+
"webpack-dev-server": "^2.4.2"
3839
}
3940
}

samples/react/00 SimpleForm/src/actions/customerSaveCompleted.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface ICustomerSaveCompletedAction {
66
formValidationResult: FormValidationResult;
77
}
88

9-
let customerSaveCompleted = (formValidationResult: FormValidationResult): ICustomerSaveCompletedAction => {
9+
const customerSaveCompleted = (formValidationResult: FormValidationResult): ICustomerSaveCompletedAction => {
1010
return {
1111
type: actionsDef.customer.CUSTOMER_SAVE_COMPLETED,
1212
formValidationResult

0 commit comments

Comments
 (0)