Skip to content

Commit 7fff080

Browse files
committed
Adjustments for modernization
1 parent e1148ff commit 7fff080

12 files changed

+37
-57
lines changed

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050
"babel-eslint": "^7.2.3",
5151
"babel-loader": "~7.0.0",
5252
"babel-plugin-remove-proptypes": "~1.0.0",
53-
"babel-polyfill": "^6.7.2",
53+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
54+
"babel-polyfill": "^6.23.0",
55+
"babel-preset-es2015": "^6.24.1",
56+
"babel-preset-react": "^6.24.1",
57+
"babel-preset-stage-0": "^6.24.1",
5458
"babel-runtime": "~6.23.0",
5559
"css-loader": "~0.28.2",
5660
"eslint": "^3.8.1",
@@ -100,14 +104,10 @@
100104
},
101105
"main": "Parse-Dashboard/app.js",
102106
"jest": {
103-
"testPathDirs": [
107+
"roots": [
104108
"src/lib"
105109
],
106-
"scriptPreprocessor": "<rootDir>/testing/preprocessor.js",
107-
"testDirectoryName": "tests",
108-
"testFileExtensions": [
109-
"test.js"
110-
],
110+
"transform": {".*": "<rootDir>/testing/preprocessor.js"},
111111
"unmockedModulePathPatterns": [
112112
"react",
113113
"react-dom",

src/lib/tests/Button.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jest.dontMock('../../components/Button/Button.react');
1010
import React from 'react';
1111
import TestUtils from 'react-addons-test-utils';
1212

13-
const Button = require('../../components/Button/Button.react');
13+
const Button = require('../../components/Button/Button.react').default;
1414

1515
describe('Button', () => {
1616
it('has a default state', () => {

src/lib/tests/Tooltip.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
jest.dontMock('../../components/Tooltip/Tooltip.react');
99

1010
describe('Tooltip', () => {
11-
// test suite goes here
11+
it('does nothing', () => {});
1212
});

src/lib/tests/passwordStrength.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* the root directory of this source tree.
77
*/
88
jest.dontMock('../passwordStrength');
9-
const passwordStrength = require('../passwordStrength');
9+
const passwordStrength = require('../passwordStrength').default;
1010

1111
describe('passwordStrength', () => {
1212
it('returns 0 for passwords that are too short', () => {

src/lib/tests/prettyNumber.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* the root directory of this source tree.
77
*/
88
jest.dontMock('../prettyNumber');
9-
const prettyNumber = require('../prettyNumber');
9+
const prettyNumber = require('../prettyNumber').default;
1010

1111
describe('prettyNumber', () => {
1212
it('does not change small numbers', () => {

testing/preprocessor.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ module.exports = {
2222

2323
// Ignore all files within node_modules
2424
// babel files can be .js, .es, .jsx or .es6
25-
if (filename.indexOf('node_modules') < 0 && babel.canCompile(filename)) {
25+
if (filename.indexOf('node_modules') < 0) {
2626
return babel.transform(src, {
2727
filename: filename,
28-
stage: 0,
2928
retainLines: true,
29+
plugins: ['transform-decorators-legacy'],
30+
presets: ['react', 'es2015', 'stage-0']
3031
// Remove propTypes for tests so we don't have to keep unmocking lib/PropTypes
3132
// Also it's more representative of the production environment
32-
plugins: [ 'babel-plugin-remove-proptypes' ]
33+
//plugins: [ 'babel-plugin-remove-proptypes' ]
3334
}).code;
3435
}
3536

webpack/PIG.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
var configuration = require('./base.config.js');
99

1010
configuration.entry = {PIG: './parse-interface-guide/index.js'};
11-
configuration.output.path = './PIG/bundles';
11+
configuration.output.path = __dirname + '/PIG/bundles';
1212

1313
module.exports = configuration;

webpack/base.config.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,36 @@ module.exports = {
2323
publicPath: 'bundles/'
2424
},
2525
resolve: {
26-
root: [__dirname,path.join(__dirname, '../src'), path.join(__dirname, 'node_modules')]
26+
modules: [__dirname,path.join(__dirname, '../src'), path.join(__dirname, '../node_modules')]
2727
},
2828
resolveLoader: {
29-
root: path.join(__dirname, '../node_modules')
29+
modules: [path.join(__dirname, '../node_modules')]
3030
},
3131
module: {
32-
loaders: [
32+
rules: [
3333
{
3434
test: /\.js$/,
3535
exclude: /node_modules/,
36-
loader: 'babel-loader',
37-
query: {
38-
optional: ['runtime', 'es7.decorators']
39-
}
36+
use: {
37+
loader: 'babel-loader',
38+
query: {
39+
plugins: ['transform-decorators-legacy'],
40+
presets: ['react', 'es2015', 'stage-0']
41+
}
42+
},
4043
}, {
4144
test: /\.scss$/,
42-
loader: "style-loader!css-loader?modules&localIdentName=[local]__[hash:base64:5]!sass-loader?includePaths[]=" +
43-
encodeURIComponent(path.resolve(__dirname, '../src'))
45+
use: [ "style-loader", "css-loader?modules&localIdentName=[local]__[hash:base64:5]!sass-loader?includePaths[]=" +
46+
encodeURIComponent(path.resolve(__dirname, '../src')) ]
4447
}, {
4548
test: /\.css$/,
46-
loader: 'style-loader!css-loader'
49+
use: [ 'style-loader', 'css-loader' ]
4750
}, {
4851
test: /\.png$/,
49-
loader: 'file-loader?name=img/[hash].[ext]',
52+
use: { loader: 'file-loader?name=img/[hash].[ext]' }
5053
}, {
5154
test: /\.jpg$/,
52-
loader: 'file-loader?name=img/[hash].[ext]',
55+
use: { loader: 'file-loader?name=img/[hash].[ext]' }
5356
}
5457
]
5558
},

webpack/build.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ configuration.entry = {
1111
dashboard: './dashboard/index.js',
1212
login: './login/index.js'
1313
};
14-
configuration.output.path = './Parse-Dashboard/public/bundles';
14+
configuration.output.path = __dirname + '/Parse-Dashboard/public/bundles';
1515

1616
module.exports = configuration;

webpack/production.config.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,10 @@ configuration.entry = {
1313
PIG: './parse-interface-guide/index.js',
1414
quickstart: './quickstart/index.js',
1515
};
16-
configuration.output.path = './production/bundles';
16+
configuration.output.path = __dirname + '/production/bundles';
1717

1818
var webpack = require('webpack');
1919

20-
// Add propType removal to Babel
21-
var loaders = configuration.module.loaders;
22-
for (var i = 0; i < loaders.length; i++) {
23-
if (loaders[i].loader === 'babel-loader') {
24-
if (!loaders[i].query.plugins) {
25-
loaders[i].query.plugins = [];
26-
}
27-
loaders[i].query.plugins.push('babel-plugin-remove-proptypes');
28-
break;
29-
}
30-
}
31-
3220
// Enable minification
3321
configuration.plugins.push(
3422
new webpack.DefinePlugin({
@@ -41,7 +29,7 @@ configuration.plugins.push(
4129
warnings: false
4230
}
4331
}),
44-
new webpack.optimize.OccurenceOrderPlugin(),
32+
new webpack.optimize.OccurrenceOrderPlugin(),
4533
function() {
4634
this.plugin('done', function(stats) {
4735
if (stats.compilation.errors && stats.compilation.errors.length) {

webpack/publish.config.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,10 @@ configuration.entry = {
1111
dashboard: './dashboard/index.js',
1212
login: './login/index.js'
1313
};
14-
configuration.output.path = './Parse-Dashboard/public/bundles';
14+
configuration.output.path = __dirname + '/Parse-Dashboard/public/bundles';
1515

1616
var webpack = require('webpack');
1717

18-
// Add propType removal to Babel
19-
var loaders = configuration.module.loaders;
20-
for (var i = 0; i < loaders.length; i++) {
21-
if (loaders[i].loader === 'babel-loader') {
22-
if (!loaders[i].query.plugins) {
23-
loaders[i].query.plugins = [];
24-
}
25-
loaders[i].query.plugins.push('babel-plugin-remove-proptypes');
26-
break;
27-
}
28-
}
29-
3018
// Enable minification
3119
configuration.plugins.push(
3220
new webpack.DefinePlugin({
@@ -39,7 +27,7 @@ configuration.plugins.push(
3927
warnings: false
4028
}
4129
}),
42-
new webpack.optimize.OccurenceOrderPlugin(),
30+
new webpack.optimize.OccurrenceOrderPlugin(),
4331
function() {
4432
this.plugin('done', function(stats) {
4533
if (stats.compilation.errors && stats.compilation.errors.length) {

webpack/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ configuration.entry = {
1414
PIG: './parse-interface-guide/index.js',
1515
quickstart: './quickstart/index.js',
1616
};
17-
configuration.output.path = './bundles';
17+
configuration.output.path = __dirname + '/bundles';
1818

1919
module.exports = configuration;

0 commit comments

Comments
 (0)