Skip to content

Commit

Permalink
Adjustments for modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed May 22, 2017
1 parent e1148ff commit 7fff080
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 57 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@
"babel-eslint": "^7.2.3",
"babel-loader": "~7.0.0",
"babel-plugin-remove-proptypes": "~1.0.0",
"babel-polyfill": "^6.7.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "~6.23.0",
"css-loader": "~0.28.2",
"eslint": "^3.8.1",
Expand Down Expand Up @@ -100,14 +104,10 @@
},
"main": "Parse-Dashboard/app.js",
"jest": {
"testPathDirs": [
"roots": [
"src/lib"
],
"scriptPreprocessor": "<rootDir>/testing/preprocessor.js",
"testDirectoryName": "tests",
"testFileExtensions": [
"test.js"
],
"transform": {".*": "<rootDir>/testing/preprocessor.js"},
"unmockedModulePathPatterns": [
"react",
"react-dom",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tests/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jest.dontMock('../../components/Button/Button.react');
import React from 'react';
import TestUtils from 'react-addons-test-utils';

const Button = require('../../components/Button/Button.react');
const Button = require('../../components/Button/Button.react').default;

describe('Button', () => {
it('has a default state', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tests/Tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
jest.dontMock('../../components/Tooltip/Tooltip.react');

describe('Tooltip', () => {
// test suite goes here
it('does nothing', () => {});
});
2 changes: 1 addition & 1 deletion src/lib/tests/passwordStrength.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* the root directory of this source tree.
*/
jest.dontMock('../passwordStrength');
const passwordStrength = require('../passwordStrength');
const passwordStrength = require('../passwordStrength').default;

describe('passwordStrength', () => {
it('returns 0 for passwords that are too short', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tests/prettyNumber.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* the root directory of this source tree.
*/
jest.dontMock('../prettyNumber');
const prettyNumber = require('../prettyNumber');
const prettyNumber = require('../prettyNumber').default;

describe('prettyNumber', () => {
it('does not change small numbers', () => {
Expand Down
7 changes: 4 additions & 3 deletions testing/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ module.exports = {

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

Expand Down
2 changes: 1 addition & 1 deletion webpack/PIG.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
var configuration = require('./base.config.js');

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

module.exports = configuration;
27 changes: 15 additions & 12 deletions webpack/base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,36 @@ module.exports = {
publicPath: 'bundles/'
},
resolve: {
root: [__dirname,path.join(__dirname, '../src'), path.join(__dirname, 'node_modules')]
modules: [__dirname,path.join(__dirname, '../src'), path.join(__dirname, '../node_modules')]
},
resolveLoader: {
root: path.join(__dirname, '../node_modules')
modules: [path.join(__dirname, '../node_modules')]
},
module: {
loaders: [
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
optional: ['runtime', 'es7.decorators']
}
use: {
loader: 'babel-loader',
query: {
plugins: ['transform-decorators-legacy'],
presets: ['react', 'es2015', 'stage-0']
}
},
}, {
test: /\.scss$/,
loader: "style-loader!css-loader?modules&localIdentName=[local]__[hash:base64:5]!sass-loader?includePaths[]=" +
encodeURIComponent(path.resolve(__dirname, '../src'))
use: [ "style-loader", "css-loader?modules&localIdentName=[local]__[hash:base64:5]!sass-loader?includePaths[]=" +
encodeURIComponent(path.resolve(__dirname, '../src')) ]
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
use: [ 'style-loader', 'css-loader' ]
}, {
test: /\.png$/,
loader: 'file-loader?name=img/[hash].[ext]',
use: { loader: 'file-loader?name=img/[hash].[ext]' }
}, {
test: /\.jpg$/,
loader: 'file-loader?name=img/[hash].[ext]',
use: { loader: 'file-loader?name=img/[hash].[ext]' }
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion webpack/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ configuration.entry = {
dashboard: './dashboard/index.js',
login: './login/index.js'
};
configuration.output.path = './Parse-Dashboard/public/bundles';
configuration.output.path = __dirname + '/Parse-Dashboard/public/bundles';

module.exports = configuration;
16 changes: 2 additions & 14 deletions webpack/production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,10 @@ configuration.entry = {
PIG: './parse-interface-guide/index.js',
quickstart: './quickstart/index.js',
};
configuration.output.path = './production/bundles';
configuration.output.path = __dirname + '/production/bundles';

var webpack = require('webpack');

// Add propType removal to Babel
var loaders = configuration.module.loaders;
for (var i = 0; i < loaders.length; i++) {
if (loaders[i].loader === 'babel-loader') {
if (!loaders[i].query.plugins) {
loaders[i].query.plugins = [];
}
loaders[i].query.plugins.push('babel-plugin-remove-proptypes');
break;
}
}

// Enable minification
configuration.plugins.push(
new webpack.DefinePlugin({
Expand All @@ -41,7 +29,7 @@ configuration.plugins.push(
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
function() {
this.plugin('done', function(stats) {
if (stats.compilation.errors && stats.compilation.errors.length) {
Expand Down
16 changes: 2 additions & 14 deletions webpack/publish.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,10 @@ configuration.entry = {
dashboard: './dashboard/index.js',
login: './login/index.js'
};
configuration.output.path = './Parse-Dashboard/public/bundles';
configuration.output.path = __dirname + '/Parse-Dashboard/public/bundles';

var webpack = require('webpack');

// Add propType removal to Babel
var loaders = configuration.module.loaders;
for (var i = 0; i < loaders.length; i++) {
if (loaders[i].loader === 'babel-loader') {
if (!loaders[i].query.plugins) {
loaders[i].query.plugins = [];
}
loaders[i].query.plugins.push('babel-plugin-remove-proptypes');
break;
}
}

// Enable minification
configuration.plugins.push(
new webpack.DefinePlugin({
Expand All @@ -39,7 +27,7 @@ configuration.plugins.push(
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
function() {
this.plugin('done', function(stats) {
if (stats.compilation.errors && stats.compilation.errors.length) {
Expand Down
2 changes: 1 addition & 1 deletion webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ configuration.entry = {
PIG: './parse-interface-guide/index.js',
quickstart: './quickstart/index.js',
};
configuration.output.path = './bundles';
configuration.output.path = __dirname + '/bundles';

module.exports = configuration;

0 comments on commit 7fff080

Please sign in to comment.