Skip to content

Commit 2c1a29c

Browse files
committed
Upgrade deps. Convert from webpack to rollup
1 parent d76ac52 commit 2c1a29c

19 files changed

+8271
-155
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sourceMaps": "inline",
3-
"presets": ["es3", "es2015-mod"],
3+
"presets": ["@babel/preset-env"],
44
"auxiliaryCommentBefore": "istanbul ignore start",
55
"auxiliaryCommentAfter": "istanbul ignore end"
66
}

.eslintrc

+17-35
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
{
2+
"parser": "babel-eslint",
23
"env": {
34
"browser": true
45
},
5-
"ecmaFeatures": {
6-
// Enabling features that can be implemented without polyfills. Want to avoid polyfills at this time.
7-
"arrowFunctions": true,
8-
"blockBindings": true,
9-
"classes": false,
10-
"defaultParams": true,
11-
"destructuring": true,
12-
"modules": true,
13-
"objectLiteralComputedProperties": true,
14-
"objectLiteralDuplicateProperties": true,
15-
"objectLiteralShorthandMethods": true,
16-
"objectLiteralShorthandProperties": true,
17-
"regexUFlag": true,
18-
"restParams": true,
19-
"spread": true,
20-
"templateStrings": true
21-
},
226
"rules": {
237
// Possible Errors //
248
//-----------------//
@@ -63,22 +47,20 @@
6347
"valid-jsdoc": 0,
6448
"valid-typeof": 2,
6549

66-
6750
// Best Practices //
6851
//----------------//
6952
"block-scoped-var": 0,
7053
"complexity": 0,
7154
"consistent-return": 0,
7255
"curly": 2,
7356
"default-case": 1,
74-
"dot-notation": [2, {"allowKeywords": false}],
57+
"dot-notation": [2, { "allowKeywords": false }],
7558
"eqeqeq": 0,
7659
"guard-for-in": 1,
7760
"no-alert": 2,
7861
"no-caller": 2,
7962
"no-div-regex": 1,
8063
"no-else-return": 0,
81-
"no-empty-label": 2,
8264
"no-eq-null": 0,
8365
"no-eval": 2,
8466
"no-extend-native": 2,
@@ -116,12 +98,10 @@
11698
"wrap-iife": 2,
11799
"yoda": 0,
118100

119-
120101
// Strict //
121102
//--------//
122103
"strict": 0,
123104

124-
125105
// Variables //
126106
//-----------//
127107
"no-catch-shadow": 2,
@@ -132,31 +112,32 @@
132112
"no-undef": 2,
133113
"no-undef-init": 2,
134114
"no-undefined": 0,
135-
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
115+
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
136116
"no-use-before-define": [2, "nofunc"],
137117

138-
139118
// Node.js //
140119
//---------//
141120
// Others left to environment defaults
142121
"no-mixed-requires": 0,
143122

144-
145123
// Stylistic //
146124
//-----------//
147125
"indent": 0,
148-
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
126+
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
149127
"camelcase": 2,
150-
"comma-spacing": [2, {"before": false, "after": true}],
128+
"comma-spacing": [2, { "before": false, "after": true }],
151129
"comma-style": [2, "last"],
152130
"consistent-this": [1, "self"],
153131
"eol-last": 2,
154132
"func-names": 0,
155133
"func-style": [2, "declaration"],
156-
"key-spacing": [2, {
134+
"key-spacing": [
135+
2,
136+
{
157137
"beforeColon": false,
158138
"afterColon": true
159-
}],
139+
}
140+
],
160141
"max-nested-callbacks": 0,
161142
"new-cap": 2,
162143
"new-parens": 2,
@@ -176,22 +157,23 @@
176157
"one-var": 0,
177158
"operator-assignment": 0,
178159
"padded-blocks": 0,
179-
"quote-props": [2, "as-needed", {"keywords": true}],
160+
"quote-props": [2, "as-needed", { "keywords": true }],
180161
"quotes": [2, "single", "avoid-escape"],
181162
"semi": 2,
182-
"semi-spacing": [2, {"before": false, "after": true}],
163+
"semi-spacing": [2, { "before": false, "after": true }],
183164
"sort-vars": 0,
184-
"space-after-keywords": [2, "always"],
185165
"space-before-blocks": [2, "always"],
186-
"space-before-function-paren": [2, {"anonymous": "never", "named": "never"}],
166+
"space-before-function-paren": [
167+
2,
168+
{ "anonymous": "never", "named": "never" }
169+
],
187170
"space-in-brackets": 0,
188171
"space-in-parens": [2, "never"],
189172
"space-infix-ops": 2,
190-
"space-return-throw-case": 2,
191173
"space-unary-ops": 2,
192174
"spaced-comment": [2, "always"],
193175
"wrap-regex": 1,
194176

195177
"no-var": 2
196178
}
197-
}
179+
}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ coverage
22
node_modules
33
npm-debug.log
44
lib
5-
dist
5+
dist
6+
yarn-error.log

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
We also accept [pull requests][pull-request]!
66

