feat: bundling with rollup

Squashed commit of the following:

commit 52bcf0f2dd79bcb2ee21bc134522edd259a3d35e
Author: Adam Pash <adam.pash@gmail.com>
Date:   Fri Sep 2 13:42:29 2016 -0400

    fix: converting date to ISO string

commit 11e827e27129ac229a96f66ca03f0b18dc5d289d
Author: Adam Pash <adam.pash@gmail.com>
Date:   Fri Sep 2 13:42:12 2016 -0400

    feat: bundling with rollup

commit 1ff752a3e44e5836b955f7f15c799abbbdfc9207
Author: Adam Pash <adam.pash@gmail.com>
Date:   Fri Sep 2 12:11:39 2016 -0400

    clean
pull/1/head
Adam Pash 8 years ago
parent 0ff3082295
commit 752331eaae

@ -5,22 +5,28 @@
"main": "index.js",
"scripts": {
"start": "node ./build",
"build": "rollup -c",
"test": "mocha --compilers js:babel-register --recursive src/**/*.test.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-plugin-external-helpers": "^6.8.0",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-es2015-rollup": "^1.2.0",
"babel-register": "^6.11.6",
"mocha": "^3.0.2"
"babelrc-rollup": "^3.0.0",
"mocha": "^3.0.2",
"rollup": "^0.34.13",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-commonjs": "^4.1.0"
},
"dependencies": {
"cheerio": "^0.20.0",
"moment": "^2.14.1",
"rollup": "^0.34.10",
"valid-url": "^1.0.9",
"wuzzy": "^0.1.2"
}

@ -1,6 +1,13 @@
import babel from 'rollup-plugin-babel'
import babelrc from 'babelrc-rollup'
import commonjs from 'rollup-plugin-commonjs'
export default {
// entry: 'index.js',
entry: 'src/index.js'
entry: 'src/index.js',
plugins: [
commonjs(),
babel(babelrc()),
],
format: 'cjs',
dest: 'dist/bundle.js' // equivalent to --output
};
}

@ -6,13 +6,25 @@ import { clean } from './utils/dom/test-helpers'
import GenericContentExtractor from './extractor'
describe('GenericContentExtractor', () => {
describe('GenericContentExtractor', function() {
this.timeout(1000000)
describe('parse(html, opts)', () => {
it("parses html and returns the article", () => {
const html = fs.readFileSync('../fixtures/latimes.html', 'utf-8')
// Array.from(range(1, 100)).map((i) => {
// console.log(i)
// clean(GenericContentExtractor.parse(null, html))
// })
const result = clean(GenericContentExtractor.parse(null, html))
console.log(result)
// console.log(result)
})
})
})
function* range(start = 1, end = 1) {
while (start <= end) {
yield start++
}
}

@ -36,7 +36,7 @@ const GenericExtractor = {
return {
title,
author,
datePublished,
datePublished: datePublished ? datePublished.toISOString() : null,
dek,
leadImageUrl,
content,
@ -45,4 +45,3 @@ const GenericExtractor = {
}
export default GenericExtractor

@ -2,6 +2,9 @@ import fs from 'fs'
import GenericExtractor from './extractor/generic/index.js'
const html = fs.readFileSync('../fixtures/wired.html', 'utf-8')
const result = GenericExtractor.parse(html)
console.log(result)
// const html = fs.readFileSync('../fixtures/wired.html', 'utf-8')
// const url = 'http://wired.com'
// const result = GenericExtractor.parse(url, html)
// console.log(result)
export default GenericExtractor

Loading…
Cancel
Save