Skip to content

Commit 30fb3a9

Browse files
authored
Replace browserify with webpack (OctoLinker#97)
* Replace browserify with webpack * Fix watch task * Rename watch scripts * Replace custom install script with default npm behaviour * Replace custom lint script with npm script * Replace custom test script with npm script * Fix linting errors * Move build commands into package.json
1 parent a686314 commit 30fb3a9

File tree

17 files changed

+72
-91
lines changed

17 files changed

+72
-91
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./chrome

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ First off, thanks for taking the time to contribute! :tada: :+1:
1010
To build and run the extension follow these steps.
1111

1212
0. Clone the repository.
13-
0. Run `npm run bootstrap` to setup the project and install all required dependencies.
13+
0. Run `npm install` to setup the project and install all required dependencies.
1414
0. Start hacking. If you're adding a plugin, you may be interested in seeing the commits that add these plugins:
1515
* [Homebrew]
1616
* [Ruby]
1717
* [Composer]
1818
* [Bower]
19-
0. To build the extension run `./scripts/build`.
20-
0. If installed, deactivate the OctoLinker extension.
19+
0. To build the extension once run `npm run build` or `npm run build:watch` during development.
2120
0. Load extension https://developer.chrome.com/extensions/getstarted#unpacked.
2221

2322
[Homebrew]: https://github.com/OctoLinker/browser-extension/commit/b6df755208eae0b98e55fdf533b647b5d7bd4f8e

karma.conf.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
module.exports = function(config) {
1+
2+
const webpackConfig = require('./webpack.config');
3+
webpackConfig.devtool = 'inline-source-map';
4+
5+
module.exports = function (config) {
26
config.set({
37
basePath: '',
4-
frameworks: ['mocha', 'browserify', 'fixture', 'phantomjs-shim'],
8+
frameworks: ['mocha', 'fixture', 'phantomjs-shim'],
59
files: [
6-
'lib/**/*.js',
7-
'test/**/*.js',
8-
'packages/**/*.js',
10+
'test/main-lib.js',
11+
'test/main-packages.js',
912
'packages/*/fixtures/**/*.html',
1013
],
1114
exclude: [],
1215
preprocessors: {
13-
'lib/**/*.js': ['browserify'],
14-
'test/**/*.js': ['browserify'],
15-
'packages/**/*.js': ['browserify'],
16+
'test/main-lib.js': ['webpack', 'sourcemap'],
17+
'test/main-packages.js': ['webpack', 'sourcemap'],
1618
'packages/*/fixtures/**/*.html': ['html2js'],
1719
},
18-
browserify: {
19-
debug: true,
20-
transform: [
21-
['babelify'],
22-
],
20+
webpack: webpackConfig,
21+
webpackMiddleware: {
22+
noInfo: true,
2323
},
24-
babelPreprocessor: {},
2524
reporters: ['mocha'],
2625
browsers: ['PhantomJS'],
2726
singleRun: true,

lib/click-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function onClick(event) {
5050
if (err) {
5151
showTooltip($target, SORRY);
5252

53-
return console.error(err);
53+
return console.error(err); // eslint-disable-line no-console
5454
}
5555

5656
showTooltip($target, RESOLVED);

lib/plugins/homebrew-manifest/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { HOMEBREW } from '../../../packages/helper-grammar-regex-collection/index.js';
22
import insertLink from '../../insert-link';
33
import preset from '../../pattern-preset';
4-
import { dirname } from 'path';
54

65
export default class HomebrewManifest {
76

package.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
},
77
"main": "lib/app.js",
88
"scripts": {
9-
"bootstrap": "./scripts/bootstrap",
10-
"lint": "./scripts/lint",
11-
"test": "./scripts/test",
12-
"watch-test": "./scripts/test --no-single-run --auto-watch",
13-
"build": "./scripts/build",
14-
"watch-build": "./scripts/watch-build"
9+
"postinstall": "ln -s ./scripts/hooks/pre-commit .git/hooks/pre-commit",
10+
"lint": "eslint .",
11+
"pretest": "npm run lint",
12+
"test": "karma start",
13+
"test:watch": "karma start --no-single-run --auto-watch",
14+
"build": "webpack",
15+
"build:watch": "webpack --watch"
1516
},
1617
"dependencies": {
1718
"JSONPath": "^0.11.2",
@@ -27,23 +28,25 @@
2728
"semver-regex": "^1.0.0"
2829
},
2930
"devDependencies": {
31+
"babel-core": "^6.9.1",
3032
"babel-eslint": "^4.1.3",
31-
"babel-preset-es2015": "^6.1.18",
32-
"babelify": "^7.2.0",
33-
"browserify": "^12.0.1",
33+
"babel-loader": "^6.2.4",
34+
"babel-preset-es2015": "^6.9.0",
3435
"eslint": "^1.10.3",
3536
"eslint-config-airbnb": "2.1.1",
36-
"karma-browserify": "^4.4.0",
37+
"json-loader": "^0.5.4",
3738
"karma-fixture": "^0.2.5",
3839
"karma-html2js-preprocessor": "^0.1.0",
3940
"karma-mocha": "^0.2.0",
4041
"karma-mocha-reporter": "^1.1.1",
4142
"karma-phantomjs-launcher": "^0.2.1",
4243
"karma-phantomjs-shim": "^1.1.2",
44+
"karma-sourcemap-loader": "^0.3.7",
45+
"karma-webpack": "^1.7.0",
4346
"mocha": "^2.3.4",
4447
"phantomjs": "^1.9.18",
45-
"sinon": "^1.17.2",
46-
"watchify": "^3.6.1"
48+
"sinon": "^2.0.0-pre",
49+
"webpack": "^1.13.1"
4750
},
4851
"private": true
4952
}

packages/blob-reader/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('blob-reader', () => {
1010
let result;
1111

1212
beforeEach(() => {
13-
fixture.load(__dirname + '/fixtures/github.com/blob/89f13651df126efdb4f1e3ae40183c9fdccdb4d3.html');
13+
fixture.load('/packages/blob-reader/fixtures/github.com/blob/89f13651df126efdb4f1e3ae40183c9fdccdb4d3.html');
1414
const reader = new BlobReader();
1515
reader.read().forEach((blob) => {
1616
result = blob;
@@ -67,7 +67,7 @@ describe('blob-reader', () => {
6767
let result;
6868

6969
beforeEach(() => {
70-
fixture.load(__dirname + '/fixtures/github.com/blob/89f13651df126efdb4f1e3ae40183c9fdccdb4d3.html');
70+
fixture.load('/packages/blob-reader/fixtures/github.com/blob/89f13651df126efdb4f1e3ae40183c9fdccdb4d3.html');
7171
const reader = new BlobReader();
7272
reader.read().forEach((blob) => {
7373
result = blob;
@@ -108,7 +108,7 @@ describe('blob-reader', () => {
108108
let result;
109109

110110
beforeEach(() => {
111-
fixture.load(__dirname + '/fixtures/github.com/commit/b0775a93ea27ee381858ddd9fa2bb953d5b74acb_split.html');
111+
fixture.load('/packages/blob-reader/fixtures/github.com/commit/b0775a93ea27ee381858ddd9fa2bb953d5b74acb_split.html');
112112
const reader = new BlobReader();
113113
reader.read().forEach((blob) => {
114114
result = blob;
@@ -141,7 +141,7 @@ describe('blob-reader', () => {
141141
let result;
142142

143143
beforeEach(() => {
144-
fixture.load(__dirname + '/fixtures/github.com/commit/b0775a93ea27ee381858ddd9fa2bb953d5b74acb_unified.html');
144+
fixture.load('/packages/blob-reader/fixtures/github.com/commit/b0775a93ea27ee381858ddd9fa2bb953d5b74acb_unified.html');
145145
const reader = new BlobReader();
146146
reader.read().forEach((blob) => {
147147
result = blob;

scripts/bootstrap

Lines changed: 0 additions & 22 deletions
This file was deleted.

scripts/build

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/hooks/pre-commit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
cd "$(dirname "$0")/../.."
5-
6-
./scripts/lint
4+
npm run lint

scripts/lint

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/test

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/watch-build

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/main-lib.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'babel-polyfill';
2+
3+
const context = require.context('.', true, /.+\.test\.js?$/);
4+
context.keys().forEach(context);
5+
6+
module.exports = context; // eslint-disable-line no-undef

test/main-packages.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const context = require.context('../packages', true, /\.?test\.js?$/);
2+
context.keys().forEach(context);
3+
4+
module.exports = context; // eslint-disable-line no-undef

webpack.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
entry: {
3+
app: './lib/app',
4+
},
5+
output: {
6+
path: 'chrome',
7+
filename: '[name].js',
8+
},
9+
module: {
10+
loaders: [
11+
{
12+
test: /\.js$/,
13+
exclude: /(node_modules)/,
14+
loader: 'babel',
15+
query: {
16+
presets: ['es2015'],
17+
},
18+
},
19+
{
20+
test: /\.json$/,
21+
loader: 'json-loader',
22+
},
23+
],
24+
},
25+
};

0 commit comments

Comments
 (0)