77
Generally we like to see pull requests that
8+
89
- Maintain the existing code style
910
- Are focused on a single change (i.e. avoid large refactoring or style adjustments in untouched code if not the primary goal of the pull request)
1011
- Have [good commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
@@ -16,7 +17,7 @@ Generally we like to see pull requests that
1617
```
1718
npm install
1819
npm test
19-
````
20+
```
2021

2122
The `npm test -- dev` implements watching for tests within Node and `karma start` may be used for manual testing in browsers.
2223

@@ -32,7 +33,6 @@ A full release may be completed with the following:
3233
```
3334
yo release
3435
npm publish
35-
yo release:publish components jsdiff dist/components/
3636
```
3737

3838
[generator-release]: https://github.com/walmartlabs/generator-release

Gruntfile.js

+11-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* eslint-env node */
22
/* eslint-disable no-process-env, camelcase */
3+
const pkg = require('./package.json');
4+
const babel = require('rollup-plugin-babel');
5+
36
module.exports = function(grunt) {
47

58
grunt.initConfig({
@@ -26,27 +29,17 @@ module.exports = function(grunt) {
2629
}]
2730
}
2831
},
29-
webpack: {
30-
options: {
31-
context: 'lib/',
32-
output: {
33-
path: 'dist/',
34-
library: 'JsDiff',
35-
libraryTarget: 'umd'
36-
}
37-
},
38-
dist: {
39-
entry: './index.js',
40-
output: {
41-
filename: 'diff.js'
42-
}
32+
33+
exec: {
34+
rollup: {
35+
command: 'rollup -c'
4336
}
4437
},
4538

4639
mochaTest: {
4740
test: {
4841
options: {
49-
require: ['babel-core/register'],
42+
require: ['@babel/register'],
5043
reporter: 'dot'
5144
},
5245
src: ['test/**/*.js']
@@ -116,12 +109,6 @@ module.exports = function(grunt) {
116109
files: [
117110
{expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/'}
118111
]
119-
},
120-
components: {
121-
files: [
122-
{expand: true, cwd: 'components/', src: ['**'], dest: 'dist/components'},
123-
{expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/components'}
124-
]
125112
}
126113
},
127114

@@ -138,11 +125,11 @@ module.exports = function(grunt) {
138125
});
139126

140127
// Build a new version of the library
141-
this.registerTask('build', 'Builds a distributable version of the current project', ['eslint', 'babel', 'webpack']);
128+
this.registerTask('build', 'Builds a distributable version of the current project', ['eslint', 'babel', 'exec:rollup']);
142129
this.registerTask('test', ['build', 'mochaTest', 'karma:unit']);
143130
this.registerTask('cover', ['mocha_istanbul:coverage', 'istanbul_check_coverage']);
144131

145-
this.registerTask('release', ['clean', 'test', 'uglify', 'copy:dist', 'copy:components']);
132+
this.registerTask('release', ['clean', 'test', 'uglify', 'copy:dist']);
146133

147134
// Load tasks from npm
148135
grunt.loadNpmTasks('grunt-contrib-clean');
@@ -154,7 +141,7 @@ module.exports = function(grunt) {
154141
grunt.loadNpmTasks('grunt-karma');
155142
grunt.loadNpmTasks('grunt-mocha-test');
156143
grunt.loadNpmTasks('grunt-mocha-istanbul');
157-
grunt.loadNpmTasks('grunt-webpack');
144+
grunt.loadNpmTasks('grunt-exec');
158145

159146
grunt.task.loadTasks('tasks');
160147

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ Based on the algorithm proposed in
1212
```bash
1313
npm install diff --save
1414
```
15-
or
16-
```bash
17-
bower install jsdiff --save
18-
```
1915

2016
## API
2117

karma.conf.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ module.exports = function(config) {
1919
base: 'SauceLabs',
2020
browserName: 'internet explorer',
2121
version: '11'
22+
},
23+
HeadlessChrome: {
24+
base: 'ChromeHeadless',
25+
flags: ['--no-sandbox']
2226
}
2327
};
2428

@@ -37,7 +41,7 @@ module.exports = function(config) {
3741
webpack: {
3842
devtool: 'eval',
3943
module: {
40-
loaders: [
44+
rules: [
4145
{
4246
test: /\.jsx?$/,
4347
exclude: /node_modules/,
@@ -63,12 +67,6 @@ module.exports = function(config) {
6367
autoWatch: true,
6468
singleRun: false,
6569

66-
browsers: ['HeadlessChrome']
67-
customLaunchers: {
68-
HeadlessChrome: {
69-
base: 'ChromeHeadless',
70-
flags: [ '--no-sandbox', ],
71-
},
72-
},
70+
browsers: ['HeadlessChrome'],
7371
});
7472
};

package.json

+41-30
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,57 @@
2121
"engines": {
2222
"node": ">=0.3.1"
2323
},
24-
"main": "./lib",
24+
"main": "./lib/index.cjs.js",
25+
"module": "./lib/index.es6.js",
2526
"browser": "./dist/diff.js",
2627
"scripts": {
28+
"clean": "rm -rf lib/ dist/",
29+
"build:node": "yarn babel --out-dir lib --source-maps=inline src",
2730
"test": "grunt"
2831
},
29-
"dependencies": {},
32+
"dependencies": {
33+
"grunt-rollup": "^9.0.0",
34+
"rollup": "^1.0.2"
35+
},
3036
"devDependencies": {
31-
"async": "^1.4.2",
32-
"babel-core": "^6.0.0",
33-
"babel-loader": "^6.0.0",
34-
"babel-preset-es2015-mod": "^6.3.13",
35-
"babel-preset-es3": "^1.0.1",
36-
"chai": "^3.3.0",
37-
"colors": "^1.1.2",
38-
"eslint": "^1.6.0",
39-
"grunt": "^0.4.5",
40-
"grunt-babel": "^6.0.0",
37+
"@babel/cli": "^7.2.3",
38+
"@babel/core": "^7.2.2",
39+
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
40+
"@babel/preset-env": "^7.2.3",
41+
"@babel/register": "^7.0.0",
42+
"babel-eslint": "^10.0.1",
43+
"babel-loader": "^8.0.5",
44+
"chai": "^4.2.0",
45+
"colors": "^1.3.3",
46+
"eslint": "^5.12.0",
47+
"grunt": "^1.0.3",
48+
"grunt-babel": "^8.0.0",
4149
"grunt-clean": "^0.4.0",
42-
"grunt-cli": "^0.1.13",
43-
"grunt-contrib-clean": "^1.0.0",
50+
"grunt-cli": "^1.3.2",
51+
"grunt-contrib-clean": "^2.0.0",
4452
"grunt-contrib-copy": "^1.0.0",
45-
"grunt-contrib-uglify": "^1.0.0",
46-
"grunt-contrib-watch": "^1.0.0",
47-
"grunt-eslint": "^17.3.1",
48-
"grunt-karma": "^0.12.1",
49-
"grunt-mocha-istanbul": "^3.0.1",
50-
"grunt-mocha-test": "^0.12.7",
51-
"grunt-webpack": "^1.0.11",
53+
"grunt-contrib-uglify": "^4.0.0",
54+
"grunt-contrib-watch": "^1.1.0",
55+
"grunt-eslint": "^21.0.0",
56+
"grunt-exec": "^3.0.0",
57+
"grunt-mocha-istanbul": "^5.0.2",
58+
"grunt-mocha-test": "^0.13.3",
59+
"grunt-webpack": "^3.1.3",
5260
"istanbul": "github:kpdecker/istanbul",
53-
"karma": "^2.0.0",
54-
"karma-mocha": "^0.2.0",
55-
"karma-mocha-reporter": "^2.0.0",
61+
"karma": "^3.1.4",
5662
"karma-chrome-launcher": "^2.2.0",
57-
"karma-sauce-launcher": "^0.3.0",
63+
"karma-mocha": "^1.3.0",
64+
"karma-mocha-reporter": "^2.0.0",
65+
"karma-sauce-launcher": "^2.0.2",
5866
"karma-sourcemap-loader": "^0.3.6",
59-
"karma-webpack": "^1.7.0",
60-
"mocha": "^2.3.3",
61-
"semver": "^5.0.3",
62-
"webpack": "^1.12.2",
63-
"webpack-dev-server": "^1.12.0"
67+
"karma-webpack": "^3.0.5",
68+
"mocha": "^5.2.0",
69+
"rollup-plugin-babel": "^4.2.0",
70+
"rollup-plugin-commonjs": "^9.2.0",
71+
"rollup-plugin-node-resolve": "^4.0.0",
72+
"semver": "^5.6.0",
73+
"webpack": "^4.28.3",
74+
"webpack-dev-server": "^3.1.14"
6475
},
6576
"optionalDependencies": {}
6677
}

0 commit comments

Comments
 (0)